From patchwork Wed Dec 9 13:41:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58104 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp676151lbb; Wed, 9 Dec 2015 05:41:58 -0800 (PST) X-Received: by 10.98.10.83 with SMTP id s80mr12974363pfi.79.1449668518479; Wed, 09 Dec 2015 05:41:58 -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.41.58; Wed, 09 Dec 2015 05:41:58 -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 S1754689AbbLINlx (ORCPT + 4 others); Wed, 9 Dec 2015 08:41:53 -0500 Received: from mail-lb0-f175.google.com ([209.85.217.175]:36654 "EHLO mail-lb0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751585AbbLINlw (ORCPT ); Wed, 9 Dec 2015 08:41:52 -0500 Received: by lbblt2 with SMTP id lt2so30310419lbb.3 for ; Wed, 09 Dec 2015 05:41:51 -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=v2WARmC9q6372bJHlE83PdhD6opn0jNs8eFN/+8uAfA=; b=vkZsf/Me6k9Ds12aIbIBxRBzGz3Gu2K4x3qyfm9WmFp4T1kFOJbh78ds1VdCayOP6a YVC7CcOE/5FZdNZpvA5HI/yFYM3Qo1ie+DpiyDH4jLIaPbN55IGZTwkQMUTaM5bcTmMN nFTjkR1uH54HgqgHL8YvhqfaLTBI3TlBoMmQP+pwP7ErzNV0go9FkPpa3xPGhVjjKlDy taypUqmhAZZWy8gHPRodl/lLdA0gw9YUbH3fYlclglwrF+5DeQv4PqMSZq4us3JmaiUq 2glm/Xvw8KJJIE6dvZvwQagRaeqCx8eVlAF4i0Bhjvlola9FEtJhz3YBfQV9rMryUqd9 WEfA== 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=v2WARmC9q6372bJHlE83PdhD6opn0jNs8eFN/+8uAfA=; b=mIBaZHpX6S1dSluspeKhv6+y+/TUMdUHC/Zu/yJlTi06aDZkcvsfOEvyvISiVD+SfM lKSYcihIUbHbiTvCZKJXfma5HyIljfZEtnCOv4viQxYtlRzpyVVKi5+wjzeGoSJkOw8i EfwjG6/4B0wnEOZ+zSVl9qTQ7RIzPMXos6V73SEedZRbUyMMR53hwP9gjNaX95NANj9c DDgOtIRahKZDhkqcxK79RpFjyMJnS03Y0r/28NCuAr8bmw3AO/f5EJo7OyFJTtklTJ8n XNHKbHTtaeBq8XKgmz/LIA+ybhzeeQ9420tFCNoLc+RBlAsRWwCxXCU/iOUwGklGQKQQ 6RnQ== X-Gm-Message-State: ALoCoQncmN3vNcIrA7s+PV8o8RrrM9VV1hfFB+7DsQTl8jndcDzDnQGEBX2HeZ25pCKcKrL0vaomJwXsBtTAwDKD8xmqAkPc5Q== X-Received: by 10.112.148.6 with SMTP id to6mr2480413lbb.33.1449668510908; Wed, 09 Dec 2015 05:41:50 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j204sm1408491lfd.16.2015.12.09.05.41.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:41:50 -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 Subject: [PATCH 148/182] powerpc: qe_lib-gpio: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:41:47 +0100 Message-Id: <1449668507-5118-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: Anatolij Gustschin Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Signed-off-by: Linus Walleij --- Power maintainers: please ACK this. I cannot really say if this should ideally be broken out as a separate driver in drivers/gpio or if it is better to keep it here. For now just refactoring... --- arch/powerpc/sysdev/qe_lib/gpio.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 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/qe_lib/gpio.c b/arch/powerpc/sysdev/qe_lib/gpio.c index 521e67a49dc4..90caaad7889f 100644 --- a/arch/powerpc/sysdev/qe_lib/gpio.c +++ b/arch/powerpc/sysdev/qe_lib/gpio.c @@ -18,6 +18,8 @@ #include #include #include +#include +/* FIXME: needed for gpio_to_chip() get rid of this */ #include #include #include @@ -37,15 +39,9 @@ struct qe_gpio_chip { struct qe_pio_regs saved_regs; }; -static inline struct qe_gpio_chip * -to_qe_gpio_chip(struct of_mm_gpio_chip *mm_gc) -{ - return container_of(mm_gc, struct qe_gpio_chip, mm_gc); -} - static void qe_gpio_save_regs(struct of_mm_gpio_chip *mm_gc) { - struct qe_gpio_chip *qe_gc = to_qe_gpio_chip(mm_gc); + struct qe_gpio_chip *qe_gc = gpiochip_get_data(&mm_gc->gc); struct qe_pio_regs __iomem *regs = mm_gc->regs; qe_gc->cpdata = in_be32(®s->cpdata); @@ -69,7 +65,7 @@ static int qe_gpio_get(struct gpio_chip *gc, unsigned int gpio) static void qe_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 qe_gpio_chip *qe_gc = to_qe_gpio_chip(mm_gc); + struct qe_gpio_chip *qe_gc = gpiochip_get_data(gc); struct qe_pio_regs __iomem *regs = mm_gc->regs; unsigned long flags; u32 pin_mask = 1 << (QE_PIO_PINS - 1 - gpio); @@ -89,7 +85,7 @@ static void qe_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) static int qe_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct qe_gpio_chip *qe_gc = to_qe_gpio_chip(mm_gc); + struct qe_gpio_chip *qe_gc = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&qe_gc->lock, flags); @@ -104,7 +100,7 @@ static int qe_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) static int qe_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct qe_gpio_chip *qe_gc = to_qe_gpio_chip(mm_gc); + struct qe_gpio_chip *qe_gc = gpiochip_get_data(gc); unsigned long flags; qe_gpio_set(gc, gpio, val); @@ -165,7 +161,7 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index) } mm_gc = to_of_mm_gpio_chip(gc); - qe_gc = to_qe_gpio_chip(mm_gc); + qe_gc = gpiochip_get_data(gc); spin_lock_irqsave(&qe_gc->lock, flags); @@ -302,7 +298,7 @@ static int __init qe_add_gpiochips(void) gc->get = qe_gpio_get; gc->set = qe_gpio_set; - ret = of_mm_gpiochip_add(np, mm_gc); + ret = of_mm_gpiochip_add_data(np, mm_gc, qe_gc); if (ret) goto err; continue;