From 58383c78425e4ee1c077253cf297b641c861c02e Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Wed, 4 Nov 2015 09:56:26 +0100 Subject: gpio: change member .dev to .parent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The name .dev in a struct is normally reserved for a struct device that is let us say a superclass to the thing described by the struct. struct gpio_chip stands out by confusingly using a struct device *dev to point to the parent device (such as a platform_device) that represents the hardware. As we want to give gpio_chip:s real devices, this is not working. We need to rename this member to parent. This was done by two coccinelle scripts, I guess it is possible to combine them into one, but I don't know such stuff. They look like this: @@ struct gpio_chip *var; @@ -var->dev +var->parent and: @@ struct gpio_chip var; @@ -var.dev +var.parent and: @@ struct bgpio_chip *var; @@ -var->gc.dev +var->gc.parent Plus a few instances of bgpio that I couldn't figure out how to teach Coccinelle to rewrite. This patch hits all over the place, but I *strongly* prefer this solution to any piecemal approaches that just exercise patch mechanics all over the place. It mainly hits drivers/gpio and drivers/pinctrl which is my own backyard anyway. Cc: Haavard Skinnemoen Cc: Rafał Miłecki Cc: Richard Purdie Cc: Mauro Carvalho Chehab Cc: Alek Du Cc: Jaroslav Kysela Cc: Takashi Iwai Acked-by: Dmitry Torokhov Acked-by: Greg Kroah-Hartman Acked-by: Lee Jones Acked-by: Jiri Kosina Acked-by: Hans-Christian Egtvedt Acked-by: Jacek Anaszewski Signed-off-by: Linus Walleij --- arch/avr32/mach-at32ap/pio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/avr32/mach-at32ap/pio.c b/arch/avr32/mach-at32ap/pio.c index 4f61378c3453..aa74491771fa 100644 --- a/arch/avr32/mach-at32ap/pio.c +++ b/arch/avr32/mach-at32ap/pio.c @@ -397,7 +397,7 @@ static int __init pio_probe(struct platform_device *pdev) pio->chip.label = pio->name; pio->chip.base = pdev->id * 32; pio->chip.ngpio = 32; - pio->chip.dev = &pdev->dev; + pio->chip.parent = &pdev->dev; pio->chip.owner = THIS_MODULE; pio->chip.direction_input = direction_input; -- cgit From 0f4630f3720e7e6e921bf525c8357fea7ef3dbab Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 14:02:58 +0100 Subject: gpio: generic: factor into gpio_chip struct The separate struct bgpio_chip has been a pain to handle, both by being confusingly similar in name to struct gpio_chip and for being contained inside a struct so that struct gpio_chip is contained in a struct contained in a struct, making several steps of dereferencing necessary. Make things simpler: include the fields directly into , #ifdef:ed for CONFIG_GENERIC_GPIO, and get rid of the altogether. Prefix some of the member variables with bgpio_* and add proper kerneldoc while we're at it. Modify all users to handle the change and use a struct gpio_chip directly. And while we're at it: replace all container_of() dereferencing by gpiochip_get_data() and registering the gpio_chip with gpiochip_add_data(). Cc: arm@kernel.org Cc: Alexander Shiyan Cc: Shawn Guo Cc: Sascha Hauer Cc: Kukjin Kim Cc: Alexandre Courbot Cc: Brian Norris Cc: Florian Fainelli Cc: Sudeep Holla Cc: Lorenzo Pieralisi Cc: Nicolas Pitre Cc: Olof Johansson Cc: Vladimir Zapolskiy Cc: Rabin Vincent Cc: linux-arm-kernel@lists.infradead.org Cc: linux-omap@vger.kernel.org Cc: linux-samsung-soc@vger.kernel.org Cc: bcm-kernel-feedback-list@broadcom.com Acked-by: Gregory Fong Acked-by: Liviu Dudau Acked-by: H Hartley Sweeten Acked-by: Tony Lindgren Acked-by: Krzysztof Kozlowski Acked-by: Lee Jones Signed-off-by: Linus Walleij --- arch/arm/mach-clps711x/board-autcpu12.c | 2 +- arch/arm/mach-clps711x/board-p720t.c | 2 +- arch/arm/mach-imx/mach-mx21ads.c | 2 +- arch/arm/mach-omap1/board-ams-delta.c | 2 +- arch/arm/mach-s3c64xx/mach-crag6410.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'arch') diff --git a/arch/arm/mach-clps711x/board-autcpu12.c b/arch/arm/mach-clps711x/board-autcpu12.c index c3d964221767..ba3d7d1b28f8 100644 --- a/arch/arm/mach-clps711x/board-autcpu12.c +++ b/arch/arm/mach-clps711x/board-autcpu12.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/arm/mach-clps711x/board-p720t.c b/arch/arm/mach-clps711x/board-p720t.c index e68dd629bda2..80a16a8b3776 100644 --- a/arch/arm/mach-clps711x/board-p720t.c +++ b/arch/arm/mach-clps711x/board-p720t.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mach-imx/mach-mx21ads.c b/arch/arm/mach-imx/mach-mx21ads.c index 703ce31d7379..9986f9a697c8 100644 --- a/arch/arm/mach-imx/mach-mx21ads.c +++ b/arch/arm/mach-imx/mach-mx21ads.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index a95499ea8706..97e66558c238 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -11,7 +11,7 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ -#include +#include #include #include #include diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c b/arch/arm/mach-s3c64xx/mach-crag6410.c index f776adcdaee8..723f47fefc81 100644 --- a/arch/arm/mach-s3c64xx/mach-crag6410.c +++ b/arch/arm/mach-s3c64xx/mach-crag6410.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include -- cgit From 95bf0951e415cf71654184fd6e8c711782b1f22a Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 13:48:02 +0100 Subject: avr32: gpio: use gpiochip data pointer 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: Haavard Skinnemoen Acked-by: Hans-Christian Noren Egtvedt Signed-off-by: Linus Walleij --- arch/avr32/mach-at32ap/pio.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'arch') diff --git a/arch/avr32/mach-at32ap/pio.c b/arch/avr32/mach-at32ap/pio.c index aa74491771fa..5020057ac7a2 100644 --- a/arch/avr32/mach-at32ap/pio.c +++ b/arch/avr32/mach-at32ap/pio.c @@ -203,7 +203,7 @@ fail: static int direction_input(struct gpio_chip *chip, unsigned offset) { - struct pio_device *pio = container_of(chip, struct pio_device, chip); + struct pio_device *pio = gpiochip_get_data(chip); u32 mask = 1 << offset; if (!(pio_readl(pio, PSR) & mask)) @@ -215,7 +215,7 @@ static int direction_input(struct gpio_chip *chip, unsigned offset) static int gpio_get(struct gpio_chip *chip, unsigned offset) { - struct pio_device *pio = container_of(chip, struct pio_device, chip); + struct pio_device *pio = gpiochip_get_data(chip); return (pio_readl(pio, PDSR) >> offset) & 1; } @@ -224,7 +224,7 @@ static void gpio_set(struct gpio_chip *chip, unsigned offset, int value); static int direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct pio_device *pio = container_of(chip, struct pio_device, chip); + struct pio_device *pio = gpiochip_get_data(chip); u32 mask = 1 << offset; if (!(pio_readl(pio, PSR) & mask)) @@ -237,7 +237,7 @@ static int direction_output(struct gpio_chip *chip, unsigned offset, int value) static void gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct pio_device *pio = container_of(chip, struct pio_device, chip); + struct pio_device *pio = gpiochip_get_data(chip); u32 mask = 1 << offset; if (value) @@ -335,7 +335,7 @@ gpio_irq_setup(struct pio_device *pio, int irq, int gpio_irq) */ static void pio_bank_show(struct seq_file *s, struct gpio_chip *chip) { - struct pio_device *pio = container_of(chip, struct pio_device, chip); + struct pio_device *pio = gpiochip_get_data(chip); u32 psr, osr, imr, pdsr, pusr, ifsr, mdsr; unsigned i; u32 mask; @@ -406,7 +406,7 @@ static int __init pio_probe(struct platform_device *pdev) pio->chip.set = gpio_set; pio->chip.dbg_show = pio_bank_show; - gpiochip_add(&pio->chip); + gpiochip_add_data(&pio->chip, pio); gpio_irq_setup(pio, irq, gpio_irq_base); -- cgit