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-sch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpio/gpio-sch.c') diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c index b72906f5b999..a8a333ade9aa 100644 --- a/drivers/gpio/gpio-sch.c +++ b/drivers/gpio/gpio-sch.c @@ -171,7 +171,7 @@ static int sch_gpio_probe(struct platform_device *pdev) sch->iobase = res->start; sch->chip = sch_gpio_chip; sch->chip.label = dev_name(&pdev->dev); - sch->chip.dev = &pdev->dev; + sch->chip.parent = &pdev->dev; switch (pdev->id) { case PCI_DEVICE_ID_INTEL_SCH_LPC: -- cgit v1.2.3 From 737c8fccf1c5b2aae3c6d9a66dce17e35fc39b71 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:21:49 +0100 Subject: gpio: sch: 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: Chang Rebecca Swee Fun Acked-by: Mika Westerberg Signed-off-by: Linus Walleij --- drivers/gpio/gpio-sch.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'drivers/gpio/gpio-sch.c') diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c index a8a333ade9aa..5314ee4b947d 100644 --- a/drivers/gpio/gpio-sch.c +++ b/drivers/gpio/gpio-sch.c @@ -41,8 +41,6 @@ struct sch_gpio { unsigned short resume_base; }; -#define to_sch_gpio(gc) container_of(gc, struct sch_gpio, chip) - static unsigned sch_gpio_offset(struct sch_gpio *sch, unsigned gpio, unsigned reg) { @@ -65,7 +63,7 @@ static unsigned sch_gpio_bit(struct sch_gpio *sch, unsigned gpio) static int sch_gpio_reg_get(struct gpio_chip *gc, unsigned gpio, unsigned reg) { - struct sch_gpio *sch = to_sch_gpio(gc); + struct sch_gpio *sch = gpiochip_get_data(gc); unsigned short offset, bit; u8 reg_val; @@ -80,7 +78,7 @@ static int sch_gpio_reg_get(struct gpio_chip *gc, unsigned gpio, unsigned reg) static void sch_gpio_reg_set(struct gpio_chip *gc, unsigned gpio, unsigned reg, int val) { - struct sch_gpio *sch = to_sch_gpio(gc); + struct sch_gpio *sch = gpiochip_get_data(gc); unsigned short offset, bit; u8 reg_val; @@ -97,7 +95,7 @@ static void sch_gpio_reg_set(struct gpio_chip *gc, unsigned gpio, unsigned reg, static int sch_gpio_direction_in(struct gpio_chip *gc, unsigned gpio_num) { - struct sch_gpio *sch = to_sch_gpio(gc); + struct sch_gpio *sch = gpiochip_get_data(gc); spin_lock(&sch->lock); sch_gpio_reg_set(gc, gpio_num, GIO, 1); @@ -112,7 +110,7 @@ static int sch_gpio_get(struct gpio_chip *gc, unsigned gpio_num) static void sch_gpio_set(struct gpio_chip *gc, unsigned gpio_num, int val) { - struct sch_gpio *sch = to_sch_gpio(gc); + struct sch_gpio *sch = gpiochip_get_data(gc); spin_lock(&sch->lock); sch_gpio_reg_set(gc, gpio_num, GLV, val); @@ -122,7 +120,7 @@ static void sch_gpio_set(struct gpio_chip *gc, unsigned gpio_num, int val) static int sch_gpio_direction_out(struct gpio_chip *gc, unsigned gpio_num, int val) { - struct sch_gpio *sch = to_sch_gpio(gc); + struct sch_gpio *sch = gpiochip_get_data(gc); spin_lock(&sch->lock); sch_gpio_reg_set(gc, gpio_num, GIO, 0); @@ -217,7 +215,7 @@ static int sch_gpio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, sch); - return gpiochip_add(&sch->chip); + return gpiochip_add_data(&sch->chip, sch); } static int sch_gpio_remove(struct platform_device *pdev) -- cgit v1.2.3