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-rc5t583.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpio/gpio-rc5t583.c') diff --git a/drivers/gpio/gpio-rc5t583.c b/drivers/gpio/gpio-rc5t583.c index 6eabf239676b..f26d9f7d8cdd 100644 --- a/drivers/gpio/gpio-rc5t583.c +++ b/drivers/gpio/gpio-rc5t583.c @@ -132,7 +132,7 @@ static int rc5t583_gpio_probe(struct platform_device *pdev) rc5t583_gpio->gpio_chip.to_irq = rc5t583_gpio_to_irq, rc5t583_gpio->gpio_chip.ngpio = RC5T583_MAX_GPIO, rc5t583_gpio->gpio_chip.can_sleep = true, - rc5t583_gpio->gpio_chip.dev = &pdev->dev; + rc5t583_gpio->gpio_chip.parent = &pdev->dev; rc5t583_gpio->gpio_chip.base = -1; rc5t583_gpio->rc5t583 = rc5t583; -- cgit v1.2.3 From d660c68eb5b24051a4765d473765d9021a720975 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:08:12 +0100 Subject: gpio: rc5t583: 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(). Acked-by: Laxman Dewangan Signed-off-by: Linus Walleij --- drivers/gpio/gpio-rc5t583.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'drivers/gpio/gpio-rc5t583.c') diff --git a/drivers/gpio/gpio-rc5t583.c b/drivers/gpio/gpio-rc5t583.c index f26d9f7d8cdd..1e2d210b3369 100644 --- a/drivers/gpio/gpio-rc5t583.c +++ b/drivers/gpio/gpio-rc5t583.c @@ -34,14 +34,9 @@ struct rc5t583_gpio { struct rc5t583 *rc5t583; }; -static inline struct rc5t583_gpio *to_rc5t583_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct rc5t583_gpio, gpio_chip); -} - static int rc5t583_gpio_get(struct gpio_chip *gc, unsigned int offset) { - struct rc5t583_gpio *rc5t583_gpio = to_rc5t583_gpio(gc); + struct rc5t583_gpio *rc5t583_gpio = gpiochip_get_data(gc); struct device *parent = rc5t583_gpio->rc5t583->dev; uint8_t val = 0; int ret; @@ -55,7 +50,7 @@ static int rc5t583_gpio_get(struct gpio_chip *gc, unsigned int offset) static void rc5t583_gpio_set(struct gpio_chip *gc, unsigned int offset, int val) { - struct rc5t583_gpio *rc5t583_gpio = to_rc5t583_gpio(gc); + struct rc5t583_gpio *rc5t583_gpio = gpiochip_get_data(gc); struct device *parent = rc5t583_gpio->rc5t583->dev; if (val) rc5t583_set_bits(parent, RC5T583_GPIO_IOOUT, BIT(offset)); @@ -65,7 +60,7 @@ static void rc5t583_gpio_set(struct gpio_chip *gc, unsigned int offset, int val) static int rc5t583_gpio_dir_input(struct gpio_chip *gc, unsigned int offset) { - struct rc5t583_gpio *rc5t583_gpio = to_rc5t583_gpio(gc); + struct rc5t583_gpio *rc5t583_gpio = gpiochip_get_data(gc); struct device *parent = rc5t583_gpio->rc5t583->dev; int ret; @@ -80,7 +75,7 @@ static int rc5t583_gpio_dir_input(struct gpio_chip *gc, unsigned int offset) static int rc5t583_gpio_dir_output(struct gpio_chip *gc, unsigned offset, int value) { - struct rc5t583_gpio *rc5t583_gpio = to_rc5t583_gpio(gc); + struct rc5t583_gpio *rc5t583_gpio = gpiochip_get_data(gc); struct device *parent = rc5t583_gpio->rc5t583->dev; int ret; @@ -95,7 +90,7 @@ static int rc5t583_gpio_dir_output(struct gpio_chip *gc, unsigned offset, static int rc5t583_gpio_to_irq(struct gpio_chip *gc, unsigned offset) { - struct rc5t583_gpio *rc5t583_gpio = to_rc5t583_gpio(gc); + struct rc5t583_gpio *rc5t583_gpio = gpiochip_get_data(gc); if (offset < RC5T583_MAX_GPIO) return rc5t583_gpio->rc5t583->irq_base + @@ -105,7 +100,7 @@ static int rc5t583_gpio_to_irq(struct gpio_chip *gc, unsigned offset) static void rc5t583_gpio_free(struct gpio_chip *gc, unsigned offset) { - struct rc5t583_gpio *rc5t583_gpio = to_rc5t583_gpio(gc); + struct rc5t583_gpio *rc5t583_gpio = gpiochip_get_data(gc); struct device *parent = rc5t583_gpio->rc5t583->dev; rc5t583_set_bits(parent, RC5T583_GPIO_PGSEL, BIT(offset)); @@ -141,7 +136,7 @@ static int rc5t583_gpio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, rc5t583_gpio); - return gpiochip_add(&rc5t583_gpio->gpio_chip); + return gpiochip_add_data(&rc5t583_gpio->gpio_chip, rc5t583_gpio); } static int rc5t583_gpio_remove(struct platform_device *pdev) -- cgit v1.2.3