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 --- drivers/gpio/gpio-wm8994.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpio/gpio-wm8994.c') diff --git a/drivers/gpio/gpio-wm8994.c b/drivers/gpio/gpio-wm8994.c index 6f5e42db4b9e..de73c80163c1 100644 --- a/drivers/gpio/gpio-wm8994.c +++ b/drivers/gpio/gpio-wm8994.c @@ -260,7 +260,7 @@ static int wm8994_gpio_probe(struct platform_device *pdev) wm8994_gpio->wm8994 = wm8994; wm8994_gpio->gpio_chip = template_chip; wm8994_gpio->gpio_chip.ngpio = WM8994_GPIO_MAX; - wm8994_gpio->gpio_chip.dev = &pdev->dev; + wm8994_gpio->gpio_chip.parent = &pdev->dev; if (pdata && pdata->gpio_base) wm8994_gpio->gpio_chip.base = pdata->gpio_base; else -- cgit v1.2.3 From 765aa58778a5726a026a72773dda4d97036d3d1d Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 15:15:30 +0100 Subject: gpio: wm8994: 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: patches@opensource.wolfsonmicro.com Cc: Mark Brown Acked-by: Charles Keepax Signed-off-by: Linus Walleij --- drivers/gpio/gpio-wm8994.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'drivers/gpio/gpio-wm8994.c') 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); -- cgit v1.2.3