From patchwork Wed Dec 9 13:31:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58055 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp670194lbb; Wed, 9 Dec 2015 05:31:36 -0800 (PST) X-Received: by 10.98.66.152 with SMTP id h24mr13132969pfd.52.1449667895907; Wed, 09 Dec 2015 05:31:35 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f18si12793619pfj.115.2015.12.09.05.31.35; Wed, 09 Dec 2015 05:31:35 -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 S1754518AbbLINbf (ORCPT + 4 others); Wed, 9 Dec 2015 08:31:35 -0500 Received: from mail-lf0-f49.google.com ([209.85.215.49]:36219 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754327AbbLINbe (ORCPT ); Wed, 9 Dec 2015 08:31:34 -0500 Received: by lfs39 with SMTP id 39so34433130lfs.3 for ; Wed, 09 Dec 2015 05:31:33 -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=Hfx6rSce/9ccvfLQpjKOBjjT6GBDLwomQkwo7w0yfdk=; b=kCI47PJ4nYzgNNrvHrhreNDCmpX1JBjRXu/z1i3QACV/X6p6QRbj7fUDOsh78JWO0O wkiWZHJonc4xaQk1jJXymR1aW0RQMdxg1Llk+2C50N/bZmVMgOCcwbtf3dQz20K2y/eg mZZvGQPAL+zp0RquVA0PI7iIK2k+YvxEB5y03TLs4xvzvQKUBIKWjtlS5zTPkt2Lu/XH +xQ4AfxlqEWzdWay35+Luf3CevVWbZxidZdFXQmYEN2T25UISVV9TIXD98j9Un+wp8O3 7m+PFuBRgzqvmVDah7zox6W4abP2vexSZRLodBJ35cIKpOznEGHAf7liEKYPyQ/hdJ/z bHuA== 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=Hfx6rSce/9ccvfLQpjKOBjjT6GBDLwomQkwo7w0yfdk=; b=mxGNdGFowgHnTUj+VChhD8i9iVPMSIj4JIENvHRxIHkTK53YzrhZW0Fjb7rl/8nqpj i+0/conmAGtFrUNF+F165ycLrRp9QGwTev88Z0k7oJ7kB8/qmXPME5EOaS7xWyFFWJrs hMWlowcxjUK/GaYF6HvBatrsbO2Ysf+n15PltE1ICuq82N5xzeXl3Yw1kdTm2+tPDH+5 KulrJGHn6O7M8aWddJtqxJz4f1MDZ/qWjPPEeenn0RFXZhD8yigm0GS6RGDpabZBkOYA 9kE0YxCpMfhNxkCS0Xyn6DSuUg3hBpupkGXC4hebVpTtLTFZla7QLG+3TlChZ6lJsCFX CEWg== X-Gm-Message-State: ALoCoQmmy8Sic/0G7xRlsueSZ5HGpRokm9/pJ2X3fSp4Sn99B8yJkzBNs+80rH8CH5xFrwt4oWD1IpesRPGX0WzKRU8xrXY8cA== X-Received: by 10.25.143.134 with SMTP id r128mr2352913lfd.56.1449667893170; Wed, 09 Dec 2015 05:31:33 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id q8sm1436912lbr.1.2015.12.09.05.31.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:31:32 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Ken Xue Subject: [PATCH 099/182] pinctrl: amd: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:31:28 +0100 Message-Id: <1449667888-2402-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: Ken Xue Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-amd.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 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/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c index a74b2b0a75e0..657449431301 100644 --- a/drivers/pinctrl/pinctrl-amd.c +++ b/drivers/pinctrl/pinctrl-amd.c @@ -35,16 +35,11 @@ #include "pinctrl-utils.h" #include "pinctrl-amd.h" -static inline struct amd_gpio *to_amd_gpio(struct gpio_chip *gc) -{ - return container_of(gc, struct amd_gpio, gc); -} - static int amd_gpio_direction_input(struct gpio_chip *gc, unsigned offset) { unsigned long flags; u32 pin_reg; - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + offset * 4); @@ -71,7 +66,7 @@ static int amd_gpio_direction_output(struct gpio_chip *gc, unsigned offset, { u32 pin_reg; unsigned long flags; - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + offset * 4); @@ -90,7 +85,7 @@ static int amd_gpio_get_value(struct gpio_chip *gc, unsigned offset) { u32 pin_reg; unsigned long flags; - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + offset * 4); @@ -103,7 +98,7 @@ static void amd_gpio_set_value(struct gpio_chip *gc, unsigned offset, int value) { u32 pin_reg; unsigned long flags; - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + offset * 4); @@ -122,7 +117,7 @@ static int amd_gpio_set_debounce(struct gpio_chip *gc, unsigned offset, u32 pin_reg; int ret = 0; unsigned long flags; - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + offset * 4); @@ -186,7 +181,7 @@ static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc) u32 pin_reg; unsigned long flags; unsigned int bank, i, pin_num; - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); char *level_trig; char *active_level; @@ -327,7 +322,7 @@ static void amd_gpio_irq_enable(struct irq_data *d) u32 pin_reg; unsigned long flags; struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + (d->hwirq)*4); @@ -351,7 +346,7 @@ static void amd_gpio_irq_disable(struct irq_data *d) u32 pin_reg; unsigned long flags; struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + (d->hwirq)*4); @@ -366,7 +361,7 @@ static void amd_gpio_irq_mask(struct irq_data *d) u32 pin_reg; unsigned long flags; struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + (d->hwirq)*4); @@ -380,7 +375,7 @@ static void amd_gpio_irq_unmask(struct irq_data *d) u32 pin_reg; unsigned long flags; struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + (d->hwirq)*4); @@ -394,7 +389,7 @@ static void amd_gpio_irq_eoi(struct irq_data *d) u32 reg; unsigned long flags; struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); reg = readl(gpio_dev->base + WAKE_INT_MASTER_REG); @@ -409,7 +404,7 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) u32 pin_reg; unsigned long flags; struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + (d->hwirq)*4); @@ -504,7 +499,7 @@ static void amd_gpio_irq_handler(struct irq_desc *desc) unsigned long flags; struct irq_chip *chip = irq_desc_get_chip(desc); struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); chained_irq_enter(chip, desc); /*enable GPIO interrupt again*/ @@ -795,7 +790,7 @@ static int amd_gpio_probe(struct platform_device *pdev) return PTR_ERR(gpio_dev->pctrl); } - ret = gpiochip_add(&gpio_dev->gc); + ret = gpiochip_add_data(&gpio_dev->gc, gpio_dev); if (ret) goto out1;