From patchwork Wed Dec 9 13:41:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58099 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp675717lbb; Wed, 9 Dec 2015 05:41:14 -0800 (PST) X-Received: by 10.98.11.29 with SMTP id t29mr12989005pfi.97.1449668474498; Wed, 09 Dec 2015 05:41:14 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 86si12808196pfn.188.2015.12.09.05.41.14; Wed, 09 Dec 2015 05:41:14 -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 S1754144AbbLINlN (ORCPT + 4 others); Wed, 9 Dec 2015 08:41:13 -0500 Received: from mail-lf0-f42.google.com ([209.85.215.42]:33300 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753927AbbLINlN (ORCPT ); Wed, 9 Dec 2015 08:41:13 -0500 Received: by lfaz4 with SMTP id z4so34468997lfa.0 for ; Wed, 09 Dec 2015 05:41:11 -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=iZY85OUCmAUW3JeMkPyGoVSjdsc/ZAshDTQkjy1tqmY=; b=jY9m6TW09SctQieq/G6XOEF+cWi5DUTqZpqsyd7Q0q6BYoI6K+iYARISkH4xo3+zas MhhNh+LKmzmsjsLi/zu1Sh7IGxio/lqaAEryJotLIquoDTbrj7DENvY6UGlFBY8Omg/5 60wDxa3ryWlk1Em8n/fpY162jco0kHaC7562+X1sYmKrMcFOX6xSpyOxxvVww7Wy96uO 54ma1iAbD5SYIHehdAy2Rb5qa4hrKCIjA0Ff1h/bAumz2JGJPl56ClZkOcEYGmCx887d 5r9XLyWmVFzn4B+ssRaVRuOKq3mqFOzqVXcvKr1e5XuuQx/KqcTk6so/kRk7l9fud2R6 xOYQ== 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=iZY85OUCmAUW3JeMkPyGoVSjdsc/ZAshDTQkjy1tqmY=; b=I5cKSYeetMMNQEVqHzWEljrY+AZveOX2Lgwvv9yNb4+0VMeGUZueCErmnNtwPnZXts Jx7FqdEbD+uu9a5BGppwIVMcPxksvpuamXFroIsodqywPx8m23qM1EebkaCRb5AEu8Aa ygTnJuRI+rqCeHJxgCx8JkyDMcs+Cd4KzxavO2NUu/ZK6HK/xTYt/AD9jOPGJfEsRNxV wSWUja8Nl8eWKJWrB5SYFRtmXTrOR0QIF7OK7CQ59vvYA0f6tYg+g8/UjAF8il1PRk9+ F+GeMLE9ptD6CNG2aebyjjesHRNu8p++FMGiCXeCKnvrslE/5Bg2O/6IxlNVg2yiaHmt kXdw== X-Gm-Message-State: ALoCoQlVb3QKpchtIzwhphTleMRPfg1n3BsCP1sLPo9/Il5lA6F19i15KzNMleVbR5HV/AXTFSv1PFz47O98Y78rsN50DbGzwA== X-Received: by 10.25.29.205 with SMTP id d196mr2266394lfd.81.1449668471763; Wed, 09 Dec 2015 05:41:11 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id o5sm1403806lbw.16.2015.12.09.05.41.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:41:10 -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 143/182] powerpc: mpc52xx_gpt: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:41:06 +0100 Message-Id: <1449668466-4882-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/platforms/52xx/mpc52xx_gpt.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/platforms/52xx/mpc52xx_gpt.c b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c index 3048e34db6d8..f112e96ab8a3 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c @@ -278,14 +278,9 @@ mpc52xx_gpt_irq_setup(struct mpc52xx_gpt_priv *gpt, struct device_node *node) * GPIOLIB hooks */ #if defined(CONFIG_GPIOLIB) -static inline struct mpc52xx_gpt_priv *gc_to_mpc52xx_gpt(struct gpio_chip *gc) -{ - return container_of(gc, struct mpc52xx_gpt_priv, gc); -} - static int mpc52xx_gpt_gpio_get(struct gpio_chip *gc, unsigned int gpio) { - struct mpc52xx_gpt_priv *gpt = gc_to_mpc52xx_gpt(gc); + struct mpc52xx_gpt_priv *gpt = gpiochip_get_data(gc); return (in_be32(&gpt->regs->status) >> 8) & 1; } @@ -293,7 +288,7 @@ static int mpc52xx_gpt_gpio_get(struct gpio_chip *gc, unsigned int gpio) static void mpc52xx_gpt_gpio_set(struct gpio_chip *gc, unsigned int gpio, int v) { - struct mpc52xx_gpt_priv *gpt = gc_to_mpc52xx_gpt(gc); + struct mpc52xx_gpt_priv *gpt = gpiochip_get_data(gc); unsigned long flags; u32 r; @@ -307,7 +302,7 @@ mpc52xx_gpt_gpio_set(struct gpio_chip *gc, unsigned int gpio, int v) static int mpc52xx_gpt_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) { - struct mpc52xx_gpt_priv *gpt = gc_to_mpc52xx_gpt(gc); + struct mpc52xx_gpt_priv *gpt = gpiochip_get_data(gc); unsigned long flags; dev_dbg(gpt->dev, "%s: gpio:%d\n", __func__, gpio); @@ -354,7 +349,7 @@ mpc52xx_gpt_gpio_setup(struct mpc52xx_gpt_priv *gpt, struct device_node *node) clrsetbits_be32(&gpt->regs->mode, MPC52xx_GPT_MODE_MS_MASK, MPC52xx_GPT_MODE_MS_GPIO); - rc = gpiochip_add(&gpt->gc); + rc = gpiochip_add_data(&gpt->gc, gpt); if (rc) dev_err(gpt->dev, "gpiochip_add() failed; rc=%i\n", rc);