From patchwork Wed Dec 9 13:31:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58053 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp670114lbb; Wed, 9 Dec 2015 05:31:27 -0800 (PST) X-Received: by 10.66.150.228 with SMTP id ul4mr7957822pab.15.1449667887477; Wed, 09 Dec 2015 05:31:27 -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.27; Wed, 09 Dec 2015 05:31:27 -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 S1754592AbbLINbU (ORCPT + 4 others); Wed, 9 Dec 2015 08:31:20 -0500 Received: from mail-lf0-f45.google.com ([209.85.215.45]:36075 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754518AbbLINbS (ORCPT ); Wed, 9 Dec 2015 08:31:18 -0500 Received: by lfs39 with SMTP id 39so34427815lfs.3 for ; Wed, 09 Dec 2015 05:31:17 -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=jPK9224uWbxJStSkIHe5YE4MVunqF11vZT2rJ62Rt8s=; b=Ulawy8P9XgRxrc7JNSc4tHvEdPP3zwK8VplmaYBQ1KOtCghHVe3NtOCLqw+Ake8d6X Gea9vICcIq87u+iQlF/z8Bn5CTmKn/280c8oLZcDReamXXtkkB4YonUel0/ahOViMCOg e8BLi/N67+P6gW0V6xLw1MdkBsP92DhmrYq+WEymuvhb8SVylb7sj0zP02H5Fa+Vfspy JUKQULmgPaMbQHEiPkvUJOrMWs5kkNiNs7ohOCBAMRTe/z2+mo5//xDK25A+9YRuadvE gnCRTctlkFk/7TTT25JgTTjAewSiH9TExRmIap8XaMvzzrpVZ5Ajlj+u6CsGNZ5Dpzhp 59Vw== 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=jPK9224uWbxJStSkIHe5YE4MVunqF11vZT2rJ62Rt8s=; b=EYDBXbcOEiP0Bu5fXd3x0CjzFvUBAqERRsmKC1gSx39vCKbFufED+FK9trQmAsNw71 vVXoMcAs7FTeIuovwWq+6mc5aauGYq0p05PRqKEt+QJFHi/cG6ISMPDKgdepWSTwNM45 iFntA9gkL2rA4bkR0XH1/1e4OhFrqhGoatrxZOEVVDeYsv6gJDfBJxxgqibUh3I6/pgo mSafTDjL7IlHc9ubANjOPsUFk9S8xZO7XdNdShQNWK0ugO87uZuUu1wKFuodX2zCu99/ IYCgIG4Wtj6LPcroIIpGCw/jSkKDY18pRYeIey76BvQIdfD9Q06LRHT+IB3u9PhTN/Ua 043A== X-Gm-Message-State: ALoCoQnnmI+JWXufBGM/vVB4RdQdGsDA/t5Jex7jXPHiiVm+Ikj/Ad7fLKVATruYc/VGZXcEBPLxnw851Ogvc3FumAaihJPqbQ== X-Received: by 10.25.159.130 with SMTP id i124mr2241416lfe.144.1449667877351; Wed, 09 Dec 2015 05:31:17 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id f71sm1444026lfe.36.2015.12.09.05.31.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:31:16 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij Subject: [PATCH 097/182] pinctrl: abx500: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:31:14 +0100 Message-Id: <1449667874-2245-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(). Signed-off-by: Linus Walleij --- drivers/pinctrl/nomadik/pinctrl-abx500.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 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/nomadik/pinctrl-abx500.c b/drivers/pinctrl/nomadik/pinctrl-abx500.c index 434d5de0177b..085e60106ec2 100644 --- a/drivers/pinctrl/nomadik/pinctrl-abx500.c +++ b/drivers/pinctrl/nomadik/pinctrl-abx500.c @@ -109,19 +109,10 @@ struct abx500_pinctrl { int irq_cluster_size; }; -/** - * to_abx500_pinctrl() - get the pointer to abx500_pinctrl - * @chip: Member of the structure abx500_pinctrl - */ -static inline struct abx500_pinctrl *to_abx500_pinctrl(struct gpio_chip *chip) -{ - return container_of(chip, struct abx500_pinctrl, chip); -} - static int abx500_gpio_get_bit(struct gpio_chip *chip, u8 reg, unsigned offset, bool *bit) { - struct abx500_pinctrl *pct = to_abx500_pinctrl(chip); + struct abx500_pinctrl *pct = gpiochip_get_data(chip); u8 pos = offset % 8; u8 val; int ret; @@ -143,7 +134,7 @@ static int abx500_gpio_get_bit(struct gpio_chip *chip, u8 reg, static int abx500_gpio_set_bits(struct gpio_chip *chip, u8 reg, unsigned offset, int val) { - struct abx500_pinctrl *pct = to_abx500_pinctrl(chip); + struct abx500_pinctrl *pct = gpiochip_get_data(chip); u8 pos = offset % 8; int ret; @@ -164,7 +155,7 @@ static int abx500_gpio_set_bits(struct gpio_chip *chip, u8 reg, */ static int abx500_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct abx500_pinctrl *pct = to_abx500_pinctrl(chip); + struct abx500_pinctrl *pct = gpiochip_get_data(chip); bool bit; bool is_out; u8 gpio_offset = offset - 1; @@ -192,7 +183,7 @@ out: static void abx500_gpio_set(struct gpio_chip *chip, unsigned offset, int val) { - struct abx500_pinctrl *pct = to_abx500_pinctrl(chip); + struct abx500_pinctrl *pct = gpiochip_get_data(chip); int ret; ret = abx500_gpio_set_bits(chip, AB8500_GPIO_OUT1_REG, offset, val); @@ -272,7 +263,7 @@ out: static bool abx500_pullud_supported(struct gpio_chip *chip, unsigned gpio) { - struct abx500_pinctrl *pct = to_abx500_pinctrl(chip); + struct abx500_pinctrl *pct = gpiochip_get_data(chip); struct pullud *pullud = pct->soc->pullud; return (pullud && @@ -284,7 +275,7 @@ static int abx500_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int val) { - struct abx500_pinctrl *pct = to_abx500_pinctrl(chip); + struct abx500_pinctrl *pct = gpiochip_get_data(chip); unsigned gpio; int ret; @@ -332,7 +323,7 @@ static int abx500_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int abx500_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct abx500_pinctrl *pct = to_abx500_pinctrl(chip); + struct abx500_pinctrl *pct = gpiochip_get_data(chip); /* The AB8500 GPIO numbers are off by one */ int gpio = offset + 1; int hwirq; @@ -634,7 +625,7 @@ static void abx500_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { unsigned i; unsigned gpio = chip->base; - struct abx500_pinctrl *pct = to_abx500_pinctrl(chip); + struct abx500_pinctrl *pct = gpiochip_get_data(chip); struct pinctrl_dev *pctldev = pct->pctldev; for (i = 0; i < chip->ngpio; i++, gpio++) { @@ -1211,7 +1202,7 @@ static int abx500_gpio_probe(struct platform_device *pdev) pct->irq_cluster = pct->soc->gpio_irq_cluster; pct->irq_cluster_size = pct->soc->ngpio_irq_cluster; - ret = gpiochip_add(&pct->chip); + ret = gpiochip_add_data(&pct->chip, pct); if (ret) { dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret); return ret;