From patchwork Wed Dec 9 13:31:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58058 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp670448lbb; Wed, 9 Dec 2015 05:32:00 -0800 (PST) X-Received: by 10.98.0.138 with SMTP id 132mr12929140pfa.131.1449667920552; Wed, 09 Dec 2015 05:32:00 -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.32.00; Wed, 09 Dec 2015 05:32:00 -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 S1754281AbbLINcA (ORCPT + 4 others); Wed, 9 Dec 2015 08:32:00 -0500 Received: from mail-lf0-f47.google.com ([209.85.215.47]:36450 "EHLO mail-lf0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754132AbbLINb7 (ORCPT ); Wed, 9 Dec 2015 08:31:59 -0500 Received: by lfs39 with SMTP id 39so34441419lfs.3 for ; Wed, 09 Dec 2015 05:31:58 -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=bH43mdV3npborSdCwX4akXbgt/oBObOc2qm5K9FuzA8=; b=E86KFFDNaESt5SU7OBmNKiWcfyZhMI5L4VWlaiuTK/EPqJ3Z/PSmKSBoOKEu39Dsag DhUuvJmNtsEhy8wjWqzbwiZTIPg4dUd5WxWe5eg3ogSA+xw4YsVzSCcfm+0bX6FX9LlT GhGOrZrfGEI2QwItVGJp528b1VyL+zOMyYazpo1sDnhff23f6cR4Qcwaow/k9Ub98GOl PSRKoPTz8M7JAvny2FGsQ9ImKLM+paxdlASclQ5Iby5U1l4qxF05MVgPzfnStfj2b+Nm C1KkQPNpsBsn1dZYYeL5L55OkzPKF8mPUzYQ3E64H5jN3m/ULXfSgfjKxkJ+kI2z1Jjg ZJyQ== 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=bH43mdV3npborSdCwX4akXbgt/oBObOc2qm5K9FuzA8=; b=dzCIluPJL06Z4XFt3Sup8fQX7VQJRGP6Ntr6T+/NsgSiZMevr32UxiJArsP1y5ovAi iXIVvDs04ua5Pz/HGMwiHbB+RjyefCp/XBxfJXUtatQrFP0t/PNgzJDKjEc2y1A6kw7H RoZhNtMoLZ/Xv/RYLe7JNqWGhiEZbLdkxBZ0V4gKHvQgb8Q+K8pnTBycC6mBqevs6CCP vOKe6I4NE2m5JMB+P5x5Sc5roqRD1iuJ0v7oqkAb+zwSPpiVERrTJuCrQ35nWpIOMGv8 7hs38DpSPna6jH1GNmfZFJ7P6s+e/WsYEXIuX5zZif3jd41GkOYpc2U9xjG0iHBXhFcD b/Lg== X-Gm-Message-State: ALoCoQlR7PFzjs9eDCzwIzSxMNJ1H4CsarItUZ6bST5yKtNpt82VPRcA8qkxcfrYMMeKGry76bOFoTqec2QARzleS6YRYKdRUg== X-Received: by 10.25.30.5 with SMTP id e5mr1824567lfe.48.1449667917921; Wed, 09 Dec 2015 05:31:57 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id k14sm1442668lfb.49.2015.12.09.05.31.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:31:57 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij Subject: [PATCH 102/182] pinctrl: u300: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:31:55 +0100 Message-Id: <1449667915-2562-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/pinctrl-coh901.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 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-coh901.c b/drivers/pinctrl/pinctrl-coh901.c index e1cbf56df4b2..49da5c69845d 100644 --- a/drivers/pinctrl/pinctrl-coh901.c +++ b/drivers/pinctrl/pinctrl-coh901.c @@ -208,25 +208,16 @@ bs335_gpio_config[U300_GPIO_NUM_PORTS][U300_GPIO_PINS_PER_PORT] = { } }; -/** - * to_u300_gpio() - get the pointer to u300_gpio - * @chip: the gpio chip member of the structure u300_gpio - */ -static inline struct u300_gpio *to_u300_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct u300_gpio, chip); -} - static int u300_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); return readl(U300_PIN_REG(offset, dir)) & U300_PIN_BIT(offset); } static void u300_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); unsigned long flags; u32 val; @@ -243,7 +234,7 @@ static void u300_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int u300_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); unsigned long flags; u32 val; @@ -259,7 +250,7 @@ static int u300_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int u300_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); unsigned long flags; u32 oldmode; u32 val; @@ -290,7 +281,7 @@ int u300_gpio_config_get(struct gpio_chip *chip, unsigned offset, unsigned long *config) { - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); enum pin_config_param param = (enum pin_config_param) *config; bool biasmode; u32 drmode; @@ -348,7 +339,7 @@ int u300_gpio_config_get(struct gpio_chip *chip, int u300_gpio_config_set(struct gpio_chip *chip, unsigned offset, enum pin_config_param param) { - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); unsigned long flags; u32 val; @@ -429,7 +420,7 @@ static void u300_toggle_trigger(struct u300_gpio *gpio, unsigned offset) static int u300_gpio_irq_type(struct irq_data *d, unsigned trigger) { struct gpio_chip *chip = irq_data_get_irq_chip_data(d); - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); struct u300_gpio_port *port = &gpio->ports[d->hwirq >> 3]; int offset = d->hwirq; u32 val; @@ -466,7 +457,7 @@ static int u300_gpio_irq_type(struct irq_data *d, unsigned trigger) static void u300_gpio_irq_enable(struct irq_data *d) { struct gpio_chip *chip = irq_data_get_irq_chip_data(d); - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); struct u300_gpio_port *port = &gpio->ports[d->hwirq >> 3]; int offset = d->hwirq; u32 val; @@ -483,7 +474,7 @@ static void u300_gpio_irq_enable(struct irq_data *d) static void u300_gpio_irq_disable(struct irq_data *d) { struct gpio_chip *chip = irq_data_get_irq_chip_data(d); - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); int offset = d->hwirq; u32 val; unsigned long flags; @@ -506,7 +497,7 @@ static void u300_gpio_irq_handler(struct irq_desc *desc) unsigned int irq = irq_desc_get_irq(desc); struct irq_chip *parent_chip = irq_desc_get_chip(desc); struct gpio_chip *chip = irq_desc_get_handler_data(desc); - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); struct u300_gpio_port *port = &gpio->ports[irq - chip->base]; int pinoffset = port->number << 3; /* get the right stride */ unsigned long val; @@ -684,7 +675,7 @@ static int __init u300_gpio_probe(struct platform_device *pdev) #ifdef CONFIG_OF_GPIO gpio->chip.of_node = pdev->dev.of_node; #endif - err = gpiochip_add(&gpio->chip); + err = gpiochip_add_data(&gpio->chip, gpio); if (err) { dev_err(gpio->dev, "unable to add gpiochip: %d\n", err); goto err_no_chip;