From patchwork Wed Dec 9 13:13:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 57961 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp659537lbb; Wed, 9 Dec 2015 05:13:32 -0800 (PST) X-Received: by 10.98.72.152 with SMTP id q24mr12817875pfi.156.1449666811775; Wed, 09 Dec 2015 05:13:31 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bc9si12670093pad.140.2015.12.09.05.13.31; Wed, 09 Dec 2015 05:13:31 -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 S1753385AbbLINNb (ORCPT + 4 others); Wed, 9 Dec 2015 08:13:31 -0500 Received: from mail-lf0-f42.google.com ([209.85.215.42]:33628 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753331AbbLINNa (ORCPT ); Wed, 9 Dec 2015 08:13:30 -0500 Received: by lfaz4 with SMTP id z4so33926737lfa.0 for ; Wed, 09 Dec 2015 05:13:29 -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=hKV2YMeN35Kwp0jopnW7/cO12VlUGDqixJddk/6VXwQ=; b=u38S24RvgzTBv27IWpUP+W/c0kvIuscgXvf52ydTGHxSWl4uUHTRSsMxVh1tdtWbKA QkEBB5ErC4eXbgYkScAFR38UARIvU3ATwCC5ZPaG2k7scoohEqBYEDRrzO7EROfGL2Yr TZxYKV2TDBPd/ej6jUJ6FWJ/nHrMfoxNAmDA0XbiziyzlBwsO/tQdy17rlpUGvyR7phr jEIQvq424ZkBW1ARVkkOSMkwDwXA3p9/1twxreUJLpyj9V/rpv7mA+LH+AnxfjQY2Pv0 /RfjKE7xy+6kHcOG7z61DryN/F7ePu7UCCcs1V6DEywO8hfd01f/8sACCcIoQTqjkZtg ihmQ== 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=hKV2YMeN35Kwp0jopnW7/cO12VlUGDqixJddk/6VXwQ=; b=Hz/JveKke5qoY1vqVcGP76DXRtptSqEHx+wO1GoyLKAP1/7SAHV4IzDsi/0fRjD5gv AXlDI6a5zGuUNMzBtygH77aYCGSaiT9zJYmRvq/oXq2ax9BhDPa68X9bpXDKZaaLC7/3 2xNJMEviiALBjRxFPMSG1qxoCLeyiIgYxJjFYlM8Lt1T3ddXkhoYmT16cdzFsnQjZL6n oTQ8EK/gy+On6zzeWJ7moxeyOeXKGaAPIfx2lSYARMuC0uWKetdgcegpq7n6wrJfQFD2 7Uo7++fzND+ZTOHKy9LLghfZw/6/w+9/AVKLMTGpw2sYstwwnFUAwoAMZI86yYeXPuyL gsyA== X-Gm-Message-State: ALoCoQlGkb/arFX1lyltRp2M5ExQPK1hwV7KWRY3BBqLl6iuH7Pv4KUkWbHH49lYItBC4GWdx5xeGqZ2m6m66DXb1XfOb0fVlw== X-Received: by 10.25.209.148 with SMTP id i142mr2255029lfg.163.1449666809328; Wed, 09 Dec 2015 05:13:29 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j189sm1428091lfg.46.2015.12.09.05.13.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:13:28 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , William Breathitt Gray Subject: [PATCH 006/182] gpio: 104-idio-16: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:13:24 +0100 Message-Id: <1449666804-30018-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: William Breathitt Gray Signed-off-by: Linus Walleij --- drivers/gpio/gpio-104-idio-16.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 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-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c index efe3ff7d574e..019101e05270 100644 --- a/drivers/gpio/gpio-104-idio-16.c +++ b/drivers/gpio/gpio-104-idio-16.c @@ -72,14 +72,9 @@ static int idio_16_gpio_direction_output(struct gpio_chip *chip, return 0; } -static struct idio_16_gpio *to_idio16gpio(struct gpio_chip *gc) -{ - return container_of(gc, struct idio_16_gpio, chip); -} - static int idio_16_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct idio_16_gpio *const idio16gpio = to_idio16gpio(chip); + struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); const unsigned mask = BIT(offset-16); if (offset < 16) @@ -93,7 +88,7 @@ static int idio_16_gpio_get(struct gpio_chip *chip, unsigned offset) static void idio_16_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct idio_16_gpio *const idio16gpio = to_idio16gpio(chip); + struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); const unsigned mask = BIT(offset); unsigned long flags; @@ -118,7 +113,7 @@ static void idio_16_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static void idio_16_irq_ack(struct irq_data *data) { struct gpio_chip *chip = irq_data_get_irq_chip_data(data); - struct idio_16_gpio *const idio16gpio = to_idio16gpio(chip); + struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); unsigned long flags; spin_lock_irqsave(&idio16gpio->lock, flags); @@ -131,7 +126,7 @@ static void idio_16_irq_ack(struct irq_data *data) static void idio_16_irq_mask(struct irq_data *data) { struct gpio_chip *chip = irq_data_get_irq_chip_data(data); - struct idio_16_gpio *const idio16gpio = to_idio16gpio(chip); + struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); const unsigned long mask = BIT(irqd_to_hwirq(data)); unsigned long flags; @@ -149,7 +144,7 @@ static void idio_16_irq_mask(struct irq_data *data) static void idio_16_irq_unmask(struct irq_data *data) { struct gpio_chip *chip = irq_data_get_irq_chip_data(data); - struct idio_16_gpio *const idio16gpio = to_idio16gpio(chip); + struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); const unsigned long mask = BIT(irqd_to_hwirq(data)); const unsigned long prev_irq_mask = idio16gpio->irq_mask; unsigned long flags; @@ -236,7 +231,7 @@ static int __init idio_16_probe(struct platform_device *pdev) dev_set_drvdata(dev, idio16gpio); - err = gpiochip_add(&idio16gpio->chip); + err = gpiochip_add_data(&idio16gpio->chip, idio16gpio); if (err) { dev_err(dev, "GPIO registering failed (%d)\n", err); goto err_gpio_register;