From patchwork Wed Dec 9 13:22:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58009 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp664908lbb; Wed, 9 Dec 2015 05:22:17 -0800 (PST) X-Received: by 10.66.142.232 with SMTP id rz8mr7957616pab.74.1449667337632; Wed, 09 Dec 2015 05:22:17 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y79si12719779pfa.175.2015.12.09.05.22.17; Wed, 09 Dec 2015 05:22:17 -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 S1754523AbbLINWO (ORCPT + 4 others); Wed, 9 Dec 2015 08:22:14 -0500 Received: from mail-lf0-f54.google.com ([209.85.215.54]:34501 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754284AbbLINWN (ORCPT ); Wed, 9 Dec 2015 08:22:13 -0500 Received: by lffu14 with SMTP id u14so34114975lff.1 for ; Wed, 09 Dec 2015 05:22: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=hhRqCCYijKEqqPjIhaxS1+TSg8DR4gs1yUz/jukj8DA=; b=VEViIscOg1zADRxFeEOKo4mm56EIFHUnZoyqXD2mMp0pSom86V5fYWTcaSeZrmD/oP dJYIv/1HVhkauZP+fqyJ6qKpuxyCLfxogzg6JxoznTaqYPpVP1L795Z0RXX4GjSvS9TO 7yn3O1KLQHdCOkg9HBiTX4S817yZDPYdNhDHHT8iXJazPQIdzCZugc2OmrtMMU360XDR LRQzR1hS/JmQq2lnjmCCt0R9wyHGaMcI338UTwsc4tLYggdL3eX7gC3gwKlHYFbGIZWH ARtFyy8nHEUKq+mQ/Rttz0C89ihp9CnsZXRHxKS7WAmpkOyrXaOgU97YmtKhMRzmeBm5 RiYA== 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=hhRqCCYijKEqqPjIhaxS1+TSg8DR4gs1yUz/jukj8DA=; b=SvVu070lNyFQZDvGEQGdl/6cvdj5SwpJrooBnW5AmX6OIKLDLWa/qWTxEBdLRjHpzp D1SimIbs3mXzKcAKZ18swF63vonIV7XOrFiGnwO52vrkABxMkxGGO9zz0v2KQYLlQkmR 9LbqIv3fhiEScoVZwkr4DF94VhboshI6HwNNWKOiLJzGZonXNG6hFsCuB0oA09BV6Jsm s/B2pcmJJXDM1+6ebhSkKmAOPJWu/RcQarf5/yE5jxTfrni3w8J7P32/Jan4U3wwEaWD maezuEOc0tS/5UuZrtZfkrqLmdHDk1GXcCHUjClBquLF0F8+FAobGYcikojTbj00OKkv S6gA== X-Gm-Message-State: ALoCoQntPf1cxT7BmXI+lB8fjSo4fTsEEd59KpM8M3b/jbS46FseCL77jgCUdOOARf9+tIh6AP9RfDHjFfgejRVRGDkXZnAKAQ== X-Received: by 10.25.27.16 with SMTP id b16mr1750142lfb.149.1449667331716; Wed, 09 Dec 2015 05:22:11 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id d130sm1446782lfe.18.2015.12.09.05.22.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:22:11 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Ulrich Hecht , Geert Uytterhoeven , Hisashi Nakamura Subject: [PATCH 054/182] gpio: rcar: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:22:08 +0100 Message-Id: <1449667328-32341-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: Ulrich Hecht Cc: Geert Uytterhoeven Cc: Hisashi Nakamura Signed-off-by: Linus Walleij --- drivers/gpio/gpio-rcar.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 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/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index 3cbb25ecfc7a..d81051f21973 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -84,8 +84,7 @@ static void gpio_rcar_modify_bit(struct gpio_rcar_priv *p, int offs, static void gpio_rcar_irq_disable(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct gpio_rcar_priv *p = container_of(gc, struct gpio_rcar_priv, - gpio_chip); + struct gpio_rcar_priv *p = gpiochip_get_data(gc); gpio_rcar_write(p, INTMSK, ~BIT(irqd_to_hwirq(d))); } @@ -93,8 +92,7 @@ static void gpio_rcar_irq_disable(struct irq_data *d) static void gpio_rcar_irq_enable(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct gpio_rcar_priv *p = container_of(gc, struct gpio_rcar_priv, - gpio_chip); + struct gpio_rcar_priv *p = gpiochip_get_data(gc); gpio_rcar_write(p, MSKCLR, BIT(irqd_to_hwirq(d))); } @@ -137,8 +135,7 @@ static void gpio_rcar_config_interrupt_input_mode(struct gpio_rcar_priv *p, static int gpio_rcar_irq_set_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct gpio_rcar_priv *p = container_of(gc, struct gpio_rcar_priv, - gpio_chip); + struct gpio_rcar_priv *p = gpiochip_get_data(gc); unsigned int hwirq = irqd_to_hwirq(d); dev_dbg(&p->pdev->dev, "sense irq = %d, type = %d\n", hwirq, type); @@ -175,8 +172,7 @@ static int gpio_rcar_irq_set_type(struct irq_data *d, unsigned int type) static int gpio_rcar_irq_set_wake(struct irq_data *d, unsigned int on) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct gpio_rcar_priv *p = container_of(gc, struct gpio_rcar_priv, - gpio_chip); + struct gpio_rcar_priv *p = gpiochip_get_data(gc); int error; if (p->irq_parent) { @@ -218,16 +214,11 @@ static irqreturn_t gpio_rcar_irq_handler(int irq, void *dev_id) return irqs_handled ? IRQ_HANDLED : IRQ_NONE; } -static inline struct gpio_rcar_priv *gpio_to_priv(struct gpio_chip *chip) -{ - return container_of(chip, struct gpio_rcar_priv, gpio_chip); -} - static void gpio_rcar_config_general_input_output_mode(struct gpio_chip *chip, unsigned int gpio, bool output) { - struct gpio_rcar_priv *p = gpio_to_priv(chip); + struct gpio_rcar_priv *p = gpiochip_get_data(chip); unsigned long flags; /* follow steps in the GPIO documentation for @@ -251,7 +242,7 @@ static void gpio_rcar_config_general_input_output_mode(struct gpio_chip *chip, static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset) { - struct gpio_rcar_priv *p = gpio_to_priv(chip); + struct gpio_rcar_priv *p = gpiochip_get_data(chip); int error; error = pm_runtime_get_sync(&p->pdev->dev); @@ -267,7 +258,7 @@ static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset) static void gpio_rcar_free(struct gpio_chip *chip, unsigned offset) { - struct gpio_rcar_priv *p = gpio_to_priv(chip); + struct gpio_rcar_priv *p = gpiochip_get_data(chip); pinctrl_free_gpio(chip->base + offset); @@ -291,15 +282,15 @@ static int gpio_rcar_get(struct gpio_chip *chip, unsigned offset) /* testing on r8a7790 shows that INDT does not show correct pin state * when configured as output, so use OUTDT in case of output pins */ - if (gpio_rcar_read(gpio_to_priv(chip), INOUTSEL) & bit) - return !!(gpio_rcar_read(gpio_to_priv(chip), OUTDT) & bit); + if (gpio_rcar_read(gpiochip_get_data(chip), INOUTSEL) & bit) + return !!(gpio_rcar_read(gpiochip_get_data(chip), OUTDT) & bit); else - return !!(gpio_rcar_read(gpio_to_priv(chip), INDT) & bit); + return !!(gpio_rcar_read(gpiochip_get_data(chip), INDT) & bit); } static void gpio_rcar_set(struct gpio_chip *chip, unsigned offset, int value) { - struct gpio_rcar_priv *p = gpio_to_priv(chip); + struct gpio_rcar_priv *p = gpiochip_get_data(chip); unsigned long flags; spin_lock_irqsave(&p->lock, flags); @@ -462,7 +453,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) irq_chip->irq_set_wake = gpio_rcar_irq_set_wake; irq_chip->flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND; - ret = gpiochip_add(gpio_chip); + ret = gpiochip_add_data(gpio_chip, p); if (ret) { dev_err(dev, "failed to add GPIO controller\n"); goto err0;