From patchwork Wed Dec 9 13:31:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58057 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp670348lbb; Wed, 9 Dec 2015 05:31:52 -0800 (PST) X-Received: by 10.66.55.6 with SMTP id n6mr7860364pap.33.1449667911927; Wed, 09 Dec 2015 05:31:51 -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.51; Wed, 09 Dec 2015 05:31:51 -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 S1754352AbbLINbv (ORCPT + 4 others); Wed, 9 Dec 2015 08:31:51 -0500 Received: from mail-lf0-f41.google.com ([209.85.215.41]:36363 "EHLO mail-lf0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754233AbbLINbu (ORCPT ); Wed, 9 Dec 2015 08:31:50 -0500 Received: by lfs39 with SMTP id 39so34438342lfs.3 for ; Wed, 09 Dec 2015 05:31:49 -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=/bWuKYJzqiiRb6VMZVG/gdan/VEdublx05EvzR36+Tc=; b=Ch0WnFLMonyldCD828gHtdFSIa6vuEiLgOlURS5cvGCEPQVQFfij6JKTQLUYvUA7M/ Sd5y2qg8bqLnT1hXE1cM2Z3RFeqmk8BdkXYhQ+JQGunsE0kyqLDzVbFej3x0FB0wnnei 2KqyYA9/MtfojHKv1ve5JA6C4yXOiPT3AoSVSqaM2GMba/qm4kilqQ/fxLCELJor8lSy 40cx63+Q6qf1AMbnEO1HdX8YxaCdrONBNckn0Aq2Y+LfPZaMi908zOzz52J4pDATYZhz EDRH1SxxXNQE8nG65RVQx763YmQDGxo0yYnD1p7WGl8RyhY5YhnqSn9+a8yumiKT7PVI x5fQ== 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=/bWuKYJzqiiRb6VMZVG/gdan/VEdublx05EvzR36+Tc=; b=H0/dofv7ie+QUyoym+EgFR1cdYPF9TFBKIqwlabLuMTNL7KgkGLrnCxH6rz+VP8tAX 6dW/FWptdPTaLXWrmEa0qQPPEoP1+Sa5ddBgQ7Mv0Hnv8jzhkwXJz5qRgAeEMwaWvA0j ELkOrsuFzxRsxi0ZRpByvawJ81cxZ9AARFCEffCx3a2gfGd5ztcawjvFN4EWuDkYDI08 sJOcfJfvHpixJ4JvVFkK3becD0LqiBJTTbTF99Ic34OhBT1Gb7IaoKzK1l6wkcV9D5R3 6wdzZoiAiDJWLKgaumDa/U+ZxsziOJXYYsdzQbP4HylTpQbUjJgRbkJUhzBBD+fBm8Si xGOA== X-Gm-Message-State: ALoCoQlWGSuu5BLU+ohwQ5WPbH65vnw75L3KAU/mQqJ7+BfIWkI05PIqFG8pv8PE4q/PQdInjG0kW56lFhGdDIrJanX9WVWfLA== X-Received: by 10.25.80.204 with SMTP id e195mr2421708lfb.133.1449667908949; Wed, 09 Dec 2015 05:31:48 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id zs6sm1410948lbb.26.2015.12.09.05.31.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:31:48 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Jean-Christophe Plagniol-Villard Subject: [PATCH 101/182] pinctrl: at91: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:31:45 +0100 Message-Id: <1449667905-2505-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: Jean-Christophe Plagniol-Villard Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-at91.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 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-at91.c b/drivers/pinctrl/pinctrl-at91.c index 667d90607abc..dd300683153f 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -45,8 +45,6 @@ struct at91_gpio_chip { struct at91_pinctrl_mux_ops *ops; /* ops */ }; -#define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip) - static struct at91_gpio_chip *gpio_chips[MAX_GPIO_BANKS]; static int gpio_banks; @@ -811,7 +809,7 @@ static int at91_gpio_request_enable(struct pinctrl_dev *pctldev, return -EINVAL; } chip = range->gc; - at91_chip = container_of(chip, struct at91_gpio_chip, chip); + at91_chip = gpiochip_get_data(chip); dev_dbg(npct->dev, "enable pin %u as GPIO\n", offset); @@ -1282,7 +1280,7 @@ static int at91_pinctrl_remove(struct platform_device *pdev) static int at91_gpio_get_direction(struct gpio_chip *chip, unsigned offset) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; u32 osr; @@ -1293,7 +1291,7 @@ static int at91_gpio_get_direction(struct gpio_chip *chip, unsigned offset) static int at91_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; @@ -1303,7 +1301,7 @@ static int at91_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int at91_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; u32 pdsr; @@ -1315,7 +1313,7 @@ static int at91_gpio_get(struct gpio_chip *chip, unsigned offset) static void at91_gpio_set(struct gpio_chip *chip, unsigned offset, int val) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; @@ -1325,7 +1323,7 @@ static void at91_gpio_set(struct gpio_chip *chip, unsigned offset, static void at91_gpio_set_multiple(struct gpio_chip *chip, unsigned long *mask, unsigned long *bits) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; #define BITS_MASK(bits) (((bits) == 32) ? ~0U : (BIT(bits) - 1)) @@ -1340,7 +1338,7 @@ static void at91_gpio_set_multiple(struct gpio_chip *chip, static int at91_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int val) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; @@ -1355,7 +1353,7 @@ static void at91_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { enum at91_mux mode; int i; - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; for (i = 0; i < chip->ngpio; i++) { @@ -1570,9 +1568,7 @@ static void gpio_irq_handler(struct irq_desc *desc) { struct irq_chip *chip = irq_desc_get_chip(desc); struct gpio_chip *gpio_chip = irq_desc_get_handler_data(desc); - struct at91_gpio_chip *at91_gpio = container_of(gpio_chip, - struct at91_gpio_chip, chip); - + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(gpio_chip); void __iomem *pio = at91_gpio->regbase; unsigned long isr; int n; @@ -1648,7 +1644,7 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev, return 0; } - prev = container_of(gpiochip_prev, struct at91_gpio_chip, chip); + prev = gpiochip_get_data(gpiochip_prev); /* we can only have 2 banks before */ for (i = 0; i < 2; i++) { @@ -1783,7 +1779,7 @@ static int at91_gpio_probe(struct platform_device *pdev) range->npins = chip->ngpio; range->gc = chip; - ret = gpiochip_add(chip); + ret = gpiochip_add_data(chip, at91_chip); if (ret) goto gpiochip_add_err;