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-adnp.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'drivers/gpio/gpio-adnp.c') diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c index d3d0a90fe542..b34a62a5a7e1 100644 --- a/drivers/gpio/gpio-adnp.c +++ b/drivers/gpio/gpio-adnp.c @@ -47,7 +47,7 @@ static int adnp_read(struct adnp *adnp, unsigned offset, uint8_t *value) err = i2c_smbus_read_byte_data(adnp->client, offset); if (err < 0) { - dev_err(adnp->gpio.dev, "%s failed: %d\n", + dev_err(adnp->gpio.parent, "%s failed: %d\n", "i2c_smbus_read_byte_data()", err); return err; } @@ -62,7 +62,7 @@ static int adnp_write(struct adnp *adnp, unsigned offset, uint8_t value) err = i2c_smbus_write_byte_data(adnp->client, offset, value); if (err < 0) { - dev_err(adnp->gpio.dev, "%s failed: %d\n", + dev_err(adnp->gpio.parent, "%s failed: %d\n", "i2c_smbus_write_byte_data()", err); return err; } @@ -266,8 +266,8 @@ static int adnp_gpio_setup(struct adnp *adnp, unsigned int num_gpios) chip->base = -1; chip->ngpio = num_gpios; chip->label = adnp->client->name; - chip->dev = &adnp->client->dev; - chip->of_node = chip->dev->of_node; + chip->parent = &adnp->client->dev; + chip->of_node = chip->parent->of_node; chip->owner = THIS_MODULE; err = gpiochip_add(chip); @@ -435,7 +435,8 @@ static int adnp_irq_setup(struct adnp *adnp) * is chosen to match the register layout of the hardware in that * each segment contains the corresponding bits for all interrupts. */ - adnp->irq_enable = devm_kzalloc(chip->dev, num_regs * 6, GFP_KERNEL); + adnp->irq_enable = devm_kzalloc(chip->parent, num_regs * 6, + GFP_KERNEL); if (!adnp->irq_enable) return -ENOMEM; @@ -462,12 +463,12 @@ static int adnp_irq_setup(struct adnp *adnp) adnp->irq_enable[i] = 0x00; } - err = devm_request_threaded_irq(chip->dev, adnp->client->irq, + err = devm_request_threaded_irq(chip->parent, adnp->client->irq, NULL, adnp_irq, IRQF_TRIGGER_RISING | IRQF_ONESHOT, - dev_name(chip->dev), adnp); + dev_name(chip->parent), adnp); if (err != 0) { - dev_err(chip->dev, "can't request IRQ#%d: %d\n", + dev_err(chip->parent, "can't request IRQ#%d: %d\n", adnp->client->irq, err); return err; } @@ -478,7 +479,7 @@ static int adnp_irq_setup(struct adnp *adnp) handle_simple_irq, IRQ_TYPE_NONE); if (err) { - dev_err(chip->dev, + dev_err(chip->parent, "could not connect irqchip to gpiochip\n"); return err; } -- cgit v1.2.3 From d9110e9ce7ed98b24fa58764833e89a430843c21 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 19 Nov 2015 12:57:11 +0900 Subject: gpio: Drop owner assignment from i2c_driver i2c_driver does not need to set an owner because i2c_register_driver() will set it. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Linus Walleij --- drivers/gpio/gpio-adnp.c | 1 - drivers/gpio/gpio-max7300.c | 1 - drivers/gpio/gpio-max732x.c | 1 - drivers/gpio/gpio-mc9s08dz60.c | 1 - drivers/gpio/gpio-pcf857x.c | 1 - drivers/gpio/gpio-sx150x.c | 1 - 6 files changed, 6 deletions(-) (limited to 'drivers/gpio/gpio-adnp.c') diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c index b34a62a5a7e1..b8a1ac133390 100644 --- a/drivers/gpio/gpio-adnp.c +++ b/drivers/gpio/gpio-adnp.c @@ -548,7 +548,6 @@ MODULE_DEVICE_TABLE(of, adnp_of_match); static struct i2c_driver adnp_i2c_driver = { .driver = { .name = "gpio-adnp", - .owner = THIS_MODULE, .of_match_table = adnp_of_match, }, .probe = adnp_i2c_probe, diff --git a/drivers/gpio/gpio-max7300.c b/drivers/gpio/gpio-max7300.c index 0cc2c279ab5c..1ae9ba851c9a 100644 --- a/drivers/gpio/gpio-max7300.c +++ b/drivers/gpio/gpio-max7300.c @@ -65,7 +65,6 @@ MODULE_DEVICE_TABLE(i2c, max7300_id); static struct i2c_driver max7300_driver = { .driver = { .name = "max7300", - .owner = THIS_MODULE, }, .probe = max7300_probe, .remove = max7300_remove, diff --git a/drivers/gpio/gpio-max732x.c b/drivers/gpio/gpio-max732x.c index c1e7b55644b0..a1094984b666 100644 --- a/drivers/gpio/gpio-max732x.c +++ b/drivers/gpio/gpio-max732x.c @@ -749,7 +749,6 @@ static int max732x_remove(struct i2c_client *client) static struct i2c_driver max732x_driver = { .driver = { .name = "max732x", - .owner = THIS_MODULE, .of_match_table = of_match_ptr(max732x_of_table), }, .probe = max732x_probe, diff --git a/drivers/gpio/gpio-mc9s08dz60.c b/drivers/gpio/gpio-mc9s08dz60.c index defa38f958fb..45f176018378 100644 --- a/drivers/gpio/gpio-mc9s08dz60.c +++ b/drivers/gpio/gpio-mc9s08dz60.c @@ -131,7 +131,6 @@ MODULE_DEVICE_TABLE(i2c, mc9s08dz60_id); static struct i2c_driver mc9s08dz60_i2c_driver = { .driver = { - .owner = THIS_MODULE, .name = "mc9s08dz60", }, .probe = mc9s08dz60_probe, diff --git a/drivers/gpio/gpio-pcf857x.c b/drivers/gpio/gpio-pcf857x.c index c7552106a80c..407ca5e1aafa 100644 --- a/drivers/gpio/gpio-pcf857x.c +++ b/drivers/gpio/gpio-pcf857x.c @@ -447,7 +447,6 @@ static int pcf857x_remove(struct i2c_client *client) static struct i2c_driver pcf857x_driver = { .driver = { .name = "pcf857x", - .owner = THIS_MODULE, .of_match_table = of_match_ptr(pcf857x_of_table), }, .probe = pcf857x_probe, diff --git a/drivers/gpio/gpio-sx150x.c b/drivers/gpio/gpio-sx150x.c index c0145159a127..cf12d8e3ce3e 100644 --- a/drivers/gpio/gpio-sx150x.c +++ b/drivers/gpio/gpio-sx150x.c @@ -680,7 +680,6 @@ static int sx150x_remove(struct i2c_client *client) static struct i2c_driver sx150x_driver = { .driver = { .name = "sx150x", - .owner = THIS_MODULE, .of_match_table = of_match_ptr(sx150x_of_match), }, .probe = sx150x_probe, -- cgit v1.2.3 From 1e69c4fe2a67a63e6b392338dd01627ee26f9ca3 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 14:56:15 +0100 Subject: gpio: adnp: 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(). Signed-off-by: Linus Walleij --- drivers/gpio/gpio-adnp.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'drivers/gpio/gpio-adnp.c') diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c index b8a1ac133390..fb5b47b69f14 100644 --- a/drivers/gpio/gpio-adnp.c +++ b/drivers/gpio/gpio-adnp.c @@ -36,11 +36,6 @@ struct adnp { u8 *irq_low; }; -static inline struct adnp *to_adnp(struct gpio_chip *chip) -{ - return container_of(chip, struct adnp, gpio); -} - static int adnp_read(struct adnp *adnp, unsigned offset, uint8_t *value) { int err; @@ -72,7 +67,7 @@ static int adnp_write(struct adnp *adnp, unsigned offset, uint8_t value) static int adnp_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct adnp *adnp = to_adnp(chip); + struct adnp *adnp = gpiochip_get_data(chip); unsigned int reg = offset >> adnp->reg_shift; unsigned int pos = offset & 7; u8 value; @@ -106,7 +101,7 @@ static void __adnp_gpio_set(struct adnp *adnp, unsigned offset, int value) static void adnp_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct adnp *adnp = to_adnp(chip); + struct adnp *adnp = gpiochip_get_data(chip); mutex_lock(&adnp->i2c_lock); __adnp_gpio_set(adnp, offset, value); @@ -115,7 +110,7 @@ static void adnp_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int adnp_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct adnp *adnp = to_adnp(chip); + struct adnp *adnp = gpiochip_get_data(chip); unsigned int reg = offset >> adnp->reg_shift; unsigned int pos = offset & 7; u8 value; @@ -150,7 +145,7 @@ out: static int adnp_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct adnp *adnp = to_adnp(chip); + struct adnp *adnp = gpiochip_get_data(chip); unsigned int reg = offset >> adnp->reg_shift; unsigned int pos = offset & 7; int err; @@ -187,7 +182,7 @@ out: static void adnp_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { - struct adnp *adnp = to_adnp(chip); + struct adnp *adnp = gpiochip_get_data(chip); unsigned int num_regs = 1 << adnp->reg_shift, i, j; int err; @@ -270,7 +265,7 @@ static int adnp_gpio_setup(struct adnp *adnp, unsigned int num_gpios) chip->of_node = chip->parent->of_node; chip->owner = THIS_MODULE; - err = gpiochip_add(chip); + err = gpiochip_add_data(chip, adnp); if (err) return err; @@ -340,7 +335,7 @@ static irqreturn_t adnp_irq(int irq, void *data) static void adnp_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct adnp *adnp = to_adnp(gc); + struct adnp *adnp = gpiochip_get_data(gc); unsigned int reg = d->hwirq >> adnp->reg_shift; unsigned int pos = d->hwirq & 7; @@ -350,7 +345,7 @@ static void adnp_irq_mask(struct irq_data *d) static void adnp_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct adnp *adnp = to_adnp(gc); + struct adnp *adnp = gpiochip_get_data(gc); unsigned int reg = d->hwirq >> adnp->reg_shift; unsigned int pos = d->hwirq & 7; @@ -360,7 +355,7 @@ static void adnp_irq_unmask(struct irq_data *d) static int adnp_irq_set_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct adnp *adnp = to_adnp(gc); + struct adnp *adnp = gpiochip_get_data(gc); unsigned int reg = d->hwirq >> adnp->reg_shift; unsigned int pos = d->hwirq & 7; @@ -390,7 +385,7 @@ static int adnp_irq_set_type(struct irq_data *d, unsigned int type) static void adnp_irq_bus_lock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct adnp *adnp = to_adnp(gc); + struct adnp *adnp = gpiochip_get_data(gc); mutex_lock(&adnp->irq_lock); } @@ -398,7 +393,7 @@ static void adnp_irq_bus_lock(struct irq_data *d) static void adnp_irq_bus_unlock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct adnp *adnp = to_adnp(gc); + struct adnp *adnp = gpiochip_get_data(gc); unsigned int num_regs = 1 << adnp->reg_shift, i; mutex_lock(&adnp->i2c_lock); -- cgit v1.2.3