diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2015-12-04 14:02:58 +0100 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-01-05 11:21:00 +0100 |
commit | 0f4630f3720e7e6e921bf525c8357fea7ef3dbab (patch) | |
tree | 61c1904593d1ee424464c2d57668ba0fd2fbcbb4 /drivers/gpio/gpio-etraxfs.c | |
parent | 3208b0f0c010b26e4d461a3bca59989d03ed9087 (diff) | |
download | linux-stable-0f4630f3720e7e6e921bf525c8357fea7ef3dbab.tar.gz linux-stable-0f4630f3720e7e6e921bf525c8357fea7ef3dbab.tar.bz2 linux-stable-0f4630f3720e7e6e921bf525c8357fea7ef3dbab.zip |
gpio: generic: factor into gpio_chip struct
The separate struct bgpio_chip has been a pain to handle, both
by being confusingly similar in name to struct gpio_chip and
for being contained inside a struct so that struct gpio_chip
is contained in a struct contained in a struct, making several
steps of dereferencing necessary.
Make things simpler: include the fields directly into
<linux/gpio/driver.h>, #ifdef:ed for CONFIG_GENERIC_GPIO, and
get rid of the <linux/basic_mmio_gpio.h> altogether. Prefix
some of the member variables with bgpio_* and add proper
kerneldoc while we're at it.
Modify all users to handle the change and use a struct
gpio_chip directly. And while we're at it: replace all
container_of() dereferencing by gpiochip_get_data() and
registering the gpio_chip with gpiochip_add_data().
Cc: arm@kernel.org
Cc: Alexander Shiyan <shc_work@mail.ru>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <kernel@pengutronix.de>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: Alexandre Courbot <gnurou@gmail.com>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
Cc: Olof Johansson <olof@lixom.net>
Cc: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Rabin Vincent <rabin@rab.in>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-omap@vger.kernel.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: bcm-kernel-feedback-list@broadcom.com
Acked-by: Gregory Fong <gregory.0xf0@gmail.com>
Acked-by: Liviu Dudau <Liviu.Dudau@arm.com>
Acked-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-etraxfs.c')
-rw-r--r-- | drivers/gpio/gpio-etraxfs.c | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/drivers/gpio/gpio-etraxfs.c b/drivers/gpio/gpio-etraxfs.c index 5c15dd12172d..00b022c9acb3 100644 --- a/drivers/gpio/gpio-etraxfs.c +++ b/drivers/gpio/gpio-etraxfs.c @@ -1,12 +1,10 @@ #include <linux/kernel.h> #include <linux/init.h> -#include <linux/gpio.h> #include <linux/gpio/driver.h> #include <linux/of_gpio.h> #include <linux/io.h> #include <linux/interrupt.h> #include <linux/platform_device.h> -#include <linux/basic_mmio_gpio.h> #define ETRAX_FS_rw_pa_dout 0 #define ETRAX_FS_r_pa_din 4 @@ -67,7 +65,7 @@ struct etraxfs_gpio_block { }; struct etraxfs_gpio_chip { - struct bgpio_chip bgc; + struct gpio_chip gc; struct etraxfs_gpio_block *block; }; @@ -176,11 +174,6 @@ static const struct etraxfs_gpio_info etraxfs_gpio_artpec3 = { .rw_intr_pins = ARTPEC3_rw_intr_pins, }; -static struct etraxfs_gpio_chip *to_etraxfs(struct gpio_chip *gc) -{ - return container_of(gc, struct etraxfs_gpio_chip, bgc.gc); -} - static unsigned int etraxfs_gpio_chip_to_port(struct gpio_chip *gc) { return gc->label[0] - 'A'; @@ -220,13 +213,13 @@ static unsigned int etraxfs_gpio_to_group_irq(unsigned int gpio) static unsigned int etraxfs_gpio_to_group_pin(struct etraxfs_gpio_chip *chip, unsigned int gpio) { - return 4 * etraxfs_gpio_chip_to_port(&chip->bgc.gc) + gpio / 8; + return 4 * etraxfs_gpio_chip_to_port(&chip->gc) + gpio / 8; } static void etraxfs_gpio_irq_ack(struct irq_data *d) { struct etraxfs_gpio_chip *chip = - to_etraxfs(irq_data_get_irq_chip_data(d)); + gpiochip_get_data(irq_data_get_irq_chip_data(d)); struct etraxfs_gpio_block *block = chip->block; unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); @@ -236,7 +229,7 @@ static void etraxfs_gpio_irq_ack(struct irq_data *d) static void etraxfs_gpio_irq_mask(struct irq_data *d) { struct etraxfs_gpio_chip *chip = - to_etraxfs(irq_data_get_irq_chip_data(d)); + gpiochip_get_data(irq_data_get_irq_chip_data(d)); struct etraxfs_gpio_block *block = chip->block; unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); @@ -249,7 +242,7 @@ static void etraxfs_gpio_irq_mask(struct irq_data *d) static void etraxfs_gpio_irq_unmask(struct irq_data *d) { struct etraxfs_gpio_chip *chip = - to_etraxfs(irq_data_get_irq_chip_data(d)); + gpiochip_get_data(irq_data_get_irq_chip_data(d)); struct etraxfs_gpio_block *block = chip->block; unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); @@ -262,7 +255,7 @@ static void etraxfs_gpio_irq_unmask(struct irq_data *d) static int etraxfs_gpio_irq_set_type(struct irq_data *d, u32 type) { struct etraxfs_gpio_chip *chip = - to_etraxfs(irq_data_get_irq_chip_data(d)); + gpiochip_get_data(irq_data_get_irq_chip_data(d)); struct etraxfs_gpio_block *block = chip->block; unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); u32 cfg; @@ -299,7 +292,7 @@ static int etraxfs_gpio_irq_set_type(struct irq_data *d, u32 type) static int etraxfs_gpio_irq_request_resources(struct irq_data *d) { struct etraxfs_gpio_chip *chip = - to_etraxfs(irq_data_get_irq_chip_data(d)); + gpiochip_get_data(irq_data_get_irq_chip_data(d)); struct etraxfs_gpio_block *block = chip->block; unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); int ret = -EBUSY; @@ -308,7 +301,7 @@ static int etraxfs_gpio_irq_request_resources(struct irq_data *d) if (block->group[grpirq]) goto out; - ret = gpiochip_lock_as_irq(&chip->bgc.gc, d->hwirq); + ret = gpiochip_lock_as_irq(&chip->gc, d->hwirq); if (ret) goto out; @@ -330,13 +323,13 @@ out: static void etraxfs_gpio_irq_release_resources(struct irq_data *d) { struct etraxfs_gpio_chip *chip = - to_etraxfs(irq_data_get_irq_chip_data(d)); + gpiochip_get_data(irq_data_get_irq_chip_data(d)); struct etraxfs_gpio_block *block = chip->block; unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); spin_lock(&block->lock); block->group[grpirq] = 0; - gpiochip_unlock_as_irq(&chip->bgc.gc, d->hwirq); + gpiochip_unlock_as_irq(&chip->gc, d->hwirq); spin_unlock(&block->lock); } @@ -419,7 +412,7 @@ static int etraxfs_gpio_probe(struct platform_device *pdev) for (i = 0; i < info->num_ports; i++) { struct etraxfs_gpio_chip *chip = &chips[i]; - struct bgpio_chip *bgc = &chip->bgc; + struct gpio_chip *gc = &chip->gc; const struct etraxfs_gpio_port *port = &info->ports[i]; unsigned long flags = BGPIOF_READ_OUTPUT_REG_SET; void __iomem *dat = regs + port->din; @@ -433,7 +426,7 @@ static int etraxfs_gpio_probe(struct platform_device *pdev) flags = BGPIOF_NO_OUTPUT; } - ret = bgpio_init(bgc, dev, 4, + ret = bgpio_init(gc, dev, 4, dat, set, NULL, dirout, NULL, flags); if (ret) { @@ -442,28 +435,28 @@ static int etraxfs_gpio_probe(struct platform_device *pdev) continue; } - bgc->gc.ngpio = port->ngpio; - bgc->gc.label = port->label; + gc->ngpio = port->ngpio; + gc->label = port->label; - bgc->gc.of_node = dev->of_node; - bgc->gc.of_gpio_n_cells = 3; - bgc->gc.of_xlate = etraxfs_gpio_of_xlate; + gc->of_node = dev->of_node; + gc->of_gpio_n_cells = 3; + gc->of_xlate = etraxfs_gpio_of_xlate; - ret = gpiochip_add(&bgc->gc); + ret = gpiochip_add_data(gc, chip); if (ret) { dev_err(dev, "Unable to register port %s\n", - bgc->gc.label); + gc->label); continue; } if (i > 0 && !allportsirq) continue; - ret = gpiochip_irqchip_add(&bgc->gc, &etraxfs_gpio_irq_chip, 0, + ret = gpiochip_irqchip_add(gc, &etraxfs_gpio_irq_chip, 0, handle_level_irq, IRQ_TYPE_NONE); if (ret) { dev_err(dev, "Unable to add irqchip to port %s\n", - bgc->gc.label); + gc->label); } } |