From patchwork Wed Dec 9 13:27:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58033 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp667855lbb; Wed, 9 Dec 2015 05:27:36 -0800 (PST) X-Received: by 10.67.22.99 with SMTP id hr3mr7853662pad.10.1449667656271; Wed, 09 Dec 2015 05:27:36 -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.36; Wed, 09 Dec 2015 05:27:36 -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 S1754179AbbLIN1f (ORCPT + 4 others); Wed, 9 Dec 2015 08:27:35 -0500 Received: from mail-lb0-f182.google.com ([209.85.217.182]:32924 "EHLO mail-lb0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753754AbbLIN1f (ORCPT ); Wed, 9 Dec 2015 08:27:35 -0500 Received: by lbbkw15 with SMTP id kw15so29960102lbb.0 for ; Wed, 09 Dec 2015 05:27:33 -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=zCe6mezUAqzJQEMGsl1UPqSqWYwsfJy2+8CbGARJw34=; b=GDG1wnTSQighfmIbl/t6JTaNgMV+bVNbdzlixn3xXC5TWALjtseCf/6bfcvF7Iff9w bf+v/QZqDn+dThvXiiEupYxYZvC8R4fKGf00hY+Cx/SDOMzF7GKQexsw+zavDljgUS0M dwrX1d+ltPy3Dk7W2rSfZhksYzwk5nfYhpMOGXnQusI7BrLjNu7rqBYjKLJH/bPmqkjY vaJXXZ416apHqwNAWmG5w1VIEbRdFncaeIsQluV6SQ8T2xsxDi0njfBXpupqCjmMCzYt o515MLwmxMx/J9bnNHDz5PxoSpUpZtpDxrfsj61gVEFUbZ+Cbr03NlRrmJuDxTSk/rsV 46yQ== 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=zCe6mezUAqzJQEMGsl1UPqSqWYwsfJy2+8CbGARJw34=; b=VnIPHzTCYqpmHPNVON1ky/Ot0JlKAf70N0Vx79fc1H5uPgCYdPvzvleJPpETHgDP/a 75oFp8ZFMCyz4+c2kddAqudD9b/5axfzJoPkKt4zl5SXMERbYqRIj/rM4Ec6Ai1qmAvT cK0OFs238W/Mktmx6RDUFkci+g6rsLMRvFgQHJl2o7eebYbxFmh9j3hLW2iQpxPYvCYK thqsuOlfkftVqbVopQqXKNzk7SpdSatBpdGgsElQUTTwBV/PdG/fmGonBA8zGH1iWjE+ izJvIThtcr6SLhcdRgxemzeU8wRVzoB4bFqsNsqw6Hw8VMaW0Qh+ps9wu8pY9GeQ6VLa xVtQ== X-Gm-Message-State: ALoCoQk53CTYgh+xbsRHUC+nLCS0QzzTFNs0Ox/3IX/SprwtWEaLWI0sAiVLw4Zn/qcSTel0kC0MxkF6e3Af9INbO+LW0qoKGg== X-Received: by 10.112.137.101 with SMTP id qh5mr2314244lbb.81.1449667653516; Wed, 09 Dec 2015 05:27:33 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id of8sm1413383lbb.7.2015.12.09.05.27.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:27:32 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Lars Poeschel Subject: [PATCH 077/182] gpio: viperboard: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:27:30 +0100 Message-Id: <1449667650-1062-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: Lars Poeschel Signed-off-by: Linus Walleij --- drivers/gpio/gpio-viperboard.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 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-viperboard.c b/drivers/gpio/gpio-viperboard.c index 26e7edb74f42..023496d62b87 100644 --- a/drivers/gpio/gpio-viperboard.c +++ b/drivers/gpio/gpio-viperboard.c @@ -88,8 +88,7 @@ static int vprbrd_gpioa_get(struct gpio_chip *chip, unsigned offset) { int ret, answer, error = 0; - struct vprbrd_gpio *gpio = - container_of(chip, struct vprbrd_gpio, gpioa); + struct vprbrd_gpio *gpio = gpiochip_get_data(chip); struct vprbrd *vb = gpio->vb; struct vprbrd_gpioa_msg *gamsg = (struct vprbrd_gpioa_msg *)vb->buf; @@ -139,8 +138,7 @@ static void vprbrd_gpioa_set(struct gpio_chip *chip, unsigned offset, int value) { int ret; - struct vprbrd_gpio *gpio = - container_of(chip, struct vprbrd_gpio, gpioa); + struct vprbrd_gpio *gpio = gpiochip_get_data(chip); struct vprbrd *vb = gpio->vb; struct vprbrd_gpioa_msg *gamsg = (struct vprbrd_gpioa_msg *)vb->buf; @@ -181,8 +179,7 @@ static int vprbrd_gpioa_direction_input(struct gpio_chip *chip, unsigned offset) { int ret; - struct vprbrd_gpio *gpio = - container_of(chip, struct vprbrd_gpio, gpioa); + struct vprbrd_gpio *gpio = gpiochip_get_data(chip); struct vprbrd *vb = gpio->vb; struct vprbrd_gpioa_msg *gamsg = (struct vprbrd_gpioa_msg *)vb->buf; @@ -219,8 +216,7 @@ static int vprbrd_gpioa_direction_output(struct gpio_chip *chip, unsigned offset, int value) { int ret; - struct vprbrd_gpio *gpio = - container_of(chip, struct vprbrd_gpio, gpioa); + struct vprbrd_gpio *gpio = gpiochip_get_data(chip); struct vprbrd *vb = gpio->vb; struct vprbrd_gpioa_msg *gamsg = (struct vprbrd_gpioa_msg *)vb->buf; @@ -287,8 +283,7 @@ static int vprbrd_gpiob_get(struct gpio_chip *chip, { int ret; u16 val; - struct vprbrd_gpio *gpio = - container_of(chip, struct vprbrd_gpio, gpiob); + struct vprbrd_gpio *gpio = gpiochip_get_data(chip); struct vprbrd *vb = gpio->vb; struct vprbrd_gpiob_msg *gbmsg = (struct vprbrd_gpiob_msg *)vb->buf; @@ -319,8 +314,7 @@ static void vprbrd_gpiob_set(struct gpio_chip *chip, unsigned offset, int value) { int ret; - struct vprbrd_gpio *gpio = - container_of(chip, struct vprbrd_gpio, gpiob); + struct vprbrd_gpio *gpio = gpiochip_get_data(chip); struct vprbrd *vb = gpio->vb; struct vprbrd_gpiob_msg *gbmsg = (struct vprbrd_gpiob_msg *)vb->buf; @@ -353,8 +347,7 @@ static int vprbrd_gpiob_direction_input(struct gpio_chip *chip, unsigned offset) { int ret; - struct vprbrd_gpio *gpio = - container_of(chip, struct vprbrd_gpio, gpiob); + struct vprbrd_gpio *gpio = gpiochip_get_data(chip); struct vprbrd *vb = gpio->vb; gpio->gpiob_out &= ~(1 << offset); @@ -375,8 +368,7 @@ static int vprbrd_gpiob_direction_output(struct gpio_chip *chip, unsigned offset, int value) { int ret; - struct vprbrd_gpio *gpio = - container_of(chip, struct vprbrd_gpio, gpiob); + struct vprbrd_gpio *gpio = gpiochip_get_data(chip); struct vprbrd *vb = gpio->vb; gpio->gpiob_out |= (1 << offset); @@ -418,7 +410,7 @@ static int vprbrd_gpio_probe(struct platform_device *pdev) vb_gpio->gpioa.get = vprbrd_gpioa_get; vb_gpio->gpioa.direction_input = vprbrd_gpioa_direction_input; vb_gpio->gpioa.direction_output = vprbrd_gpioa_direction_output; - ret = gpiochip_add(&vb_gpio->gpioa); + ret = gpiochip_add_data(&vb_gpio->gpioa, vb_gpio); if (ret < 0) { dev_err(vb_gpio->gpioa.parent, "could not add gpio a"); goto err_gpioa; @@ -435,7 +427,7 @@ static int vprbrd_gpio_probe(struct platform_device *pdev) vb_gpio->gpiob.get = vprbrd_gpiob_get; vb_gpio->gpiob.direction_input = vprbrd_gpiob_direction_input; vb_gpio->gpiob.direction_output = vprbrd_gpiob_direction_output; - ret = gpiochip_add(&vb_gpio->gpiob); + ret = gpiochip_add_data(&vb_gpio->gpiob, vb_gpio); if (ret < 0) { dev_err(vb_gpio->gpiob.parent, "could not add gpio b"); goto err_gpiob;