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-amd8111.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpio/gpio-amd8111.c') diff --git a/drivers/gpio/gpio-amd8111.c b/drivers/gpio/gpio-amd8111.c index d00d81928fe8..5c378e9f53a0 100644 --- a/drivers/gpio/gpio-amd8111.c +++ b/drivers/gpio/gpio-amd8111.c @@ -220,7 +220,7 @@ found: goto out; } gp.pdev = pdev; - gp.chip.dev = &pdev->dev; + gp.chip.parent = &pdev->dev; spin_lock_init(&gp.lock); -- cgit v1.2.3 From 57683ec203a642e8fc8befac94c8341d237f5d54 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 15:26:35 +0100 Subject: gpio: amd8111: 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: Dmitry Eremin-Solenikov Signed-off-by: Linus Walleij --- drivers/gpio/gpio-amd8111.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'drivers/gpio/gpio-amd8111.c') diff --git a/drivers/gpio/gpio-amd8111.c b/drivers/gpio/gpio-amd8111.c index 5c378e9f53a0..c7040fffc5b4 100644 --- a/drivers/gpio/gpio-amd8111.c +++ b/drivers/gpio/gpio-amd8111.c @@ -75,11 +75,9 @@ struct amd_gpio { u8 orig[32]; }; -#define to_agp(chip) container_of(chip, struct amd_gpio, chip) - static int amd_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); agp->orig[offset] = ioread8(agp->pm + AMD_REG_GPIO(offset)) & (AMD_GPIO_DEBOUNCE | AMD_GPIO_MODE_MASK | AMD_GPIO_X_MASK); @@ -91,7 +89,7 @@ static int amd_gpio_request(struct gpio_chip *chip, unsigned offset) static void amd_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); dev_dbg(&agp->pdev->dev, "Freed gpio %d, data %x\n", offset, agp->orig[offset]); @@ -100,7 +98,7 @@ static void amd_gpio_free(struct gpio_chip *chip, unsigned offset) static void amd_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); u8 temp; unsigned long flags; @@ -115,7 +113,7 @@ static void amd_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int amd_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); u8 temp; temp = ioread8(agp->pm + AMD_REG_GPIO(offset)); @@ -127,7 +125,7 @@ static int amd_gpio_get(struct gpio_chip *chip, unsigned offset) static int amd_gpio_dirout(struct gpio_chip *chip, unsigned offset, int value) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); u8 temp; unsigned long flags; @@ -144,7 +142,7 @@ static int amd_gpio_dirout(struct gpio_chip *chip, unsigned offset, int value) static int amd_gpio_dirin(struct gpio_chip *chip, unsigned offset) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); u8 temp; unsigned long flags; @@ -225,7 +223,7 @@ found: spin_lock_init(&gp.lock); printk(KERN_INFO "AMD-8111 GPIO detected\n"); - err = gpiochip_add(&gp.chip); + err = gpiochip_add_data(&gp.chip, &gp); if (err) { printk(KERN_ERR "GPIO registering failed (%d)\n", err); -- cgit v1.2.3