From patchwork Wed Dec 9 13:28:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58037 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp668174lbb; Wed, 9 Dec 2015 05:28:08 -0800 (PST) X-Received: by 10.66.255.10 with SMTP id am10mr7898693pad.79.1449667688154; Wed, 09 Dec 2015 05:28:08 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ny6si12718088pab.215.2015.12.09.05.28.07; Wed, 09 Dec 2015 05:28:08 -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 S1753902AbbLIN2H (ORCPT + 4 others); Wed, 9 Dec 2015 08:28:07 -0500 Received: from mail-lf0-f42.google.com ([209.85.215.42]:34638 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751617AbbLIN2F (ORCPT ); Wed, 9 Dec 2015 08:28:05 -0500 Received: by lffu14 with SMTP id u14so34230415lff.1 for ; Wed, 09 Dec 2015 05:28:04 -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=w7VdfK5wHkNHmcs2ZZwM3Vdx/Db+1lz0K8eLqPgigpo=; b=i/9+Y4A1JzuIq1MpijoLXBp7dWvYv1DavJgSElk9/T4VKxY3b6H2etu+D9cDovjoLr /YlCxg/M1h8+4VAw6xYxl0rQsh7CIGaJZuibRiDEudC7LMgo130AEhHP0l4myy/AJmmZ 7vk82FUCMtisJ6nRBqKEGf3DhWKqP6Rl6QX7ww55qPMH9oHlSBgR3QSQW9kC6i+QdNow cI8rKD+ozT79UmZK6TDm/Zjp0Z4A/PCj5HyLTV+lmeujoM7VfOBZM4yLulrDuROgdGMW eypXXyWVbZpcr+YQLf26/EBWz/A8mFjoDi1CQhv1BqtOM6hspOiIOoTdBEI4DwFJFYv5 0rzw== 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=w7VdfK5wHkNHmcs2ZZwM3Vdx/Db+1lz0K8eLqPgigpo=; b=javxC7T+rgqv7re8cF9BAXFG5kPpi6cXEJhb1PB0bDR+B/V1ccKDro3m5mkjGeZnCg PnvJ0slEe4KwFxRPXqPIE0ONDPIgpeyyTmnhWPaBzZW/ZTQDT4y55eF6Qbm/Mq3Q+5GN pTZ5hxCk0tg8RVC7a4T3VlUktP9aM49moWMY2+PQFzaArZ9BtbL2FhQmmzC/v4/4ty/V PDZ/tg39FJdoNzTWIgujK6qCR8+zqKkusOySsiz46q5BtmVD7eGZlUDqbKD0pH7TJ6p1 ELpcTWWpzWfx+JWsr5K7HE48DoOzxfo4UtMfG1ZsW/O5BUSEK0cAWhsMDKsuBPcIcJoC 9m/Q== X-Gm-Message-State: ALoCoQlKfLzdxrC1TMODtnl5suGRwr9ip7ofrrDtSb7jQKu0YaUu/jmc2ePj21xX1sQqH7XFEO3v1J7KCMKKGiVYgjrqwRQv2Q== X-Received: by 10.25.167.209 with SMTP id q200mr2308651lfe.15.1449667684300; Wed, 09 Dec 2015 05:28:04 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s185sm1424529lfe.24.2015.12.09.05.28.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:28:03 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , patches@opensource.wolfsonmicro.com, Mark Brown Subject: [PATCH 081/182] gpio: wm8994: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:28:01 +0100 Message-Id: <1449667681-1258-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: patches@opensource.wolfsonmicro.com Cc: Mark Brown Signed-off-by: Linus Walleij --- drivers/gpio/gpio-wm8994.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 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-wm8994.c b/drivers/gpio/gpio-wm8994.c index de73c80163c1..3ae4c1597494 100644 --- a/drivers/gpio/gpio-wm8994.c +++ b/drivers/gpio/gpio-wm8994.c @@ -31,14 +31,9 @@ struct wm8994_gpio { struct gpio_chip gpio_chip; }; -static inline struct wm8994_gpio *to_wm8994_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct wm8994_gpio, gpio_chip); -} - static int wm8994_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip); + struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); struct wm8994 *wm8994 = wm8994_gpio->wm8994; switch (wm8994->type) { @@ -61,7 +56,7 @@ static int wm8994_gpio_request(struct gpio_chip *chip, unsigned offset) static int wm8994_gpio_direction_in(struct gpio_chip *chip, unsigned offset) { - struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip); + struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); struct wm8994 *wm8994 = wm8994_gpio->wm8994; return wm8994_set_bits(wm8994, WM8994_GPIO_1 + offset, @@ -70,7 +65,7 @@ static int wm8994_gpio_direction_in(struct gpio_chip *chip, unsigned offset) static int wm8994_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip); + struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); struct wm8994 *wm8994 = wm8994_gpio->wm8994; int ret; @@ -87,7 +82,7 @@ static int wm8994_gpio_get(struct gpio_chip *chip, unsigned offset) static int wm8994_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { - struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip); + struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); struct wm8994 *wm8994 = wm8994_gpio->wm8994; if (value) @@ -99,7 +94,7 @@ static int wm8994_gpio_direction_out(struct gpio_chip *chip, static void wm8994_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip); + struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); struct wm8994 *wm8994 = wm8994_gpio->wm8994; if (value) @@ -110,7 +105,7 @@ static void wm8994_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int wm8994_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip); + struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); struct wm8994 *wm8994 = wm8994_gpio->wm8994; return regmap_irq_get_virq(wm8994->irq_data, offset); @@ -174,7 +169,7 @@ static const char *wm8994_gpio_fn(u16 fn) static void wm8994_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { - struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip); + struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); struct wm8994 *wm8994 = wm8994_gpio->wm8994; int i; @@ -266,7 +261,7 @@ static int wm8994_gpio_probe(struct platform_device *pdev) else wm8994_gpio->gpio_chip.base = -1; - ret = gpiochip_add(&wm8994_gpio->gpio_chip); + ret = gpiochip_add_data(&wm8994_gpio->gpio_chip, wm8994_gpio); if (ret < 0) { dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);