From patchwork Wed Dec 9 13:27: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: 58035 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp668002lbb; Wed, 9 Dec 2015 05:27:50 -0800 (PST) X-Received: by 10.66.100.196 with SMTP id fa4mr7827374pab.21.1449667670672; Wed, 09 Dec 2015 05:27:50 -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.27.50; Wed, 09 Dec 2015 05:27:50 -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 S1753950AbbLIN1u (ORCPT + 4 others); Wed, 9 Dec 2015 08:27:50 -0500 Received: from mail-lf0-f51.google.com ([209.85.215.51]:34482 "EHLO mail-lf0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753754AbbLIN1t (ORCPT ); Wed, 9 Dec 2015 08:27:49 -0500 Received: by lffu14 with SMTP id u14so34224887lff.1 for ; Wed, 09 Dec 2015 05:27:48 -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=QcU27atJxkTgWn1n+lchSzYduPXsIoHjvHffZ0M6TAE=; b=v/gdIfr1A5sbyLgIkObXTLOLw14vJm+xcDvSPcQ9e0kaCyia6V5Dc3GvY8fluN8XCY H0ZkwYszMVx7o4Ymdpu/t9zIJFWncUn1jIsP3Q/j251J35+6hNF0Yz8OKTBv03EhgRAY G4LJUaM2qpF3GTAIFgDXYqegCwXCit+3SsgfhbrduPnK36K1Tm1wGEOknJxopF1N3vY9 3UqL7JaivUb6QBvqJqzKOYJZo1oJRFKYRds0kEuQ7N5CNMqQw+cu8lya29ivpdQKL3Fw +78vc+0aWoYa5ldDjVS3yCnZF05blTUfZC5xSc3byD7dGalJJ4Y04BLhZZUTMPRtpp3q 8IYQ== 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=QcU27atJxkTgWn1n+lchSzYduPXsIoHjvHffZ0M6TAE=; b=YTqNtUwDhjviZ31QrU2HbqzMt+txjIpeAgWjzrjH8I5oJgRs2V6f0j1Vc2WBGXQnt3 aIyNADTTtGaRR9SQv6zDc+jb7iwTchRjkbTadMLJ7c0BaTVMP2NJkgkttb82HfHY5MIe REw7uwsVTVkQMXtR3h/VYsJMQZnWtutwTZBs32l05X37mgWxk2EehtClj/iDo74rFg7E GW674IKY+uwQHYFWkaIqOY2eLKa5bDf6nqqFxbfkbo1XiaHzSRmbcz4WyyNz/tp3icMu bCfNesD9EgsDXvLUowK2qik7O78RIBkLoTtQLOW2Q+ICnBIGXXM+B9mhxxhorLfu9DYy R4jA== X-Gm-Message-State: ALoCoQnQcmlcUHUlYiYq+LiZgdzCRsUltsLtX0u0QKA2BoNOjG7Z1ga+wOTckAcC3XEeFtkM9bMVzwWEOJOQUUE/2/XY8VwWjg== X-Received: by 10.25.83.146 with SMTP id h140mr2019914lfb.52.1449667668090; Wed, 09 Dec 2015 05:27:48 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id lc3sm1422045lbc.32.2015.12.09.05.27.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:27:47 -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 079/182] gpio: wm831x: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:27:45 +0100 Message-Id: <1449667665-1156-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-wm831x.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-wm831x.c b/drivers/gpio/gpio-wm831x.c index 2e73e4b52c69..98390070fb64 100644 --- a/drivers/gpio/gpio-wm831x.c +++ b/drivers/gpio/gpio-wm831x.c @@ -30,14 +30,9 @@ struct wm831x_gpio { struct gpio_chip gpio_chip; }; -static inline struct wm831x_gpio *to_wm831x_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct wm831x_gpio, gpio_chip); -} - static int wm831x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) { - struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); + struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip); struct wm831x *wm831x = wm831x_gpio->wm831x; int val = WM831X_GPN_DIR; @@ -51,7 +46,7 @@ static int wm831x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) static int wm831x_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); + struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip); struct wm831x *wm831x = wm831x_gpio->wm831x; int ret; @@ -67,7 +62,7 @@ static int wm831x_gpio_get(struct gpio_chip *chip, unsigned offset) static void wm831x_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); + struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip); struct wm831x *wm831x = wm831x_gpio->wm831x; wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, 1 << offset, @@ -77,7 +72,7 @@ static void wm831x_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int wm831x_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { - struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); + struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip); struct wm831x *wm831x = wm831x_gpio->wm831x; int val = 0; int ret; @@ -99,7 +94,7 @@ static int wm831x_gpio_direction_out(struct gpio_chip *chip, static int wm831x_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); + struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip); struct wm831x *wm831x = wm831x_gpio->wm831x; return irq_create_mapping(wm831x->irq_domain, @@ -109,7 +104,7 @@ static int wm831x_gpio_to_irq(struct gpio_chip *chip, unsigned offset) static int wm831x_gpio_set_debounce(struct gpio_chip *chip, unsigned offset, unsigned debounce) { - struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); + struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip); struct wm831x *wm831x = wm831x_gpio->wm831x; int reg = WM831X_GPIO1_CONTROL + offset; int ret, fn; @@ -140,7 +135,7 @@ static int wm831x_gpio_set_debounce(struct gpio_chip *chip, unsigned offset, #ifdef CONFIG_DEBUG_FS static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { - struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); + struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip); struct wm831x *wm831x = wm831x_gpio->wm831x; int i, tristated; @@ -264,7 +259,7 @@ static int wm831x_gpio_probe(struct platform_device *pdev) else wm831x_gpio->gpio_chip.base = -1; - ret = gpiochip_add(&wm831x_gpio->gpio_chip); + ret = gpiochip_add_data(&wm831x_gpio->gpio_chip, wm831x_gpio); if (ret < 0) { dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); return ret;