From patchwork Wed Dec 9 13:41:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58105 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp676174lbb; Wed, 9 Dec 2015 05:42:01 -0800 (PST) X-Received: by 10.66.234.226 with SMTP id uh2mr7863037pac.6.1449668521460; Wed, 09 Dec 2015 05:42:01 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u63si12822783pfa.181.2015.12.09.05.42.01; Wed, 09 Dec 2015 05:42:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754691AbbLINmA (ORCPT + 4 others); Wed, 9 Dec 2015 08:42:00 -0500 Received: from mail-lb0-f170.google.com ([209.85.217.170]:33847 "EHLO mail-lb0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751585AbbLINl7 (ORCPT ); Wed, 9 Dec 2015 08:41:59 -0500 Received: by lbbcs9 with SMTP id cs9so30123407lbb.1 for ; Wed, 09 Dec 2015 05:41:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=oO+6XIkVDlGyWWiIEQo81tjJXfGeqJFMefv9dp/gkvw=; b=A3r/6/EjQjTv1zBI5BbuyU0YfvjQbTC/6Z8FK1PM1RbCARltxYk4Fa6onLb21E/W8O Zp7WPn6VOH2j6JLCxZup/aPycUW1IrUuA4Jb/sdS7XOnpAeVtmoZ1m+dXuiy/rvIUtir pGe4k/v908IrEQY75DQqAD5WSVCJBMCW7BWKqyGEPRzVa5MJoTU3xgPtI+uxB32uuMsG 5XvVs4HWVyZ5BKK+PRp0BH8AysO2iVvtKGaf0cMcIVBI8yxy4jB4MsSWj05b20J/ltZn WzrGx6upkxNV3RDK2574lDj/2Ie4UEf+ClpqsWdLRPUV4xr6YmBokTJuYBDPtqyAUCm5 QLTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=oO+6XIkVDlGyWWiIEQo81tjJXfGeqJFMefv9dp/gkvw=; b=Ul8wG1CA2Irwg3ph8RdfSXSBzss0AYr5HUiyXPreyUPfm5ovJ2eEIWxtqfpi99Ruw+ NIlZRsdCON3A2Ii/R6kwV4AcEHZd/b7p657dGjOZFdgB/fxTg0UCNv8BfN3ITziLMj8l DfDqCI7Xk6Pl74junR0f3mE+QGGMmk9vG6NItr644FQaRI1UtOviiCG3FqlBX8TPVCAU L+awqW7lF31gUxyVsRzRKFTTDnsWhy0sTFh1gstT98kC3+y9XT5fyVOattAJ/9lOuCV/ rfaug/pqQ2bXqNyw+ABV8uPn12dT83eGDPgBt2tIiZyHrZCKZrSd3BjwT9HyKsHPeknr 8oPA== X-Gm-Message-State: ALoCoQk3nR2p5U1s07LukLu9FlCUtsKUcR5IfE/RzO5RnZpxxWELjAnM/lI1WkU5uzhdzGbYSdJVr1a0D52pAfzkjs8MZA5wug== X-Received: by 10.112.138.135 with SMTP id qq7mr2400989lbb.21.1449668518530; Wed, 09 Dec 2015 05:41:58 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id a2sm1433854lbp.37.2015.12.09.05.41.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:41:57 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann , Anatolij Gustschin , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: Linus Walleij , Anton Vorontsov Subject: [PATCH 149/182] powerpc: simple-gpio: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:41:55 +0100 Message-Id: <1449668515-5167-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.3 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This makes the driver use the data pointer added to the gpio_chip to store a pointer to the state container instead of relying on container_of(). Cc: Anton Vorontsov Cc: Anatolij Gustschin Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Signed-off-by: Linus Walleij --- Power maintainers: please ACK this. This looks like a pretty clean GPIO driver that should ideally move to drivers/gpio. It should be fine to change the include from to on this as it does not appear to use the consumer API. I wonder if this can even use the simple DT bound platform driver inside drivers/gpio/gpio-generic these days? --- arch/powerpc/sysdev/simple_gpio.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) -- 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/powerpc/sysdev/simple_gpio.c b/arch/powerpc/sysdev/simple_gpio.c index ff5e73230a36..c2fa46cfa4cd 100644 --- a/arch/powerpc/sysdev/simple_gpio.c +++ b/arch/powerpc/sysdev/simple_gpio.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include "simple_gpio.h" @@ -32,11 +32,6 @@ struct u8_gpio_chip { u8 data; }; -static struct u8_gpio_chip *to_u8_gpio_chip(struct of_mm_gpio_chip *mm_gc) -{ - return container_of(mm_gc, struct u8_gpio_chip, mm_gc); -} - static u8 u8_pin2mask(unsigned int pin) { return 1 << (8 - 1 - pin); @@ -52,7 +47,7 @@ static int u8_gpio_get(struct gpio_chip *gc, unsigned int gpio) static void u8_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct u8_gpio_chip *u8_gc = to_u8_gpio_chip(mm_gc); + struct u8_gpio_chip *u8_gc = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&u8_gc->lock, flags); @@ -80,7 +75,7 @@ static int u8_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) static void u8_gpio_save_regs(struct of_mm_gpio_chip *mm_gc) { - struct u8_gpio_chip *u8_gc = to_u8_gpio_chip(mm_gc); + struct u8_gpio_chip *u8_gc = gpiochip_get_data(&mm_gc->gc); u8_gc->data = in_8(mm_gc->regs); } @@ -108,7 +103,7 @@ static int __init u8_simple_gpiochip_add(struct device_node *np) gc->get = u8_gpio_get; gc->set = u8_gpio_set; - ret = of_mm_gpiochip_add(np, mm_gc); + ret = of_mm_gpiochip_add_data(np, mm_gc, u8_gc); if (ret) goto err; return 0;