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/pinctrl/pinctrl-at91.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/pinctrl/pinctrl-at91.c') diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index 0d2fc0cff35e..667d90607abc 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -1750,7 +1750,7 @@ static int at91_gpio_probe(struct platform_device *pdev) chip = &at91_chip->chip; chip->of_node = np; chip->label = dev_name(&pdev->dev); - chip->dev = &pdev->dev; + chip->parent = &pdev->dev; chip->owner = THIS_MODULE; chip->base = alias_idx * MAX_NB_GPIO_PER_BANK; -- cgit v1.2.3 From 370ea61134e9d13cef0dc671ce1fbc5a60756b59 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 09:27:45 +0100 Subject: pinctrl: at91: 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: Jean-Christophe Plagniol-Villard Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-at91.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'drivers/pinctrl/pinctrl-at91.c') diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index 667d90607abc..dd300683153f 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -45,8 +45,6 @@ struct at91_gpio_chip { struct at91_pinctrl_mux_ops *ops; /* ops */ }; -#define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip) - static struct at91_gpio_chip *gpio_chips[MAX_GPIO_BANKS]; static int gpio_banks; @@ -811,7 +809,7 @@ static int at91_gpio_request_enable(struct pinctrl_dev *pctldev, return -EINVAL; } chip = range->gc; - at91_chip = container_of(chip, struct at91_gpio_chip, chip); + at91_chip = gpiochip_get_data(chip); dev_dbg(npct->dev, "enable pin %u as GPIO\n", offset); @@ -1282,7 +1280,7 @@ static int at91_pinctrl_remove(struct platform_device *pdev) static int at91_gpio_get_direction(struct gpio_chip *chip, unsigned offset) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; u32 osr; @@ -1293,7 +1291,7 @@ static int at91_gpio_get_direction(struct gpio_chip *chip, unsigned offset) static int at91_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; @@ -1303,7 +1301,7 @@ static int at91_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int at91_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; u32 pdsr; @@ -1315,7 +1313,7 @@ static int at91_gpio_get(struct gpio_chip *chip, unsigned offset) static void at91_gpio_set(struct gpio_chip *chip, unsigned offset, int val) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; @@ -1325,7 +1323,7 @@ static void at91_gpio_set(struct gpio_chip *chip, unsigned offset, static void at91_gpio_set_multiple(struct gpio_chip *chip, unsigned long *mask, unsigned long *bits) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; #define BITS_MASK(bits) (((bits) == 32) ? ~0U : (BIT(bits) - 1)) @@ -1340,7 +1338,7 @@ static void at91_gpio_set_multiple(struct gpio_chip *chip, static int at91_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int val) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; @@ -1355,7 +1353,7 @@ static void at91_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { enum at91_mux mode; int i; - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; for (i = 0; i < chip->ngpio; i++) { @@ -1570,9 +1568,7 @@ static void gpio_irq_handler(struct irq_desc *desc) { struct irq_chip *chip = irq_desc_get_chip(desc); struct gpio_chip *gpio_chip = irq_desc_get_handler_data(desc); - struct at91_gpio_chip *at91_gpio = container_of(gpio_chip, - struct at91_gpio_chip, chip); - + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(gpio_chip); void __iomem *pio = at91_gpio->regbase; unsigned long isr; int n; @@ -1648,7 +1644,7 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev, return 0; } - prev = container_of(gpiochip_prev, struct at91_gpio_chip, chip); + prev = gpiochip_get_data(gpiochip_prev); /* we can only have 2 banks before */ for (i = 0; i < 2; i++) { @@ -1783,7 +1779,7 @@ static int at91_gpio_probe(struct platform_device *pdev) range->npins = chip->ngpio; range->gc = chip; - ret = gpiochip_add(chip); + ret = gpiochip_add_data(chip, at91_chip); if (ret) goto gpiochip_add_err; -- cgit v1.2.3