From patchwork Wed Dec 9 13:17:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 554501 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id CD9E814030D for ; Thu, 10 Dec 2015 00:17:12 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro-org.20150623.gappssmtp.com header.i=@linaro-org.20150623.gappssmtp.com header.b=MPOPrNqV; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753592AbbLINRM (ORCPT ); Wed, 9 Dec 2015 08:17:12 -0500 Received: from mail-lb0-f181.google.com ([209.85.217.181]:34344 "EHLO mail-lb0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753145AbbLINRL (ORCPT ); Wed, 9 Dec 2015 08:17:11 -0500 Received: by lbbcs9 with SMTP id cs9so29701931lbb.1 for ; Wed, 09 Dec 2015 05:17:10 -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=xCVZ2jXsfva/fJq9tkXhPeIxRNQSJwQTGPVnx8Ps3yc=; b=MPOPrNqVTvsIRypbejF4GcT6Bx7wvP3WqNV7jJ2bW+N6Mb5Zfrfd588bjyJ7HJY3km JF/pIiaWuoxROzf4WBQQZUD1dEyXyZq1X6cX3kmgqdkZA+hcSRiNKYJnlMVn3k0NCbtK kJruGj9CuNRSHjBAYgRo7e+HJ0BAhaTx+MMVlInnZXbWo/TH5MOitz2EiQ7ty8geq/9A Eseq6x6JxHYjg6FDDB37ucQlvyWx/mJGSo7jmkHmsBMhzf3Gtw1wJfrjD8AUn/vUszC4 44KAB/B9pSJWO5Quqt0t68NyxJF/CYIjtVqmGM1sWDDn3bQC+hmzQ9JSKLC2uKn+GQBB M5Xg== 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=xCVZ2jXsfva/fJq9tkXhPeIxRNQSJwQTGPVnx8Ps3yc=; b=NUf1KgxtAfuA7upKH9yqoCmks9ohS7d0+2dnp7fhVJA2vnkqbVKaxJnWNkvj+qOvsK i2TkhI32jz3iHaSqOz97UWQlrjTAQz+fPuVjf6uWXAyb6T8zyWImVbVI20i8XQyxVerj Wcm0fxzyFS0jerPctOtw1LGJtyC06HLjxnaAaANIcKFXuVwJlJuYg9CGWfNcBAUt65xD 8JRIISyp0/1yriPd66sgYHRp1hEAA3yVuCuGlNRhW6wTnSIpCoJYQX80okhXQ9XXs8RB nqhA2KjxrOG3KzmkxEC8HSKUi5Nhoz81BUPWN0r13KHGuP2dsgCRZ88FVh/mCHyUQc26 ghhg== X-Gm-Message-State: ALoCoQl+w59jUEGyL5Xiy8r+hEJLQtCnfs2b/ULk7sp1B5w/pOFz6wcWdxF+liywpxeKr7zcurVKy5t5wFnnWqIyei+KqJ7cgQ== X-Received: by 10.112.181.225 with SMTP id dz1mr1904831lbc.103.1449667030256; Wed, 09 Dec 2015 05:17:10 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e9sm1410359lbs.13.2015.12.09.05.17.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:17:09 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Roland Stigge Subject: [PATCH 031/182] gpio: lpc32xx: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:17:06 +0100 Message-Id: <1449667026-31219-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: Roland Stigge Signed-off-by: Linus Walleij Acked-by: Vladimir Zapolskiy --- Roland: this looks like a driver that should move to drivers/pinctrl since it is obviously controlling a lot of pins. Can you confirm? --- drivers/gpio/gpio-lpc32xx.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/drivers/gpio/gpio-lpc32xx.c b/drivers/gpio/gpio-lpc32xx.c index 47e2dde63734..b4df5057a48c 100644 --- a/drivers/gpio/gpio-lpc32xx.c +++ b/drivers/gpio/gpio-lpc32xx.c @@ -165,12 +165,6 @@ struct lpc32xx_gpio_chip { struct gpio_regs *gpio_grp; }; -static inline struct lpc32xx_gpio_chip *to_lpc32xx_gpio( - struct gpio_chip *gpc) -{ - return container_of(gpc, struct lpc32xx_gpio_chip, chip); -} - static void __set_gpio_dir_p012(struct lpc32xx_gpio_chip *group, unsigned pin, int input) { @@ -261,7 +255,7 @@ static int __get_gpo_state_p3(struct lpc32xx_gpio_chip *group, static int lpc32xx_gpio_dir_input_p012(struct gpio_chip *chip, unsigned pin) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); __set_gpio_dir_p012(group, pin, 1); @@ -271,7 +265,7 @@ static int lpc32xx_gpio_dir_input_p012(struct gpio_chip *chip, static int lpc32xx_gpio_dir_input_p3(struct gpio_chip *chip, unsigned pin) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); __set_gpio_dir_p3(group, pin, 1); @@ -286,21 +280,21 @@ static int lpc32xx_gpio_dir_in_always(struct gpio_chip *chip, static int lpc32xx_gpio_get_value_p012(struct gpio_chip *chip, unsigned pin) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); return __get_gpio_state_p012(group, pin); } static int lpc32xx_gpio_get_value_p3(struct gpio_chip *chip, unsigned pin) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); return __get_gpio_state_p3(group, pin); } static int lpc32xx_gpi_get_value(struct gpio_chip *chip, unsigned pin) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); return __get_gpi_state_p3(group, pin); } @@ -308,7 +302,7 @@ static int lpc32xx_gpi_get_value(struct gpio_chip *chip, unsigned pin) static int lpc32xx_gpio_dir_output_p012(struct gpio_chip *chip, unsigned pin, int value) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); __set_gpio_level_p012(group, pin, value); __set_gpio_dir_p012(group, pin, 0); @@ -319,7 +313,7 @@ static int lpc32xx_gpio_dir_output_p012(struct gpio_chip *chip, unsigned pin, static int lpc32xx_gpio_dir_output_p3(struct gpio_chip *chip, unsigned pin, int value) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); __set_gpio_level_p3(group, pin, value); __set_gpio_dir_p3(group, pin, 0); @@ -330,7 +324,7 @@ static int lpc32xx_gpio_dir_output_p3(struct gpio_chip *chip, unsigned pin, static int lpc32xx_gpio_dir_out_always(struct gpio_chip *chip, unsigned pin, int value) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); __set_gpo_level_p3(group, pin, value); return 0; @@ -339,7 +333,7 @@ static int lpc32xx_gpio_dir_out_always(struct gpio_chip *chip, unsigned pin, static void lpc32xx_gpio_set_value_p012(struct gpio_chip *chip, unsigned pin, int value) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); __set_gpio_level_p012(group, pin, value); } @@ -347,7 +341,7 @@ static void lpc32xx_gpio_set_value_p012(struct gpio_chip *chip, unsigned pin, static void lpc32xx_gpio_set_value_p3(struct gpio_chip *chip, unsigned pin, int value) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); __set_gpio_level_p3(group, pin, value); } @@ -355,14 +349,14 @@ static void lpc32xx_gpio_set_value_p3(struct gpio_chip *chip, unsigned pin, static void lpc32xx_gpo_set_value(struct gpio_chip *chip, unsigned pin, int value) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); __set_gpo_level_p3(group, pin, value); } static int lpc32xx_gpo_get_value(struct gpio_chip *chip, unsigned pin) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); return __get_gpo_state_p3(group, pin); } @@ -553,7 +547,8 @@ static int lpc32xx_gpio_probe(struct platform_device *pdev) lpc32xx_gpiochip[i].chip.of_gpio_n_cells = 3; lpc32xx_gpiochip[i].chip.of_node = pdev->dev.of_node; } - gpiochip_add(&lpc32xx_gpiochip[i].chip); + gpiochip_add_data(&lpc32xx_gpiochip[i].chip, + &lpc32xx_gpiochip[i]); } return 0;