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/sirf/pinctrl-atlas7.c | 2 +- drivers/pinctrl/sirf/pinctrl-sirf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/pinctrl/sirf') diff --git a/drivers/pinctrl/sirf/pinctrl-atlas7.c b/drivers/pinctrl/sirf/pinctrl-atlas7.c index 829018c812bd..1850dc1b3863 100644 --- a/drivers/pinctrl/sirf/pinctrl-atlas7.c +++ b/drivers/pinctrl/sirf/pinctrl-atlas7.c @@ -6012,7 +6012,7 @@ static int atlas7_gpio_probe(struct platform_device *pdev) chip->label = kstrdup(np->name, GFP_KERNEL); chip->of_node = np; chip->of_gpio_n_cells = 2; - chip->dev = &pdev->dev; + chip->parent = &pdev->dev; /* Add gpio chip to system */ ret = gpiochip_add(chip); diff --git a/drivers/pinctrl/sirf/pinctrl-sirf.c b/drivers/pinctrl/sirf/pinctrl-sirf.c index 2a8d69725de8..ae97bdc75a69 100644 --- a/drivers/pinctrl/sirf/pinctrl-sirf.c +++ b/drivers/pinctrl/sirf/pinctrl-sirf.c @@ -811,7 +811,7 @@ static int sirfsoc_gpio_probe(struct device_node *np) sgpio->chip.gc.of_node = np; sgpio->chip.gc.of_xlate = sirfsoc_gpio_of_xlate; sgpio->chip.gc.of_gpio_n_cells = 2; - sgpio->chip.gc.dev = &pdev->dev; + sgpio->chip.gc.parent = &pdev->dev; sgpio->chip.regs = regs; err = gpiochip_add(&sgpio->chip.gc); -- cgit v1.2.3 From 9420023a5327f29a37cf0a6198bd7d8d80f9634c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 10:27:16 +0100 Subject: pinctrl: sirf-atlas7: 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: Barry Song Signed-off-by: Linus Walleij --- drivers/pinctrl/sirf/pinctrl-atlas7.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'drivers/pinctrl/sirf') diff --git a/drivers/pinctrl/sirf/pinctrl-atlas7.c b/drivers/pinctrl/sirf/pinctrl-atlas7.c index 1850dc1b3863..3a95ffdbaa72 100644 --- a/drivers/pinctrl/sirf/pinctrl-atlas7.c +++ b/drivers/pinctrl/sirf/pinctrl-atlas7.c @@ -355,11 +355,6 @@ struct atlas7_gpio_chip { struct atlas7_gpio_bank banks[0]; }; -static inline struct atlas7_gpio_chip *to_atlas7_gpio(struct gpio_chip *gc) -{ - return container_of(gc, struct atlas7_gpio_chip, chip); -} - /** * @dev: a pointer back to containing device * @virtbase: the offset to the controller in virtual memory @@ -5600,7 +5595,7 @@ static int __atlas7_gpio_to_pin(struct atlas7_gpio_chip *a7gc, u32 gpio) static void atlas7_gpio_irq_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(gc); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(gc); struct atlas7_gpio_bank *bank; void __iomem *ctrl_reg; u32 val, pin_in_bank; @@ -5638,7 +5633,7 @@ static void __atlas7_gpio_irq_mask(struct atlas7_gpio_chip *a7gc, int idx) static void atlas7_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(gc); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&a7gc->lock, flags); @@ -5651,7 +5646,7 @@ static void atlas7_gpio_irq_mask(struct irq_data *d) static void atlas7_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(gc); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(gc); struct atlas7_gpio_bank *bank; void __iomem *ctrl_reg; u32 val, pin_in_bank; @@ -5675,7 +5670,7 @@ static int atlas7_gpio_irq_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(gc); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(gc); struct atlas7_gpio_bank *bank; void __iomem *ctrl_reg; u32 val, pin_in_bank; @@ -5744,7 +5739,7 @@ static struct irq_chip atlas7_gpio_irq_chip = { static void atlas7_gpio_handle_irq(struct irq_desc *desc) { struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(gc); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(gc); struct atlas7_gpio_bank *bank = NULL; u32 status, ctrl; int pin_in_bank = 0, idx; @@ -5812,7 +5807,7 @@ static void __atlas7_gpio_set_input(struct atlas7_gpio_chip *a7gc, static int atlas7_gpio_request(struct gpio_chip *chip, unsigned int gpio) { - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(chip); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(chip); int ret; unsigned long flags; @@ -5840,7 +5835,7 @@ static int atlas7_gpio_request(struct gpio_chip *chip, static void atlas7_gpio_free(struct gpio_chip *chip, unsigned int gpio) { - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(chip); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(chip); unsigned long flags; spin_lock_irqsave(&a7gc->lock, flags); @@ -5856,7 +5851,7 @@ static void atlas7_gpio_free(struct gpio_chip *chip, static int atlas7_gpio_direction_input(struct gpio_chip *chip, unsigned int gpio) { - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(chip); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(chip); unsigned long flags; spin_lock_irqsave(&a7gc->lock, flags); @@ -5893,7 +5888,7 @@ static void __atlas7_gpio_set_output(struct atlas7_gpio_chip *a7gc, static int atlas7_gpio_direction_output(struct gpio_chip *chip, unsigned int gpio, int value) { - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(chip); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(chip); unsigned long flags; spin_lock_irqsave(&a7gc->lock, flags); @@ -5908,7 +5903,7 @@ static int atlas7_gpio_direction_output(struct gpio_chip *chip, static int atlas7_gpio_get_value(struct gpio_chip *chip, unsigned int gpio) { - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(chip); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(chip); struct atlas7_gpio_bank *bank; u32 val, pin_in_bank; unsigned long flags; @@ -5928,7 +5923,7 @@ static int atlas7_gpio_get_value(struct gpio_chip *chip, static void atlas7_gpio_set_value(struct gpio_chip *chip, unsigned int gpio, int value) { - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(chip); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(chip); struct atlas7_gpio_bank *bank; void __iomem *ctrl_reg; u32 ctrl, pin_in_bank; @@ -6015,7 +6010,7 @@ static int atlas7_gpio_probe(struct platform_device *pdev) chip->parent = &pdev->dev; /* Add gpio chip to system */ - ret = gpiochip_add(chip); + ret = gpiochip_add_data(chip, a7gc); if (ret) { dev_err(&pdev->dev, "%s: error in probe function with status %d\n", -- cgit v1.2.3 From 192d3507e2e65790f03ff43aeb1930ae097a8315 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 10:29:35 +0100 Subject: pinctrl: sirf: 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: Barry Song Signed-off-by: Linus Walleij --- drivers/pinctrl/sirf/pinctrl-sirf.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'drivers/pinctrl/sirf') diff --git a/drivers/pinctrl/sirf/pinctrl-sirf.c b/drivers/pinctrl/sirf/pinctrl-sirf.c index ae97bdc75a69..aa87fa90b884 100644 --- a/drivers/pinctrl/sirf/pinctrl-sirf.c +++ b/drivers/pinctrl/sirf/pinctrl-sirf.c @@ -399,11 +399,6 @@ static int __init sirfsoc_pinmux_init(void) } arch_initcall(sirfsoc_pinmux_init); -static inline struct sirfsoc_gpio_chip *to_sirfsoc_gpio(struct gpio_chip *gc) -{ - return container_of(gc, struct sirfsoc_gpio_chip, chip.gc); -} - static inline struct sirfsoc_gpio_bank * sirfsoc_gpio_to_bank(struct sirfsoc_gpio_chip *sgpio, unsigned int offset) { @@ -418,7 +413,7 @@ static inline int sirfsoc_gpio_to_bankoff(unsigned int offset) static void sirfsoc_gpio_irq_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); int idx = sirfsoc_gpio_to_bankoff(d->hwirq); u32 val, offset; @@ -457,7 +452,7 @@ static void __sirfsoc_gpio_irq_mask(struct sirfsoc_gpio_chip *sgpio, static void sirfsoc_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); __sirfsoc_gpio_irq_mask(sgpio, bank, d->hwirq % SIRFSOC_GPIO_BANK_SIZE); @@ -466,7 +461,7 @@ static void sirfsoc_gpio_irq_mask(struct irq_data *d) static void sirfsoc_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); int idx = sirfsoc_gpio_to_bankoff(d->hwirq); u32 val, offset; @@ -487,7 +482,7 @@ static void sirfsoc_gpio_irq_unmask(struct irq_data *d) static int sirfsoc_gpio_irq_type(struct irq_data *d, unsigned type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); int idx = sirfsoc_gpio_to_bankoff(d->hwirq); u32 val, offset; @@ -549,7 +544,7 @@ static void sirfsoc_gpio_handle_irq(struct irq_desc *desc) { unsigned int irq = irq_desc_get_irq(desc); struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); struct sirfsoc_gpio_bank *bank; u32 status, ctrl; int idx = 0; @@ -607,7 +602,7 @@ static inline void sirfsoc_gpio_set_input(struct sirfsoc_gpio_chip *sgpio, static int sirfsoc_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); unsigned long flags; @@ -630,7 +625,7 @@ static int sirfsoc_gpio_request(struct gpio_chip *chip, unsigned offset) static void sirfsoc_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); unsigned long flags; @@ -646,7 +641,7 @@ static void sirfsoc_gpio_free(struct gpio_chip *chip, unsigned offset) static int sirfsoc_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, gpio); int idx = sirfsoc_gpio_to_bankoff(gpio); unsigned long flags; @@ -689,7 +684,7 @@ static inline void sirfsoc_gpio_set_output(struct sirfsoc_gpio_chip *sgpio, static int sirfsoc_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, gpio); int idx = sirfsoc_gpio_to_bankoff(gpio); u32 offset; @@ -708,7 +703,7 @@ static int sirfsoc_gpio_direction_output(struct gpio_chip *chip, static int sirfsoc_gpio_get_value(struct gpio_chip *chip, unsigned offset) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); u32 val; unsigned long flags; @@ -725,7 +720,7 @@ static int sirfsoc_gpio_get_value(struct gpio_chip *chip, unsigned offset) static void sirfsoc_gpio_set_value(struct gpio_chip *chip, unsigned offset, int value) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); u32 ctrl; unsigned long flags; @@ -814,7 +809,7 @@ static int sirfsoc_gpio_probe(struct device_node *np) sgpio->chip.gc.parent = &pdev->dev; sgpio->chip.regs = regs; - err = gpiochip_add(&sgpio->chip.gc); + err = gpiochip_add_data(&sgpio->chip.gc, sgpio); if (err) { dev_err(&pdev->dev, "%s: error in probe function with status %d\n", np->full_name, err); -- cgit v1.2.3