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 --- arch/avr32/mach-at32ap/pio.c | 2 +- drivers/bcma/driver_gpio.c | 2 +- drivers/gpio/gpio-104-idio-16.c | 2 +- drivers/gpio/gpio-74x164.c | 4 +-- drivers/gpio/gpio-adnp.c | 19 ++++++----- drivers/gpio/gpio-altera.c | 2 +- drivers/gpio/gpio-amd8111.c | 2 +- drivers/gpio/gpio-amdpt.c | 18 +++++----- drivers/gpio/gpio-arizona.c | 2 +- drivers/gpio/gpio-ath79.c | 2 +- drivers/gpio/gpio-bcm-kona.c | 6 ++-- drivers/gpio/gpio-crystalcove.c | 2 +- drivers/gpio/gpio-davinci.c | 4 +-- drivers/gpio/gpio-dln2.c | 10 +++--- drivers/gpio/gpio-em.c | 4 +-- drivers/gpio/gpio-f7188x.c | 2 +- drivers/gpio/gpio-generic.c | 2 +- drivers/gpio/gpio-ich.c | 2 +- drivers/gpio/gpio-intel-mid.c | 2 +- drivers/gpio/gpio-janz-ttl.c | 6 ++-- drivers/gpio/gpio-kempld.c | 2 +- drivers/gpio/gpio-lp3943.c | 2 +- drivers/gpio/gpio-lpc18xx.c | 2 +- drivers/gpio/gpio-lynxpoint.c | 2 +- drivers/gpio/gpio-max730x.c | 2 +- drivers/gpio/gpio-max732x.c | 4 +-- drivers/gpio/gpio-mb86s7x.c | 2 +- drivers/gpio/gpio-mc33880.c | 2 +- drivers/gpio/gpio-mc9s08dz60.c | 2 +- drivers/gpio/gpio-mcp23s08.c | 16 +++++---- drivers/gpio/gpio-moxart.c | 2 +- drivers/gpio/gpio-msic.c | 2 +- drivers/gpio/gpio-mvebu.c | 2 +- drivers/gpio/gpio-octeon.c | 2 +- drivers/gpio/gpio-omap.c | 4 +-- drivers/gpio/gpio-palmas.c | 14 ++++---- drivers/gpio/gpio-pca953x.c | 2 +- drivers/gpio/gpio-pcf857x.c | 2 +- drivers/gpio/gpio-pch.c | 2 +- drivers/gpio/gpio-pl061.c | 12 +++---- drivers/gpio/gpio-rc5t583.c | 2 +- drivers/gpio/gpio-rcar.c | 2 +- drivers/gpio/gpio-sch.c | 2 +- drivers/gpio/gpio-sch311x.c | 4 +-- drivers/gpio/gpio-spear-spics.c | 2 +- drivers/gpio/gpio-stmpe.c | 2 +- drivers/gpio/gpio-stp-xway.c | 4 +-- drivers/gpio/gpio-sx150x.c | 2 +- drivers/gpio/gpio-syscon.c | 4 +-- drivers/gpio/gpio-tb10x.c | 2 +- drivers/gpio/gpio-tc3589x.c | 2 +- drivers/gpio/gpio-timberdale.c | 2 +- drivers/gpio/gpio-tps6586x.c | 2 +- drivers/gpio/gpio-tps65910.c | 2 +- drivers/gpio/gpio-tps65912.c | 2 +- drivers/gpio/gpio-ts5500.c | 5 +-- drivers/gpio/gpio-twl4030.c | 4 +-- drivers/gpio/gpio-twl6040.c | 6 ++-- drivers/gpio/gpio-tz1090-pdc.c | 2 +- drivers/gpio/gpio-tz1090.c | 2 +- drivers/gpio/gpio-vf610.c | 2 +- drivers/gpio/gpio-viperboard.c | 16 ++++----- drivers/gpio/gpio-vr41xx.c | 4 +-- drivers/gpio/gpio-wm831x.c | 2 +- drivers/gpio/gpio-wm8350.c | 2 +- drivers/gpio/gpio-wm8994.c | 2 +- drivers/gpio/gpio-xgene.c | 2 +- drivers/gpio/gpio-xilinx.c | 2 +- drivers/gpio/gpio-xlp.c | 2 +- drivers/gpio/gpio-zevio.c | 4 +-- drivers/gpio/gpio-zx.c | 2 +- drivers/gpio/gpio-zynq.c | 6 ++-- drivers/gpio/gpiolib-acpi.c | 47 ++++++++++++++------------- drivers/gpio/gpiolib-of.c | 4 +-- drivers/gpio/gpiolib-sysfs.c | 5 +-- drivers/gpio/gpiolib.c | 19 ++++++----- drivers/hid/hid-cp2112.c | 2 +- drivers/input/touchscreen/ad7879.c | 2 +- drivers/leds/leds-pca9532.c | 6 ++-- drivers/leds/leds-tca6507.c | 2 +- drivers/media/dvb-frontends/cxd2820r_core.c | 2 +- drivers/mfd/dm355evm_msp.c | 2 +- drivers/mfd/htc-egpio.c | 2 +- drivers/mfd/htc-i2cpld.c | 4 +-- drivers/mfd/tps65010.c | 2 +- drivers/mfd/ucb1x00-core.c | 2 +- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 8 ++--- drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c | 2 +- drivers/pinctrl/intel/pinctrl-baytrail.c | 2 +- drivers/pinctrl/intel/pinctrl-cherryview.c | 2 +- drivers/pinctrl/intel/pinctrl-intel.c | 2 +- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 12 +++---- drivers/pinctrl/meson/pinctrl-meson.c | 2 +- drivers/pinctrl/nomadik/pinctrl-abx500.c | 7 ++-- drivers/pinctrl/nomadik/pinctrl-nomadik.c | 8 ++--- drivers/pinctrl/pinctrl-amd.c | 2 +- drivers/pinctrl/pinctrl-as3722.c | 2 +- drivers/pinctrl/pinctrl-at91-pio4.c | 12 +++---- drivers/pinctrl/pinctrl-at91.c | 2 +- drivers/pinctrl/pinctrl-coh901.c | 2 +- drivers/pinctrl/pinctrl-digicolor.c | 2 +- drivers/pinctrl/pinctrl-pistachio.c | 2 +- drivers/pinctrl/pinctrl-rockchip.c | 2 +- drivers/pinctrl/pinctrl-st.c | 2 +- drivers/pinctrl/pinctrl-xway.c | 10 +++--- drivers/pinctrl/qcom/pinctrl-msm.c | 2 +- drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 2 +- drivers/pinctrl/qcom/pinctrl-spmi-mpp.c | 2 +- drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c | 2 +- drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c | 2 +- drivers/pinctrl/samsung/pinctrl-exynos.c | 3 +- drivers/pinctrl/samsung/pinctrl-exynos5440.c | 12 +++---- drivers/pinctrl/samsung/pinctrl-samsung.c | 2 +- drivers/pinctrl/sh-pfc/gpio.c | 2 +- drivers/pinctrl/sirf/pinctrl-atlas7.c | 2 +- drivers/pinctrl/sirf/pinctrl-sirf.c | 2 +- drivers/pinctrl/spear/pinctrl-plgpio.c | 2 +- drivers/pinctrl/sunxi/pinctrl-sunxi.c | 10 +++--- drivers/pinctrl/vt8500/pinctrl-wmt.c | 8 ++--- drivers/platform/x86/intel_pmic_gpio.c | 4 +-- drivers/tty/serial/max310x.c | 2 +- drivers/tty/serial/sc16is7xx.c | 2 +- include/linux/gpio/driver.h | 4 +-- sound/soc/codecs/rt5677.c | 2 +- sound/soc/codecs/wm5100.c | 2 +- sound/soc/codecs/wm8903.c | 2 +- sound/soc/codecs/wm8962.c | 2 +- sound/soc/codecs/wm8996.c | 2 +- 128 files changed, 274 insertions(+), 261 deletions(-) diff --git a/arch/avr32/mach-at32ap/pio.c b/arch/avr32/mach-at32ap/pio.c index 4f61378c3453..aa74491771fa 100644 --- a/arch/avr32/mach-at32ap/pio.c +++ b/arch/avr32/mach-at32ap/pio.c @@ -397,7 +397,7 @@ static int __init pio_probe(struct platform_device *pdev) pio->chip.label = pio->name; pio->chip.base = pdev->id * 32; pio->chip.ngpio = 32; - pio->chip.dev = &pdev->dev; + pio->chip.parent = &pdev->dev; pio->chip.owner = THIS_MODULE; pio->chip.direction_input = direction_input; diff --git a/drivers/bcma/driver_gpio.c b/drivers/bcma/driver_gpio.c index 504899a72966..949754427ce2 100644 --- a/drivers/bcma/driver_gpio.c +++ b/drivers/bcma/driver_gpio.c @@ -188,7 +188,7 @@ int bcma_gpio_init(struct bcma_drv_cc *cc) chip->direction_input = bcma_gpio_direction_input; chip->direction_output = bcma_gpio_direction_output; chip->owner = THIS_MODULE; - chip->dev = bcma_bus_get_host_dev(bus); + chip->parent = bcma_bus_get_host_dev(bus); #if IS_BUILTIN(CONFIG_OF) if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC) chip->of_node = cc->core->dev.of_node; diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c index 5400d7d4d8fd..107cfd7105a8 100644 --- a/drivers/gpio/gpio-104-idio-16.c +++ b/drivers/gpio/gpio-104-idio-16.c @@ -127,7 +127,7 @@ static int __init idio_16_probe(struct platform_device *pdev) } idio16gpio->chip.label = NAME; - idio16gpio->chip.dev = dev; + idio16gpio->chip.parent = dev; idio16gpio->chip.owner = THIS_MODULE; idio16gpio->chip.base = -1; idio16gpio->chip.ngpio = 32; diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index 60172f835d15..fb555300008f 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -33,7 +33,7 @@ static struct gen_74x164_chip *gpio_to_74x164_chip(struct gpio_chip *gc) static int __gen_74x164_write_config(struct gen_74x164_chip *chip) { - struct spi_device *spi = to_spi_device(chip->gpio_chip.dev); + struct spi_device *spi = to_spi_device(chip->gpio_chip.parent); struct spi_message message; struct spi_transfer *msg_buf; int i, ret = 0; @@ -143,7 +143,7 @@ static int gen_74x164_probe(struct spi_device *spi) return -ENOMEM; chip->gpio_chip.can_sleep = true; - chip->gpio_chip.dev = &spi->dev; + chip->gpio_chip.parent = &spi->dev; chip->gpio_chip.owner = THIS_MODULE; mutex_init(&chip->lock); 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; } diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c index 3e6661bab54a..84a20af01a9a 100644 --- a/drivers/gpio/gpio-altera.c +++ b/drivers/gpio/gpio-altera.c @@ -290,7 +290,7 @@ static int altera_gpio_probe(struct platform_device *pdev) altera_gc->mmchip.gc.get = altera_gpio_get; altera_gc->mmchip.gc.set = altera_gpio_set; altera_gc->mmchip.gc.owner = THIS_MODULE; - altera_gc->mmchip.gc.dev = &pdev->dev; + altera_gc->mmchip.gc.parent = &pdev->dev; ret = of_mm_gpiochip_add(node, &altera_gc->mmchip); if (ret) { diff --git a/drivers/gpio/gpio-amd8111.c b/drivers/gpio/gpio-amd8111.c index d00d81928fe8..5c378e9f53a0 100644 --- a/drivers/gpio/gpio-amd8111.c +++ b/drivers/gpio/gpio-amd8111.c @@ -220,7 +220,7 @@ found: goto out; } gp.pdev = pdev; - gp.chip.dev = &pdev->dev; + gp.chip.parent = &pdev->dev; spin_lock_init(&gp.lock); diff --git a/drivers/gpio/gpio-amdpt.c b/drivers/gpio/gpio-amdpt.c index cbbb966d4fc0..f842ccc45e64 100644 --- a/drivers/gpio/gpio-amdpt.c +++ b/drivers/gpio/gpio-amdpt.c @@ -39,14 +39,14 @@ static int pt_gpio_request(struct gpio_chip *gc, unsigned offset) unsigned long flags; u32 using_pins; - dev_dbg(gc->dev, "pt_gpio_request offset=%x\n", offset); + dev_dbg(gc->parent, "pt_gpio_request offset=%x\n", offset); spin_lock_irqsave(&pt_gpio->lock, flags); using_pins = readl(pt_gpio->reg_base + PT_SYNC_REG); if (using_pins & BIT(offset)) { - dev_warn(gc->dev, "PT GPIO pin %x reconfigured\n", - offset); + dev_warn(gc->parent, "PT GPIO pin %x reconfigured\n", + offset); spin_unlock_irqrestore(&pt_gpio->lock, flags); return -EINVAL; } @@ -72,7 +72,7 @@ static void pt_gpio_free(struct gpio_chip *gc, unsigned offset) spin_unlock_irqrestore(&pt_gpio->lock, flags); - dev_dbg(gc->dev, "pt_gpio_free offset=%x\n", offset); + dev_dbg(gc->parent, "pt_gpio_free offset=%x\n", offset); } static void pt_gpio_set_value(struct gpio_chip *gc, unsigned offset, int value) @@ -81,7 +81,7 @@ static void pt_gpio_set_value(struct gpio_chip *gc, unsigned offset, int value) unsigned long flags; u32 data; - dev_dbg(gc->dev, "pt_gpio_set_value offset=%x, value=%x\n", + dev_dbg(gc->parent, "pt_gpio_set_value offset=%x, value=%x\n", offset, value); spin_lock_irqsave(&pt_gpio->lock, flags); @@ -116,7 +116,7 @@ static int pt_gpio_get_value(struct gpio_chip *gc, unsigned offset) data >>= offset; data &= 1; - dev_dbg(gc->dev, "pt_gpio_get_value offset=%x, value=%x\n", + dev_dbg(gc->parent, "pt_gpio_get_value offset=%x, value=%x\n", offset, data); return data; @@ -128,7 +128,7 @@ static int pt_gpio_direction_input(struct gpio_chip *gc, unsigned offset) unsigned long flags; u32 data; - dev_dbg(gc->dev, "pt_gpio_dirction_input offset=%x\n", offset); + dev_dbg(gc->parent, "pt_gpio_dirction_input offset=%x\n", offset); spin_lock_irqsave(&pt_gpio->lock, flags); @@ -148,7 +148,7 @@ static int pt_gpio_direction_output(struct gpio_chip *gc, unsigned long flags; u32 data; - dev_dbg(gc->dev, "pt_gpio_direction_output offset=%x, value=%x\n", + dev_dbg(gc->parent, "pt_gpio_direction_output offset=%x, value=%x\n", offset, value); spin_lock_irqsave(&pt_gpio->lock, flags); @@ -202,7 +202,7 @@ static int pt_gpio_probe(struct platform_device *pdev) pt_gpio->gc.label = pdev->name; pt_gpio->gc.owner = THIS_MODULE; - pt_gpio->gc.dev = dev; + pt_gpio->gc.parent = dev; pt_gpio->gc.request = pt_gpio_request; pt_gpio->gc.free = pt_gpio_free; pt_gpio->gc.direction_input = pt_gpio_direction_input; diff --git a/drivers/gpio/gpio-arizona.c b/drivers/gpio/gpio-arizona.c index ca002739616a..412d131b513d 100644 --- a/drivers/gpio/gpio-arizona.c +++ b/drivers/gpio/gpio-arizona.c @@ -108,7 +108,7 @@ static int arizona_gpio_probe(struct platform_device *pdev) arizona_gpio->arizona = arizona; arizona_gpio->gpio_chip = template_chip; - arizona_gpio->gpio_chip.dev = &pdev->dev; + arizona_gpio->gpio_chip.parent = &pdev->dev; #ifdef CONFIG_OF_GPIO arizona_gpio->gpio_chip.of_node = arizona->dev->of_node; #endif diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c index e5827a56ff3b..b1410226dc95 100644 --- a/drivers/gpio/gpio-ath79.c +++ b/drivers/gpio/gpio-ath79.c @@ -177,7 +177,7 @@ static int ath79_gpio_probe(struct platform_device *pdev) spin_lock_init(&ctrl->lock); memcpy(&ctrl->chip, &ath79_gpio_chip, sizeof(ctrl->chip)); - ctrl->chip.dev = &pdev->dev; + ctrl->chip.parent = &pdev->dev; ctrl->chip.ngpio = ath79_gpio_count; if (oe_inverted) { ctrl->chip.direction_input = ar934x_gpio_direction_input; diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c index 33a1f9779b86..21c3280d66e1 100644 --- a/drivers/gpio/gpio-bcm-kona.c +++ b/drivers/gpio/gpio-bcm-kona.c @@ -273,7 +273,7 @@ static int bcm_kona_gpio_set_debounce(struct gpio_chip *chip, unsigned gpio, reg_base = kona_gpio->reg_base; /* debounce must be 1-128ms (or 0) */ if ((debounce > 0 && debounce < 1000) || debounce > 128000) { - dev_err(chip->dev, "Debounce value %u not in range\n", + dev_err(chip->parent, "Debounce value %u not in range\n", debounce); return -EINVAL; } @@ -416,7 +416,7 @@ static int bcm_kona_gpio_irq_set_type(struct irq_data *d, unsigned int type) case IRQ_TYPE_LEVEL_LOW: /* BCM GPIO doesn't support level triggering */ default: - dev_err(kona_gpio->gpio_chip.dev, + dev_err(kona_gpio->gpio_chip.parent, "Invalid BCM GPIO irq type 0x%x\n", type); return -EINVAL; } @@ -477,7 +477,7 @@ static int bcm_kona_gpio_irq_reqres(struct irq_data *d) struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); if (gpiochip_lock_as_irq(&kona_gpio->gpio_chip, d->hwirq)) { - dev_err(kona_gpio->gpio_chip.dev, + dev_err(kona_gpio->gpio_chip.parent, "unable to lock HW IRQ %lu for IRQ\n", d->hwirq); return -EINVAL; diff --git a/drivers/gpio/gpio-crystalcove.c b/drivers/gpio/gpio-crystalcove.c index fddd204dc9b6..141093a8cd3f 100644 --- a/drivers/gpio/gpio-crystalcove.c +++ b/drivers/gpio/gpio-crystalcove.c @@ -341,7 +341,7 @@ static int crystalcove_gpio_probe(struct platform_device *pdev) cg->chip.base = -1; cg->chip.ngpio = CRYSTALCOVE_VGPIO_NUM; cg->chip.can_sleep = true; - cg->chip.dev = dev; + cg->chip.parent = dev; cg->chip.dbg_show = crystalcove_gpio_dbg_show; cg->regmap = pmic->regmap; diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 5e715388803d..cf31179726b1 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -179,8 +179,8 @@ static int davinci_gpio_of_xlate(struct gpio_chip *gc, const struct of_phandle_args *gpiospec, u32 *flags) { - struct davinci_gpio_controller *chips = dev_get_drvdata(gc->dev); - struct davinci_gpio_platform_data *pdata = dev_get_platdata(gc->dev); + struct davinci_gpio_controller *chips = dev_get_drvdata(gc->parent); + struct davinci_gpio_platform_data *pdata = dev_get_platdata(gc->parent); if (gpiospec->args[0] > pdata->ngpio) return -EINVAL; diff --git a/drivers/gpio/gpio-dln2.c b/drivers/gpio/gpio-dln2.c index 6685712c15cf..e541af03dd45 100644 --- a/drivers/gpio/gpio-dln2.c +++ b/drivers/gpio/gpio-dln2.c @@ -377,7 +377,7 @@ static void dln2_irq_bus_unlock(struct irq_data *irqd) ret = dln2_gpio_set_event_cfg(dln2, pin, type, 0); if (ret) - dev_err(dln2->gpio.dev, "failed to set event\n"); + dev_err(dln2->gpio.parent, "failed to set event\n"); } mutex_unlock(&dln2->irq_lock); @@ -406,19 +406,19 @@ static void dln2_gpio_event(struct platform_device *pdev, u16 echo, struct dln2_gpio *dln2 = platform_get_drvdata(pdev); if (len < sizeof(*event)) { - dev_err(dln2->gpio.dev, "short event message\n"); + dev_err(dln2->gpio.parent, "short event message\n"); return; } pin = le16_to_cpu(event->pin); if (pin >= dln2->gpio.ngpio) { - dev_err(dln2->gpio.dev, "out of bounds pin %d\n", pin); + dev_err(dln2->gpio.parent, "out of bounds pin %d\n", pin); return; } irq = irq_find_mapping(dln2->gpio.irqdomain, pin); if (!irq) { - dev_err(dln2->gpio.dev, "pin %d not mapped to IRQ\n", pin); + dev_err(dln2->gpio.parent, "pin %d not mapped to IRQ\n", pin); return; } @@ -462,7 +462,7 @@ static int dln2_gpio_probe(struct platform_device *pdev) dln2->pdev = pdev; dln2->gpio.label = "dln2"; - dln2->gpio.dev = dev; + dln2->gpio.parent = dev; dln2->gpio.owner = THIS_MODULE; dln2->gpio.base = -1; dln2->gpio.ngpio = pins; diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c index 6bca1e125e12..c3ca2b1c1dfe 100644 --- a/drivers/gpio/gpio-em.c +++ b/drivers/gpio/gpio-em.c @@ -103,7 +103,7 @@ static int em_gio_irq_reqres(struct irq_data *d) struct em_gio_priv *p = irq_data_get_irq_chip_data(d); if (gpiochip_lock_as_irq(&p->gpio_chip, irqd_to_hwirq(d))) { - dev_err(p->gpio_chip.dev, + dev_err(p->gpio_chip.parent, "unable to lock HW IRQ %lu for IRQ\n", irqd_to_hwirq(d)); return -EINVAL; @@ -332,7 +332,7 @@ static int em_gio_probe(struct platform_device *pdev) gpio_chip->request = em_gio_request; gpio_chip->free = em_gio_free; gpio_chip->label = name; - gpio_chip->dev = &pdev->dev; + gpio_chip->parent = &pdev->dev; gpio_chip->owner = THIS_MODULE; gpio_chip->base = -1; gpio_chip->ngpio = ngpios; diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio-f7188x.c index 5e3c4fa67d82..1734e4fbd2b5 100644 --- a/drivers/gpio/gpio-f7188x.c +++ b/drivers/gpio/gpio-f7188x.c @@ -333,7 +333,7 @@ static int f7188x_gpio_probe(struct platform_device *pdev) for (i = 0; i < data->nr_bank; i++) { struct f7188x_gpio_bank *bank = &data->bank[i]; - bank->chip.dev = &pdev->dev; + bank->chip.parent = &pdev->dev; bank->data = data; err = gpiochip_add(&bank->chip); diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c index bd5193c67a9c..72088028d7a9 100644 --- a/drivers/gpio/gpio-generic.c +++ b/drivers/gpio/gpio-generic.c @@ -545,7 +545,7 @@ int bgpio_init(struct bgpio_chip *bgc, struct device *dev, return -EINVAL; spin_lock_init(&bgc->lock); - bgc->gc.dev = dev; + bgc->gc.parent = dev; bgc->gc.label = dev_name(dev); bgc->gc.base = -1; bgc->gc.ngpio = bgc->bits; diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c index 4ba7ed502131..8623d12e23c1 100644 --- a/drivers/gpio/gpio-ich.c +++ b/drivers/gpio/gpio-ich.c @@ -282,7 +282,7 @@ static void ichx_gpiolib_setup(struct gpio_chip *chip) { chip->owner = THIS_MODULE; chip->label = DRV_NAME; - chip->dev = &ichx_priv.dev->dev; + chip->parent = &ichx_priv.dev->dev; /* Allow chip-specific overrides of request()/get() */ chip->request = ichx_priv.desc->request ? diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c index 70097472b02c..1c46a7ef2680 100644 --- a/drivers/gpio/gpio-intel-mid.c +++ b/drivers/gpio/gpio-intel-mid.c @@ -392,7 +392,7 @@ static int intel_gpio_probe(struct pci_dev *pdev, priv->reg_base = pcim_iomap_table(pdev)[0]; priv->chip.label = dev_name(&pdev->dev); - priv->chip.dev = &pdev->dev; + priv->chip.parent = &pdev->dev; priv->chip.request = intel_gpio_request; priv->chip.direction_input = intel_gpio_direction_input; priv->chip.direction_output = intel_gpio_direction_output; diff --git a/drivers/gpio/gpio-janz-ttl.c b/drivers/gpio/gpio-janz-ttl.c index 3a1664335f5e..e5f85cab0100 100644 --- a/drivers/gpio/gpio-janz-ttl.c +++ b/drivers/gpio/gpio-janz-ttl.c @@ -59,7 +59,7 @@ struct ttl_module { static int ttl_get_value(struct gpio_chip *gpio, unsigned offset) { - struct ttl_module *mod = dev_get_drvdata(gpio->dev); + struct ttl_module *mod = dev_get_drvdata(gpio->parent); u8 *shadow; int ret; @@ -81,7 +81,7 @@ static int ttl_get_value(struct gpio_chip *gpio, unsigned offset) static void ttl_set_value(struct gpio_chip *gpio, unsigned offset, int value) { - struct ttl_module *mod = dev_get_drvdata(gpio->dev); + struct ttl_module *mod = dev_get_drvdata(gpio->parent); void __iomem *port; u8 *shadow; @@ -172,7 +172,7 @@ static int ttl_probe(struct platform_device *pdev) /* Initialize the GPIO data structures */ gpio = &mod->gpio; - gpio->dev = &pdev->dev; + gpio->parent = &pdev->dev; gpio->label = pdev->name; gpio->get = ttl_get_value; gpio->set = ttl_set_value; diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c index 83f281dda1e0..35dd1e0af364 100644 --- a/drivers/gpio/gpio-kempld.c +++ b/drivers/gpio/gpio-kempld.c @@ -166,7 +166,7 @@ static int kempld_gpio_probe(struct platform_device *pdev) chip = &gpio->chip; chip->label = "gpio-kempld"; chip->owner = THIS_MODULE; - chip->dev = dev; + chip->parent = dev; chip->can_sleep = true; if (pdata && pdata->gpio_base) chip->base = pdata->gpio_base; diff --git a/drivers/gpio/gpio-lp3943.c b/drivers/gpio/gpio-lp3943.c index cfc5b12b43ad..f979c3be217f 100644 --- a/drivers/gpio/gpio-lp3943.c +++ b/drivers/gpio/gpio-lp3943.c @@ -205,7 +205,7 @@ static int lp3943_gpio_probe(struct platform_device *pdev) lp3943_gpio->lp3943 = lp3943; lp3943_gpio->chip = lp3943_gpio_chip; - lp3943_gpio->chip.dev = &pdev->dev; + lp3943_gpio->chip.parent = &pdev->dev; platform_set_drvdata(pdev, lp3943_gpio); diff --git a/drivers/gpio/gpio-lpc18xx.c b/drivers/gpio/gpio-lpc18xx.c index e39dcb0af8ae..b01fbc9db7cd 100644 --- a/drivers/gpio/gpio-lpc18xx.c +++ b/drivers/gpio/gpio-lpc18xx.c @@ -127,7 +127,7 @@ static int lpc18xx_gpio_probe(struct platform_device *pdev) spin_lock_init(&gc->lock); - gc->gpio.dev = &pdev->dev; + gc->gpio.parent = &pdev->dev; ret = gpiochip_add(&gc->gpio); if (ret) { diff --git a/drivers/gpio/gpio-lynxpoint.c b/drivers/gpio/gpio-lynxpoint.c index 127c37b380ae..6a48ffd6e0db 100644 --- a/drivers/gpio/gpio-lynxpoint.c +++ b/drivers/gpio/gpio-lynxpoint.c @@ -368,7 +368,7 @@ static int lp_gpio_probe(struct platform_device *pdev) gc->base = -1; gc->ngpio = LP_NUM_GPIO; gc->can_sleep = false; - gc->dev = dev; + gc->parent = dev; ret = gpiochip_add(gc); if (ret) { diff --git a/drivers/gpio/gpio-max730x.c b/drivers/gpio/gpio-max730x.c index 0f57d2d248ec..5d6a723cb414 100644 --- a/drivers/gpio/gpio-max730x.c +++ b/drivers/gpio/gpio-max730x.c @@ -189,7 +189,7 @@ int __max730x_probe(struct max7301 *ts) ts->chip.ngpio = PIN_NUMBER; ts->chip.can_sleep = true; - ts->chip.dev = dev; + ts->chip.parent = dev; ts->chip.owner = THIS_MODULE; /* diff --git a/drivers/gpio/gpio-max732x.c b/drivers/gpio/gpio-max732x.c index 8c5252c6c327..c1e7b55644b0 100644 --- a/drivers/gpio/gpio-max732x.c +++ b/drivers/gpio/gpio-max732x.c @@ -603,7 +603,7 @@ static int max732x_setup_gpio(struct max732x_chip *chip, gc->base = gpio_start; gc->ngpio = port; gc->label = chip->client->name; - gc->dev = &chip->client->dev; + gc->parent = &chip->client->dev; gc->owner = THIS_MODULE; return port; @@ -649,7 +649,7 @@ static int max732x_probe(struct i2c_client *client, chip->client = client; nr_port = max732x_setup_gpio(chip, id, pdata->gpio_base); - chip->gpio_chip.dev = &client->dev; + chip->gpio_chip.parent = &client->dev; addr_a = (client->addr & 0x0f) | 0x60; addr_b = (client->addr & 0x0f) | 0x50; diff --git a/drivers/gpio/gpio-mb86s7x.c b/drivers/gpio/gpio-mb86s7x.c index ee93c0ab0a59..93d61a5be0d4 100644 --- a/drivers/gpio/gpio-mb86s7x.c +++ b/drivers/gpio/gpio-mb86s7x.c @@ -187,7 +187,7 @@ static int mb86s70_gpio_probe(struct platform_device *pdev) gchip->gc.label = dev_name(&pdev->dev); gchip->gc.ngpio = 32; gchip->gc.owner = THIS_MODULE; - gchip->gc.dev = &pdev->dev; + gchip->gc.parent = &pdev->dev; gchip->gc.base = -1; platform_set_drvdata(pdev, gchip); diff --git a/drivers/gpio/gpio-mc33880.c b/drivers/gpio/gpio-mc33880.c index 2853731db5bc..b46b9e522e8c 100644 --- a/drivers/gpio/gpio-mc33880.c +++ b/drivers/gpio/gpio-mc33880.c @@ -116,7 +116,7 @@ static int mc33880_probe(struct spi_device *spi) mc->chip.base = pdata->base; mc->chip.ngpio = PIN_NUMBER; mc->chip.can_sleep = true; - mc->chip.dev = &spi->dev; + mc->chip.parent = &spi->dev; mc->chip.owner = THIS_MODULE; mc->port_config = 0x00; diff --git a/drivers/gpio/gpio-mc9s08dz60.c b/drivers/gpio/gpio-mc9s08dz60.c index d62b4f8182bf..defa38f958fb 100644 --- a/drivers/gpio/gpio-mc9s08dz60.c +++ b/drivers/gpio/gpio-mc9s08dz60.c @@ -99,7 +99,7 @@ static int mc9s08dz60_probe(struct i2c_client *client, mc9s->chip.label = client->name; mc9s->chip.base = -1; - mc9s->chip.dev = &client->dev; + mc9s->chip.parent = &client->dev; mc9s->chip.owner = THIS_MODULE; mc9s->chip.ngpio = GPIO_NUM; mc9s->chip.can_sleep = true; diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c index 4a41694919da..13cace0ca6f7 100644 --- a/drivers/gpio/gpio-mcp23s08.c +++ b/drivers/gpio/gpio-mcp23s08.c @@ -446,7 +446,7 @@ static int mcp23s08_irq_reqres(struct irq_data *data) struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data); if (gpiochip_lock_as_irq(&mcp->chip, data->hwirq)) { - dev_err(mcp->chip.dev, + dev_err(mcp->chip.parent, "unable to lock HW IRQ %lu for IRQ usage\n", data->hwirq); return -EINVAL; @@ -481,7 +481,8 @@ static int mcp23s08_irq_setup(struct mcp23s08 *mcp) mutex_init(&mcp->irq_lock); - mcp->irq_domain = irq_domain_add_linear(chip->dev->of_node, chip->ngpio, + mcp->irq_domain = irq_domain_add_linear(chip->parent->of_node, + chip->ngpio, &irq_domain_simple_ops, mcp); if (!mcp->irq_domain) return -ENODEV; @@ -491,10 +492,11 @@ static int mcp23s08_irq_setup(struct mcp23s08 *mcp) else irqflags |= IRQF_TRIGGER_LOW; - err = devm_request_threaded_irq(chip->dev, mcp->irq, NULL, mcp23s08_irq, - irqflags, dev_name(chip->dev), mcp); + err = devm_request_threaded_irq(chip->parent, mcp->irq, NULL, + mcp23s08_irq, + irqflags, dev_name(chip->parent), mcp); if (err != 0) { - dev_err(chip->dev, "unable to request IRQ#%d: %d\n", + dev_err(chip->parent, "unable to request IRQ#%d: %d\n", mcp->irq, err); return err; } @@ -638,7 +640,7 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, mcp->chip.base = pdata->base; mcp->chip.can_sleep = true; - mcp->chip.dev = dev; + mcp->chip.parent = dev; mcp->chip.owner = THIS_MODULE; /* verify MCP_IOCON.SEQOP = 0, so sequential reads work, @@ -652,7 +654,7 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, mcp->irq_controller = pdata->irq_controller; if (mcp->irq && mcp->irq_controller) { mcp->irq_active_high = - of_property_read_bool(mcp->chip.dev->of_node, + of_property_read_bool(mcp->chip.parent->of_node, "microchip,irq-active-high"); if (type == MCP_TYPE_017) diff --git a/drivers/gpio/gpio-moxart.c b/drivers/gpio/gpio-moxart.c index d3355a6dc9b1..8942f4909a31 100644 --- a/drivers/gpio/gpio-moxart.c +++ b/drivers/gpio/gpio-moxart.c @@ -61,7 +61,7 @@ static int moxart_gpio_probe(struct platform_device *pdev) bgc->data = bgc->read_reg(bgc->reg_set); bgc->gc.base = 0; bgc->gc.ngpio = 32; - bgc->gc.dev = dev; + bgc->gc.parent = dev; bgc->gc.owner = THIS_MODULE; ret = gpiochip_add(&bgc->gc); diff --git a/drivers/gpio/gpio-msic.c b/drivers/gpio/gpio-msic.c index 22523aae8abe..fe9ef2bc981a 100644 --- a/drivers/gpio/gpio-msic.c +++ b/drivers/gpio/gpio-msic.c @@ -293,7 +293,7 @@ static int platform_msic_gpio_probe(struct platform_device *pdev) mg->chip.base = pdata->gpio_base; mg->chip.ngpio = MSIC_NUM_GPIO; mg->chip.can_sleep = true; - mg->chip.dev = dev; + mg->chip.parent = dev; mutex_init(&mg->buslock); diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index d428b97876c5..6acedf4e9b1c 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c @@ -698,7 +698,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev) mvchip->soc_variant = soc_variant; mvchip->chip.label = dev_name(&pdev->dev); - mvchip->chip.dev = &pdev->dev; + mvchip->chip.parent = &pdev->dev; mvchip->chip.request = gpiochip_generic_request; mvchip->chip.free = gpiochip_generic_free; mvchip->chip.direction_input = mvebu_gpio_direction_input; diff --git a/drivers/gpio/gpio-octeon.c b/drivers/gpio/gpio-octeon.c index 62ae251d4490..3c66ce4fe9ed 100644 --- a/drivers/gpio/gpio-octeon.c +++ b/drivers/gpio/gpio-octeon.c @@ -108,7 +108,7 @@ static int octeon_gpio_probe(struct platform_device *pdev) pdev->dev.platform_data = chip; chip->label = "octeon-gpio"; - chip->dev = &pdev->dev; + chip->parent = &pdev->dev; chip->owner = THIS_MODULE; chip->base = 0; chip->can_sleep = false; diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 56d2d026e62e..7e4f7c5f999a 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -1090,7 +1090,7 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) if (bank->is_mpuio) { bank->chip.label = "mpuio"; if (bank->regs->wkup_en) - bank->chip.dev = &omap_mpuio_device.dev; + bank->chip.parent = &omap_mpuio_device.dev; bank->chip.base = OMAP_MPUIO(0); } else { bank->chip.label = "gpio"; @@ -1199,7 +1199,7 @@ static int omap_gpio_probe(struct platform_device *pdev) } bank->dev = dev; - bank->chip.dev = dev; + bank->chip.parent = dev; bank->chip.owner = THIS_MODULE; bank->dbck_flag = pdata->dbck_flag; bank->stride = pdata->bank_stride; diff --git a/drivers/gpio/gpio-palmas.c b/drivers/gpio/gpio-palmas.c index 171a6389f9ce..5f09ed1700dc 100644 --- a/drivers/gpio/gpio-palmas.c +++ b/drivers/gpio/gpio-palmas.c @@ -54,7 +54,7 @@ static int palmas_gpio_get(struct gpio_chip *gc, unsigned offset) ret = palmas_read(palmas, PALMAS_GPIO_BASE, reg, &val); if (ret < 0) { - dev_err(gc->dev, "Reg 0x%02x read failed, %d\n", reg, ret); + dev_err(gc->parent, "Reg 0x%02x read failed, %d\n", reg, ret); return ret; } @@ -65,7 +65,7 @@ static int palmas_gpio_get(struct gpio_chip *gc, unsigned offset) ret = palmas_read(palmas, PALMAS_GPIO_BASE, reg, &val); if (ret < 0) { - dev_err(gc->dev, "Reg 0x%02x read failed, %d\n", reg, ret); + dev_err(gc->parent, "Reg 0x%02x read failed, %d\n", reg, ret); return ret; } return !!(val & BIT(offset)); @@ -90,7 +90,7 @@ static void palmas_gpio_set(struct gpio_chip *gc, unsigned offset, ret = palmas_write(palmas, PALMAS_GPIO_BASE, reg, BIT(offset)); if (ret < 0) - dev_err(gc->dev, "Reg 0x%02x write failed, %d\n", reg, ret); + dev_err(gc->parent, "Reg 0x%02x write failed, %d\n", reg, ret); } static int palmas_gpio_output(struct gpio_chip *gc, unsigned offset, @@ -111,7 +111,8 @@ static int palmas_gpio_output(struct gpio_chip *gc, unsigned offset, ret = palmas_update_bits(palmas, PALMAS_GPIO_BASE, reg, BIT(offset), BIT(offset)); if (ret < 0) - dev_err(gc->dev, "Reg 0x%02x update failed, %d\n", reg, ret); + dev_err(gc->parent, "Reg 0x%02x update failed, %d\n", reg, + ret); return ret; } @@ -128,7 +129,8 @@ static int palmas_gpio_input(struct gpio_chip *gc, unsigned offset) ret = palmas_update_bits(palmas, PALMAS_GPIO_BASE, reg, BIT(offset), 0); if (ret < 0) - dev_err(gc->dev, "Reg 0x%02x update failed, %d\n", reg, ret); + dev_err(gc->parent, "Reg 0x%02x update failed, %d\n", reg, + ret); return ret; } @@ -186,7 +188,7 @@ static int palmas_gpio_probe(struct platform_device *pdev) palmas_gpio->gpio_chip.to_irq = palmas_gpio_to_irq; palmas_gpio->gpio_chip.set = palmas_gpio_set; palmas_gpio->gpio_chip.get = palmas_gpio_get; - palmas_gpio->gpio_chip.dev = &pdev->dev; + palmas_gpio->gpio_chip.parent = &pdev->dev; #ifdef CONFIG_OF_GPIO palmas_gpio->gpio_chip.of_node = pdev->dev.of_node; #endif diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 2d4892cc70fb..ddbbbe57eef8 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -367,7 +367,7 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios) gc->base = chip->gpio_start; gc->ngpio = gpios; gc->label = chip->client->name; - gc->dev = &chip->client->dev; + gc->parent = &chip->client->dev; gc->owner = THIS_MODULE; gc->names = chip->names; } diff --git a/drivers/gpio/gpio-pcf857x.c b/drivers/gpio/gpio-pcf857x.c index 1d4d9bc8b69d..c7552106a80c 100644 --- a/drivers/gpio/gpio-pcf857x.c +++ b/drivers/gpio/gpio-pcf857x.c @@ -293,7 +293,7 @@ static int pcf857x_probe(struct i2c_client *client, gpio->chip.base = pdata ? pdata->gpio_base : -1; gpio->chip.can_sleep = true; - gpio->chip.dev = &client->dev; + gpio->chip.parent = &client->dev; gpio->chip.owner = THIS_MODULE; gpio->chip.get = pcf857x_get; gpio->chip.set = pcf857x_set; diff --git a/drivers/gpio/gpio-pch.c b/drivers/gpio/gpio-pch.c index 34ed176df15a..e43db64e52b3 100644 --- a/drivers/gpio/gpio-pch.c +++ b/drivers/gpio/gpio-pch.c @@ -220,7 +220,7 @@ static void pch_gpio_setup(struct pch_gpio *chip) struct gpio_chip *gpio = &chip->gpio; gpio->label = dev_name(chip->dev); - gpio->dev = chip->dev; + gpio->parent = chip->dev; gpio->owner = THIS_MODULE; gpio->direction_input = pch_gpio_direction_input; gpio->get = pch_gpio_get; diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index 4d4b37676702..e041639adc14 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c @@ -131,7 +131,7 @@ static int pl061_irq_type(struct irq_data *d, unsigned trigger) if ((trigger & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) && (trigger & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING))) { - dev_err(gc->dev, + dev_err(gc->parent, "trying to configure line %d for both level and edge " "detection, choose one!\n", offset); @@ -158,7 +158,7 @@ static int pl061_irq_type(struct irq_data *d, unsigned trigger) else gpioiev &= ~bit; irq_set_handler_locked(d, handle_level_irq); - dev_dbg(gc->dev, "line %d: IRQ on %s level\n", + dev_dbg(gc->parent, "line %d: IRQ on %s level\n", offset, polarity ? "HIGH" : "LOW"); } else if ((trigger & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) { @@ -167,7 +167,7 @@ static int pl061_irq_type(struct irq_data *d, unsigned trigger) /* Select both edges, setting this makes GPIOEV be ignored */ gpioibe |= bit; irq_set_handler_locked(d, handle_edge_irq); - dev_dbg(gc->dev, "line %d: IRQ on both edges\n", offset); + dev_dbg(gc->parent, "line %d: IRQ on both edges\n", offset); } else if ((trigger & IRQ_TYPE_EDGE_RISING) || (trigger & IRQ_TYPE_EDGE_FALLING)) { bool rising = trigger & IRQ_TYPE_EDGE_RISING; @@ -182,7 +182,7 @@ static int pl061_irq_type(struct irq_data *d, unsigned trigger) else gpioiev &= ~bit; irq_set_handler_locked(d, handle_edge_irq); - dev_dbg(gc->dev, "line %d: IRQ on %s edge\n", + dev_dbg(gc->parent, "line %d: IRQ on %s edge\n", offset, rising ? "RISING" : "FALLING"); } else { @@ -191,7 +191,7 @@ static int pl061_irq_type(struct irq_data *d, unsigned trigger) gpioibe &= ~bit; gpioiev &= ~bit; irq_set_handler_locked(d, handle_bad_irq); - dev_warn(gc->dev, "no trigger selected for line %d\n", + dev_warn(gc->parent, "no trigger selected for line %d\n", offset); } @@ -316,7 +316,7 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) chip->gc.set = pl061_set_value; chip->gc.ngpio = PL061_GPIO_NR; chip->gc.label = dev_name(dev); - chip->gc.dev = dev; + chip->gc.parent = dev; chip->gc.owner = THIS_MODULE; ret = gpiochip_add(&chip->gc); diff --git a/drivers/gpio/gpio-rc5t583.c b/drivers/gpio/gpio-rc5t583.c index 6eabf239676b..f26d9f7d8cdd 100644 --- a/drivers/gpio/gpio-rc5t583.c +++ b/drivers/gpio/gpio-rc5t583.c @@ -132,7 +132,7 @@ static int rc5t583_gpio_probe(struct platform_device *pdev) rc5t583_gpio->gpio_chip.to_irq = rc5t583_gpio_to_irq, rc5t583_gpio->gpio_chip.ngpio = RC5T583_MAX_GPIO, rc5t583_gpio->gpio_chip.can_sleep = true, - rc5t583_gpio->gpio_chip.dev = &pdev->dev; + rc5t583_gpio->gpio_chip.parent = &pdev->dev; rc5t583_gpio->gpio_chip.base = -1; rc5t583_gpio->rc5t583 = rc5t583; diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index 2a8122444614..3cbb25ecfc7a 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -449,7 +449,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) gpio_chip->direction_output = gpio_rcar_direction_output; gpio_chip->set = gpio_rcar_set; gpio_chip->label = name; - gpio_chip->dev = dev; + gpio_chip->parent = dev; gpio_chip->owner = THIS_MODULE; gpio_chip->base = p->config.gpio_base; gpio_chip->ngpio = p->config.number_of_pins; 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: diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c index 0cb11413e814..3841398d1078 100644 --- a/drivers/gpio/gpio-sch311x.c +++ b/drivers/gpio/gpio-sch311x.c @@ -149,7 +149,7 @@ static int sch311x_gpio_request(struct gpio_chip *chip, unsigned offset) if (!request_region(block->runtime_reg + block->config_regs[offset], 1, DRV_NAME)) { - dev_err(chip->dev, "Failed to request region 0x%04x.\n", + dev_err(chip->parent, "Failed to request region 0x%04x.\n", block->runtime_reg + block->config_regs[offset]); return -EBUSY; } @@ -261,7 +261,7 @@ static int sch311x_gpio_probe(struct platform_device *pdev) block->chip.get = sch311x_gpio_get; block->chip.set = sch311x_gpio_set; block->chip.ngpio = 8; - block->chip.dev = &pdev->dev; + block->chip.parent = &pdev->dev; block->chip.base = sch311x_gpio_blocks[i].base; block->config_regs = sch311x_gpio_blocks[i].config_regs; block->data_reg = sch311x_gpio_blocks[i].data_reg; diff --git a/drivers/gpio/gpio-spear-spics.c b/drivers/gpio/gpio-spear-spics.c index 69ffca5b073b..bd436b7f86e1 100644 --- a/drivers/gpio/gpio-spear-spics.c +++ b/drivers/gpio/gpio-spear-spics.c @@ -164,7 +164,7 @@ static int spics_gpio_probe(struct platform_device *pdev) spics->chip.get = spics_get_value; spics->chip.set = spics_set_value; spics->chip.label = dev_name(&pdev->dev); - spics->chip.dev = &pdev->dev; + spics->chip.parent = &pdev->dev; spics->chip.owner = THIS_MODULE; spics->last_off = -1; diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c index dabfb99dddef..9e471979aa9e 100644 --- a/drivers/gpio/gpio-stmpe.c +++ b/drivers/gpio/gpio-stmpe.c @@ -356,7 +356,7 @@ static int stmpe_gpio_probe(struct platform_device *pdev) stmpe_gpio->stmpe = stmpe; stmpe_gpio->chip = template_chip; stmpe_gpio->chip.ngpio = stmpe->num_gpios; - stmpe_gpio->chip.dev = &pdev->dev; + stmpe_gpio->chip.parent = &pdev->dev; stmpe_gpio->chip.of_node = np; stmpe_gpio->chip.base = -1; diff --git a/drivers/gpio/gpio-stp-xway.c b/drivers/gpio/gpio-stp-xway.c index 81bdbe7ba2a4..c250f21b9e40 100644 --- a/drivers/gpio/gpio-stp-xway.c +++ b/drivers/gpio/gpio-stp-xway.c @@ -139,7 +139,7 @@ static int xway_stp_request(struct gpio_chip *gc, unsigned gpio) container_of(gc, struct xway_stp, gc); if ((gpio < 8) && (chip->reserved & BIT(gpio))) { - dev_err(gc->dev, "GPIO %d is driven by hardware\n", gpio); + dev_err(gc->parent, "GPIO %d is driven by hardware\n", gpio); return -ENODEV; } @@ -214,7 +214,7 @@ static int xway_stp_probe(struct platform_device *pdev) if (IS_ERR(chip->virt)) return PTR_ERR(chip->virt); - chip->gc.dev = &pdev->dev; + chip->gc.parent = &pdev->dev; chip->gc.label = "stp-xway"; chip->gc.direction_output = xway_stp_dir_out; chip->gc.set = xway_stp_set; diff --git a/drivers/gpio/gpio-sx150x.c b/drivers/gpio/gpio-sx150x.c index 76f920173a2f..c0145159a127 100644 --- a/drivers/gpio/gpio-sx150x.c +++ b/drivers/gpio/gpio-sx150x.c @@ -473,7 +473,7 @@ static void sx150x_init_chip(struct sx150x_chip *chip, chip->client = client; chip->dev_cfg = &sx150x_devices[driver_data]; - chip->gpio_chip.dev = &client->dev; + chip->gpio_chip.parent = &client->dev; chip->gpio_chip.label = client->name; chip->gpio_chip.direction_input = sx150x_gpio_direction_input; chip->gpio_chip.direction_output = sx150x_gpio_direction_output; diff --git a/drivers/gpio/gpio-syscon.c b/drivers/gpio/gpio-syscon.c index 045a952576c7..cd6afee11f84 100644 --- a/drivers/gpio/gpio-syscon.c +++ b/drivers/gpio/gpio-syscon.c @@ -159,7 +159,7 @@ static void keystone_gpio_set(struct gpio_chip *chip, unsigned offset, int val) BIT(offs % SYSCON_REG_BITS) | KEYSTONE_LOCK_BIT, BIT(offs % SYSCON_REG_BITS) | KEYSTONE_LOCK_BIT); if (ret < 0) - dev_err(chip->dev, "gpio write failed ret(%d)\n", ret); + dev_err(chip->parent, "gpio write failed ret(%d)\n", ret); } static const struct syscon_gpio_data keystone_dsp_gpio = { @@ -224,7 +224,7 @@ static int syscon_gpio_probe(struct platform_device *pdev) priv->dir_reg_offset <<= 3; } - priv->chip.dev = dev; + priv->chip.parent = dev; priv->chip.owner = THIS_MODULE; priv->chip.label = dev_name(dev); priv->chip.base = -1; diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c index 4356e6c20fc5..1a7c3efae5d8 100644 --- a/drivers/gpio/gpio-tb10x.c +++ b/drivers/gpio/gpio-tb10x.c @@ -197,7 +197,7 @@ static int tb10x_gpio_probe(struct platform_device *pdev) return PTR_ERR(tb10x_gpio->base); tb10x_gpio->gc.label = of_node_full_name(dn); - tb10x_gpio->gc.dev = &pdev->dev; + tb10x_gpio->gc.parent = &pdev->dev; tb10x_gpio->gc.owner = THIS_MODULE; tb10x_gpio->gc.direction_input = tb10x_gpio_direction_in; tb10x_gpio->gc.get = tb10x_gpio_get; diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c index d1d585ddb9ab..7c1537ed6dff 100644 --- a/drivers/gpio/gpio-tc3589x.c +++ b/drivers/gpio/gpio-tc3589x.c @@ -258,7 +258,7 @@ static int tc3589x_gpio_probe(struct platform_device *pdev) tc3589x_gpio->chip = template_chip; tc3589x_gpio->chip.ngpio = tc3589x->num_gpio; - tc3589x_gpio->chip.dev = &pdev->dev; + tc3589x_gpio->chip.parent = &pdev->dev; tc3589x_gpio->chip.base = -1; tc3589x_gpio->chip.of_node = np; diff --git a/drivers/gpio/gpio-timberdale.c b/drivers/gpio/gpio-timberdale.c index 30653e6319e9..dda8f21811eb 100644 --- a/drivers/gpio/gpio-timberdale.c +++ b/drivers/gpio/gpio-timberdale.c @@ -268,7 +268,7 @@ static int timbgpio_probe(struct platform_device *pdev) gc->label = dev_name(&pdev->dev); gc->owner = THIS_MODULE; - gc->dev = &pdev->dev; + gc->parent = &pdev->dev; gc->direction_input = timbgpio_gpio_direction_input; gc->get = timbgpio_gpio_get; gc->direction_output = timbgpio_gpio_direction_output; diff --git a/drivers/gpio/gpio-tps6586x.c b/drivers/gpio/gpio-tps6586x.c index 9c9238e838a9..89b2249100b0 100644 --- a/drivers/gpio/gpio-tps6586x.c +++ b/drivers/gpio/gpio-tps6586x.c @@ -104,7 +104,7 @@ static int tps6586x_gpio_probe(struct platform_device *pdev) tps6586x_gpio->gpio_chip.owner = THIS_MODULE; tps6586x_gpio->gpio_chip.label = pdev->name; - tps6586x_gpio->gpio_chip.dev = &pdev->dev; + tps6586x_gpio->gpio_chip.parent = &pdev->dev; tps6586x_gpio->gpio_chip.ngpio = 4; tps6586x_gpio->gpio_chip.can_sleep = true; diff --git a/drivers/gpio/gpio-tps65910.c b/drivers/gpio/gpio-tps65910.c index 88f1f5ff4e96..83894c0387fb 100644 --- a/drivers/gpio/gpio-tps65910.c +++ b/drivers/gpio/gpio-tps65910.c @@ -146,7 +146,7 @@ static int tps65910_gpio_probe(struct platform_device *pdev) tps65910_gpio->gpio_chip.direction_output = tps65910_gpio_output; tps65910_gpio->gpio_chip.set = tps65910_gpio_set; tps65910_gpio->gpio_chip.get = tps65910_gpio_get; - tps65910_gpio->gpio_chip.dev = &pdev->dev; + tps65910_gpio->gpio_chip.parent = &pdev->dev; #ifdef CONFIG_OF_GPIO tps65910_gpio->gpio_chip.of_node = tps65910->dev->of_node; #endif diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c index 9cdbc0c9cb2d..0f073ffa74cf 100644 --- a/drivers/gpio/gpio-tps65912.c +++ b/drivers/gpio/gpio-tps65912.c @@ -104,7 +104,7 @@ static int tps65912_gpio_probe(struct platform_device *pdev) tps65912_gpio->tps65912 = tps65912; tps65912_gpio->gpio_chip = template_chip; - tps65912_gpio->gpio_chip.dev = &pdev->dev; + tps65912_gpio->gpio_chip.parent = &pdev->dev; if (pdata && pdata->gpio_base) tps65912_gpio->gpio_chip.base = pdata->gpio_base; diff --git a/drivers/gpio/gpio-ts5500.c b/drivers/gpio/gpio-ts5500.c index b29a102d136b..aafe7910e030 100644 --- a/drivers/gpio/gpio-ts5500.c +++ b/drivers/gpio/gpio-ts5500.c @@ -315,7 +315,8 @@ static void ts5500_disable_irq(struct ts5500_priv *priv) else if (priv->hwirq == 1) ts5500_clear_mask(BIT(6), 0x7d); /* LCD_RS on IRQ1 */ else - dev_err(priv->gpio_chip.dev, "invalid hwirq %d\n", priv->hwirq); + dev_err(priv->gpio_chip.parent, "invalid hwirq %d\n", + priv->hwirq); spin_unlock_irqrestore(&priv->lock, flags); } @@ -346,7 +347,7 @@ static int ts5500_dio_probe(struct platform_device *pdev) priv->gpio_chip.owner = THIS_MODULE; priv->gpio_chip.label = name; - priv->gpio_chip.dev = dev; + priv->gpio_chip.parent = dev; priv->gpio_chip.direction_input = ts5500_gpio_input; priv->gpio_chip.direction_output = ts5500_gpio_output; priv->gpio_chip.get = ts5500_gpio_get; diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c index 9e1dbb9877c1..14f40bf64e34 100644 --- a/drivers/gpio/gpio-twl4030.c +++ b/drivers/gpio/gpio-twl4030.c @@ -256,7 +256,7 @@ static int twl_request(struct gpio_chip *chip, unsigned offset) /* optionally have the first two GPIOs switch vMMC1 * and vMMC2 power supplies based on card presence. */ - pdata = dev_get_platdata(chip->dev); + pdata = dev_get_platdata(chip->parent); if (pdata) value |= pdata->mmc_cd & 0x03; @@ -509,7 +509,7 @@ no_irqs: priv->gpio_chip = template_chip; priv->gpio_chip.base = -1; priv->gpio_chip.ngpio = TWL4030_GPIO_MAX; - priv->gpio_chip.dev = &pdev->dev; + priv->gpio_chip.parent = &pdev->dev; mutex_init(&priv->mutex); diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c index c946e7eef3ee..2da7c5f70034 100644 --- a/drivers/gpio/gpio-twl6040.c +++ b/drivers/gpio/gpio-twl6040.c @@ -36,7 +36,7 @@ static struct gpio_chip twl6040gpo_chip; static int twl6040gpo_get(struct gpio_chip *chip, unsigned offset) { - struct twl6040 *twl6040 = dev_get_drvdata(chip->dev->parent); + struct twl6040 *twl6040 = dev_get_drvdata(chip->parent->parent); int ret = 0; ret = twl6040_reg_read(twl6040, TWL6040_REG_GPOCTL); @@ -55,7 +55,7 @@ static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset, static void twl6040gpo_set(struct gpio_chip *chip, unsigned offset, int value) { - struct twl6040 *twl6040 = dev_get_drvdata(chip->dev->parent); + struct twl6040 *twl6040 = dev_get_drvdata(chip->parent->parent); int ret; u8 gpoctl; @@ -95,7 +95,7 @@ static int gpo_twl6040_probe(struct platform_device *pdev) else twl6040gpo_chip.ngpio = 1; /* twl6041 have 1 GPO */ - twl6040gpo_chip.dev = &pdev->dev; + twl6040gpo_chip.parent = &pdev->dev; #ifdef CONFIG_OF_GPIO twl6040gpo_chip.of_node = twl6040_core_dev->of_node; #endif diff --git a/drivers/gpio/gpio-tz1090-pdc.c b/drivers/gpio/gpio-tz1090-pdc.c index 3623d009d808..a974397164b2 100644 --- a/drivers/gpio/gpio-tz1090-pdc.c +++ b/drivers/gpio/gpio-tz1090-pdc.c @@ -188,7 +188,7 @@ static int tz1090_pdc_gpio_probe(struct platform_device *pdev) /* Set up GPIO chip */ priv->chip.label = "tz1090-pdc-gpio"; - priv->chip.dev = &pdev->dev; + priv->chip.parent = &pdev->dev; priv->chip.direction_input = tz1090_pdc_gpio_direction_input; priv->chip.direction_output = tz1090_pdc_gpio_direction_output; priv->chip.get = tz1090_pdc_gpio_get; diff --git a/drivers/gpio/gpio-tz1090.c b/drivers/gpio/gpio-tz1090.c index 87bb1b1eee8d..7858d90202f3 100644 --- a/drivers/gpio/gpio-tz1090.c +++ b/drivers/gpio/gpio-tz1090.c @@ -425,7 +425,7 @@ static int tz1090_gpio_bank_probe(struct tz1090_gpio_bank_info *info) snprintf(bank->label, sizeof(bank->label), "tz1090-gpio-%u", info->index); bank->chip.label = bank->label; - bank->chip.dev = dev; + bank->chip.parent = dev; bank->chip.direction_input = tz1090_gpio_direction_input; bank->chip.direction_output = tz1090_gpio_direction_output; bank->chip.get = tz1090_gpio_get; diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c index 87b950cec6ec..9031e60c815c 100644 --- a/drivers/gpio/gpio-vf610.c +++ b/drivers/gpio/gpio-vf610.c @@ -249,7 +249,7 @@ static int vf610_gpio_probe(struct platform_device *pdev) gc = &port->gc; gc->of_node = np; - gc->dev = dev; + gc->parent = dev; gc->label = "vf610-gpio"; gc->ngpio = VF610_GPIO_PER_PORT; gc->base = of_alias_get_id(np, "gpio") * VF610_GPIO_PER_PORT; diff --git a/drivers/gpio/gpio-viperboard.c b/drivers/gpio/gpio-viperboard.c index e2a11f27807f..26e7edb74f42 100644 --- a/drivers/gpio/gpio-viperboard.c +++ b/drivers/gpio/gpio-viperboard.c @@ -173,7 +173,7 @@ static void vprbrd_gpioa_set(struct gpio_chip *chip, mutex_unlock(&vb->lock); if (ret != sizeof(struct vprbrd_gpioa_msg)) - dev_err(chip->dev, "usb error setting pin value\n"); + dev_err(chip->parent, "usb error setting pin value\n"); } } @@ -345,7 +345,7 @@ static void vprbrd_gpiob_set(struct gpio_chip *chip, mutex_unlock(&vb->lock); if (ret != sizeof(struct vprbrd_gpiob_msg)) - dev_err(chip->dev, "usb error setting pin value\n"); + dev_err(chip->parent, "usb error setting pin value\n"); } } @@ -366,7 +366,7 @@ static int vprbrd_gpiob_direction_input(struct gpio_chip *chip, mutex_unlock(&vb->lock); if (ret) - dev_err(chip->dev, "usb error setting pin to input\n"); + dev_err(chip->parent, "usb error setting pin to input\n"); return ret; } @@ -385,7 +385,7 @@ static int vprbrd_gpiob_direction_output(struct gpio_chip *chip, ret = vprbrd_gpiob_setdir(vb, offset, 1); if (ret) - dev_err(chip->dev, "usb error setting pin to output\n"); + dev_err(chip->parent, "usb error setting pin to output\n"); mutex_unlock(&vb->lock); @@ -409,7 +409,7 @@ static int vprbrd_gpio_probe(struct platform_device *pdev) vb_gpio->vb = vb; /* registering gpio a */ vb_gpio->gpioa.label = "viperboard gpio a"; - vb_gpio->gpioa.dev = &pdev->dev; + vb_gpio->gpioa.parent = &pdev->dev; vb_gpio->gpioa.owner = THIS_MODULE; vb_gpio->gpioa.base = -1; vb_gpio->gpioa.ngpio = 16; @@ -420,13 +420,13 @@ static int vprbrd_gpio_probe(struct platform_device *pdev) vb_gpio->gpioa.direction_output = vprbrd_gpioa_direction_output; ret = gpiochip_add(&vb_gpio->gpioa); if (ret < 0) { - dev_err(vb_gpio->gpioa.dev, "could not add gpio a"); + dev_err(vb_gpio->gpioa.parent, "could not add gpio a"); goto err_gpioa; } /* registering gpio b */ vb_gpio->gpiob.label = "viperboard gpio b"; - vb_gpio->gpiob.dev = &pdev->dev; + vb_gpio->gpiob.parent = &pdev->dev; vb_gpio->gpiob.owner = THIS_MODULE; vb_gpio->gpiob.base = -1; vb_gpio->gpiob.ngpio = 16; @@ -437,7 +437,7 @@ static int vprbrd_gpio_probe(struct platform_device *pdev) vb_gpio->gpiob.direction_output = vprbrd_gpiob_direction_output; ret = gpiochip_add(&vb_gpio->gpiob); if (ret < 0) { - dev_err(vb_gpio->gpiob.dev, "could not add gpio b"); + dev_err(vb_gpio->gpiob.parent, "could not add gpio b"); goto err_gpiob; } diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c index c1caa459c02d..1947531b7cf5 100644 --- a/drivers/gpio/gpio-vr41xx.c +++ b/drivers/gpio/gpio-vr41xx.c @@ -139,7 +139,7 @@ static void unmask_giuint_low(struct irq_data *d) static unsigned int startup_giuint(struct irq_data *data) { if (gpiochip_lock_as_irq(&vr41xx_gpio_chip, data->hwirq)) - dev_err(vr41xx_gpio_chip.dev, + dev_err(vr41xx_gpio_chip.parent, "unable to lock HW IRQ %lu for IRQ\n", data->hwirq); /* Satisfy the .enable semantics by unmasking the line */ @@ -542,7 +542,7 @@ static int giu_probe(struct platform_device *pdev) if (!giu_base) return -ENOMEM; - vr41xx_gpio_chip.dev = &pdev->dev; + vr41xx_gpio_chip.parent = &pdev->dev; ret = gpiochip_add(&vr41xx_gpio_chip); if (!ret) { diff --git a/drivers/gpio/gpio-wm831x.c b/drivers/gpio/gpio-wm831x.c index 58ce75c188b7..2e73e4b52c69 100644 --- a/drivers/gpio/gpio-wm831x.c +++ b/drivers/gpio/gpio-wm831x.c @@ -258,7 +258,7 @@ static int wm831x_gpio_probe(struct platform_device *pdev) wm831x_gpio->wm831x = wm831x; wm831x_gpio->gpio_chip = template_chip; wm831x_gpio->gpio_chip.ngpio = wm831x->num_gpio; - wm831x_gpio->gpio_chip.dev = &pdev->dev; + wm831x_gpio->gpio_chip.parent = &pdev->dev; if (pdata && pdata->gpio_base) wm831x_gpio->gpio_chip.base = pdata->gpio_base; else diff --git a/drivers/gpio/gpio-wm8350.c b/drivers/gpio/gpio-wm8350.c index 060b89303bb6..1e3d8da61ff3 100644 --- a/drivers/gpio/gpio-wm8350.c +++ b/drivers/gpio/gpio-wm8350.c @@ -124,7 +124,7 @@ static int wm8350_gpio_probe(struct platform_device *pdev) wm8350_gpio->wm8350 = wm8350; wm8350_gpio->gpio_chip = template_chip; wm8350_gpio->gpio_chip.ngpio = 13; - wm8350_gpio->gpio_chip.dev = &pdev->dev; + wm8350_gpio->gpio_chip.parent = &pdev->dev; if (pdata && pdata->gpio_base) wm8350_gpio->gpio_chip.base = pdata->gpio_base; else diff --git a/drivers/gpio/gpio-wm8994.c b/drivers/gpio/gpio-wm8994.c index 6f5e42db4b9e..de73c80163c1 100644 --- a/drivers/gpio/gpio-wm8994.c +++ b/drivers/gpio/gpio-wm8994.c @@ -260,7 +260,7 @@ static int wm8994_gpio_probe(struct platform_device *pdev) wm8994_gpio->wm8994 = wm8994; wm8994_gpio->gpio_chip = template_chip; wm8994_gpio->gpio_chip.ngpio = WM8994_GPIO_MAX; - wm8994_gpio->gpio_chip.dev = &pdev->dev; + wm8994_gpio->gpio_chip.parent = &pdev->dev; if (pdata && pdata->gpio_base) wm8994_gpio->gpio_chip.base = pdata->gpio_base; else diff --git a/drivers/gpio/gpio-xgene.c b/drivers/gpio/gpio-xgene.c index 18a8182d4fec..b8ceb71885f6 100644 --- a/drivers/gpio/gpio-xgene.c +++ b/drivers/gpio/gpio-xgene.c @@ -188,7 +188,7 @@ static int xgene_gpio_probe(struct platform_device *pdev) gpio->chip.ngpio = XGENE_MAX_GPIOS; spin_lock_init(&gpio->lock); - gpio->chip.dev = &pdev->dev; + gpio->chip.parent = &pdev->dev; gpio->chip.direction_input = xgene_gpio_dir_in; gpio->chip.direction_output = xgene_gpio_dir_out; gpio->chip.get = xgene_gpio_get; diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index d5284dfe01fe..5c2971e1cb08 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -305,7 +305,7 @@ static int xgpio_probe(struct platform_device *pdev) } chip->mmchip.gc.ngpio = chip->gpio_width[0] + chip->gpio_width[1]; - chip->mmchip.gc.dev = &pdev->dev; + chip->mmchip.gc.parent = &pdev->dev; chip->mmchip.gc.direction_input = xgpio_dir_in; chip->mmchip.gc.direction_output = xgpio_dir_out; chip->mmchip.gc.get = xgpio_get; diff --git a/drivers/gpio/gpio-xlp.c b/drivers/gpio/gpio-xlp.c index bc06a2cd2c1d..3f31aac2ba3c 100644 --- a/drivers/gpio/gpio-xlp.c +++ b/drivers/gpio/gpio-xlp.c @@ -373,7 +373,7 @@ static int xlp_gpio_probe(struct platform_device *pdev) gc->owner = THIS_MODULE; gc->label = dev_name(&pdev->dev); gc->base = 0; - gc->dev = &pdev->dev; + gc->parent = &pdev->dev; gc->ngpio = ngpio; gc->of_node = pdev->dev.of_node; gc->direction_output = xlp_gpio_dir_output; diff --git a/drivers/gpio/gpio-zevio.c b/drivers/gpio/gpio-zevio.c index 6f02d7c4cc57..65b61dcc6268 100644 --- a/drivers/gpio/gpio-zevio.c +++ b/drivers/gpio/gpio-zevio.c @@ -185,7 +185,7 @@ static int zevio_gpio_probe(struct platform_device *pdev) /* Copy our reference */ controller->chip.gc = zevio_gpio_chip; - controller->chip.gc.dev = &pdev->dev; + controller->chip.gc.parent = &pdev->dev; status = of_mm_gpiochip_add(pdev->dev.of_node, &(controller->chip)); if (status) { @@ -199,7 +199,7 @@ static int zevio_gpio_probe(struct platform_device *pdev) for (i = 0; i < controller->chip.gc.ngpio; i += 8) zevio_gpio_port_set(controller, i, ZEVIO_GPIO_INT_MASK, 0xFF); - dev_dbg(controller->chip.gc.dev, "ZEVIO GPIO controller set up!\n"); + dev_dbg(controller->chip.gc.parent, "ZEVIO GPIO controller set up!\n"); return 0; } diff --git a/drivers/gpio/gpio-zx.c b/drivers/gpio/gpio-zx.c index 1dcf7a66dd36..ab2e54fa46cf 100644 --- a/drivers/gpio/gpio-zx.c +++ b/drivers/gpio/gpio-zx.c @@ -245,7 +245,7 @@ static int zx_gpio_probe(struct platform_device *pdev) chip->gc.base = ZX_GPIO_NR * id; chip->gc.ngpio = ZX_GPIO_NR; chip->gc.label = dev_name(dev); - chip->gc.dev = dev; + chip->gc.parent = dev; chip->gc.owner = THIS_MODULE; ret = gpiochip_add(&chip->gc); diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c index 8abeacac5885..8a04e00bef32 100644 --- a/drivers/gpio/gpio-zynq.c +++ b/drivers/gpio/gpio-zynq.c @@ -592,7 +592,7 @@ static int zynq_gpio_request(struct gpio_chip *chip, unsigned offset) { int ret; - ret = pm_runtime_get_sync(chip->dev); + ret = pm_runtime_get_sync(chip->parent); /* * If the device is already active pm_runtime_get() will return 1 on @@ -603,7 +603,7 @@ static int zynq_gpio_request(struct gpio_chip *chip, unsigned offset) static void zynq_gpio_free(struct gpio_chip *chip, unsigned offset) { - pm_runtime_put(chip->dev); + pm_runtime_put(chip->parent); } static const struct dev_pm_ops zynq_gpio_dev_pm_ops = { @@ -698,7 +698,7 @@ static int zynq_gpio_probe(struct platform_device *pdev) chip = &gpio->chip; chip->label = gpio->p_data->label; chip->owner = THIS_MODULE; - chip->dev = &pdev->dev; + chip->parent = &pdev->dev; chip->get = zynq_gpio_get_value; chip->set = zynq_gpio_set_value; chip->request = zynq_gpio_request; diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 16a7b6816744..e4620e14457f 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -51,10 +51,10 @@ struct acpi_gpio_chip { static int acpi_gpiochip_find(struct gpio_chip *gc, void *data) { - if (!gc->dev) + if (!gc->parent) return false; - return ACPI_HANDLE(gc->dev) == data; + return ACPI_HANDLE(gc->parent) == data; } #ifdef CONFIG_PINCTRL @@ -184,7 +184,7 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares, if (agpio->connection_type != ACPI_RESOURCE_GPIO_TYPE_INT) return AE_OK; - handle = ACPI_HANDLE(chip->dev); + handle = ACPI_HANDLE(chip->parent); pin = agpio->pin_table[0]; if (pin <= 255) { @@ -208,7 +208,7 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares, desc = gpiochip_request_own_desc(chip, pin, "ACPI:Event"); if (IS_ERR(desc)) { - dev_err(chip->dev, "Failed to request GPIO\n"); + dev_err(chip->parent, "Failed to request GPIO\n"); return AE_ERROR; } @@ -216,13 +216,13 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares, ret = gpiochip_lock_as_irq(chip, pin); if (ret) { - dev_err(chip->dev, "Failed to lock GPIO as interrupt\n"); + dev_err(chip->parent, "Failed to lock GPIO as interrupt\n"); goto fail_free_desc; } irq = gpiod_to_irq(desc); if (irq < 0) { - dev_err(chip->dev, "Failed to translate GPIO to IRQ\n"); + dev_err(chip->parent, "Failed to translate GPIO to IRQ\n"); goto fail_unlock_irq; } @@ -259,7 +259,8 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares, ret = request_threaded_irq(event->irq, NULL, handler, irqflags, "ACPI:Event", event); if (ret) { - dev_err(chip->dev, "Failed to setup interrupt handler for %d\n", + dev_err(chip->parent, + "Failed to setup interrupt handler for %d\n", event->irq); goto fail_free_event; } @@ -293,10 +294,10 @@ void acpi_gpiochip_request_interrupts(struct gpio_chip *chip) acpi_handle handle; acpi_status status; - if (!chip->dev || !chip->to_irq) + if (!chip->parent || !chip->to_irq) return; - handle = ACPI_HANDLE(chip->dev); + handle = ACPI_HANDLE(chip->parent); if (!handle) return; @@ -323,10 +324,10 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip) acpi_handle handle; acpi_status status; - if (!chip->dev || !chip->to_irq) + if (!chip->parent || !chip->to_irq) return; - handle = ACPI_HANDLE(chip->dev); + handle = ACPI_HANDLE(chip->parent); if (!handle) return; @@ -748,7 +749,7 @@ out: static void acpi_gpiochip_request_regions(struct acpi_gpio_chip *achip) { struct gpio_chip *chip = achip->chip; - acpi_handle handle = ACPI_HANDLE(chip->dev); + acpi_handle handle = ACPI_HANDLE(chip->parent); acpi_status status; INIT_LIST_HEAD(&achip->conns); @@ -757,20 +758,22 @@ static void acpi_gpiochip_request_regions(struct acpi_gpio_chip *achip) acpi_gpio_adr_space_handler, NULL, achip); if (ACPI_FAILURE(status)) - dev_err(chip->dev, "Failed to install GPIO OpRegion handler\n"); + dev_err(chip->parent, + "Failed to install GPIO OpRegion handler\n"); } static void acpi_gpiochip_free_regions(struct acpi_gpio_chip *achip) { struct gpio_chip *chip = achip->chip; - acpi_handle handle = ACPI_HANDLE(chip->dev); + acpi_handle handle = ACPI_HANDLE(chip->parent); struct acpi_gpio_connection *conn, *tmp; acpi_status status; status = acpi_remove_address_space_handler(handle, ACPI_ADR_SPACE_GPIO, acpi_gpio_adr_space_handler); if (ACPI_FAILURE(status)) { - dev_err(chip->dev, "Failed to remove GPIO OpRegion handler\n"); + dev_err(chip->parent, + "Failed to remove GPIO OpRegion handler\n"); return; } @@ -787,16 +790,16 @@ void acpi_gpiochip_add(struct gpio_chip *chip) acpi_handle handle; acpi_status status; - if (!chip || !chip->dev) + if (!chip || !chip->parent) return; - handle = ACPI_HANDLE(chip->dev); + handle = ACPI_HANDLE(chip->parent); if (!handle) return; acpi_gpio = kzalloc(sizeof(*acpi_gpio), GFP_KERNEL); if (!acpi_gpio) { - dev_err(chip->dev, + dev_err(chip->parent, "Failed to allocate memory for ACPI GPIO chip\n"); return; } @@ -806,7 +809,7 @@ void acpi_gpiochip_add(struct gpio_chip *chip) status = acpi_attach_data(handle, acpi_gpio_chip_dh, acpi_gpio); if (ACPI_FAILURE(status)) { - dev_err(chip->dev, "Failed to attach ACPI GPIO chip\n"); + dev_err(chip->parent, "Failed to attach ACPI GPIO chip\n"); kfree(acpi_gpio); return; } @@ -820,16 +823,16 @@ void acpi_gpiochip_remove(struct gpio_chip *chip) acpi_handle handle; acpi_status status; - if (!chip || !chip->dev) + if (!chip || !chip->parent) return; - handle = ACPI_HANDLE(chip->dev); + handle = ACPI_HANDLE(chip->parent); if (!handle) return; status = acpi_get_data(handle, acpi_gpio_chip_dh, (void **)&acpi_gpio); if (ACPI_FAILURE(status)) { - dev_warn(chip->dev, "Failed to retrieve ACPI GPIO chip\n"); + dev_warn(chip->parent, "Failed to retrieve ACPI GPIO chip\n"); return; } diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 5fe34a9df3e6..6ed465ea2e12 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -423,8 +423,8 @@ int of_gpiochip_add(struct gpio_chip *chip) { int status; - if ((!chip->of_node) && (chip->dev)) - chip->of_node = chip->dev->of_node; + if ((!chip->of_node) && (chip->parent)) + chip->of_node = chip->parent->of_node; if (!chip->of_node) return 0; diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c index b57ed8e55ab5..405dfcaadc4c 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c @@ -605,7 +605,7 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change) if (chip->names && chip->names[offset]) ioname = chip->names[offset]; - dev = device_create_with_groups(&gpio_class, chip->dev, + dev = device_create_with_groups(&gpio_class, chip->parent, MKDEV(0, 0), data, gpio_groups, ioname ? ioname : "gpio%u", desc_to_gpio(desc)); @@ -730,7 +730,8 @@ int gpiochip_sysfs_register(struct gpio_chip *chip) return 0; /* use chip->base for the ID; it's already known to be unique */ - dev = device_create_with_groups(&gpio_class, chip->dev, MKDEV(0, 0), + dev = device_create_with_groups(&gpio_class, chip->parent, + MKDEV(0, 0), chip, gpiochip_groups, "gpiochip%d", chip->base); if (IS_ERR(dev)) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index a18f00fc1bb8..8b35457013da 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -205,8 +205,8 @@ static int gpiochip_add_to_list(struct gpio_chip *chip) if (pos != &gpio_chips && pos->prev != &gpio_chips) { _chip = list_entry(pos->prev, struct gpio_chip, list); if (_chip->base + _chip->ngpio > chip->base) { - dev_err(chip->dev, - "GPIO integer space overlap, cannot add chip\n"); + dev_err(chip->parent, + "GPIO integer space overlap, cannot add chip\n"); err = -EBUSY; } } @@ -267,7 +267,7 @@ static int gpiochip_set_desc_names(struct gpio_chip *gc) gpio = gpio_name_to_desc(gc->names[i]); if (gpio) - dev_warn(gc->dev, "Detected name collision for " + dev_warn(gc->parent, "Detected name collision for " "GPIO name '%s'\n", gc->names[i]); } @@ -348,8 +348,8 @@ int gpiochip_add(struct gpio_chip *chip) INIT_LIST_HEAD(&chip->pin_ranges); #endif - if (!chip->owner && chip->dev && chip->dev->driver) - chip->owner = chip->dev->driver->owner; + if (!chip->owner && chip->parent && chip->parent->driver) + chip->owner = chip->parent->driver->owner; status = gpiochip_set_desc_names(chip); if (status) @@ -424,7 +424,8 @@ void gpiochip_remove(struct gpio_chip *chip) spin_unlock_irqrestore(&gpio_lock, flags); if (requested) - dev_crit(chip->dev, "REMOVING GPIOCHIP WITH GPIOS STILL REQUESTED\n"); + dev_crit(chip->parent, + "REMOVING GPIOCHIP WITH GPIOS STILL REQUESTED\n"); kfree(chip->desc); chip->desc = NULL; @@ -683,11 +684,11 @@ int _gpiochip_irqchip_add(struct gpio_chip *gpiochip, if (!gpiochip || !irqchip) return -EINVAL; - if (!gpiochip->dev) { + if (!gpiochip->parent) { pr_err("missing gpiochip .dev parent pointer\n"); return -EINVAL; } - of_node = gpiochip->dev->of_node; + of_node = gpiochip->parent->of_node; #ifdef CONFIG_OF_GPIO /* * If the gpiochip has an assigned OF node this takes precedence @@ -2503,7 +2504,7 @@ static int gpiolib_seq_show(struct seq_file *s, void *v) seq_printf(s, "%sGPIOs %d-%d", (char *)s->private, chip->base, chip->base + chip->ngpio - 1); - dev = chip->dev; + dev = chip->parent; if (dev) seq_printf(s, ", %s/%s", dev->bus ? dev->bus->name : "no-bus", dev_name(dev)); diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 7afc3fcc122c..f47954e8fd2c 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -1104,7 +1104,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) dev->gc.base = -1; dev->gc.ngpio = 8; dev->gc.can_sleep = 1; - dev->gc.dev = &hdev->dev; + dev->gc.parent = &hdev->dev; ret = gpiochip_add(&dev->gc); if (ret < 0) { diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c index fec66ad80513..16b5cc2196f2 100644 --- a/drivers/input/touchscreen/ad7879.c +++ b/drivers/input/touchscreen/ad7879.c @@ -454,7 +454,7 @@ static int ad7879_gpio_add(struct ad7879 *ts, ts->gc.ngpio = 1; ts->gc.label = "AD7879-GPIO"; ts->gc.owner = THIS_MODULE; - ts->gc.dev = ts->dev; + ts->gc.parent = ts->dev; ret = gpiochip_add(&ts->gc); if (ret) diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c index 5a6363d161a2..a975b32ee8c8 100644 --- a/drivers/leds/leds-pca9532.c +++ b/drivers/leds/leds-pca9532.c @@ -319,7 +319,7 @@ static int pca9532_destroy_devices(struct pca9532_data *data, int n_devs) } #ifdef CONFIG_LEDS_PCA9532_GPIO - if (data->gpio.dev) + if (data->gpio.parent) gpiochip_remove(&data->gpio); #endif @@ -413,13 +413,13 @@ static int pca9532_configure(struct i2c_client *client, data->gpio.can_sleep = 1; data->gpio.base = pdata->gpio_base; data->gpio.ngpio = data->chip_info->num_leds; - data->gpio.dev = &client->dev; + data->gpio.parent = &client->dev; data->gpio.owner = THIS_MODULE; err = gpiochip_add(&data->gpio); if (err) { /* Use data->gpio.dev as a flag for freeing gpiochip */ - data->gpio.dev = NULL; + data->gpio.parent = NULL; dev_warn(&client->dev, "could not add gpiochip\n"); } else { dev_info(&client->dev, "gpios %i...%i\n", diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c index edbecc4ca2da..75529a24a615 100644 --- a/drivers/leds/leds-tca6507.c +++ b/drivers/leds/leds-tca6507.c @@ -651,7 +651,7 @@ static int tca6507_probe_gpios(struct i2c_client *client, tca->gpio.owner = THIS_MODULE; tca->gpio.direction_output = tca6507_gpio_direction_output; tca->gpio.set = tca6507_gpio_set_value; - tca->gpio.dev = &client->dev; + tca->gpio.parent = &client->dev; #ifdef CONFIG_OF_GPIO tca->gpio.of_node = of_node_get(client->dev.of_node); #endif diff --git a/drivers/media/dvb-frontends/cxd2820r_core.c b/drivers/media/dvb-frontends/cxd2820r_core.c index def6d21d1445..24a457d9d803 100644 --- a/drivers/media/dvb-frontends/cxd2820r_core.c +++ b/drivers/media/dvb-frontends/cxd2820r_core.c @@ -722,7 +722,7 @@ struct dvb_frontend *cxd2820r_attach(const struct cxd2820r_config *cfg, #ifdef CONFIG_GPIOLIB /* add GPIOs */ priv->gpio_chip.label = KBUILD_MODNAME; - priv->gpio_chip.dev = &priv->i2c->dev; + priv->gpio_chip.parent = &priv->i2c->dev; priv->gpio_chip.owner = THIS_MODULE; priv->gpio_chip.direction_output = cxd2820r_gpio_direction_output; diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c index 4c826f78acd0..bc90efe01b59 100644 --- a/drivers/mfd/dm355evm_msp.c +++ b/drivers/mfd/dm355evm_msp.c @@ -259,7 +259,7 @@ static int add_children(struct i2c_client *client) int i; /* GPIO-ish stuff */ - dm355evm_msp_gpio.dev = &client->dev; + dm355evm_msp_gpio.parent = &client->dev; status = gpiochip_add(&dm355evm_msp_gpio); if (status < 0) return status; diff --git a/drivers/mfd/htc-egpio.c b/drivers/mfd/htc-egpio.c index 6ccaf90d98fd..d334e7d8a77d 100644 --- a/drivers/mfd/htc-egpio.c +++ b/drivers/mfd/htc-egpio.c @@ -321,7 +321,7 @@ static int __init egpio_probe(struct platform_device *pdev) ei->chip[i].dev = &(pdev->dev); chip = &(ei->chip[i].chip); chip->label = "htc-egpio"; - chip->dev = &pdev->dev; + chip->parent = &pdev->dev; chip->owner = THIS_MODULE; chip->get = egpio_get; chip->set = egpio_set; diff --git a/drivers/mfd/htc-i2cpld.c b/drivers/mfd/htc-i2cpld.c index 0c6ff727b2ec..bd6b96d07ab8 100644 --- a/drivers/mfd/htc-i2cpld.c +++ b/drivers/mfd/htc-i2cpld.c @@ -429,7 +429,7 @@ static int htcpld_register_chip_gpio( /* Setup the GPIO chips */ gpio_chip = &(chip->chip_out); gpio_chip->label = "htcpld-out"; - gpio_chip->dev = dev; + gpio_chip->parent = dev; gpio_chip->owner = THIS_MODULE; gpio_chip->get = htcpld_chip_get; gpio_chip->set = htcpld_chip_set; @@ -440,7 +440,7 @@ static int htcpld_register_chip_gpio( gpio_chip = &(chip->chip_in); gpio_chip->label = "htcpld-in"; - gpio_chip->dev = dev; + gpio_chip->parent = dev; gpio_chip->owner = THIS_MODULE; gpio_chip->get = htcpld_chip_get; gpio_chip->set = NULL; diff --git a/drivers/mfd/tps65010.c b/drivers/mfd/tps65010.c index 448f0a182dc4..b96847491277 100644 --- a/drivers/mfd/tps65010.c +++ b/drivers/mfd/tps65010.c @@ -638,7 +638,7 @@ static int tps65010_probe(struct i2c_client *client, tps->outmask = board->outmask; tps->chip.label = client->name; - tps->chip.dev = &client->dev; + tps->chip.parent = &client->dev; tps->chip.owner = THIS_MODULE; tps->chip.set = tps65010_gpio_set; diff --git a/drivers/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c index f691d7ecad52..a6ec7cc0fac6 100644 --- a/drivers/mfd/ucb1x00-core.c +++ b/drivers/mfd/ucb1x00-core.c @@ -570,7 +570,7 @@ static int ucb1x00_probe(struct mcp *mcp) if (pdata && pdata->gpio_base) { ucb->gpio.label = dev_name(&ucb->dev); - ucb->gpio.dev = &ucb->dev; + ucb->gpio.parent = &ucb->dev; ucb->gpio.owner = THIS_MODULE; ucb->gpio.base = pdata->gpio_base; ucb->gpio.ngpio = 10; diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c index a1ea565fcd46..0bc1abcedbae 100644 --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -337,7 +337,7 @@ static int bcm2835_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int bcm2835_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct bcm2835_pinctrl *pc = dev_get_drvdata(chip->dev); + struct bcm2835_pinctrl *pc = dev_get_drvdata(chip->parent); return bcm2835_gpio_get_bit(pc, GPLEV0, offset); } @@ -350,14 +350,14 @@ static int bcm2835_gpio_direction_output(struct gpio_chip *chip, static void bcm2835_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct bcm2835_pinctrl *pc = dev_get_drvdata(chip->dev); + struct bcm2835_pinctrl *pc = dev_get_drvdata(chip->parent); bcm2835_gpio_set_bit(pc, value ? GPSET0 : GPCLR0, offset); } static int bcm2835_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct bcm2835_pinctrl *pc = dev_get_drvdata(chip->dev); + struct bcm2835_pinctrl *pc = dev_get_drvdata(chip->parent); return irq_linear_revmap(pc->irq_domain, offset); } @@ -963,7 +963,7 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev) return PTR_ERR(pc->base); pc->gpio_chip = bcm2835_gpio_chip; - pc->gpio_chip.dev = dev; + pc->gpio_chip.parent = dev; pc->gpio_chip.of_node = np; pc->irq_domain = irq_domain_add_linear(np, BCM2835_NUM_GPIOS, diff --git a/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c b/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c index 12a48f498b75..bd212b269094 100644 --- a/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c +++ b/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c @@ -720,7 +720,7 @@ static int cygnus_gpio_probe(struct platform_device *pdev) gc->ngpio = ngpios; chip->num_banks = (ngpios + NGPIOS_PER_BANK - 1) / NGPIOS_PER_BANK; gc->label = dev_name(dev); - gc->dev = dev; + gc->parent = dev; gc->of_node = dev->of_node; gc->request = cygnus_gpio_request; gc->free = cygnus_gpio_free; diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c index b59ce75b1947..bb92f8ae6b33 100644 --- a/drivers/pinctrl/intel/pinctrl-baytrail.c +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c @@ -598,7 +598,7 @@ static int byt_gpio_probe(struct platform_device *pdev) gc->dbg_show = byt_gpio_dbg_show; gc->base = -1; gc->can_sleep = false; - gc->dev = dev; + gc->parent = dev; #ifdef CONFIG_PM_SLEEP vg->saved_context = devm_kcalloc(&pdev->dev, gc->ngpio, diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c index 84936bae6e5e..dac8ec46aeb4 100644 --- a/drivers/pinctrl/intel/pinctrl-cherryview.c +++ b/drivers/pinctrl/intel/pinctrl-cherryview.c @@ -1436,7 +1436,7 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq) chip->ngpio = pctrl->community->ngpios; chip->label = dev_name(pctrl->dev); - chip->dev = pctrl->dev; + chip->parent = pctrl->dev; chip->base = -1; ret = gpiochip_add(chip); diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c index 392e28d3f48d..401c186244be 100644 --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c @@ -874,7 +874,7 @@ static int intel_gpio_probe(struct intel_pinctrl *pctrl, int irq) pctrl->chip.ngpio = pctrl->soc->npins; pctrl->chip.label = dev_name(pctrl->dev); - pctrl->chip.dev = pctrl->dev; + pctrl->chip.parent = pctrl->dev; pctrl->chip.base = -1; ret = gpiochip_add(&pctrl->chip); diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c index f307f1d27d64..a71f68362967 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c @@ -95,7 +95,7 @@ static void mtk_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { unsigned int reg_addr; unsigned int bit; - struct mtk_pinctrl *pctl = dev_get_drvdata(chip->dev); + struct mtk_pinctrl *pctl = dev_get_drvdata(chip->parent); reg_addr = mtk_get_port(pctl, offset) + pctl->devdata->dout_offset; bit = BIT(offset & 0xf); @@ -742,7 +742,7 @@ static int mtk_gpio_get_direction(struct gpio_chip *chip, unsigned offset) unsigned int bit; unsigned int read_val = 0; - struct mtk_pinctrl *pctl = dev_get_drvdata(chip->dev); + struct mtk_pinctrl *pctl = dev_get_drvdata(chip->parent); reg_addr = mtk_get_port(pctl, offset) + pctl->devdata->dir_offset; bit = BIT(offset & 0xf); @@ -755,7 +755,7 @@ static int mtk_gpio_get(struct gpio_chip *chip, unsigned offset) unsigned int reg_addr; unsigned int bit; unsigned int read_val = 0; - struct mtk_pinctrl *pctl = dev_get_drvdata(chip->dev); + struct mtk_pinctrl *pctl = dev_get_drvdata(chip->parent); if (mtk_gpio_get_direction(chip, offset)) reg_addr = mtk_get_port(pctl, offset) + @@ -772,7 +772,7 @@ static int mtk_gpio_get(struct gpio_chip *chip, unsigned offset) static int mtk_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { const struct mtk_desc_pin *pin; - struct mtk_pinctrl *pctl = dev_get_drvdata(chip->dev); + struct mtk_pinctrl *pctl = dev_get_drvdata(chip->parent); int irq; pin = pctl->devdata->pins + offset; @@ -940,7 +940,7 @@ static void mtk_eint_unmask(struct irq_data *d) static int mtk_gpio_set_debounce(struct gpio_chip *chip, unsigned offset, unsigned debounce) { - struct mtk_pinctrl *pctl = dev_get_drvdata(chip->dev); + struct mtk_pinctrl *pctl = dev_get_drvdata(chip->parent); int eint_num, virq, eint_offset; unsigned int set_offset, bit, clr_bit, clr_offset, rst, i, unmask, dbnc; static const unsigned int dbnc_arr[] = {0 , 1, 16, 32, 64, 128, 256}; @@ -1348,7 +1348,7 @@ int mtk_pctrl_init(struct platform_device *pdev, *pctl->chip = mtk_gpio_chip; pctl->chip->ngpio = pctl->devdata->npins; pctl->chip->label = dev_name(&pdev->dev); - pctl->chip->dev = &pdev->dev; + pctl->chip->parent = &pdev->dev; pctl->chip->base = -1; ret = gpiochip_add(pctl->chip); diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c index 84943e4cff09..4b5f6829144d 100644 --- a/drivers/pinctrl/meson/pinctrl-meson.c +++ b/drivers/pinctrl/meson/pinctrl-meson.c @@ -562,7 +562,7 @@ static int meson_gpiolib_register(struct meson_pinctrl *pc) domain = &pc->domains[i]; domain->chip.label = domain->data->name; - domain->chip.dev = pc->dev; + domain->chip.parent = pc->dev; domain->chip.request = meson_gpio_request; domain->chip.free = meson_gpio_free; domain->chip.direction_input = meson_gpio_direction_input; diff --git a/drivers/pinctrl/nomadik/pinctrl-abx500.c b/drivers/pinctrl/nomadik/pinctrl-abx500.c index b59fbb4b1fb1..434d5de0177b 100644 --- a/drivers/pinctrl/nomadik/pinctrl-abx500.c +++ b/drivers/pinctrl/nomadik/pinctrl-abx500.c @@ -986,7 +986,7 @@ static int abx500_pin_config_set(struct pinctrl_dev *pctldev, param = pinconf_to_config_param(configs[i]); argument = pinconf_to_config_argument(configs[i]); - dev_dbg(chip->dev, "pin %d [%#lx]: %s %s\n", + dev_dbg(chip->parent, "pin %d [%#lx]: %s %s\n", pin, configs[i], (param == PIN_CONFIG_OUTPUT) ? "output " : "input", (param == PIN_CONFIG_OUTPUT) ? @@ -1077,7 +1077,8 @@ static int abx500_pin_config_set(struct pinctrl_dev *pctldev, break; default: - dev_err(chip->dev, "illegal configuration requested\n"); + dev_err(chip->parent, + "illegal configuration requested\n"); } } /* for each config */ out: @@ -1172,7 +1173,7 @@ static int abx500_gpio_probe(struct platform_device *pdev) pct->dev = &pdev->dev; pct->parent = dev_get_drvdata(pdev->dev.parent); pct->chip = abx500gpio_chip; - pct->chip.dev = &pdev->dev; + pct->chip.parent = &pdev->dev; pct->chip.base = -1; /* Dynamic allocation */ match = of_match_device(abx500_gpio_match, &pdev->dev); diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/nomadik/pinctrl-nomadik.c index eebfae0c9b7c..cb4a327425a0 100644 --- a/drivers/pinctrl/nomadik/pinctrl-nomadik.c +++ b/drivers/pinctrl/nomadik/pinctrl-nomadik.c @@ -438,7 +438,7 @@ nmk_gpio_disable_lazy_irq(struct nmk_gpio_chip *nmk_chip, unsigned offset) nmk_chip->addr + NMK_GPIO_FIMSC); } - dev_dbg(nmk_chip->chip.dev, "%d: clearing interrupt mask\n", gpio); + dev_dbg(nmk_chip->chip.parent, "%d: clearing interrupt mask\n", gpio); } static void nmk_write_masked(void __iomem *reg, u32 mask, u32 value) @@ -1188,7 +1188,7 @@ static struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np, chip->base = id * NMK_GPIO_PER_CHIP; chip->ngpio = NMK_GPIO_PER_CHIP; chip->label = dev_name(&gpio_pdev->dev); - chip->dev = &gpio_pdev->dev; + chip->parent = &gpio_pdev->dev; res = platform_get_resource(gpio_pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(&pdev->dev, res); @@ -1890,7 +1890,7 @@ static int nmk_pin_config_set(struct pinctrl_dev *pctldev, unsigned pin, if (slpm_val) val = slpm_val - 1; - dev_dbg(nmk_chip->chip.dev, + dev_dbg(nmk_chip->chip.parent, "pin %d: sleep pull %s, dir %s, val %s\n", pin, slpm_pull ? pullnames[pull] : "same", @@ -1899,7 +1899,7 @@ static int nmk_pin_config_set(struct pinctrl_dev *pctldev, unsigned pin, slpm_val ? (val ? "high" : "low") : "same"); } - dev_dbg(nmk_chip->chip.dev, + dev_dbg(nmk_chip->chip.parent, "pin %d [%#lx]: pull %s, slpm %s (%s%s), lowemi %s\n", pin, cfg, pullnames[pull], slpmnames[slpm], output ? "output " : "input", diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c index 3318f1d6193c..a74b2b0a75e0 100644 --- a/drivers/pinctrl/pinctrl-amd.c +++ b/drivers/pinctrl/pinctrl-amd.c @@ -778,7 +778,7 @@ static int amd_gpio_probe(struct platform_device *pdev) gpio_dev->gc.base = 0; gpio_dev->gc.label = pdev->name; gpio_dev->gc.owner = THIS_MODULE; - gpio_dev->gc.dev = &pdev->dev; + gpio_dev->gc.parent = &pdev->dev; gpio_dev->gc.ngpio = TOTAL_NUMBER_OF_PINS; #if defined(CONFIG_OF_GPIO) gpio_dev->gc.of_node = pdev->dev.of_node; diff --git a/drivers/pinctrl/pinctrl-as3722.c b/drivers/pinctrl/pinctrl-as3722.c index 56af28b95a44..89479bea6262 100644 --- a/drivers/pinctrl/pinctrl-as3722.c +++ b/drivers/pinctrl/pinctrl-as3722.c @@ -582,7 +582,7 @@ static int as3722_pinctrl_probe(struct platform_device *pdev) } as_pci->gpio_chip = as3722_gpio_chip; - as_pci->gpio_chip.dev = &pdev->dev; + as_pci->gpio_chip.parent = &pdev->dev; as_pci->gpio_chip.of_node = pdev->dev.parent->of_node; ret = gpiochip_add(&as_pci->gpio_chip); if (ret < 0) { diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c index 33edd07d9149..f1daf8580167 100644 --- a/drivers/pinctrl/pinctrl-at91-pio4.c +++ b/drivers/pinctrl/pinctrl-at91-pio4.c @@ -290,7 +290,7 @@ static void atmel_gpio_irq_handler(struct irq_desc *desc) static int atmel_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(chip->dev); + struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(chip->parent); struct atmel_pin *pin = atmel_pioctrl->pins[offset]; unsigned reg; @@ -305,7 +305,7 @@ static int atmel_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int atmel_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(chip->dev); + struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(chip->parent); struct atmel_pin *pin = atmel_pioctrl->pins[offset]; unsigned reg; @@ -317,7 +317,7 @@ static int atmel_gpio_get(struct gpio_chip *chip, unsigned offset) static int atmel_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(chip->dev); + struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(chip->parent); struct atmel_pin *pin = atmel_pioctrl->pins[offset]; unsigned reg; @@ -336,7 +336,7 @@ static int atmel_gpio_direction_output(struct gpio_chip *chip, unsigned offset, static void atmel_gpio_set(struct gpio_chip *chip, unsigned offset, int val) { - struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(chip->dev); + struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(chip->parent); struct atmel_pin *pin = atmel_pioctrl->pins[offset]; atmel_gpio_write(atmel_pioctrl, pin->bank, @@ -346,7 +346,7 @@ static void atmel_gpio_set(struct gpio_chip *chip, unsigned offset, int val) static int atmel_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(chip->dev); + struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(chip->parent); return irq_find_mapping(atmel_pioctrl->irq_domain, offset); } @@ -969,7 +969,7 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) atmel_pioctrl->gpio_chip->of_node = dev->of_node; atmel_pioctrl->gpio_chip->ngpio = atmel_pioctrl->npins; atmel_pioctrl->gpio_chip->label = dev_name(dev); - atmel_pioctrl->gpio_chip->dev = dev; + atmel_pioctrl->gpio_chip->parent = dev; atmel_pioctrl->gpio_chip->names = atmel_pioctrl->group_names; atmel_pioctrl->pm_wakeup_sources = devm_kzalloc(dev, 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; diff --git a/drivers/pinctrl/pinctrl-coh901.c b/drivers/pinctrl/pinctrl-coh901.c index 813eb7c771ec..e1cbf56df4b2 100644 --- a/drivers/pinctrl/pinctrl-coh901.c +++ b/drivers/pinctrl/pinctrl-coh901.c @@ -637,7 +637,7 @@ static int __init u300_gpio_probe(struct platform_device *pdev) gpio->chip = u300_gpio_chip; gpio->chip.ngpio = U300_GPIO_NUM_PORTS * U300_GPIO_PINS_PER_PORT; - gpio->chip.dev = &pdev->dev; + gpio->chip.parent = &pdev->dev; gpio->chip.base = 0; gpio->dev = &pdev->dev; diff --git a/drivers/pinctrl/pinctrl-digicolor.c b/drivers/pinctrl/pinctrl-digicolor.c index 38a7799f8257..d8efb2ccac6c 100644 --- a/drivers/pinctrl/pinctrl-digicolor.c +++ b/drivers/pinctrl/pinctrl-digicolor.c @@ -244,7 +244,7 @@ static int dc_gpiochip_add(struct dc_pinmap *pmap, struct device_node *np) int ret; chip->label = DRIVER_NAME; - chip->dev = pmap->dev; + chip->parent = pmap->dev; chip->request = gpiochip_generic_request; chip->free = gpiochip_generic_free; chip->direction_input = dc_gpio_direction_input; diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c index 85c9046c690e..fd5148d106a3 100644 --- a/drivers/pinctrl/pinctrl-pistachio.c +++ b/drivers/pinctrl/pinctrl-pistachio.c @@ -1388,7 +1388,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl) bank->pctl = pctl; bank->base = pctl->base + GPIO_BANK_BASE(i); - bank->gpio_chip.dev = pctl->dev; + bank->gpio_chip.parent = pctl->dev; bank->gpio_chip.of_node = child; ret = gpiochip_add(&bank->gpio_chip); if (ret < 0) { diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index a0651128e23a..2b88a40f61d3 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -1754,7 +1754,7 @@ static int rockchip_gpiolib_register(struct platform_device *pdev, gc = &bank->gpio_chip; gc->base = bank->pin_base; gc->ngpio = bank->nr_pins; - gc->dev = &pdev->dev; + gc->parent = &pdev->dev; gc->of_node = bank->of_node; gc->label = bank->name; diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index b58d3f29148a..52639e65ea67 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -1522,7 +1522,7 @@ static int st_gpiolib_register_bank(struct st_pinctrl *info, bank->gpio_chip.base = bank_num * ST_GPIO_PINS_PER_BANK; bank->gpio_chip.ngpio = ST_GPIO_PINS_PER_BANK; bank->gpio_chip.of_node = np; - bank->gpio_chip.dev = dev; + bank->gpio_chip.parent = dev; spin_lock_init(&bank->lock); of_property_read_string(np, "st,bank-name", &range->name); diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c index ae724bdab3d3..b4380fb72001 100644 --- a/drivers/pinctrl/pinctrl-xway.c +++ b/drivers/pinctrl/pinctrl-xway.c @@ -648,7 +648,7 @@ static struct ltq_pinmux_info xway_info = { /* --------- gpio_chip related code --------- */ static void xway_gpio_set(struct gpio_chip *chip, unsigned int pin, int val) { - struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev); + struct ltq_pinmux_info *info = dev_get_drvdata(chip->parent); if (val) gpio_setbit(info->membase[0], GPIO_OUT(pin), PORT_PIN(pin)); @@ -658,14 +658,14 @@ static void xway_gpio_set(struct gpio_chip *chip, unsigned int pin, int val) static int xway_gpio_get(struct gpio_chip *chip, unsigned int pin) { - struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev); + struct ltq_pinmux_info *info = dev_get_drvdata(chip->parent); return gpio_getbit(info->membase[0], GPIO_IN(pin), PORT_PIN(pin)); } static int xway_gpio_dir_in(struct gpio_chip *chip, unsigned int pin) { - struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev); + struct ltq_pinmux_info *info = dev_get_drvdata(chip->parent); gpio_clearbit(info->membase[0], GPIO_DIR(pin), PORT_PIN(pin)); @@ -674,7 +674,7 @@ static int xway_gpio_dir_in(struct gpio_chip *chip, unsigned int pin) static int xway_gpio_dir_out(struct gpio_chip *chip, unsigned int pin, int val) { - struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev); + struct ltq_pinmux_info *info = dev_get_drvdata(chip->parent); gpio_setbit(info->membase[0], GPIO_DIR(pin), PORT_PIN(pin)); xway_gpio_set(chip, pin, val); @@ -783,7 +783,7 @@ static int pinmux_xway_probe(struct platform_device *pdev) xway_pctrl_desc.pins = xway_info.pads; /* load the gpio chip */ - xway_chip.dev = &pdev->dev; + xway_chip.parent = &pdev->dev; ret = gpiochip_add(&xway_chip); if (ret) { dev_err(&pdev->dev, "Failed to register gpio chip\n"); diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index 146264a41ec8..af2a13040898 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c @@ -800,7 +800,7 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl) chip->base = 0; chip->ngpio = ngpio; chip->label = dev_name(pctrl->dev); - chip->dev = pctrl->dev; + chip->parent = pctrl->dev; chip->owner = THIS_MODULE; chip->of_node = pctrl->dev->of_node; diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c index 6c42ca14d2fd..3e5ccc76d59c 100644 --- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c @@ -760,7 +760,7 @@ static int pmic_gpio_probe(struct platform_device *pdev) } state->chip = pmic_gpio_gpio_template; - state->chip.dev = dev; + state->chip.parent = dev; state->chip.base = -1; state->chip.ngpio = npins; state->chip.label = dev_name(dev); diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c index 9ce0e30e33e8..69c14ba177d0 100644 --- a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c +++ b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c @@ -862,7 +862,7 @@ static int pmic_mpp_probe(struct platform_device *pdev) } state->chip = pmic_mpp_gpio_template; - state->chip.dev = dev; + state->chip.parent = dev; state->chip.base = -1; state->chip.ngpio = npins; state->chip.label = dev_name(dev); diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c index d809c9eaa323..7b80fa9c2049 100644 --- a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c +++ b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c @@ -730,7 +730,7 @@ static int pm8xxx_gpio_probe(struct platform_device *pdev) pctrl->chip = pm8xxx_gpio_template; pctrl->chip.base = -1; - pctrl->chip.dev = &pdev->dev; + pctrl->chip.parent = &pdev->dev; pctrl->chip.of_node = pdev->dev.of_node; pctrl->chip.of_gpio_n_cells = 2; pctrl->chip.label = dev_name(pctrl->dev); diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c b/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c index 8982027de8e8..7bc1e0f27447 100644 --- a/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c +++ b/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c @@ -821,7 +821,7 @@ static int pm8xxx_mpp_probe(struct platform_device *pdev) pctrl->chip = pm8xxx_mpp_template; pctrl->chip.base = -1; - pctrl->chip.dev = &pdev->dev; + pctrl->chip.parent = &pdev->dev; pctrl->chip.of_node = pdev->dev.of_node; pctrl->chip.of_gpio_n_cells = 2; pctrl->chip.label = dev_name(pctrl->dev); diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c index 71ccf6a90b22..7d7374e57f16 100644 --- a/drivers/pinctrl/samsung/pinctrl-exynos.c +++ b/drivers/pinctrl/samsung/pinctrl-exynos.c @@ -176,7 +176,8 @@ static int exynos_irq_request_resources(struct irq_data *irqd) ret = gpiochip_lock_as_irq(&bank->gpio_chip, irqd->hwirq); if (ret) { - dev_err(bank->gpio_chip.dev, "unable to lock pin %s-%lu IRQ\n", + dev_err(bank->gpio_chip.parent, + "unable to lock pin %s-%lu IRQ\n", bank->name, irqd->hwirq); return ret; } diff --git a/drivers/pinctrl/samsung/pinctrl-exynos5440.c b/drivers/pinctrl/samsung/pinctrl-exynos5440.c index 82dc109f7ed4..f61f9a6fa9af 100644 --- a/drivers/pinctrl/samsung/pinctrl-exynos5440.c +++ b/drivers/pinctrl/samsung/pinctrl-exynos5440.c @@ -539,7 +539,7 @@ static const struct pinconf_ops exynos5440_pinconf_ops = { /* gpiolib gpio_set callback function */ static void exynos5440_gpio_set(struct gpio_chip *gc, unsigned offset, int value) { - struct exynos5440_pinctrl_priv_data *priv = dev_get_drvdata(gc->dev); + struct exynos5440_pinctrl_priv_data *priv = dev_get_drvdata(gc->parent); void __iomem *base = priv->reg_base; u32 data; @@ -553,7 +553,7 @@ static void exynos5440_gpio_set(struct gpio_chip *gc, unsigned offset, int value /* gpiolib gpio_get callback function */ static int exynos5440_gpio_get(struct gpio_chip *gc, unsigned offset) { - struct exynos5440_pinctrl_priv_data *priv = dev_get_drvdata(gc->dev); + struct exynos5440_pinctrl_priv_data *priv = dev_get_drvdata(gc->parent); void __iomem *base = priv->reg_base; u32 data; @@ -566,7 +566,7 @@ static int exynos5440_gpio_get(struct gpio_chip *gc, unsigned offset) /* gpiolib gpio_direction_input callback function */ static int exynos5440_gpio_direction_input(struct gpio_chip *gc, unsigned offset) { - struct exynos5440_pinctrl_priv_data *priv = dev_get_drvdata(gc->dev); + struct exynos5440_pinctrl_priv_data *priv = dev_get_drvdata(gc->parent); void __iomem *base = priv->reg_base; u32 data; @@ -586,7 +586,7 @@ static int exynos5440_gpio_direction_input(struct gpio_chip *gc, unsigned offset static int exynos5440_gpio_direction_output(struct gpio_chip *gc, unsigned offset, int value) { - struct exynos5440_pinctrl_priv_data *priv = dev_get_drvdata(gc->dev); + struct exynos5440_pinctrl_priv_data *priv = dev_get_drvdata(gc->parent); void __iomem *base = priv->reg_base; u32 data; @@ -607,7 +607,7 @@ static int exynos5440_gpio_direction_output(struct gpio_chip *gc, unsigned offse /* gpiolib gpio_to_irq callback function */ static int exynos5440_gpio_to_irq(struct gpio_chip *gc, unsigned offset) { - struct exynos5440_pinctrl_priv_data *priv = dev_get_drvdata(gc->dev); + struct exynos5440_pinctrl_priv_data *priv = dev_get_drvdata(gc->parent); unsigned int virq; if (offset < 16 || offset > 23) @@ -817,7 +817,7 @@ static int exynos5440_gpiolib_register(struct platform_device *pdev, priv->gc = gc; gc->base = 0; gc->ngpio = EXYNOS5440_MAX_PINS; - gc->dev = &pdev->dev; + gc->parent = &pdev->dev; gc->set = exynos5440_gpio_set; gc->get = exynos5440_gpio_get; gc->direction_input = exynos5440_gpio_direction_input; diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c index 3f622ccd8eab..bb4db2050f19 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.c +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c @@ -914,7 +914,7 @@ static int samsung_gpiolib_register(struct platform_device *pdev, gc = &bank->gpio_chip; gc->base = drvdata->pin_base + bank->pin_base; gc->ngpio = bank->nr_pins; - gc->dev = &pdev->dev; + gc->parent = &pdev->dev; gc->of_node = bank->of_node; gc->label = bank->name; diff --git a/drivers/pinctrl/sh-pfc/gpio.c b/drivers/pinctrl/sh-pfc/gpio.c index db3f09aa8993..cdb2460a7b00 100644 --- a/drivers/pinctrl/sh-pfc/gpio.c +++ b/drivers/pinctrl/sh-pfc/gpio.c @@ -246,7 +246,7 @@ static int gpio_pin_setup(struct sh_pfc_chip *chip) gc->to_irq = gpio_pin_to_irq; gc->label = pfc->info->name; - gc->dev = pfc->dev; + gc->parent = pfc->dev; gc->owner = THIS_MODULE; gc->base = 0; gc->ngpio = pfc->nr_gpio_pins; 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); diff --git a/drivers/pinctrl/spear/pinctrl-plgpio.c b/drivers/pinctrl/spear/pinctrl-plgpio.c index 1f0af250dbb5..925f597de266 100644 --- a/drivers/pinctrl/spear/pinctrl-plgpio.c +++ b/drivers/pinctrl/spear/pinctrl-plgpio.c @@ -561,7 +561,7 @@ static int plgpio_probe(struct platform_device *pdev) plgpio->chip.get = plgpio_get_value; plgpio->chip.set = plgpio_set_value; plgpio->chip.label = dev_name(&pdev->dev); - plgpio->chip.dev = &pdev->dev; + plgpio->chip.parent = &pdev->dev; plgpio->chip.owner = THIS_MODULE; plgpio->chip.of_node = pdev->dev.of_node; diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index dead97daca35..a437e4f8628b 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -454,7 +454,7 @@ static int sunxi_pinctrl_gpio_direction_input(struct gpio_chip *chip, static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->dev); + struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->parent); u32 reg = sunxi_data_reg(offset); u8 index = sunxi_data_offset(offset); u32 set_mux = pctl->desc->irq_read_needs_mux && @@ -475,7 +475,7 @@ static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset) static void sunxi_pinctrl_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->dev); + struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->parent); u32 reg = sunxi_data_reg(offset); u8 index = sunxi_data_offset(offset); unsigned long flags; @@ -522,7 +522,7 @@ static int sunxi_pinctrl_gpio_of_xlate(struct gpio_chip *gc, static int sunxi_pinctrl_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->dev); + struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->parent); struct sunxi_desc_function *desc; unsigned pinnum = pctl->desc->pin_base + offset; unsigned irqnum; @@ -536,7 +536,7 @@ static int sunxi_pinctrl_gpio_to_irq(struct gpio_chip *chip, unsigned offset) irqnum = desc->irqbank * IRQ_PER_BANK + desc->irqnum; - dev_dbg(chip->dev, "%s: request IRQ for GPIO %d, return %d\n", + dev_dbg(chip->parent, "%s: request IRQ for GPIO %d, return %d\n", chip->label, offset + chip->base, irqnum); return irq_find_mapping(pctl->domain, irqnum); @@ -959,7 +959,7 @@ int sunxi_pinctrl_init(struct platform_device *pdev, pctl->chip->ngpio = round_up(last_pin, PINS_PER_BANK) - pctl->desc->pin_base; pctl->chip->label = dev_name(&pdev->dev); - pctl->chip->dev = &pdev->dev; + pctl->chip->parent = &pdev->dev; pctl->chip->base = pctl->desc->pin_base; ret = gpiochip_add(pctl->chip); diff --git a/drivers/pinctrl/vt8500/pinctrl-wmt.c b/drivers/pinctrl/vt8500/pinctrl-wmt.c index fb22d3f62480..e9c1dfd90570 100644 --- a/drivers/pinctrl/vt8500/pinctrl-wmt.c +++ b/drivers/pinctrl/vt8500/pinctrl-wmt.c @@ -488,7 +488,7 @@ static struct pinctrl_desc wmt_desc = { static int wmt_gpio_get_direction(struct gpio_chip *chip, unsigned offset) { - struct wmt_pinctrl_data *data = dev_get_drvdata(chip->dev); + struct wmt_pinctrl_data *data = dev_get_drvdata(chip->parent); u32 bank = WMT_BANK_FROM_PIN(offset); u32 bit = WMT_BIT_FROM_PIN(offset); u32 reg_dir = data->banks[bank].reg_dir; @@ -503,7 +503,7 @@ static int wmt_gpio_get_direction(struct gpio_chip *chip, unsigned offset) static int wmt_gpio_get_value(struct gpio_chip *chip, unsigned offset) { - struct wmt_pinctrl_data *data = dev_get_drvdata(chip->dev); + struct wmt_pinctrl_data *data = dev_get_drvdata(chip->parent); u32 bank = WMT_BANK_FROM_PIN(offset); u32 bit = WMT_BIT_FROM_PIN(offset); u32 reg_data_in = data->banks[bank].reg_data_in; @@ -519,7 +519,7 @@ static int wmt_gpio_get_value(struct gpio_chip *chip, unsigned offset) static void wmt_gpio_set_value(struct gpio_chip *chip, unsigned offset, int val) { - struct wmt_pinctrl_data *data = dev_get_drvdata(chip->dev); + struct wmt_pinctrl_data *data = dev_get_drvdata(chip->parent); u32 bank = WMT_BANK_FROM_PIN(offset); u32 bit = WMT_BIT_FROM_PIN(offset); u32 reg_data_out = data->banks[bank].reg_data_out; @@ -575,7 +575,7 @@ int wmt_pinctrl_probe(struct platform_device *pdev, wmt_desc.npins = data->npins; data->gpio_chip = wmt_gpio_chip; - data->gpio_chip.dev = &pdev->dev; + data->gpio_chip.parent = &pdev->dev; data->gpio_chip.of_node = pdev->dev.of_node; data->gpio_chip.ngpio = data->nbanks * 32; diff --git a/drivers/platform/x86/intel_pmic_gpio.c b/drivers/platform/x86/intel_pmic_gpio.c index 709f0afdafa8..0e73fd10ba72 100644 --- a/drivers/platform/x86/intel_pmic_gpio.c +++ b/drivers/platform/x86/intel_pmic_gpio.c @@ -274,11 +274,11 @@ static int platform_pmic_gpio_probe(struct platform_device *pdev) pg->chip.base = pdata->gpio_base; pg->chip.ngpio = NUM_GPIO; pg->chip.can_sleep = 1; - pg->chip.dev = dev; + pg->chip.parent = dev; mutex_init(&pg->buslock); - pg->chip.dev = dev; + pg->chip.parent = dev; retval = gpiochip_add(&pg->chip); if (retval) { pr_err("Can not add pmic gpio chip\n"); diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index d45133056f51..3f98165b479c 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -1174,7 +1174,7 @@ static int max310x_probe(struct device *dev, struct max310x_devtype *devtype, #ifdef CONFIG_GPIOLIB /* Setup GPIO cotroller */ s->gpio.owner = THIS_MODULE; - s->gpio.dev = dev; + s->gpio.parent = dev; s->gpio.label = dev_name(dev); s->gpio.direction_input = max310x_gpio_direction_input; s->gpio.get = max310x_gpio_get; diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index edb5305b9d4d..cc86c348d809 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1180,7 +1180,7 @@ static int sc16is7xx_probe(struct device *dev, if (devtype->nr_gpio) { /* Setup GPIO cotroller */ s->gpio.owner = THIS_MODULE; - s->gpio.dev = dev; + s->gpio.parent = dev; s->gpio.label = dev_name(dev); s->gpio.direction_input = sc16is7xx_gpio_direction_input; s->gpio.get = sc16is7xx_gpio_get; diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index d1baebf350d8..b02c43be7859 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -20,7 +20,7 @@ struct seq_file; /** * struct gpio_chip - abstract a GPIO controller * @label: for diagnostics - * @dev: optional device providing the GPIOs + * @parent: optional parent device providing the GPIOs * @cdev: class device used by sysfs interface (may be NULL) * @owner: helps prevent removal of modules exporting active GPIOs * @list: links gpio_chips together for traversal @@ -89,7 +89,7 @@ struct seq_file; */ struct gpio_chip { const char *label; - struct device *dev; + struct device *parent; struct device *cdev; struct module *owner; struct list_head list; diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index b4cd7e3bf5f8..1f590b5a6718 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -4674,7 +4674,7 @@ static void rt5677_init_gpio(struct i2c_client *i2c) rt5677->gpio_chip = rt5677_template_chip; rt5677->gpio_chip.ngpio = RT5677_GPIO_NUM; - rt5677->gpio_chip.dev = &i2c->dev; + rt5677->gpio_chip.parent = &i2c->dev; rt5677->gpio_chip.base = -1; ret = gpiochip_add(&rt5677->gpio_chip); diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c index c2cdcae18ff6..171a23ddd15d 100644 --- a/sound/soc/codecs/wm5100.c +++ b/sound/soc/codecs/wm5100.c @@ -2306,7 +2306,7 @@ static void wm5100_init_gpio(struct i2c_client *i2c) wm5100->gpio_chip = wm5100_template_chip; wm5100->gpio_chip.ngpio = 6; - wm5100->gpio_chip.dev = &i2c->dev; + wm5100->gpio_chip.parent = &i2c->dev; if (wm5100->pdata.gpio_base) wm5100->gpio_chip.base = wm5100->pdata.gpio_base; diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index e4cc41e6c23e..2512def0d349 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c @@ -1853,7 +1853,7 @@ static void wm8903_init_gpio(struct wm8903_priv *wm8903) wm8903->gpio_chip = wm8903_template_chip; wm8903->gpio_chip.ngpio = WM8903_NUM_GPIO; - wm8903->gpio_chip.dev = wm8903->dev; + wm8903->gpio_chip.parent = wm8903->dev; if (pdata->gpio_base) wm8903->gpio_chip.base = pdata->gpio_base; diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index 39ebd7bf4f53..b563d6746ac4 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -3380,7 +3380,7 @@ static void wm8962_init_gpio(struct snd_soc_codec *codec) wm8962->gpio_chip = wm8962_template_chip; wm8962->gpio_chip.ngpio = WM8962_MAX_GPIO; - wm8962->gpio_chip.dev = codec->dev; + wm8962->gpio_chip.parent = codec->dev; if (pdata->gpio_base) wm8962->gpio_chip.base = pdata->gpio_base; diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c index f7ccd9fc5808..8d7d6c01a2f7 100644 --- a/sound/soc/codecs/wm8996.c +++ b/sound/soc/codecs/wm8996.c @@ -2204,7 +2204,7 @@ static void wm8996_init_gpio(struct wm8996_priv *wm8996) wm8996->gpio_chip = wm8996_template_chip; wm8996->gpio_chip.ngpio = 5; - wm8996->gpio_chip.dev = wm8996->dev; + wm8996->gpio_chip.parent = wm8996->dev; if (wm8996->pdata.gpio_base) wm8996->gpio_chip.base = wm8996->pdata.gpio_base; -- cgit From a11841477af65f07eccd726c1421d16d3f276088 Mon Sep 17 00:00:00 2001 From: William Breathitt Gray Date: Tue, 3 Nov 2015 07:54:23 -0500 Subject: gpio: Add IRQ support to ACCES 104-IDIO-16 driver The ACCES 104-IDIO-16 series offers Change-of-State detection interrupt functionality; if Change-of-State detection is enabled, an interrupt is fired off if any input line changes state (i.e. goes from low to high, or from high to low). This patch adds support to handle these interrupts and allows the user to mask which GPIO lines are affected. The interrupt line number for the device may be set via the idio_16_irq module parameter. Signed-off-by: William Breathitt Gray Signed-off-by: Linus Walleij --- drivers/gpio/Kconfig | 6 ++- drivers/gpio/gpio-104-idio-16.c | 112 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 116 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index b18bea08ff25..18e1aa05a616 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -496,8 +496,12 @@ menu "Port-mapped I/O GPIO drivers" config GPIO_104_IDIO_16 tristate "ACCES 104-IDIO-16 GPIO support" + select GPIOLIB_IRQCHIP help - Enables GPIO support for the ACCES 104-IDIO-16 family. + Enables GPIO support for the ACCES 104-IDIO-16 family. The base port + address for the device may be set via the idio_16_base module + parameter. The interrupt line number for the device may be set via the + idio_16_irq module parameter. config GPIO_F7188X tristate "F71869, F71869A, F71882FG and F71889F GPIO support" diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c index 107cfd7105a8..4e8adee4d8c2 100644 --- a/drivers/gpio/gpio-104-idio-16.c +++ b/drivers/gpio/gpio-104-idio-16.c @@ -11,11 +11,14 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. */ +#include #include #include #include #include #include +#include +#include #include #include #include @@ -25,20 +28,27 @@ static unsigned idio_16_base; module_param(idio_16_base, uint, 0); MODULE_PARM_DESC(idio_16_base, "ACCES 104-IDIO-16 base address"); +static unsigned idio_16_irq; +module_param(idio_16_irq, uint, 0); +MODULE_PARM_DESC(idio_16_irq, "ACCES 104-IDIO-16 interrupt line number"); /** * struct idio_16_gpio - GPIO device private data structure * @chip: instance of the gpio_chip - * @lock: synchronization lock to prevent gpio_set race conditions + * @lock: synchronization lock to prevent I/O race conditions + * @irq_mask: I/O bits affected by interrupts * @base: base port address of the GPIO device * @extent: extent of port address region of the GPIO device + * @irq: Interrupt line number * @out_state: output bits state */ struct idio_16_gpio { struct gpio_chip chip; spinlock_t lock; + unsigned long irq_mask; unsigned base; unsigned extent; + unsigned irq; unsigned out_state; }; @@ -105,6 +115,87 @@ static void idio_16_gpio_set(struct gpio_chip *chip, unsigned offset, int value) spin_unlock_irqrestore(&idio16gpio->lock, flags); } +static void idio_16_irq_ack(struct irq_data *data) +{ + struct gpio_chip *chip = irq_data_get_irq_chip_data(data); + struct idio_16_gpio *const idio16gpio = to_idio16gpio(chip); + unsigned long flags; + + spin_lock_irqsave(&idio16gpio->lock, flags); + + outb(0, idio16gpio->base + 1); + + spin_unlock_irqrestore(&idio16gpio->lock, flags); +} + +static void idio_16_irq_mask(struct irq_data *data) +{ + struct gpio_chip *chip = irq_data_get_irq_chip_data(data); + struct idio_16_gpio *const idio16gpio = to_idio16gpio(chip); + const unsigned long mask = BIT(irqd_to_hwirq(data)); + unsigned long flags; + + idio16gpio->irq_mask &= ~mask; + + if (!idio16gpio->irq_mask) { + spin_lock_irqsave(&idio16gpio->lock, flags); + + outb(0, idio16gpio->base + 2); + + spin_unlock_irqrestore(&idio16gpio->lock, flags); + } +} + +static void idio_16_irq_unmask(struct irq_data *data) +{ + struct gpio_chip *chip = irq_data_get_irq_chip_data(data); + struct idio_16_gpio *const idio16gpio = to_idio16gpio(chip); + const unsigned long mask = BIT(irqd_to_hwirq(data)); + const unsigned long prev_irq_mask = idio16gpio->irq_mask; + unsigned long flags; + + idio16gpio->irq_mask |= mask; + + if (!prev_irq_mask) { + spin_lock_irqsave(&idio16gpio->lock, flags); + + outb(0, idio16gpio->base + 1); + inb(idio16gpio->base + 2); + + spin_unlock_irqrestore(&idio16gpio->lock, flags); + } +} + +static int idio_16_irq_set_type(struct irq_data *data, unsigned flow_type) +{ + /* The only valid irq types are none and both-edges */ + if (flow_type != IRQ_TYPE_NONE && + (flow_type & IRQ_TYPE_EDGE_BOTH) != IRQ_TYPE_EDGE_BOTH) + return -EINVAL; + + return 0; +} + +static struct irq_chip idio_16_irqchip = { + .name = "104-idio-16", + .irq_ack = idio_16_irq_ack, + .irq_mask = idio_16_irq_mask, + .irq_unmask = idio_16_irq_unmask, + .irq_set_type = idio_16_irq_set_type +}; + +static irqreturn_t idio_16_irq_handler(int irq, void *dev_id) +{ + struct idio_16_gpio *const idio16gpio = dev_id; + struct gpio_chip *const chip = &idio16gpio->chip; + int gpio; + + for_each_set_bit(gpio, &idio16gpio->irq_mask, chip->ngpio) + generic_handle_irq(irq_find_mapping(chip->irqdomain, gpio)); + + return IRQ_HANDLED; +} + static int __init idio_16_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -113,6 +204,7 @@ static int __init idio_16_probe(struct platform_device *pdev) const unsigned BASE = idio_16_base; const unsigned EXTENT = 8; + const unsigned IRQ = idio_16_irq; const char *const NAME = dev_name(dev); idio16gpio = devm_kzalloc(dev, sizeof(*idio16gpio), GFP_KERNEL); @@ -138,6 +230,7 @@ static int __init idio_16_probe(struct platform_device *pdev) idio16gpio->chip.set = idio_16_gpio_set; idio16gpio->base = BASE; idio16gpio->extent = EXTENT; + idio16gpio->irq = IRQ; idio16gpio->out_state = 0xFFFF; spin_lock_init(&idio16gpio->lock); @@ -150,8 +243,24 @@ static int __init idio_16_probe(struct platform_device *pdev) goto err_gpio_register; } + err = gpiochip_irqchip_add(&idio16gpio->chip, &idio_16_irqchip, 0, + handle_edge_irq, IRQ_TYPE_NONE); + if (err) { + dev_err(dev, "Could not add irqchip (%d)\n", err); + goto err_gpiochip_irqchip_add; + } + + err = request_irq(IRQ, idio_16_irq_handler, 0, NAME, idio16gpio); + if (err) { + dev_err(dev, "IRQ handler registering failed (%d)\n", err); + goto err_request_irq; + } + return 0; +err_request_irq: +err_gpiochip_irqchip_add: + gpiochip_remove(&idio16gpio->chip); err_gpio_register: release_region(BASE, EXTENT); err_lock_io_port: @@ -162,6 +271,7 @@ static int idio_16_remove(struct platform_device *pdev) { struct idio_16_gpio *const idio16gpio = platform_get_drvdata(pdev); + free_irq(idio16gpio->irq, idio16gpio); gpiochip_remove(&idio16gpio->chip); release_region(idio16gpio->base, idio16gpio->extent); -- cgit From 615b8a969d0fb623a4067ad6afa9590ca5dcaf63 Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Wed, 4 Nov 2015 11:12:12 -0600 Subject: gpio: tps65086: Add DT bindings for the TPS65086 GPO controller The TPS65086 PMIC contains several regulators and a GPO controller. Add bindings for the TPS65086 GPO controller. Signed-off-by: Andrew F. Davis Acked-by: Rob Herring Signed-off-by: Linus Walleij --- Documentation/devicetree/bindings/gpio/gpio-tps65086.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-tps65086.txt diff --git a/Documentation/devicetree/bindings/gpio/gpio-tps65086.txt b/Documentation/devicetree/bindings/gpio/gpio-tps65086.txt new file mode 100644 index 000000000000..ba051074bedc --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/gpio-tps65086.txt @@ -0,0 +1,16 @@ +* TPS65086 GPO Controller bindings + +Required properties: + - compatible : Should be "ti,tps65086-gpio". + - gpio-controller : Marks the device node as a GPIO Controller. + - #gpio-cells : Should be two. The first cell is the pin number + and the second cell is used to specify flags. + See ../gpio/gpio.txt for possible values. + +Example: + + gpio4: gpio { + compatible = "ti,tps65086-gpio"; + gpio-controller; + #gpio-cells = <2>; + }; -- cgit From 9c3c9bc9cc980d8981f75109f3921576daf75723 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Wed, 11 Nov 2015 11:45:30 -0800 Subject: gpiolib: tighten up ACPI legacy gpio lookups We should not fall back to the legacy unnamed gpio lookup style if the driver requests gpios with different names, because we'll give out the same gpio twice. Let's keep track of the names that were used for the device and only do the fallback for the first name used. Signed-off-by: Dmitry Torokhov Acked-by: Mika Westerberg Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib-acpi.c | 43 +++++++++++++++++++++++++++++++++++++++++++ drivers/gpio/gpiolib.c | 3 +++ drivers/gpio/gpiolib.h | 8 ++++++++ 3 files changed, 54 insertions(+) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index e4620e14457f..07e571a1a377 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -925,3 +925,46 @@ int acpi_gpio_count(struct device *dev, const char *con_id) } return count; } + +struct acpi_crs_lookup { + struct list_head node; + struct acpi_device *adev; + const char *con_id; +}; + +static DEFINE_MUTEX(acpi_crs_lookup_lock); +static LIST_HEAD(acpi_crs_lookup_list); + +bool acpi_can_fallback_to_crs(struct acpi_device *adev, const char *con_id) +{ + struct acpi_crs_lookup *l, *lookup = NULL; + + /* Never allow fallback if the device has properties */ + if (adev->data.properties || adev->driver_gpios) + return false; + + mutex_lock(&acpi_crs_lookup_lock); + + list_for_each_entry(l, &acpi_crs_lookup_list, node) { + if (l->adev == adev) { + lookup = l; + break; + } + } + + if (!lookup) { + lookup = kmalloc(sizeof(*lookup), GFP_KERNEL); + if (lookup) { + lookup->adev = adev; + lookup->con_id = con_id; + list_add_tail(&lookup->node, &acpi_crs_lookup_list); + } + } + + mutex_unlock(&acpi_crs_lookup_lock); + + return lookup && + ((!lookup->con_id && !con_id) || + (lookup->con_id && con_id && + strcmp(lookup->con_id, con_id) == 0)); +} diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 8b35457013da..dfe09c06df49 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1869,6 +1869,9 @@ static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id, /* Then from plain _CRS GPIOs */ if (IS_ERR(desc)) { + if (!acpi_can_fallback_to_crs(adev, con_id)) + return ERR_PTR(-ENOENT); + desc = acpi_get_gpiod_by_index(adev, NULL, idx, &info); if (IS_ERR(desc)) return desc; diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 98ab08c0aa2d..2b87cbd68478 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -47,6 +47,8 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, struct acpi_gpio_info *info); int acpi_gpio_count(struct device *dev, const char *con_id); + +bool acpi_can_fallback_to_crs(struct acpi_device *adev, const char *con_id); #else static inline void acpi_gpiochip_add(struct gpio_chip *chip) { } static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { } @@ -73,6 +75,12 @@ static inline int acpi_gpio_count(struct device *dev, const char *con_id) { return -ENODEV; } + +static inline bool acpi_can_fallback_to_crs(struct acpi_device *adev, + const char *con_id) +{ + return false; +} #endif struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np, -- cgit From fe6435282b4c6f036427cdee83a2a83356d636c0 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 13 Nov 2015 10:35:29 -0300 Subject: MAINTAINERS: Update OMAP GPIO driver entry I'm not as involved in OMAP as I used to be and Grygorii is the most active developer working on this driver and has also been reviewing patches so let's add him as a driver maintainer instead of me. While being there, add the driver's DT binding doc to the file list. Signed-off-by: Javier Martinez Canillas Signed-off-by: Linus Walleij --- MAINTAINERS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index e9caa4b28828..629727e43d08 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7788,11 +7788,12 @@ F: drivers/usb/*/*omap* F: arch/arm/*omap*/usb* OMAP GPIO DRIVER -M: Javier Martinez Canillas +M: Grygorii Strashko M: Santosh Shilimkar M: Kevin Hilman L: linux-omap@vger.kernel.org S: Maintained +F: Documentation/devicetree/bindings/gpio/gpio-omap.txt F: drivers/gpio/gpio-omap.c OMAP/NEWFLOW NANOBONE MACHINE SUPPORT -- cgit From eae122b829483f677dc7784f82437c5d0274e019 Mon Sep 17 00:00:00 2001 From: Robert Jarzmik Date: Fri, 13 Nov 2015 21:22:38 +0100 Subject: gpio: pxa: change initcall level second attempt This patch is a second attempt at what was previously in commit 6c7e660a27da ("gpio: pxa: set initcall level to module init"). The goal is the same : enable gpio & pinctrl driver to work together. As pinctrl driver will be initialized at device level, the gpio should be as well, so that the deferring mechanism is honored. Yet this patch should also respect the legacy platforms, so the set of constraints is : - in legacy platforms (ie. non dt), gpio_[gs]et_*() should be available for machine code => core initcall - in new platforms (ie. dt based), pinctrl will be available and no machine code => device initcall In order to fullfill all these constraints, the initcall level is either postcore for non devicetree platforms, and device for devicetree platforms. Signed-off-by: Robert Jarzmik Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pxa.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index df2ce550f309..bce99182578b 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c @@ -690,11 +690,23 @@ static struct platform_driver pxa_gpio_driver = { .id_table = gpio_id_table, }; -static int __init pxa_gpio_init(void) +static int __init pxa_gpio_legacy_init(void) { + if (of_have_populated_dt()) + return 0; + return platform_driver_register(&pxa_gpio_driver); } -postcore_initcall(pxa_gpio_init); +postcore_initcall(pxa_gpio_legacy_init); + +static int __init pxa_gpio_dt_init(void) +{ + if (of_have_populated_dt()) + return platform_driver_register(&pxa_gpio_driver); + + return 0; +} +device_initcall(pxa_gpio_dt_init); #ifdef CONFIG_PM static int pxa_gpio_suspend(void) -- cgit From ed37915cb1fde446bd52069d7a708301b7e7b607 Mon Sep 17 00:00:00 2001 From: Bamvor Jian Zhang Date: Sat, 14 Nov 2015 16:43:20 +0800 Subject: gpiolib: keep comment consistent with code The commit f881bab038c9 ("gpio: keep the GPIO line names internal") change the error to warning in gpiochip_set_desc_names. Update the comment accordingly. Signed-off-by: Bamvor Jian Zhang Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index dfe09c06df49..44c8d8352748 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -252,7 +252,7 @@ static struct gpio_desc *gpio_name_to_desc(const char * const name) * Takes the names from gc->names and checks if they are all unique. If they * are, they are assigned to their gpio descriptors. * - * Returns -EEXIST if one of the names is already used for a different GPIO. + * Warning if one of the names is already used for a different GPIO. */ static int gpiochip_set_desc_names(struct gpio_chip *gc) { -- cgit From ef7c7553039b3d1c847b38b0f1ea208f8d5d8370 Mon Sep 17 00:00:00 2001 From: Bamvor Jian Zhang Date: Mon, 16 Nov 2015 13:02:46 +0800 Subject: gpiolib: improve overlap check of range of gpio There are limitations for the current checker: 1. Could not check the overlap if the new gpiochip is the secondly gpiochip. 2. Could not check the overlap if the new gpiochip is overlap with the left of gpiochip. E.g. if we insert [c, d] between [a,b] and [e, f], and e >= c + d, it will successful even if c < a + b. 3. Allow overlap of base of different gpiochip. This patch fix these issues by checking the overlap of both right and left gpiochip in the same loop statement. Signed-off-by: Bamvor Jian Zhang [Tweaked to remove unnecessary ret variable] Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 55 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 44c8d8352748..eed70c36e8ac 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -182,7 +182,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_direction); /* * Add a new chip to the global chips list, keeping the list of chips sorted - * by base order. + * by range(means [base, base + ngpio - 1]) order. * * Return -EBUSY if the new chip overlaps with some other chip's integer * space. @@ -190,31 +190,48 @@ EXPORT_SYMBOL_GPL(gpiod_get_direction); static int gpiochip_add_to_list(struct gpio_chip *chip) { struct list_head *pos; - struct gpio_chip *_chip; - int err = 0; + struct gpio_chip *iterator; + struct gpio_chip *previous = NULL; - /* find where to insert our chip */ - list_for_each(pos, &gpio_chips) { - _chip = list_entry(pos, struct gpio_chip, list); - /* shall we insert before _chip? */ - if (_chip->base >= chip->base + chip->ngpio) - break; + if (list_empty(&gpio_chips)) { + pos = gpio_chips.next; + goto found; } - /* are we stepping on the chip right before? */ - if (pos != &gpio_chips && pos->prev != &gpio_chips) { - _chip = list_entry(pos->prev, struct gpio_chip, list); - if (_chip->base + _chip->ngpio > chip->base) { - dev_err(chip->parent, - "GPIO integer space overlap, cannot add chip\n"); - err = -EBUSY; + list_for_each(pos, &gpio_chips) { + iterator = list_entry(pos, struct gpio_chip, list); + if (iterator->base >= chip->base + chip->ngpio) { + /* + * Iterator is the first GPIO chip so there is no + * previous one + */ + if (previous == NULL) { + goto found; + } else { + /* + * We found a valid range(means + * [base, base + ngpio - 1]) between previous + * and iterator chip. + */ + if (previous->base + previous->ngpio + <= chip->base) + goto found; + } } + previous = iterator; } - if (!err) - list_add_tail(&chip->list, pos); + /* We are beyond the last chip in the list */ + if (iterator->base + iterator->ngpio <= chip->base) + goto found; - return err; + dev_err(chip->parent, + "GPIO integer space overlap, cannot add chip\n"); + return -EBUSY; + +found: + list_add_tail(&chip->list, pos); + return 0; } /** -- cgit From 5ed41cc4baaf4127661d2a8f8f2ee6e3085e0fa9 Mon Sep 17 00:00:00 2001 From: Bamvor Jian Zhang Date: Mon, 16 Nov 2015 13:02:47 +0800 Subject: gpiolib: do not allow to insert an empty gpiochip We need to check if number of gpio is positive if there is no such check in devicetree or acpi or whatever called before gpiochip_add. I suppose that devicetree and acpi do not allow insert gpiochip with zero number but I do not know if it is enough to ignore this check in gpiochip_add. Signed-off-by: Bamvor Jian Zhang Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index eed70c36e8ac..89e01538e40e 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -325,6 +325,11 @@ int gpiochip_add(struct gpio_chip *chip) if (!descs) return -ENOMEM; + if (chip->ngpio == 0) { + chip_err(chip, "tried to insert a GPIO chip with zero lines\n"); + return -EINVAL; + } + spin_lock_irqsave(&gpio_lock, flags); if (base < 0) { -- cgit From 6e0171b4064d4337a51e48f495f2471d043dcd90 Mon Sep 17 00:00:00 2001 From: William Breathitt Gray Date: Tue, 17 Nov 2015 18:58:16 -0500 Subject: gpio: 104-idio-16: Use lowercase symbol names for const variables To prevent confusion, and to match the existing coding style used in other GPIO drivers, symbol names within the 104-idio-16 GPIO driver should be lowercase. Signed-off-by: William Breathitt Gray Reviewed-by: Alexandre Courbot Signed-off-by: Linus Walleij --- drivers/gpio/gpio-104-idio-16.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c index 4e8adee4d8c2..81b6904bdfe6 100644 --- a/drivers/gpio/gpio-104-idio-16.c +++ b/drivers/gpio/gpio-104-idio-16.c @@ -80,21 +80,21 @@ static struct idio_16_gpio *to_idio16gpio(struct gpio_chip *gc) static int idio_16_gpio_get(struct gpio_chip *chip, unsigned offset) { struct idio_16_gpio *const idio16gpio = to_idio16gpio(chip); - const unsigned BIT_MASK = 1U << (offset-16); + const unsigned mask = BIT(offset-16); if (offset < 16) return -EINVAL; if (offset < 24) - return !!(inb(idio16gpio->base + 1) & BIT_MASK); + return !!(inb(idio16gpio->base + 1) & mask); - return !!(inb(idio16gpio->base + 5) & (BIT_MASK>>8)); + return !!(inb(idio16gpio->base + 5) & (mask>>8)); } static void idio_16_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { struct idio_16_gpio *const idio16gpio = to_idio16gpio(chip); - const unsigned BIT_MASK = 1U << offset; + const unsigned mask = BIT(offset); unsigned long flags; if (offset > 15) @@ -103,9 +103,9 @@ static void idio_16_gpio_set(struct gpio_chip *chip, unsigned offset, int value) spin_lock_irqsave(&idio16gpio->lock, flags); if (value) - idio16gpio->out_state |= BIT_MASK; + idio16gpio->out_state |= mask; else - idio16gpio->out_state &= ~BIT_MASK; + idio16gpio->out_state &= ~mask; if (offset > 7) outb(idio16gpio->out_state >> 8, idio16gpio->base + 4); @@ -200,25 +200,24 @@ static int __init idio_16_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct idio_16_gpio *idio16gpio; + const unsigned base = idio_16_base; + const unsigned extent = 8; + const char *const name = dev_name(dev); int err; - - const unsigned BASE = idio_16_base; - const unsigned EXTENT = 8; - const unsigned IRQ = idio_16_irq; - const char *const NAME = dev_name(dev); + const unsigned irq = idio_16_irq; idio16gpio = devm_kzalloc(dev, sizeof(*idio16gpio), GFP_KERNEL); if (!idio16gpio) return -ENOMEM; - if (!request_region(BASE, EXTENT, NAME)) { + if (!request_region(base, extent, name)) { dev_err(dev, "Unable to lock %s port addresses (0x%X-0x%X)\n", - NAME, BASE, BASE + EXTENT); + name, base, base + extent); err = -EBUSY; goto err_lock_io_port; } - idio16gpio->chip.label = NAME; + idio16gpio->chip.label = name; idio16gpio->chip.parent = dev; idio16gpio->chip.owner = THIS_MODULE; idio16gpio->chip.base = -1; @@ -228,9 +227,9 @@ static int __init idio_16_probe(struct platform_device *pdev) idio16gpio->chip.direction_output = idio_16_gpio_direction_output; idio16gpio->chip.get = idio_16_gpio_get; idio16gpio->chip.set = idio_16_gpio_set; - idio16gpio->base = BASE; - idio16gpio->extent = EXTENT; - idio16gpio->irq = IRQ; + idio16gpio->base = base; + idio16gpio->extent = extent; + idio16gpio->irq = irq; idio16gpio->out_state = 0xFFFF; spin_lock_init(&idio16gpio->lock); @@ -250,7 +249,7 @@ static int __init idio_16_probe(struct platform_device *pdev) goto err_gpiochip_irqchip_add; } - err = request_irq(IRQ, idio_16_irq_handler, 0, NAME, idio16gpio); + err = request_irq(irq, idio_16_irq_handler, 0, name, idio16gpio); if (err) { dev_err(dev, "IRQ handler registering failed (%d)\n", err); goto err_request_irq; @@ -262,7 +261,7 @@ err_request_irq: err_gpiochip_irqchip_add: gpiochip_remove(&idio16gpio->chip); err_gpio_register: - release_region(BASE, EXTENT); + release_region(base, extent); err_lock_io_port: return err; } -- cgit From c88402c2e63d0dc957d4748e249dfc40ec954086 Mon Sep 17 00:00:00 2001 From: Bamvor Jian Zhang Date: Wed, 18 Nov 2015 17:07:07 +0800 Subject: gpiolib: make comment consistent with code Commit f4d566a8a0e6 ("gpio: change member .dev to .parent") changes member of gpiochip from .dev to .parent. Update the corresponding comment. Signed-off-by: Bamvor Jian Zhang Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 89e01538e40e..e63bebc9ae60 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -306,7 +306,7 @@ static int gpiochip_set_desc_names(struct gpio_chip *gc) * different chip. Otherwise it returns zero as a success code. * * When gpiochip_add() is called very early during boot, so that GPIOs - * can be freely used, the chip->dev device must be registered before + * can be freely used, the chip->parent device must be registered before * the gpio framework's arch_initcall(). Otherwise sysfs initialization * for GPIOs will fail rudely. * @@ -714,7 +714,8 @@ int _gpiochip_irqchip_add(struct gpio_chip *gpiochip, #ifdef CONFIG_OF_GPIO /* * If the gpiochip has an assigned OF node this takes precedence - * FIXME: get rid of this and use gpiochip->dev->of_node everywhere + * FIXME: get rid of this and use gpiochip->parent->of_node + * everywhere */ if (gpiochip->of_node) of_node = gpiochip->of_node; -- cgit 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(-) 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 From fb50cdfeeda868ae2bfe7ec2e0afebff53eca2d5 Mon Sep 17 00:00:00 2001 From: William Breathitt Gray Date: Sun, 22 Nov 2015 11:38:55 -0500 Subject: gpio: 104-idio-16: Disable IRQ on device probe IRQ should be disabled on device probe so that the device IRQ is in a known starting state. If IRQ is not disabled, interrupts may be reported as handled by the IRQ handler, despite no irq_unmask calls made by the user. Signed-off-by: William Breathitt Gray Signed-off-by: Linus Walleij --- drivers/gpio/gpio-104-idio-16.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c index 81b6904bdfe6..efe3ff7d574e 100644 --- a/drivers/gpio/gpio-104-idio-16.c +++ b/drivers/gpio/gpio-104-idio-16.c @@ -242,6 +242,9 @@ static int __init idio_16_probe(struct platform_device *pdev) goto err_gpio_register; } + /* Disable IRQ by default */ + outb(0, base + 2); + err = gpiochip_irqchip_add(&idio16gpio->chip, &idio_16_irqchip, 0, handle_edge_irq, IRQ_TYPE_NONE); if (err) { -- cgit From ab128afce4ea8a496fc42553215f6635a14f05c3 Mon Sep 17 00:00:00 2001 From: Nizam Haider Date: Mon, 23 Nov 2015 20:53:18 +0530 Subject: gpio: use dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. Signed-off-by: Nizam Haider Signed-off-by: Linus Walleij --- drivers/gpio/gpio-ath79.c | 2 +- drivers/gpio/gpio-davinci.c | 2 +- drivers/gpio/gpio-f7188x.c | 2 +- drivers/gpio/gpio-octeon.c | 2 +- drivers/gpio/gpio-sch311x.c | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c index b1410226dc95..e7e38af11ec9 100644 --- a/drivers/gpio/gpio-ath79.c +++ b/drivers/gpio/gpio-ath79.c @@ -138,7 +138,7 @@ static const struct of_device_id ath79_gpio_of_match[] = { static int ath79_gpio_probe(struct platform_device *pdev) { - struct ath79_gpio_platform_data *pdata = pdev->dev.platform_data; + struct ath79_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); struct device_node *np = pdev->dev.of_node; struct ath79_gpio_ctrl *ctrl; struct resource *res; diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index cf31179726b1..9fd32f76ffa7 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -149,7 +149,7 @@ davinci_gpio_get_pdata(struct platform_device *pdev) u32 val; if (!IS_ENABLED(CONFIG_OF) || !pdev->dev.of_node) - return pdev->dev.platform_data; + return dev_get_platdata(&pdev->dev); pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio-f7188x.c index 1734e4fbd2b5..2be7337cf4ae 100644 --- a/drivers/gpio/gpio-f7188x.c +++ b/drivers/gpio/gpio-f7188x.c @@ -298,7 +298,7 @@ static int f7188x_gpio_probe(struct platform_device *pdev) { int err; int i; - struct f7188x_sio *sio = pdev->dev.platform_data; + struct f7188x_sio *sio = dev_get_platdata(&pdev->dev); struct f7188x_gpio_data *data; data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); diff --git a/drivers/gpio/gpio-octeon.c b/drivers/gpio/gpio-octeon.c index 3c66ce4fe9ed..afbb2417dfbc 100644 --- a/drivers/gpio/gpio-octeon.c +++ b/drivers/gpio/gpio-octeon.c @@ -128,7 +128,7 @@ out: static int octeon_gpio_remove(struct platform_device *pdev) { - struct gpio_chip *chip = pdev->dev.platform_data; + struct gpio_chip *chip = dev_get_platdata(&pdev->dev); gpiochip_remove(chip); return 0; } diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c index 3841398d1078..b454792de778 100644 --- a/drivers/gpio/gpio-sch311x.c +++ b/drivers/gpio/gpio-sch311x.c @@ -229,7 +229,7 @@ static int sch311x_gpio_direction_out(struct gpio_chip *chip, unsigned offset, static int sch311x_gpio_probe(struct platform_device *pdev) { - struct sch311x_pdev_data *pdata = pdev->dev.platform_data; + struct sch311x_pdev_data *pdata = dev_get_platdata(&pdev->dev); struct sch311x_gpio_priv *priv; struct sch311x_gpio_block *block; int err, i; @@ -289,7 +289,7 @@ exit_err: static int sch311x_gpio_remove(struct platform_device *pdev) { - struct sch311x_pdev_data *pdata = pdev->dev.platform_data; + struct sch311x_pdev_data *pdata = dev_get_platdata(&pdev->dev); struct sch311x_gpio_priv *priv = platform_get_drvdata(pdev); int i; -- cgit From 6ddcf9b486f134f1a1544c82b36b0876ef2f33e6 Mon Sep 17 00:00:00 2001 From: William Breathitt Gray Date: Mon, 23 Nov 2015 12:54:50 -0500 Subject: gpio: Add GPIO support for the ACCES 104-IDI-48 The ACCES 104-IDI-48 family of PC/104 utility boards feature 48 individually optically isolated digital inputs. Enabled inputs feature change-of-state detection capability; if change-of-state detection is enabled, an interrupt is fired off if a change of input level (low-to-high or high-to-low) is detected. Change-of-state IRQs are enabled/disabled on 8-bit boundaries, for a total of six boundaries. This driver provides GPIO and IRQ support for these 48 channels of digital input. The base port address for the device may be configured via the idi_48_base module parameter. The interrupt line number for the device may be configured via the idi_48_irq module parameter. Signed-off-by: William Breathitt Gray Signed-off-by: Linus Walleij --- MAINTAINERS | 6 + drivers/gpio/Kconfig | 9 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-104-idi-48.c | 349 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 365 insertions(+) create mode 100644 drivers/gpio/gpio-104-idi-48.c diff --git a/MAINTAINERS b/MAINTAINERS index 629727e43d08..f04fb49ef05e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -240,6 +240,12 @@ L: lm-sensors@lm-sensors.org S: Maintained F: drivers/hwmon/abituguru3.c +ACCES 104-IDI-48 GPIO DRIVER +M: "William Breathitt Gray" +L: linux-gpio@vger.kernel.org +S: Maintained +F: drivers/gpio/gpio-104-idi-48.c + ACCES 104-IDIO-16 GPIO DRIVER M: "William Breathitt Gray" L: linux-gpio@vger.kernel.org diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 18e1aa05a616..30d8bd3ed623 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -503,6 +503,15 @@ config GPIO_104_IDIO_16 parameter. The interrupt line number for the device may be set via the idio_16_irq module parameter. +config GPIO_104_IDI_48 + tristate "ACCES 104-IDI-48 GPIO support" + select GPIOLIB_IRQCHIP + help + Enables GPIO support for the ACCES 104-IDI-48 family. The base port + address for the device may be configured via the idi_48_base module + parameter. The interrupt line number for the device may be configured + via the idi_48_irq module parameter. + config GPIO_F7188X tristate "F71869, F71869A, F71882FG and F71889F GPIO support" help diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 986dbd838cea..548e9b5718ee 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_GPIO_ACPI) += gpiolib-acpi.o obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o +obj-$(CONFIG_GPIO_104_IDI_48) += gpio-104-idi-48.o obj-$(CONFIG_GPIO_74X164) += gpio-74x164.o obj-$(CONFIG_GPIO_74XX_MMIO) += gpio-74xx-mmio.o obj-$(CONFIG_GPIO_ADNP) += gpio-adnp.o diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c new file mode 100644 index 000000000000..b5c693409a58 --- /dev/null +++ b/drivers/gpio/gpio-104-idi-48.c @@ -0,0 +1,349 @@ +/* + * GPIO driver for the ACCES 104-IDI-48 family + * Copyright (C) 2015 William Breathitt Gray + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static unsigned idi_48_base; +module_param(idi_48_base, uint, 0); +MODULE_PARM_DESC(idi_48_base, "ACCES 104-IDI-48 base address"); +static unsigned idi_48_irq; +module_param(idi_48_irq, uint, 0); +MODULE_PARM_DESC(idi_48_irq, "ACCES 104-IDI-48 interrupt line number"); + +/** + * struct idi_48_gpio - GPIO device private data structure + * @chip: instance of the gpio_chip + * @lock: synchronization lock to prevent I/O race conditions + * @irq_mask: input bits affected by interrupts + * @base: base port address of the GPIO device + * @extent: extent of port address region of the GPIO device + * @irq: Interrupt line number + * @cos_enb: Change-Of-State IRQ enable boundaries mask + */ +struct idi_48_gpio { + struct gpio_chip chip; + spinlock_t lock; + unsigned char irq_mask[6]; + unsigned base; + unsigned extent; + unsigned irq; + unsigned char cos_enb; +}; + +static int idi_48_gpio_get_direction(struct gpio_chip *chip, unsigned offset) +{ + return 1; +} + +static int idi_48_gpio_direction_input(struct gpio_chip *chip, unsigned offset) +{ + return 0; +} + +static struct idi_48_gpio *to_idi48gpio(struct gpio_chip *gc) +{ + return container_of(gc, struct idi_48_gpio, chip); +} + +static int idi_48_gpio_get(struct gpio_chip *chip, unsigned offset) +{ + struct idi_48_gpio *const idi48gpio = to_idi48gpio(chip); + unsigned i; + const unsigned register_offset[6] = { 0, 1, 2, 4, 5, 6 }; + unsigned base_offset; + unsigned mask; + + for (i = 0; i < 48; i += 8) + if (offset < i + 8) { + base_offset = register_offset[i / 8]; + mask = BIT(offset - i); + + return !!(inb(idi48gpio->base + base_offset) & mask); + } + + /* The following line should never execute since offset < 48 */ + return 0; +} + +static void idi_48_irq_ack(struct irq_data *data) +{ + struct gpio_chip *chip = irq_data_get_irq_chip_data(data); + struct idi_48_gpio *const idi48gpio = to_idi48gpio(chip); + unsigned long flags; + + spin_lock_irqsave(&idi48gpio->lock, flags); + + inb(idi48gpio->base + 7); + + spin_unlock_irqrestore(&idi48gpio->lock, flags); +} + +static void idi_48_irq_mask(struct irq_data *data) +{ + struct gpio_chip *chip = irq_data_get_irq_chip_data(data); + struct idi_48_gpio *const idi48gpio = to_idi48gpio(chip); + const unsigned offset = irqd_to_hwirq(data); + unsigned i; + unsigned mask; + unsigned boundary; + unsigned long flags; + + for (i = 0; i < 48; i += 8) + if (offset < i + 8) { + mask = BIT(offset - i); + boundary = i / 8; + + idi48gpio->irq_mask[boundary] &= ~mask; + + if (!idi48gpio->irq_mask[boundary]) { + idi48gpio->cos_enb &= ~BIT(boundary); + + spin_lock_irqsave(&idi48gpio->lock, flags); + + outb(idi48gpio->cos_enb, idi48gpio->base + 7); + + spin_unlock_irqrestore(&idi48gpio->lock, flags); + } + + return; + } +} + +static void idi_48_irq_unmask(struct irq_data *data) +{ + struct gpio_chip *chip = irq_data_get_irq_chip_data(data); + struct idi_48_gpio *const idi48gpio = to_idi48gpio(chip); + const unsigned offset = irqd_to_hwirq(data); + unsigned i; + unsigned mask; + unsigned boundary; + unsigned prev_irq_mask; + unsigned long flags; + + for (i = 0; i < 48; i += 8) + if (offset < i + 8) { + mask = BIT(offset - i); + boundary = i / 8; + prev_irq_mask = idi48gpio->irq_mask[boundary]; + + idi48gpio->irq_mask[boundary] |= mask; + + if (!prev_irq_mask) { + idi48gpio->cos_enb |= BIT(boundary); + + spin_lock_irqsave(&idi48gpio->lock, flags); + + outb(idi48gpio->cos_enb, idi48gpio->base + 7); + + spin_unlock_irqrestore(&idi48gpio->lock, flags); + } + + return; + } +} + +static int idi_48_irq_set_type(struct irq_data *data, unsigned flow_type) +{ + /* The only valid irq types are none and both-edges */ + if (flow_type != IRQ_TYPE_NONE && + (flow_type & IRQ_TYPE_EDGE_BOTH) != IRQ_TYPE_EDGE_BOTH) + return -EINVAL; + + return 0; +} + +static struct irq_chip idi_48_irqchip = { + .name = "104-idi-48", + .irq_ack = idi_48_irq_ack, + .irq_mask = idi_48_irq_mask, + .irq_unmask = idi_48_irq_unmask, + .irq_set_type = idi_48_irq_set_type +}; + +static irqreturn_t idi_48_irq_handler(int irq, void *dev_id) +{ + struct idi_48_gpio *const idi48gpio = dev_id; + unsigned long cos_status; + unsigned long boundary; + unsigned long irq_mask; + unsigned long bit_num; + unsigned long gpio; + struct gpio_chip *const chip = &idi48gpio->chip; + + spin_lock(&idi48gpio->lock); + + cos_status = inb(idi48gpio->base + 7); + + spin_unlock(&idi48gpio->lock); + + /* IRQ Status (bit 6) is active low (0 = IRQ generated by device) */ + if (cos_status & BIT(6)) + return IRQ_NONE; + + /* Bit 0-5 indicate which Change-Of-State boundary triggered the IRQ */ + cos_status &= 0x3F; + + for_each_set_bit(boundary, &cos_status, 6) { + irq_mask = idi48gpio->irq_mask[boundary]; + + for_each_set_bit(bit_num, &irq_mask, 8) { + gpio = bit_num + boundary * 8; + + generic_handle_irq(irq_find_mapping(chip->irqdomain, + gpio)); + } + } + + return IRQ_HANDLED; +} + +static int __init idi_48_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct idi_48_gpio *idi48gpio; + const unsigned base = idi_48_base; + const unsigned extent = 8; + const char *const name = dev_name(dev); + int err; + const unsigned irq = idi_48_irq; + + idi48gpio = devm_kzalloc(dev, sizeof(*idi48gpio), GFP_KERNEL); + if (!idi48gpio) + return -ENOMEM; + + if (!request_region(base, extent, name)) { + dev_err(dev, "Unable to lock %s port addresses (0x%X-0x%X)\n", + name, base, base + extent); + err = -EBUSY; + goto err_lock_io_port; + } + + idi48gpio->chip.label = name; + idi48gpio->chip.parent = dev; + idi48gpio->chip.owner = THIS_MODULE; + idi48gpio->chip.base = -1; + idi48gpio->chip.ngpio = 48; + idi48gpio->chip.get_direction = idi_48_gpio_get_direction; + idi48gpio->chip.direction_input = idi_48_gpio_direction_input; + idi48gpio->chip.get = idi_48_gpio_get; + idi48gpio->base = base; + idi48gpio->extent = extent; + idi48gpio->irq = irq; + + spin_lock_init(&idi48gpio->lock); + + dev_set_drvdata(dev, idi48gpio); + + err = gpiochip_add(&idi48gpio->chip); + if (err) { + dev_err(dev, "GPIO registering failed (%d)\n", err); + goto err_gpio_register; + } + + /* Disable IRQ by default */ + outb(0, base + 7); + inb(base + 7); + + err = gpiochip_irqchip_add(&idi48gpio->chip, &idi_48_irqchip, 0, + handle_edge_irq, IRQ_TYPE_NONE); + if (err) { + dev_err(dev, "Could not add irqchip (%d)\n", err); + goto err_gpiochip_irqchip_add; + } + + err = request_irq(irq, idi_48_irq_handler, 0, name, idi48gpio); + if (err) { + dev_err(dev, "IRQ handler registering failed (%d)\n", err); + goto err_request_irq; + } + + return 0; + +err_request_irq: +err_gpiochip_irqchip_add: + gpiochip_remove(&idi48gpio->chip); +err_gpio_register: + release_region(base, extent); +err_lock_io_port: + return err; +} + +static int idi_48_remove(struct platform_device *pdev) +{ + struct idi_48_gpio *const idi48gpio = platform_get_drvdata(pdev); + + free_irq(idi48gpio->irq, idi48gpio); + gpiochip_remove(&idi48gpio->chip); + release_region(idi48gpio->base, idi48gpio->extent); + + return 0; +} + +static struct platform_device *idi_48_device; + +static struct platform_driver idi_48_driver = { + .driver = { + .name = "104-idi-48" + }, + .remove = idi_48_remove +}; + +static void __exit idi_48_exit(void) +{ + platform_device_unregister(idi_48_device); + platform_driver_unregister(&idi_48_driver); +} + +static int __init idi_48_init(void) +{ + int err; + + idi_48_device = platform_device_alloc(idi_48_driver.driver.name, -1); + if (!idi_48_device) + return -ENOMEM; + + err = platform_device_add(idi_48_device); + if (err) + goto err_platform_device; + + err = platform_driver_probe(&idi_48_driver, idi_48_probe); + if (err) + goto err_platform_driver; + + return 0; + +err_platform_driver: + platform_device_del(idi_48_device); +err_platform_device: + platform_device_put(idi_48_device); + return err; +} + +module_init(idi_48_init); +module_exit(idi_48_exit); + +MODULE_AUTHOR("William Breathitt Gray "); +MODULE_DESCRIPTION("ACCES 104-IDI-48 GPIO driver"); +MODULE_LICENSE("GPL"); -- cgit From 6ddbaed3eff9f60d29805413404251670d2e8f0c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 14:13:59 +0100 Subject: gpio: davinci: fix missed parent conversion I missed to convert this driver properly to use .parent to point to the parent device. ARMv7 multiplatform would not compile. Signed-off-by: Linus Walleij --- drivers/gpio/gpio-davinci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 9fd32f76ffa7..65ebaef935e1 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -254,7 +254,7 @@ static int davinci_gpio_probe(struct platform_device *pdev) #ifdef CONFIG_OF_GPIO chips[i].chip.of_gpio_n_cells = 2; chips[i].chip.of_xlate = davinci_gpio_of_xlate; - chips[i].chip.dev = dev; + chips[i].chip.parent = dev; chips[i].chip.of_node = dev->of_node; #endif spin_lock_init(&chips[i].lock); -- cgit From a1eb9d5751220433998ae2e66216288161b1355b Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 13:32:28 +0100 Subject: ASoC: ac97: fix parent assignment Upstream GPIO has substituted .dev for .parent in struct gpio_chip. Signed-off-by: Linus Walleij --- sound/soc/soc-ac97.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/soc-ac97.c b/sound/soc/soc-ac97.c index ae563e379a72..a2012652f212 100644 --- a/sound/soc/soc-ac97.c +++ b/sound/soc/soc-ac97.c @@ -142,7 +142,7 @@ static int snd_soc_ac97_init_gpio(struct snd_ac97 *ac97, gpio_priv->codec = codec; gpio_priv->gpio_chip = snd_soc_ac97_gpio_chip; gpio_priv->gpio_chip.ngpio = AC97_NUM_GPIOS; - gpio_priv->gpio_chip.dev = codec->dev; + gpio_priv->gpio_chip.parent = codec->dev; gpio_priv->gpio_chip.base = -1; ret = gpiochip_add(&gpio_priv->gpio_chip); -- cgit From 9f49f6dd0473c8fab4522e2e2cb16e93ffb8f3f0 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Tue, 8 Dec 2015 10:19:25 +0000 Subject: gpio: pca953x: add onsemi,pca9654 id Add onsemi,pca9654 which is also compatible with the nxp,pca9524 as it is an 8bit expander with an interrupt output. Signed-off-by: Ben Dooks Signed-off-by: Linus Walleij --- Documentation/devicetree/bindings/gpio/gpio-pca953x.txt | 1 + drivers/gpio/gpio-pca953x.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/gpio/gpio-pca953x.txt b/Documentation/devicetree/bindings/gpio/gpio-pca953x.txt index 13df9933f4cd..6b4a98f74be3 100644 --- a/Documentation/devicetree/bindings/gpio/gpio-pca953x.txt +++ b/Documentation/devicetree/bindings/gpio/gpio-pca953x.txt @@ -25,6 +25,7 @@ Required properties: ti,tca6416 ti,tca6424 ti,tca9539 + onsemi,pca9654 exar,xra1202 Example: diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index ddbbbe57eef8..cad6dc99ae12 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -781,6 +781,8 @@ static const struct of_device_id pca953x_dt_ids[] = { { .compatible = "ti,tca6416", }, { .compatible = "ti,tca6424", }, + { .compatible = "onsemi,pca9654" }, + { .compatible = "exar,xra1202", }, { } }; -- cgit From 6f29c9afbe636fc0e35c82a11eaf45c3b85eb07a Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Tue, 8 Dec 2015 10:19:26 +0000 Subject: gpio: pca935x: fix of-only probed devices If the pca953x device is probed from OF using the proper OF probing then the i2c-client will be NULL and the device probe will fail as id is NULL and it isn't an ACPI device (previous drivers would simply OOPS out). Add support for the of_device_id table having the same data as the others so that the correct paths will be taken when registering a device. An example of current valid of node which did not work: gpio@38 { compatible = "onsemi,pca9654", "nxp,pca9534"; reg = <0x38>; interrupt-parent = <&gpio5>; interrupts = <25 IRQ_TYPE_LEVEL_LOW>; }; Signed-off-by: Ben Dooks Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pca953x.c | 76 ++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index cad6dc99ae12..14729657a112 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -660,6 +660,8 @@ out: return ret; } +static const struct of_device_id pca953x_dt_ids[]; + static int pca953x_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -691,12 +693,18 @@ static int pca953x_probe(struct i2c_client *client, chip->driver_data = id->driver_data; } else { const struct acpi_device_id *id; + const struct of_device_id *match; - id = acpi_match_device(pca953x_acpi_ids, &client->dev); - if (!id) - return -ENODEV; + match = of_match_device(pca953x_dt_ids, &client->dev); + if (match) { + chip->driver_data = (int)(uintptr_t)match->data; + } else { + id = acpi_match_device(pca953x_acpi_ids, &client->dev); + if (!id) + return -ENODEV; - chip->driver_data = id->driver_data; + chip->driver_data = id->driver_data; + } } chip->chip_type = PCA_CHIP_TYPE(chip->driver_data); @@ -755,35 +763,39 @@ static int pca953x_remove(struct i2c_client *client) return 0; } +/* convenience to stop overlong match-table lines */ +#define OF_953X(__nrgpio, __int) (void *)(__nrgpio | PCA953X_TYPE | __int) +#define OF_957X(__nrgpio, __int) (void *)(__nrgpio | PCA957X_TYPE | __int) + static const struct of_device_id pca953x_dt_ids[] = { - { .compatible = "nxp,pca9505", }, - { .compatible = "nxp,pca9534", }, - { .compatible = "nxp,pca9535", }, - { .compatible = "nxp,pca9536", }, - { .compatible = "nxp,pca9537", }, - { .compatible = "nxp,pca9538", }, - { .compatible = "nxp,pca9539", }, - { .compatible = "nxp,pca9554", }, - { .compatible = "nxp,pca9555", }, - { .compatible = "nxp,pca9556", }, - { .compatible = "nxp,pca9557", }, - { .compatible = "nxp,pca9574", }, - { .compatible = "nxp,pca9575", }, - { .compatible = "nxp,pca9698", }, - - { .compatible = "maxim,max7310", }, - { .compatible = "maxim,max7312", }, - { .compatible = "maxim,max7313", }, - { .compatible = "maxim,max7315", }, - - { .compatible = "ti,pca6107", }, - { .compatible = "ti,tca6408", }, - { .compatible = "ti,tca6416", }, - { .compatible = "ti,tca6424", }, - - { .compatible = "onsemi,pca9654" }, - - { .compatible = "exar,xra1202", }, + { .compatible = "nxp,pca9505", .data = OF_953X(40, PCA_INT), }, + { .compatible = "nxp,pca9534", .data = OF_953X( 8, PCA_INT), }, + { .compatible = "nxp,pca9535", .data = OF_953X(16, PCA_INT), }, + { .compatible = "nxp,pca9536", .data = OF_953X( 4, 0), }, + { .compatible = "nxp,pca9537", .data = OF_953X( 4, PCA_INT), }, + { .compatible = "nxp,pca9538", .data = OF_953X( 8, PCA_INT), }, + { .compatible = "nxp,pca9539", .data = OF_953X(16, PCA_INT), }, + { .compatible = "nxp,pca9554", .data = OF_953X( 8, PCA_INT), }, + { .compatible = "nxp,pca9555", .data = OF_953X(16, PCA_INT), }, + { .compatible = "nxp,pca9556", .data = OF_953X( 8, 0), }, + { .compatible = "nxp,pca9557", .data = OF_953X( 8, 0), }, + { .compatible = "nxp,pca9574", .data = OF_957X( 8, PCA_INT), }, + { .compatible = "nxp,pca9575", .data = OF_957X(16, PCA_INT), }, + { .compatible = "nxp,pca9698", .data = OF_953X(40, 0), }, + + { .compatible = "maxim,max7310", .data = OF_953X( 8, 0), }, + { .compatible = "maxim,max7312", .data = OF_953X(16, PCA_INT), }, + { .compatible = "maxim,max7313", .data = OF_953X(16, PCA_INT), }, + { .compatible = "maxim,max7315", .data = OF_953X( 8, PCA_INT), }, + + { .compatible = "ti,pca6107", .data = OF_953X( 8, PCA_INT), }, + { .compatible = "ti,tca6408", .data = OF_953X( 8, PCA_INT), }, + { .compatible = "ti,tca6416", .data = OF_953X(16, PCA_INT), }, + { .compatible = "ti,tca6424", .data = OF_953X(24, PCA_INT), }, + + { .compatible = "onsemi,pca9654", .data = OF_953X( 8, PCA_INT), }, + + { .compatible = "exar,xra1202", .data = OF_953X( 8, 0), }, { } }; -- cgit From c2369d3f8cad978dae54fe2149c055a851c32a02 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Wed, 9 Dec 2015 11:01:33 +0100 Subject: gpio: pca953x: make inclusion of unconditional MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After adding the DT matching in commit 6f29c9afbe636fc0e35c82a11eaf45c3b85eb07a "gpio: pca935x: fix of-only probed devices" compilation fails like this: CC [M] drivers/gpio/gpio-pca953x.o gpio-pca953x.c: In function ‘pca953x_probe’: gpio-pca953x.c:693:11: error: implicit declaration of function ‘of_match_device’ [-Werror=implicit-function-declaration] match = of_match_device(pca953x_dt_ids, &client->dev); ^ gpio-pca953x.c:693:9: warning: assignment makes pointer from integer without a cast [-Wint-conversion] match = of_match_device(pca953x_dt_ids, &client->dev); ^ cc1: some warnings being treated as errors ../scripts/Makefile.build:264: recipe for target 'drivers/gpio/gpio-pca953x.o' failed After removing the conditional inclusion guards compilation works fine again. Might be a module problem so that fix. Cc: Ben Dooks Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pca953x.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 14729657a112..2eaf235a39e5 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -18,9 +18,7 @@ #include #include #include -#ifdef CONFIG_OF_GPIO #include -#endif #include #define PCA953X_INPUT 0 -- cgit From fc0589ca64786a2ade9f916fc9c7ca95d375c182 Mon Sep 17 00:00:00 2001 From: Robert Jarzmik Date: Sat, 28 Nov 2015 22:37:42 +0100 Subject: gpio: pxa: convert to one gpiochip The pxa gpio IP is provided by one chip, which holds multiple banks. Another reason the driver should register only one gpiochip instead of multiple gpiochips (ie. 1 per each bank) is that for pincontrol and devicetree integration (think gpio-ranges), it's impossible to have the contiguous pin range 0..127 mapped to gpios 0..127. This patch, amongst other thinks, paves the path to loosen the bond with the global structure variable pxa_gpio_chip. Signed-off-by: Robert Jarzmik Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pxa.c | 221 ++++++++++++++++++++++++++---------------------- 1 file changed, 120 insertions(+), 101 deletions(-) diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index bce99182578b..540b2115f741 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c @@ -69,15 +69,11 @@ static struct irq_domain *domain; static struct device_node *pxa_gpio_of_node; #endif -struct pxa_gpio_chip { - struct gpio_chip chip; +struct pxa_gpio_bank { void __iomem *regbase; - char label[10]; - unsigned long irq_mask; unsigned long irq_edge_rise; unsigned long irq_edge_fall; - int (*set_wake)(unsigned int gpio, unsigned int on); #ifdef CONFIG_PM unsigned long saved_gplr; @@ -87,6 +83,16 @@ struct pxa_gpio_chip { #endif }; +struct pxa_gpio_chip { + struct device *dev; + struct gpio_chip chip; + struct pxa_gpio_bank *banks; + + int irq0; + int irq1; + int (*set_wake)(unsigned int gpio, unsigned int on); +}; + enum pxa_gpio_type { PXA25X_GPIO = 0, PXA26X_GPIO, @@ -104,9 +110,8 @@ struct pxa_gpio_id { }; static DEFINE_SPINLOCK(gpio_lock); -static struct pxa_gpio_chip *pxa_gpio_chips; +static struct pxa_gpio_chip *pxa_gpio_chip; static enum pxa_gpio_type gpio_type; -static void __iomem *gpio_reg_base; static struct pxa_gpio_id pxa25x_id = { .type = PXA25X_GPIO, @@ -148,17 +153,27 @@ static struct pxa_gpio_id pxa1928_id = { .gpio_nums = 224, }; -#define for_each_gpio_chip(i, c) \ - for (i = 0, c = &pxa_gpio_chips[0]; i <= pxa_last_gpio; i += 32, c++) +#define for_each_gpio_bank(i, b, pc) \ + for (i = 0, b = pc->banks; i <= pxa_last_gpio; i += 32, b++) -static inline void __iomem *gpio_chip_base(struct gpio_chip *c) +static inline struct pxa_gpio_chip *chip_to_pxachip(struct gpio_chip *c) { - return container_of(c, struct pxa_gpio_chip, chip)->regbase; + struct pxa_gpio_chip *pxa_chip = + container_of(c, struct pxa_gpio_chip, chip); + + return pxa_chip; } +static inline void __iomem *gpio_bank_base(struct gpio_chip *c, int gpio) +{ + struct pxa_gpio_bank *bank = chip_to_pxachip(c)->banks + (gpio / 32); -static inline struct pxa_gpio_chip *gpio_to_pxachip(unsigned gpio) + return bank->regbase; +} + +static inline struct pxa_gpio_bank *gpio_to_pxabank(struct gpio_chip *c, + unsigned gpio) { - return &pxa_gpio_chips[gpio_to_bank(gpio)]; + return chip_to_pxachip(c)->banks + gpio / 32; } static inline int gpio_is_pxa_type(int type) @@ -187,15 +202,13 @@ static inline int __gpio_is_inverted(int gpio) * is attributed as "occupied" here (I know this terminology isn't * accurate, you are welcome to propose a better one :-) */ -static inline int __gpio_is_occupied(unsigned gpio) +static inline int __gpio_is_occupied(struct pxa_gpio_chip *pchip, unsigned gpio) { - struct pxa_gpio_chip *pxachip; void __iomem *base; unsigned long gafr = 0, gpdr = 0; int ret, af = 0, dir = 0; - pxachip = gpio_to_pxachip(gpio); - base = gpio_chip_base(&pxachip->chip); + base = gpio_bank_base(&pchip->chip, gpio); gpdr = readl_relaxed(base + GPDR_OFFSET); switch (gpio_type) { @@ -220,7 +233,7 @@ static inline int __gpio_is_occupied(unsigned gpio) static int pxa_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - return chip->base + offset + irq_base; + return offset + irq_base; } int pxa_irq_to_gpio(int irq) @@ -230,8 +243,8 @@ int pxa_irq_to_gpio(int irq) static int pxa_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - void __iomem *base = gpio_chip_base(chip); - uint32_t value, mask = 1 << offset; + void __iomem *base = gpio_bank_base(chip, offset); + uint32_t value, mask = GPIO_bit(offset); unsigned long flags; spin_lock_irqsave(&gpio_lock, flags); @@ -250,8 +263,8 @@ static int pxa_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int pxa_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - void __iomem *base = gpio_chip_base(chip); - uint32_t tmp, mask = 1 << offset; + void __iomem *base = gpio_bank_base(chip, offset); + uint32_t tmp, mask = GPIO_bit(offset); unsigned long flags; writel_relaxed(mask, base + (value ? GPSR_OFFSET : GPCR_OFFSET)); @@ -271,14 +284,18 @@ static int pxa_gpio_direction_output(struct gpio_chip *chip, static int pxa_gpio_get(struct gpio_chip *chip, unsigned offset) { - u32 gplr = readl_relaxed(gpio_chip_base(chip) + GPLR_OFFSET); - return !!(gplr & (1 << offset)); + void __iomem *base = gpio_bank_base(chip, offset); + u32 gplr = readl_relaxed(base + GPLR_OFFSET); + + return !!(gplr & GPIO_bit(offset)); } static void pxa_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - writel_relaxed(1 << offset, gpio_chip_base(chip) + - (value ? GPSR_OFFSET : GPCR_OFFSET)); + void __iomem *base = gpio_bank_base(chip, offset); + + writel_relaxed(GPIO_bit(offset), + base + (value ? GPSR_OFFSET : GPCR_OFFSET)); } #ifdef CONFIG_OF_GPIO @@ -289,61 +306,49 @@ static int pxa_gpio_of_xlate(struct gpio_chip *gc, if (gpiospec->args[0] > pxa_last_gpio) return -EINVAL; - if (gc != &pxa_gpio_chips[gpiospec->args[0] / 32].chip) - return -EINVAL; - if (flags) *flags = gpiospec->args[1]; - return gpiospec->args[0] % 32; + return gpiospec->args[0]; } #endif -static int pxa_init_gpio_chip(int gpio_end, - int (*set_wake)(unsigned int, unsigned int)) +static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, int ngpio, + void __iomem *regbase) { - int i, gpio, nbanks = gpio_to_bank(gpio_end) + 1; - struct pxa_gpio_chip *chips; + int i, gpio, nbanks = DIV_ROUND_UP(ngpio, 32); + struct pxa_gpio_bank *bank; - chips = kzalloc(nbanks * sizeof(struct pxa_gpio_chip), GFP_KERNEL); - if (chips == NULL) { - pr_err("%s: failed to allocate GPIO chips\n", __func__); + pchip->banks = devm_kcalloc(pchip->dev, nbanks, sizeof(*pchip->banks), + GFP_KERNEL); + if (!pchip->banks) return -ENOMEM; - } - for (i = 0, gpio = 0; i < nbanks; i++, gpio += 32) { - struct gpio_chip *c = &chips[i].chip; - - sprintf(chips[i].label, "gpio-%d", i); - chips[i].regbase = gpio_reg_base + BANK_OFF(i); - chips[i].set_wake = set_wake; - - c->base = gpio; - c->label = chips[i].label; - - c->direction_input = pxa_gpio_direction_input; - c->direction_output = pxa_gpio_direction_output; - c->get = pxa_gpio_get; - c->set = pxa_gpio_set; - c->to_irq = pxa_gpio_to_irq; + pchip->chip.label = "gpio-pxa"; + pchip->chip.direction_input = pxa_gpio_direction_input; + pchip->chip.direction_output = pxa_gpio_direction_output; + pchip->chip.get = pxa_gpio_get; + pchip->chip.set = pxa_gpio_set; + pchip->chip.to_irq = pxa_gpio_to_irq; + pchip->chip.ngpio = ngpio; #ifdef CONFIG_OF_GPIO - c->of_node = pxa_gpio_of_node; - c->of_xlate = pxa_gpio_of_xlate; - c->of_gpio_n_cells = 2; + pchip->chip.of_node = pxa_gpio_of_node; + pchip->chip.of_xlate = pxa_gpio_of_xlate; + pchip->chip.of_gpio_n_cells = 2; #endif - /* number of GPIOs on last bank may be less than 32 */ - c->ngpio = (gpio + 31 > gpio_end) ? (gpio_end - gpio + 1) : 32; - gpiochip_add(c); + for (i = 0, gpio = 0; i < nbanks; i++, gpio += 32) { + bank = pchip->banks + i; + bank->regbase = regbase + BANK_OFF(i); } - pxa_gpio_chips = chips; - return 0; + + return gpiochip_add(&pchip->chip); } /* Update only those GRERx and GFERx edge detection register bits if those * bits are set in c->irq_mask */ -static inline void update_edge_detect(struct pxa_gpio_chip *c) +static inline void update_edge_detect(struct pxa_gpio_bank *c) { uint32_t grer, gfer; @@ -357,12 +362,11 @@ static inline void update_edge_detect(struct pxa_gpio_chip *c) static int pxa_gpio_irq_type(struct irq_data *d, unsigned int type) { - struct pxa_gpio_chip *c; + struct pxa_gpio_chip *pchip = pxa_gpio_chip; int gpio = pxa_irq_to_gpio(d->irq); + struct pxa_gpio_bank *c = gpio_to_pxabank(&pchip->chip, gpio); unsigned long gpdr, mask = GPIO_bit(gpio); - c = gpio_to_pxachip(gpio); - if (type == IRQ_TYPE_PROBE) { /* Don't mess with enabled GPIOs using preconfigured edges or * GPIOs set to alternate function or to output during probe @@ -370,7 +374,7 @@ static int pxa_gpio_irq_type(struct irq_data *d, unsigned int type) if ((c->irq_edge_rise | c->irq_edge_fall) & GPIO_bit(gpio)) return 0; - if (__gpio_is_occupied(gpio)) + if (__gpio_is_occupied(pchip, gpio)) return 0; type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; @@ -403,18 +407,17 @@ static int pxa_gpio_irq_type(struct irq_data *d, unsigned int type) static void pxa_gpio_demux_handler(struct irq_desc *desc) { - struct pxa_gpio_chip *c; - int loop, gpio, gpio_base, n; + int loop, gpio, n, handled = 0; unsigned long gedr; struct irq_chip *chip = irq_desc_get_chip(desc); + struct pxa_gpio_chip *pchip = pxa_gpio_chip; + struct pxa_gpio_bank *c; chained_irq_enter(chip, desc); do { loop = 0; - for_each_gpio_chip(gpio, c) { - gpio_base = c->chip.base; - + for_each_gpio_bank(gpio, c, pchip) { gedr = readl_relaxed(c->regbase + GEDR_OFFSET); gedr = gedr & c->irq_mask; writel_relaxed(gedr, c->regbase + GEDR_OFFSET); @@ -422,7 +425,7 @@ static void pxa_gpio_demux_handler(struct irq_desc *desc) for_each_set_bit(n, &gedr, BITS_PER_LONG) { loop = 1; - generic_handle_irq(gpio_to_irq(gpio_base + n)); + generic_handle_irq(gpio_to_irq(gpio + n)); } } } while (loop); @@ -432,41 +435,45 @@ static void pxa_gpio_demux_handler(struct irq_desc *desc) static void pxa_ack_muxed_gpio(struct irq_data *d) { + struct pxa_gpio_chip *pchip = pxa_gpio_chip; int gpio = pxa_irq_to_gpio(d->irq); - struct pxa_gpio_chip *c = gpio_to_pxachip(gpio); + void __iomem *base = gpio_bank_base(&pchip->chip, gpio); - writel_relaxed(GPIO_bit(gpio), c->regbase + GEDR_OFFSET); + writel_relaxed(GPIO_bit(gpio), base + GEDR_OFFSET); } static void pxa_mask_muxed_gpio(struct irq_data *d) { + struct pxa_gpio_chip *pchip = pxa_gpio_chip; int gpio = pxa_irq_to_gpio(d->irq); - struct pxa_gpio_chip *c = gpio_to_pxachip(gpio); + struct pxa_gpio_bank *b = gpio_to_pxabank(&pchip->chip, gpio); + void __iomem *base = gpio_bank_base(&pchip->chip, gpio); uint32_t grer, gfer; - c->irq_mask &= ~GPIO_bit(gpio); + b->irq_mask &= ~GPIO_bit(gpio); - grer = readl_relaxed(c->regbase + GRER_OFFSET) & ~GPIO_bit(gpio); - gfer = readl_relaxed(c->regbase + GFER_OFFSET) & ~GPIO_bit(gpio); - writel_relaxed(grer, c->regbase + GRER_OFFSET); - writel_relaxed(gfer, c->regbase + GFER_OFFSET); + grer = readl_relaxed(base + GRER_OFFSET) & ~GPIO_bit(gpio); + gfer = readl_relaxed(base + GFER_OFFSET) & ~GPIO_bit(gpio); + writel_relaxed(grer, base + GRER_OFFSET); + writel_relaxed(gfer, base + GFER_OFFSET); } static int pxa_gpio_set_wake(struct irq_data *d, unsigned int on) { int gpio = pxa_irq_to_gpio(d->irq); - struct pxa_gpio_chip *c = gpio_to_pxachip(gpio); + struct pxa_gpio_chip *pchip = pxa_gpio_chip; - if (c->set_wake) - return c->set_wake(gpio, on); + if (pchip->set_wake) + return pchip->set_wake(gpio, on); else return 0; } static void pxa_unmask_muxed_gpio(struct irq_data *d) { + struct pxa_gpio_chip *pchip = pxa_gpio_chip; int gpio = pxa_irq_to_gpio(d->irq); - struct pxa_gpio_chip *c = gpio_to_pxachip(gpio); + struct pxa_gpio_bank *c = gpio_to_pxabank(&pchip->chip, gpio); c->irq_mask |= GPIO_bit(gpio); update_edge_detect(c); @@ -533,9 +540,10 @@ const struct irq_domain_ops pxa_irq_domain_ops = { .xlate = irq_domain_xlate_twocell, }; -static int pxa_gpio_probe_dt(struct platform_device *pdev) +static int pxa_gpio_probe_dt(struct platform_device *pdev, + struct pxa_gpio_chip *pchip) { - int ret = 0, nr_gpios; + int nr_gpios; struct device_node *np = pdev->dev.of_node; const struct of_device_id *of_id = of_match_device(pxa_gpio_dt_ids, &pdev->dev); @@ -554,40 +562,44 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev) irq_base = irq_alloc_descs(-1, 0, nr_gpios, 0); if (irq_base < 0) { dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n"); - ret = irq_base; - goto err; + return irq_base; } domain = irq_domain_add_legacy(np, nr_gpios, irq_base, 0, - &pxa_irq_domain_ops, NULL); + &pxa_irq_domain_ops, pchip); pxa_gpio_of_node = np; return 0; -err: - iounmap(gpio_reg_base); - return ret; } #else -#define pxa_gpio_probe_dt(pdev) (-1) +#define pxa_gpio_probe_dt(pdev, pchip) (-1) #endif static int pxa_gpio_probe(struct platform_device *pdev) { - struct pxa_gpio_chip *c; + struct pxa_gpio_chip *pchip; + struct pxa_gpio_bank *c; struct resource *res; struct clk *clk; struct pxa_gpio_platform_data *info; + void __iomem *gpio_reg_base; int gpio, irq, ret, use_of = 0; int irq0 = 0, irq1 = 0, irq_mux, gpio_offset = 0; + pchip = devm_kzalloc(&pdev->dev, sizeof(*pchip), GFP_KERNEL); + if (!pchip) + return -ENOMEM; + pchip->dev = &pdev->dev; + info = dev_get_platdata(&pdev->dev); if (info) { irq_base = info->irq_base; if (irq_base <= 0) return -EINVAL; pxa_last_gpio = pxa_gpio_nums(pdev); + pchip->set_wake = info->gpio_set_wake; } else { irq_base = 0; use_of = 1; - ret = pxa_gpio_probe_dt(pdev); + ret = pxa_gpio_probe_dt(pdev, pchip); if (ret < 0) return -EINVAL; } @@ -626,10 +638,14 @@ static int pxa_gpio_probe(struct platform_device *pdev) } /* Initialize GPIO chips */ - pxa_init_gpio_chip(pxa_last_gpio, info ? info->gpio_set_wake : NULL); + ret = pxa_init_gpio_chip(pchip, pxa_last_gpio + 1, gpio_reg_base); + if (ret) { + clk_put(clk); + return ret; + } /* clear all GPIO edge detects */ - for_each_gpio_chip(gpio, c) { + for_each_gpio_bank(gpio, c, pchip) { writel_relaxed(0, c->regbase + GFER_OFFSET); writel_relaxed(0, c->regbase + GRER_OFFSET); writel_relaxed(~0, c->regbase + GEDR_OFFSET); @@ -664,6 +680,7 @@ static int pxa_gpio_probe(struct platform_device *pdev) irq_set_chained_handler(irq0, pxa_gpio_demux_handler); if (irq1 > 0) irq_set_chained_handler(irq1, pxa_gpio_demux_handler); + pxa_gpio_chip = pchip; irq_set_chained_handler(irq_mux, pxa_gpio_demux_handler); return 0; @@ -711,10 +728,11 @@ device_initcall(pxa_gpio_dt_init); #ifdef CONFIG_PM static int pxa_gpio_suspend(void) { - struct pxa_gpio_chip *c; + struct pxa_gpio_chip *pchip = pxa_gpio_chip; + struct pxa_gpio_bank *c; int gpio; - for_each_gpio_chip(gpio, c) { + for_each_gpio_bank(gpio, c, pchip) { c->saved_gplr = readl_relaxed(c->regbase + GPLR_OFFSET); c->saved_gpdr = readl_relaxed(c->regbase + GPDR_OFFSET); c->saved_grer = readl_relaxed(c->regbase + GRER_OFFSET); @@ -728,10 +746,11 @@ static int pxa_gpio_suspend(void) static void pxa_gpio_resume(void) { - struct pxa_gpio_chip *c; + struct pxa_gpio_chip *pchip = pxa_gpio_chip; + struct pxa_gpio_bank *c; int gpio; - for_each_gpio_chip(gpio, c) { + for_each_gpio_bank(gpio, c, pchip) { /* restore level with set/clear */ writel_relaxed(c->saved_gplr, c->regbase + GPSR_OFFSET); writel_relaxed(~c->saved_gplr, c->regbase + GPCR_OFFSET); -- cgit From 8852b2f7dbf69544fb2ea65896405e11d930e132 Mon Sep 17 00:00:00 2001 From: Robert Jarzmik Date: Sat, 28 Nov 2015 22:37:43 +0100 Subject: gpio: pxa: convert to devm_ioremap Use the device managed ioremap to simplify the probe function. Signed-off-by: Robert Jarzmik Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pxa.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index 540b2115f741..69916c65f094 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c @@ -614,9 +614,8 @@ static int pxa_gpio_probe(struct platform_device *pdev) || (irq_mux <= 0)) return -EINVAL; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) - return -EINVAL; - gpio_reg_base = ioremap(res->start, resource_size(res)); + gpio_reg_base = devm_ioremap(&pdev->dev, res->start, + resource_size(res)); if (!gpio_reg_base) return -EINVAL; @@ -627,13 +626,11 @@ static int pxa_gpio_probe(struct platform_device *pdev) if (IS_ERR(clk)) { dev_err(&pdev->dev, "Error %ld to get gpio clock\n", PTR_ERR(clk)); - iounmap(gpio_reg_base); return PTR_ERR(clk); } ret = clk_prepare_enable(clk); if (ret) { clk_put(clk); - iounmap(gpio_reg_base); return ret; } -- cgit From 384ca3c6a28d27030ec971f20b775c596ff87ae5 Mon Sep 17 00:00:00 2001 From: Robert Jarzmik Date: Sat, 28 Nov 2015 22:37:44 +0100 Subject: gpio: pxa: change the interrupt management The interrupt management is changed by this patch to rely on chip data instead of chained interrupts. The main goal is to loosen the dependency on the global pxa chip structure in favor of the passed chip data. The secondary goal is to better show in /proc/interrupts the difference between interrupts for gpio0 and gpio1 (directly wired to interrupt controller), and the other gpios (wired onto a third line in the interrupt controller). The last advantage of this patch is that the interrupt is actually requested, so that another driver cannot steal this line, or overwrite the handler. Signed-off-by: Robert Jarzmik Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pxa.c | 145 +++++++++++++++++++++++++++--------------------- 1 file changed, 82 insertions(+), 63 deletions(-) diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index 69916c65f094..ccc83faf9275 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c @@ -64,11 +64,6 @@ int pxa_last_gpio; static int irq_base; -#ifdef CONFIG_OF -static struct irq_domain *domain; -static struct device_node *pxa_gpio_of_node; -#endif - struct pxa_gpio_bank { void __iomem *regbase; unsigned long irq_mask; @@ -87,6 +82,7 @@ struct pxa_gpio_chip { struct device *dev; struct gpio_chip chip; struct pxa_gpio_bank *banks; + struct irq_domain *irqdomain; int irq0; int irq1; @@ -231,14 +227,23 @@ static inline int __gpio_is_occupied(struct pxa_gpio_chip *pchip, unsigned gpio) return ret; } -static int pxa_gpio_to_irq(struct gpio_chip *chip, unsigned offset) +int pxa_irq_to_gpio(int irq) { - return offset + irq_base; + struct pxa_gpio_chip *pchip = pxa_gpio_chip; + int irq_gpio0; + + irq_gpio0 = irq_find_mapping(pchip->irqdomain, 0); + if (irq_gpio0 > 0) + return irq - irq_gpio0; + + return irq_gpio0; } -int pxa_irq_to_gpio(int irq) +static int pxa_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - return irq - irq_base; + struct pxa_gpio_chip *pchip = chip_to_pxachip(chip); + + return irq_find_mapping(pchip->irqdomain, offset); } static int pxa_gpio_direction_input(struct gpio_chip *chip, unsigned offset) @@ -314,7 +319,7 @@ static int pxa_gpio_of_xlate(struct gpio_chip *gc, #endif static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, int ngpio, - void __iomem *regbase) + struct device_node *np, void __iomem *regbase) { int i, gpio, nbanks = DIV_ROUND_UP(ngpio, 32); struct pxa_gpio_bank *bank; @@ -332,7 +337,7 @@ static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, int ngpio, pchip->chip.to_irq = pxa_gpio_to_irq; pchip->chip.ngpio = ngpio; #ifdef CONFIG_OF_GPIO - pchip->chip.of_node = pxa_gpio_of_node; + pchip->chip.of_node = np; pchip->chip.of_xlate = pxa_gpio_of_xlate; pchip->chip.of_gpio_n_cells = 2; #endif @@ -362,8 +367,8 @@ static inline void update_edge_detect(struct pxa_gpio_bank *c) static int pxa_gpio_irq_type(struct irq_data *d, unsigned int type) { - struct pxa_gpio_chip *pchip = pxa_gpio_chip; - int gpio = pxa_irq_to_gpio(d->irq); + struct pxa_gpio_chip *pchip = irq_data_get_irq_chip_data(d); + unsigned int gpio = irqd_to_hwirq(d); struct pxa_gpio_bank *c = gpio_to_pxabank(&pchip->chip, gpio); unsigned long gpdr, mask = GPIO_bit(gpio); @@ -405,16 +410,13 @@ static int pxa_gpio_irq_type(struct irq_data *d, unsigned int type) return 0; } -static void pxa_gpio_demux_handler(struct irq_desc *desc) +static irqreturn_t pxa_gpio_demux_handler(int in_irq, void *d) { int loop, gpio, n, handled = 0; unsigned long gedr; - struct irq_chip *chip = irq_desc_get_chip(desc); - struct pxa_gpio_chip *pchip = pxa_gpio_chip; + struct pxa_gpio_chip *pchip = d; struct pxa_gpio_bank *c; - chained_irq_enter(chip, desc); - do { loop = 0; for_each_gpio_bank(gpio, c, pchip) { @@ -428,15 +430,31 @@ static void pxa_gpio_demux_handler(struct irq_desc *desc) generic_handle_irq(gpio_to_irq(gpio + n)); } } + handled += loop; } while (loop); - chained_irq_exit(chip, desc); + return handled ? IRQ_HANDLED : IRQ_NONE; +} + +static irqreturn_t pxa_gpio_direct_handler(int in_irq, void *d) +{ + struct pxa_gpio_chip *pchip = d; + + if (in_irq == pchip->irq0) { + generic_handle_irq(gpio_to_irq(0)); + } else if (in_irq == pchip->irq1) { + generic_handle_irq(gpio_to_irq(1)); + } else { + pr_err("%s() unknown irq %d\n", __func__, in_irq); + return IRQ_NONE; + } + return IRQ_HANDLED; } static void pxa_ack_muxed_gpio(struct irq_data *d) { - struct pxa_gpio_chip *pchip = pxa_gpio_chip; - int gpio = pxa_irq_to_gpio(d->irq); + struct pxa_gpio_chip *pchip = irq_data_get_irq_chip_data(d); + unsigned int gpio = irqd_to_hwirq(d); void __iomem *base = gpio_bank_base(&pchip->chip, gpio); writel_relaxed(GPIO_bit(gpio), base + GEDR_OFFSET); @@ -444,8 +462,8 @@ static void pxa_ack_muxed_gpio(struct irq_data *d) static void pxa_mask_muxed_gpio(struct irq_data *d) { - struct pxa_gpio_chip *pchip = pxa_gpio_chip; - int gpio = pxa_irq_to_gpio(d->irq); + struct pxa_gpio_chip *pchip = irq_data_get_irq_chip_data(d); + unsigned int gpio = irqd_to_hwirq(d); struct pxa_gpio_bank *b = gpio_to_pxabank(&pchip->chip, gpio); void __iomem *base = gpio_bank_base(&pchip->chip, gpio); uint32_t grer, gfer; @@ -460,8 +478,8 @@ static void pxa_mask_muxed_gpio(struct irq_data *d) static int pxa_gpio_set_wake(struct irq_data *d, unsigned int on) { - int gpio = pxa_irq_to_gpio(d->irq); - struct pxa_gpio_chip *pchip = pxa_gpio_chip; + struct pxa_gpio_chip *pchip = irq_data_get_irq_chip_data(d); + unsigned int gpio = irqd_to_hwirq(d); if (pchip->set_wake) return pchip->set_wake(gpio, on); @@ -471,8 +489,8 @@ static int pxa_gpio_set_wake(struct irq_data *d, unsigned int on) static void pxa_unmask_muxed_gpio(struct irq_data *d) { - struct pxa_gpio_chip *pchip = pxa_gpio_chip; - int gpio = pxa_irq_to_gpio(d->irq); + struct pxa_gpio_chip *pchip = irq_data_get_irq_chip_data(d); + unsigned int gpio = irqd_to_hwirq(d); struct pxa_gpio_bank *c = gpio_to_pxabank(&pchip->chip, gpio); c->irq_mask |= GPIO_bit(gpio); @@ -531,6 +549,7 @@ static int pxa_irq_domain_map(struct irq_domain *d, unsigned int irq, { irq_set_chip_and_handler(irq, &pxa_muxed_gpio_chip, handle_edge_irq); + irq_set_chip_data(irq, d->host_data); irq_set_noprobe(irq); return 0; } @@ -544,7 +563,6 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev, struct pxa_gpio_chip *pchip) { int nr_gpios; - struct device_node *np = pdev->dev.of_node; const struct of_device_id *of_id = of_match_device(pxa_gpio_dt_ids, &pdev->dev); const struct pxa_gpio_id *gpio_id; @@ -564,10 +582,7 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev, dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n"); return irq_base; } - domain = irq_domain_add_legacy(np, nr_gpios, irq_base, 0, - &pxa_irq_domain_ops, pchip); - pxa_gpio_of_node = np; - return 0; + return irq_base; } #else #define pxa_gpio_probe_dt(pdev, pchip) (-1) @@ -581,7 +596,7 @@ static int pxa_gpio_probe(struct platform_device *pdev) struct clk *clk; struct pxa_gpio_platform_data *info; void __iomem *gpio_reg_base; - int gpio, irq, ret, use_of = 0; + int gpio, ret; int irq0 = 0, irq1 = 0, irq_mux, gpio_offset = 0; pchip = devm_kzalloc(&pdev->dev, sizeof(*pchip), GFP_KERNEL); @@ -597,22 +612,29 @@ static int pxa_gpio_probe(struct platform_device *pdev) pxa_last_gpio = pxa_gpio_nums(pdev); pchip->set_wake = info->gpio_set_wake; } else { - irq_base = 0; - use_of = 1; - ret = pxa_gpio_probe_dt(pdev, pchip); - if (ret < 0) + irq_base = pxa_gpio_probe_dt(pdev, pchip); + if (irq_base < 0) return -EINVAL; } if (!pxa_last_gpio) return -EINVAL; + pchip->irqdomain = irq_domain_add_legacy(pdev->dev.of_node, + pxa_last_gpio + 1, irq_base, + 0, &pxa_irq_domain_ops, pchip); + if (IS_ERR(pchip->irqdomain)) + return PTR_ERR(pchip->irqdomain); + irq0 = platform_get_irq_byname(pdev, "gpio0"); irq1 = platform_get_irq_byname(pdev, "gpio1"); irq_mux = platform_get_irq_byname(pdev, "gpio_mux"); if ((irq0 > 0 && irq1 <= 0) || (irq0 <= 0 && irq1 > 0) || (irq_mux <= 0)) return -EINVAL; + + pchip->irq0 = irq0; + pchip->irq1 = irq1; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); gpio_reg_base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); @@ -635,7 +657,8 @@ static int pxa_gpio_probe(struct platform_device *pdev) } /* Initialize GPIO chips */ - ret = pxa_init_gpio_chip(pchip, pxa_last_gpio + 1, gpio_reg_base); + ret = pxa_init_gpio_chip(pchip, pxa_last_gpio + 1, pdev->dev.of_node, + gpio_reg_base); if (ret) { clk_put(clk); return ret; @@ -651,35 +674,31 @@ static int pxa_gpio_probe(struct platform_device *pdev) writel_relaxed(~0, c->regbase + ED_MASK_OFFSET); } - if (!use_of) { - if (irq0 > 0) { - irq = gpio_to_irq(0); - irq_set_chip_and_handler(irq, &pxa_muxed_gpio_chip, - handle_edge_irq); - irq_clear_status_flags(irq, IRQ_NOREQUEST | IRQ_NOPROBE); - } - if (irq1 > 0) { - irq = gpio_to_irq(1); - irq_set_chip_and_handler(irq, &pxa_muxed_gpio_chip, - handle_edge_irq); - irq_clear_status_flags(irq, IRQ_NOREQUEST | IRQ_NOPROBE); - } - - for (irq = gpio_to_irq(gpio_offset); - irq <= gpio_to_irq(pxa_last_gpio); irq++) { - irq_set_chip_and_handler(irq, &pxa_muxed_gpio_chip, - handle_edge_irq); - irq_clear_status_flags(irq, IRQ_NOREQUEST | IRQ_NOPROBE); - } + if (irq0 > 0) { + ret = devm_request_irq(&pdev->dev, + irq0, pxa_gpio_direct_handler, 0, + "gpio-0", pchip); + if (ret) + dev_err(&pdev->dev, "request of gpio0 irq failed: %d\n", + ret); } + if (irq1 > 0) { + ret = devm_request_irq(&pdev->dev, + irq1, pxa_gpio_direct_handler, 0, + "gpio-1", pchip); + if (ret) + dev_err(&pdev->dev, "request of gpio1 irq failed: %d\n", + ret); + } + ret = devm_request_irq(&pdev->dev, + irq_mux, pxa_gpio_demux_handler, 0, + "gpio-mux", pchip); + if (ret) + dev_err(&pdev->dev, "request of gpio-mux irq failed: %d\n", + ret); - if (irq0 > 0) - irq_set_chained_handler(irq0, pxa_gpio_demux_handler); - if (irq1 > 0) - irq_set_chained_handler(irq1, pxa_gpio_demux_handler); pxa_gpio_chip = pchip; - irq_set_chained_handler(irq_mux, pxa_gpio_demux_handler); return 0; } -- cgit From 410f4574f43c8bd61cd413a15e26e8f03c608085 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 30 Nov 2015 15:35:25 +0100 Subject: gpio: 74x164: Allocate buffer with gen_74x164_chip By moving the internal buffer to the end of struct gen_74x164_chip and converting it from a pointer to a zero-sized array, it can be allocated together with gen_74x164_chip, reducing the number of managed allocations. Signed-off-by: Geert Uytterhoeven Signed-off-by: Linus Walleij --- drivers/gpio/gpio-74x164.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index fb555300008f..b0939e0ff0b9 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -20,10 +20,10 @@ #define GEN_74X164_NUMBER_GPIOS 8 struct gen_74x164_chip { - u8 *buffer; struct gpio_chip gpio_chip; struct mutex lock; u32 registers; + u8 buffer[0]; }; static struct gen_74x164_chip *gpio_to_74x164_chip(struct gpio_chip *gc) @@ -107,6 +107,7 @@ static int gen_74x164_direction_output(struct gpio_chip *gc, static int gen_74x164_probe(struct spi_device *spi) { struct gen_74x164_chip *chip; + u32 nregs; int ret; /* @@ -118,7 +119,14 @@ static int gen_74x164_probe(struct spi_device *spi) if (ret < 0) return ret; - chip = devm_kzalloc(&spi->dev, sizeof(*chip), GFP_KERNEL); + if (of_property_read_u32(spi->dev.of_node, "registers-number", + &nregs)) { + dev_err(&spi->dev, + "Missing registers-number property in the DT.\n"); + return -EINVAL; + } + + chip = devm_kzalloc(&spi->dev, sizeof(*chip) + nregs, GFP_KERNEL); if (!chip) return -ENOMEM; @@ -130,17 +138,8 @@ static int gen_74x164_probe(struct spi_device *spi) chip->gpio_chip.set = gen_74x164_set_value; chip->gpio_chip.base = -1; - if (of_property_read_u32(spi->dev.of_node, "registers-number", - &chip->registers)) { - dev_err(&spi->dev, - "Missing registers-number property in the DT.\n"); - return -EINVAL; - } - + chip->registers = nregs; chip->gpio_chip.ngpio = GEN_74X164_NUMBER_GPIOS * chip->registers; - chip->buffer = devm_kzalloc(&spi->dev, chip->registers, GFP_KERNEL); - if (!chip->buffer) - return -ENOMEM; chip->gpio_chip.can_sleep = true; chip->gpio_chip.parent = &spi->dev; -- cgit From 902e7e60086b925e27f68261feda4898c5be6966 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 30 Nov 2015 15:35:26 +0100 Subject: gpio: 74x164: Use a single SPI transfer instead of multiple transfers Currently the 74x164 driver assembles an SPI message from an array of one-byte SPI transfers, one for each daisy-chained shift register, as the first byte sent will end up in the last register. This array is allocated and deallocated on each GPIO write access. By storing the data in the internal buffer in reverse order, we can use a single SPI transfer with the internal buffer directly, simplifying the code a lot, and avoiding memory (de)allocations. This also avoids transient values on the GPIO outputs when using an SPI master that cannot keep the hardware chip select asserted in between multiple transfers (and would need cs-gpios for proper operation). Signed-off-by: Geert Uytterhoeven Cc: Mark Brown [Rebased changing .dev to .parent] Signed-off-by: Linus Walleij --- drivers/gpio/gpio-74x164.c | 47 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index b0939e0ff0b9..54a4147fba52 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -23,6 +23,13 @@ struct gen_74x164_chip { struct gpio_chip gpio_chip; struct mutex lock; u32 registers; + /* + * Since the registers are chained, every byte sent will make + * the previous byte shift to the next register in the + * chain. Thus, the first byte sent will end up in the last + * register at the end of the transfer. So, to have a logical + * numbering, store the bytes in reverse order. + */ u8 buffer[0]; }; @@ -33,43 +40,19 @@ static struct gen_74x164_chip *gpio_to_74x164_chip(struct gpio_chip *gc) static int __gen_74x164_write_config(struct gen_74x164_chip *chip) { - struct spi_device *spi = to_spi_device(chip->gpio_chip.parent); - struct spi_message message; - struct spi_transfer *msg_buf; - int i, ret = 0; - - msg_buf = kzalloc(chip->registers * sizeof(struct spi_transfer), - GFP_KERNEL); - if (!msg_buf) - return -ENOMEM; - - spi_message_init(&message); + struct spi_transfer xfer = { + .tx_buf = chip->buffer, + .len = chip->registers, + }; - /* - * Since the registers are chained, every byte sent will make - * the previous byte shift to the next register in the - * chain. Thus, the first byte send will end up in the last - * register at the end of the transfer. So, to have a logical - * numbering, send the bytes in reverse order so that the last - * byte of the buffer will end up in the last register. - */ - for (i = chip->registers - 1; i >= 0; i--) { - msg_buf[i].tx_buf = chip->buffer + i; - msg_buf[i].len = sizeof(u8); - spi_message_add_tail(msg_buf + i, &message); - } - - ret = spi_sync(spi, &message); - - kfree(msg_buf); - - return ret; + return spi_sync_transfer(to_spi_device(chip->gpio_chip.parent), + &xfer, 1); } static int gen_74x164_get_value(struct gpio_chip *gc, unsigned offset) { struct gen_74x164_chip *chip = gpio_to_74x164_chip(gc); - u8 bank = offset / 8; + u8 bank = chip->registers - 1 - offset / 8; u8 pin = offset % 8; int ret; @@ -84,7 +67,7 @@ static void gen_74x164_set_value(struct gpio_chip *gc, unsigned offset, int val) { struct gen_74x164_chip *chip = gpio_to_74x164_chip(gc); - u8 bank = offset / 8; + u8 bank = chip->registers - 1 - offset / 8; u8 pin = offset % 8; mutex_lock(&chip->lock); -- cgit From dfaf19de59cab02177d94ee3b0b8c0e243016f3f Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Mon, 30 Nov 2015 16:21:37 +0000 Subject: gpio: pch: allow build on MIPS platforms Allow the pch_gpio driver to be built for MIPS platforms, in preparation for use on the MIPS Boston board. Signed-off-by: Paul Burton Signed-off-by: Linus Walleij --- drivers/gpio/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 30d8bd3ed623..535c4c4dd5f2 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -965,7 +965,7 @@ config GPIO_ML_IOH config GPIO_PCH tristate "Intel EG20T PCH/LAPIS Semiconductor IOH(ML7223/ML7831) GPIO" - depends on PCI && (X86_32 || COMPILE_TEST) + depends on PCI && (X86_32 || MIPS || COMPILE_TEST) select GENERIC_IRQ_CHIP help This driver is for PCH(Platform controller Hub) GPIO of Intel Topcliff -- cgit From 1cfadea8f395e3fb6a15ea548e3e86c8b6d64f98 Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Mon, 30 Nov 2015 16:21:38 +0000 Subject: gpio: pch: allow use from device tree Allow GPIOs from the gpio-pch driver to be referenced from device tree by simply setting the struct gpio_chip of_node pointer to that of the struct pci_dev. Signed-off-by: Paul Burton Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpio/gpio-pch.c b/drivers/gpio/gpio-pch.c index e43db64e52b3..a650a6cc1312 100644 --- a/drivers/gpio/gpio-pch.c +++ b/drivers/gpio/gpio-pch.c @@ -394,6 +394,7 @@ static int pch_gpio_probe(struct pci_dev *pdev, pci_set_drvdata(pdev, chip); spin_lock_init(&chip->spinlock); pch_gpio_setup(chip); + chip->gpio.of_node = pdev->dev.of_node; ret = gpiochip_add(&chip->gpio); if (ret) { dev_err(&pdev->dev, "PCH gpio: Failed to register GPIO\n"); -- cgit From 0374452968bbd05098b176f8074d8c577eb97c57 Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Sun, 6 Dec 2015 14:52:45 -0600 Subject: gpio: drop surplus PCI and USB dependencies The PCI/USB expander menus already depend on PCI/USB, drop subdependecies on individual drivers. Signed-off-by: Andrew F. Davis [Rebased to the GPIO tree] Signed-off-by: Linus Walleij --- drivers/gpio/Kconfig | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 535c4c4dd5f2..b60f40a423f3 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -920,7 +920,6 @@ menu "PCI GPIO expanders" config GPIO_AMD8111 tristate "AMD 8111 GPIO driver" - depends on PCI help The AMD 8111 south bridge contains 32 GPIO pins which can be used. @@ -932,7 +931,7 @@ config GPIO_AMD8111 config GPIO_BT8XX tristate "BT8XX GPIO abuser" - depends on PCI && VIDEO_BT848=n + depends on VIDEO_BT848=n help The BT8xx frame grabber chip has 24 GPIO pins that can be abused as a cheap PCI GPIO card. @@ -948,14 +947,13 @@ config GPIO_BT8XX config GPIO_INTEL_MID bool "Intel Mid GPIO support" - depends on PCI && X86 + depends on X86 select GPIOLIB_IRQCHIP help Say Y here to support Intel Mid GPIO. config GPIO_ML_IOH tristate "OKI SEMICONDUCTOR ML7213 IOH GPIO support" - depends on PCI select GENERIC_IRQ_CHIP help ML7213 is companion chip for Intel Atom E6xx series. @@ -965,7 +963,7 @@ config GPIO_ML_IOH config GPIO_PCH tristate "Intel EG20T PCH/LAPIS Semiconductor IOH(ML7223/ML7831) GPIO" - depends on PCI && (X86_32 || MIPS || COMPILE_TEST) + depends on X86_32 || MIPS || COMPILE_TEST select GENERIC_IRQ_CHIP help This driver is for PCH(Platform controller Hub) GPIO of Intel Topcliff @@ -981,7 +979,6 @@ config GPIO_PCH config GPIO_RDC321X tristate "RDC R-321x GPIO support" - depends on PCI select MFD_CORE select MFD_RDC321X help @@ -990,7 +987,7 @@ config GPIO_RDC321X config GPIO_SODAVILLE bool "Intel Sodaville GPIO support" - depends on X86 && PCI && OF + depends on X86 && OF select GPIO_GENERIC select GENERIC_IRQ_CHIP help @@ -1041,7 +1038,7 @@ menu "USB GPIO expanders" config GPIO_VIPERBOARD tristate "Viperboard GPIO a & b support" - depends on MFD_VIPERBOARD && USB + depends on MFD_VIPERBOARD help Say yes here to access the GPIO signals of Nano River Technologies Viperboard. There are two GPIO chips on the -- cgit From 01821412eeb10ca996da0824d2d56d9a13b5c013 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 10 Dec 2015 18:50:51 +0100 Subject: pinctrl: nsp-gpio: fix up parent attribute The .dev field has been renamed .parent in the GPIO tree. Fix it up. Cc: Yendapally Reddy Dhananjaya Reddy Signed-off-by: Linus Walleij --- drivers/pinctrl/bcm/pinctrl-nsp-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c index 06b7aaf3548c..bb7891e786e3 100644 --- a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c +++ b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c @@ -668,7 +668,7 @@ static int nsp_gpio_probe(struct platform_device *pdev) gc->can_sleep = false; gc->ngpio = val; gc->label = dev_name(dev); - gc->dev = dev; + gc->parent = dev; gc->of_node = dev->of_node; gc->request = nsp_gpio_request; gc->free = nsp_gpio_free; -- cgit From 12b61c9d7e0750f2569392999fcfa85778185b06 Mon Sep 17 00:00:00 2001 From: William Breathitt Gray Date: Wed, 2 Dec 2015 20:23:04 -0500 Subject: gpio: 104-idio-16: Clear pending interrupt in IRQ handler The ACCES 104-IDIO-16 uses a single interrupt to indicate a possible change-of-state in any of the digital input lines. As such, only a single write to the device's "Clear Interrupt" register is necessary to acknowledge the IRQ for all respective GPIO. This patch moves the "Clear Interrupt" register write operation from the irq_ack callback to the IRQ handler function, wherefore each interrupt may be cleared respectively by executing a single outb call at the end of the idio_16_irq_handler function, rather than multiple redundant outb calls as a result of the generic_handle_irq call for each masked GPIO. Signed-off-by: William Breathitt Gray Signed-off-by: Linus Walleij --- drivers/gpio/gpio-104-idio-16.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c index efe3ff7d574e..91c8b5b17f64 100644 --- a/drivers/gpio/gpio-104-idio-16.c +++ b/drivers/gpio/gpio-104-idio-16.c @@ -117,15 +117,6 @@ static void idio_16_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static void idio_16_irq_ack(struct irq_data *data) { - struct gpio_chip *chip = irq_data_get_irq_chip_data(data); - struct idio_16_gpio *const idio16gpio = to_idio16gpio(chip); - unsigned long flags; - - spin_lock_irqsave(&idio16gpio->lock, flags); - - outb(0, idio16gpio->base + 1); - - spin_unlock_irqrestore(&idio16gpio->lock, flags); } static void idio_16_irq_mask(struct irq_data *data) @@ -159,7 +150,6 @@ static void idio_16_irq_unmask(struct irq_data *data) if (!prev_irq_mask) { spin_lock_irqsave(&idio16gpio->lock, flags); - outb(0, idio16gpio->base + 1); inb(idio16gpio->base + 2); spin_unlock_irqrestore(&idio16gpio->lock, flags); @@ -193,6 +183,12 @@ static irqreturn_t idio_16_irq_handler(int irq, void *dev_id) for_each_set_bit(gpio, &idio16gpio->irq_mask, chip->ngpio) generic_handle_irq(irq_find_mapping(chip->irqdomain, gpio)); + spin_lock(&idio16gpio->lock); + + outb(0, idio16gpio->base + 1); + + spin_unlock(&idio16gpio->lock); + return IRQ_HANDLED; } @@ -244,6 +240,7 @@ static int __init idio_16_probe(struct platform_device *pdev) /* Disable IRQ by default */ outb(0, base + 2); + outb(0, base + 1); err = gpiochip_irqchip_add(&idio16gpio->chip, &idio_16_irqchip, 0, handle_edge_irq, IRQ_TYPE_NONE); -- cgit From 20d7090ffd4a30c66f3e2eb6741bb1e5baa56e8b Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Wed, 2 Dec 2015 17:19:55 +0100 Subject: gpio: mpc5200: Use platform_register/unregister_drivers() These new helpers simplify implementing multi-driver modules and properly handle failure to register one driver by unregistering all previously registered drivers. Signed-off-by: Thierry Reding Signed-off-by: Linus Walleij --- drivers/gpio/gpio-mpc5200.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-mpc5200.c b/drivers/gpio/gpio-mpc5200.c index 4c542153e923..044bbbb747f2 100644 --- a/drivers/gpio/gpio-mpc5200.c +++ b/drivers/gpio/gpio-mpc5200.c @@ -360,15 +360,14 @@ static struct platform_driver mpc52xx_simple_gpiochip_driver = { .remove = mpc52xx_gpiochip_remove, }; +static struct platform_driver * const drivers[] = { + &mpc52xx_wkup_gpiochip_driver, + &mpc52xx_simple_gpiochip_driver, +}; + static int __init mpc52xx_gpio_init(void) { - if (platform_driver_register(&mpc52xx_wkup_gpiochip_driver)) - printk(KERN_ERR "Unable to register wakeup GPIO driver\n"); - - if (platform_driver_register(&mpc52xx_simple_gpiochip_driver)) - printk(KERN_ERR "Unable to register simple GPIO driver\n"); - - return 0; + return platform_register_drivers(drivers, ARRAY_SIZE(drivers)); } /* Make sure we get initialised before anyone else tries to use us */ @@ -376,9 +375,7 @@ subsys_initcall(mpc52xx_gpio_init); static void __exit mpc52xx_gpio_exit(void) { - platform_driver_unregister(&mpc52xx_wkup_gpiochip_driver); - - platform_driver_unregister(&mpc52xx_simple_gpiochip_driver); + platform_unregister_drivers(drivers, ARRAY_SIZE(drivers)); } module_exit(mpc52xx_gpio_exit); -- cgit From b4818afeacbd81821f89a89951471cffcb6a65e0 Mon Sep 17 00:00:00 2001 From: Phil Reid Date: Fri, 4 Dec 2015 15:52:30 +0800 Subject: gpio: pca953x: Add set_multiple to allow multiple bits to be set in one write. Tested with TCA6408 / TCA6416 devices. Signed-off-by: Phil Reid Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pca953x.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 2eaf235a39e5..be3e3b903ff0 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -350,6 +350,43 @@ exit: mutex_unlock(&chip->i2c_lock); } + +static void pca953x_gpio_set_multiple(struct gpio_chip *gc, + unsigned long *mask, unsigned long *bits) +{ + struct pca953x_chip *chip = to_pca(gc); + u8 reg_val[MAX_BANK]; + int ret, offset = 0; + int bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ); + int bank; + + switch (chip->chip_type) { + case PCA953X_TYPE: + offset = PCA953X_OUTPUT; + break; + case PCA957X_TYPE: + offset = PCA957X_OUT; + break; + } + + memcpy(reg_val, chip->reg_output, NBANK(chip)); + mutex_lock(&chip->i2c_lock); + for(bank=0; bank> ((bank % 4) * 8); + if(bankmask) { + unsigned bankval = bits[bank/4] >> ((bank % 4) * 8); + reg_val[bank] = (reg_val[bank] & ~bankmask) | bankval; + } + } + ret = i2c_smbus_write_i2c_block_data(chip->client, offset << bank_shift, NBANK(chip), reg_val); + if (ret) + goto exit; + + memcpy(chip->reg_output, reg_val, NBANK(chip)); +exit: + mutex_unlock(&chip->i2c_lock); +} + static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios) { struct gpio_chip *gc; @@ -360,6 +397,7 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios) gc->direction_output = pca953x_gpio_direction_output; gc->get = pca953x_gpio_get_value; gc->set = pca953x_gpio_set_value; + gc->set_multiple = pca953x_gpio_set_multiple; gc->can_sleep = true; gc->base = chip->gpio_start; -- cgit From 3e640743fee6e6a82ead1f163737755b2a965712 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Fri, 4 Dec 2015 11:05:44 +0100 Subject: pinctrl: lantiq: Implement gpio_chip.to_irq Some drivers require a way to translate GPIO pins to their IRQ numbers. This patch adds the .to_irq() gpiolib callback to the pinctrl-xway driver, which returns an IRQ mapping for a given GPIO pin. Signed-off-by: John Crispin Signed-off-by: Martin Schiller [Switched ->dev to ->parent] Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-xway.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c index b4380fb72001..e56222eac96c 100644 --- a/drivers/pinctrl/pinctrl-xway.c +++ b/drivers/pinctrl/pinctrl-xway.c @@ -682,6 +682,22 @@ static int xway_gpio_dir_out(struct gpio_chip *chip, unsigned int pin, int val) return 0; } +/* + * gpiolib gpiod_to_irq callback function. + * Returns the mapped IRQ (external interrupt) number for a given GPIO pin. + */ +static int xway_gpio_to_irq(struct gpio_chip *chip, unsigned offset) +{ + struct ltq_pinmux_info *info = dev_get_drvdata(chip->parent); + int i; + + for (i = 0; i < info->num_exin; i++) + if (info->exin[i] == offset) + return ltq_eiu_get_irq(i); + + return -1; +} + static struct gpio_chip xway_chip = { .label = "gpio-xway", .direction_input = xway_gpio_dir_in, @@ -690,6 +706,7 @@ static struct gpio_chip xway_chip = { .set = xway_gpio_set, .request = gpiochip_generic_request, .free = gpiochip_generic_free, + .to_irq = xway_gpio_to_irq, .base = -1, }; -- cgit From 0d1bb2b3b838e6731b5900bb3513c10027cb028c Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 4 Dec 2015 15:28:16 +0100 Subject: gpio: Restore indentation of parent device setup Fixes: 58383c78425e4ee1 ("gpio: change member .dev to .parent") Signed-off-by: Geert Uytterhoeven Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pcf857x.c | 2 +- drivers/gpio/gpio-tz1090-pdc.c | 2 +- drivers/gpio/gpio-tz1090.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-pcf857x.c b/drivers/gpio/gpio-pcf857x.c index 407ca5e1aafa..bf511c0efa48 100644 --- a/drivers/gpio/gpio-pcf857x.c +++ b/drivers/gpio/gpio-pcf857x.c @@ -293,7 +293,7 @@ static int pcf857x_probe(struct i2c_client *client, gpio->chip.base = pdata ? pdata->gpio_base : -1; gpio->chip.can_sleep = true; - gpio->chip.parent = &client->dev; + gpio->chip.parent = &client->dev; gpio->chip.owner = THIS_MODULE; gpio->chip.get = pcf857x_get; gpio->chip.set = pcf857x_set; diff --git a/drivers/gpio/gpio-tz1090-pdc.c b/drivers/gpio/gpio-tz1090-pdc.c index a974397164b2..0a01c8736aff 100644 --- a/drivers/gpio/gpio-tz1090-pdc.c +++ b/drivers/gpio/gpio-tz1090-pdc.c @@ -188,7 +188,7 @@ static int tz1090_pdc_gpio_probe(struct platform_device *pdev) /* Set up GPIO chip */ priv->chip.label = "tz1090-pdc-gpio"; - priv->chip.parent = &pdev->dev; + priv->chip.parent = &pdev->dev; priv->chip.direction_input = tz1090_pdc_gpio_direction_input; priv->chip.direction_output = tz1090_pdc_gpio_direction_output; priv->chip.get = tz1090_pdc_gpio_get; diff --git a/drivers/gpio/gpio-tz1090.c b/drivers/gpio/gpio-tz1090.c index 7858d90202f3..79ef6e1ce568 100644 --- a/drivers/gpio/gpio-tz1090.c +++ b/drivers/gpio/gpio-tz1090.c @@ -425,7 +425,7 @@ static int tz1090_gpio_bank_probe(struct tz1090_gpio_bank_info *info) snprintf(bank->label, sizeof(bank->label), "tz1090-gpio-%u", info->index); bank->chip.label = bank->label; - bank->chip.parent = dev; + bank->chip.parent = dev; bank->chip.direction_input = tz1090_gpio_direction_input; bank->chip.direction_output = tz1090_gpio_direction_output; bank->chip.get = tz1090_gpio_get; -- cgit From 8b092be9fd6a2cd84c437128e9b0d85e364efcfb Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 4 Dec 2015 16:33:52 +0100 Subject: gpio: rcar: Remove obsolete platform data support Since commit 4baadb9e05c68962 ("ARM: shmobile: r8a7778: remove obsolete setup code"), Renesas R-Car SoCs are only supported in generic DT-only ARM multi-platform builds. The driver doesn't need to use platform data anymore, hence remove platform data configuration. Make gpio_rcar_priv.has_both_edge_trigger a boolean for consistency with gpio_rcar_info.has_both_edge_trigger. Move gpio_rcar_priv.irq_parent down while we're at it, to prevent gaps on 64-bit. Signed-off-by: Geert Uytterhoeven Acked-by: Simon Horman Signed-off-by: Linus Walleij --- drivers/gpio/gpio-rcar.c | 77 +++++++++++---------------------- include/linux/platform_data/gpio-rcar.h | 29 ------------- 2 files changed, 26 insertions(+), 80 deletions(-) delete mode 100644 include/linux/platform_data/gpio-rcar.h diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index 3cbb25ecfc7a..1ed52fc026cb 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -34,12 +33,12 @@ struct gpio_rcar_priv { void __iomem *base; spinlock_t lock; - struct gpio_rcar_config config; struct platform_device *pdev; struct gpio_chip gpio_chip; struct irq_chip irq_chip; - unsigned int irq_parent; struct clk *clk; + unsigned int irq_parent; + bool has_both_edge_trigger; }; #define IOINTSEL 0x00 /* General IO/Interrupt Switching Register */ @@ -121,7 +120,7 @@ static void gpio_rcar_config_interrupt_input_mode(struct gpio_rcar_priv *p, gpio_rcar_modify_bit(p, EDGLEVEL, hwirq, !level_trigger); /* Select one edge or both edges in BOTHEDGE */ - if (p->config.has_both_edge_trigger) + if (p->has_both_edge_trigger) gpio_rcar_modify_bit(p, BOTHEDGE, hwirq, both); /* Select "Interrupt Input Mode" in IOINTSEL */ @@ -161,7 +160,7 @@ static int gpio_rcar_irq_set_type(struct irq_data *d, unsigned int type) false); break; case IRQ_TYPE_EDGE_BOTH: - if (!p->config.has_both_edge_trigger) + if (!p->has_both_edge_trigger) return -EINVAL; gpio_rcar_config_interrupt_input_mode(p, hwirq, true, false, true); @@ -355,39 +354,29 @@ static const struct of_device_id gpio_rcar_of_table[] = { MODULE_DEVICE_TABLE(of, gpio_rcar_of_table); -static int gpio_rcar_parse_pdata(struct gpio_rcar_priv *p) +static int gpio_rcar_parse_dt(struct gpio_rcar_priv *p, unsigned int *npins) { - struct gpio_rcar_config *pdata = dev_get_platdata(&p->pdev->dev); struct device_node *np = p->pdev->dev.of_node; + const struct of_device_id *match; + const struct gpio_rcar_info *info; struct of_phandle_args args; int ret; - if (pdata) { - p->config = *pdata; - } else if (IS_ENABLED(CONFIG_OF) && np) { - const struct of_device_id *match; - const struct gpio_rcar_info *info; + match = of_match_node(gpio_rcar_of_table, np); + if (!match) + return -EINVAL; - match = of_match_node(gpio_rcar_of_table, np); - if (!match) - return -EINVAL; + info = match->data; - info = match->data; + ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0, &args); + *npins = ret == 0 ? args.args[2] : RCAR_MAX_GPIO_PER_BANK; + p->has_both_edge_trigger = info->has_both_edge_trigger; - ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0, - &args); - p->config.number_of_pins = ret == 0 ? args.args[2] - : RCAR_MAX_GPIO_PER_BANK; - p->config.gpio_base = -1; - p->config.has_both_edge_trigger = info->has_both_edge_trigger; - } - - if (p->config.number_of_pins == 0 || - p->config.number_of_pins > RCAR_MAX_GPIO_PER_BANK) { + if (*npins == 0 || *npins > RCAR_MAX_GPIO_PER_BANK) { dev_warn(&p->pdev->dev, - "Invalid number of gpio lines %u, using %u\n", - p->config.number_of_pins, RCAR_MAX_GPIO_PER_BANK); - p->config.number_of_pins = RCAR_MAX_GPIO_PER_BANK; + "Invalid number of gpio lines %u, using %u\n", *npins, + RCAR_MAX_GPIO_PER_BANK); + *npins = RCAR_MAX_GPIO_PER_BANK; } return 0; @@ -401,6 +390,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) struct irq_chip *irq_chip; struct device *dev = &pdev->dev; const char *name = dev_name(dev); + unsigned int npins; int ret; p = devm_kzalloc(dev, sizeof(*p), GFP_KERNEL); @@ -410,8 +400,8 @@ static int gpio_rcar_probe(struct platform_device *pdev) p->pdev = pdev; spin_lock_init(&p->lock); - /* Get device configuration from DT node or platform data. */ - ret = gpio_rcar_parse_pdata(p); + /* Get device configuration from DT node */ + ret = gpio_rcar_parse_dt(p, &npins); if (ret < 0) return ret; @@ -451,8 +441,8 @@ static int gpio_rcar_probe(struct platform_device *pdev) gpio_chip->label = name; gpio_chip->parent = dev; gpio_chip->owner = THIS_MODULE; - gpio_chip->base = p->config.gpio_base; - gpio_chip->ngpio = p->config.number_of_pins; + gpio_chip->base = -1; + gpio_chip->ngpio = npins; irq_chip = &p->irq_chip; irq_chip->name = name; @@ -468,8 +458,8 @@ static int gpio_rcar_probe(struct platform_device *pdev) goto err0; } - ret = gpiochip_irqchip_add(gpio_chip, irq_chip, p->config.irq_base, - handle_level_irq, IRQ_TYPE_NONE); + ret = gpiochip_irqchip_add(gpio_chip, irq_chip, 0, handle_level_irq, + IRQ_TYPE_NONE); if (ret) { dev_err(dev, "cannot add irqchip\n"); goto err1; @@ -483,22 +473,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) goto err1; } - dev_info(dev, "driving %d GPIOs\n", p->config.number_of_pins); - - /* warn in case of mismatch if irq base is specified */ - if (p->config.irq_base) { - ret = irq_find_mapping(gpio_chip->irqdomain, 0); - if (p->config.irq_base != ret) - dev_warn(dev, "irq base mismatch (%u/%u)\n", - p->config.irq_base, ret); - } - - if (p->config.pctl_name) { - ret = gpiochip_add_pin_range(gpio_chip, p->config.pctl_name, 0, - gpio_chip->base, gpio_chip->ngpio); - if (ret < 0) - dev_warn(dev, "failed to add pin range\n"); - } + dev_info(dev, "driving %d GPIOs\n", npins); return 0; diff --git a/include/linux/platform_data/gpio-rcar.h b/include/linux/platform_data/gpio-rcar.h deleted file mode 100644 index 2d8d69432813..000000000000 --- a/include/linux/platform_data/gpio-rcar.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Renesas R-Car GPIO Support - * - * Copyright (C) 2013 Magnus Damm - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef __GPIO_RCAR_H__ -#define __GPIO_RCAR_H__ - -struct gpio_rcar_config { - int gpio_base; - unsigned int irq_base; - unsigned int number_of_pins; - const char *pctl_name; - unsigned has_both_edge_trigger:1; -}; - -#define RCAR_GP_PIN(bank, pin) (((bank) * 32) + (pin)) - -#endif /* __GPIO_RCAR_H__ */ -- cgit From e1fef9e2ce4272b720ecb1ce696a72aaddbb7585 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 4 Dec 2015 16:33:53 +0100 Subject: gpio: rcar: Improve clock error handling and reporting If the Renesas R-Car GPIO driver cannot find a functional clock, it prints a warning, .e.g. gpio_rcar ffc40000.gpio: unable to get clock and continues, as the clock is optional, depending on the SoC type. This warning may confuse users. To fix this, add a flag to indicate that the clock is mandatory or optional: - If the clock is mandatory (on R-Car Gen2 and Gen3), a missing clock is now treated as a fatal error, - If the clock is optional (on R-Car Gen1), the warning is no longer printed. Suggested-by: Magnus Damm Signed-off-by: Geert Uytterhoeven Acked-by: Simon Horman Signed-off-by: Linus Walleij --- drivers/gpio/gpio-rcar.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index 1ed52fc026cb..624a435e6988 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -39,6 +39,7 @@ struct gpio_rcar_priv { struct clk *clk; unsigned int irq_parent; bool has_both_edge_trigger; + bool needs_clk; }; #define IOINTSEL 0x00 /* General IO/Interrupt Switching Register */ @@ -317,14 +318,17 @@ static int gpio_rcar_direction_output(struct gpio_chip *chip, unsigned offset, struct gpio_rcar_info { bool has_both_edge_trigger; + bool needs_clk; }; static const struct gpio_rcar_info gpio_rcar_info_gen1 = { .has_both_edge_trigger = false, + .needs_clk = false, }; static const struct gpio_rcar_info gpio_rcar_info_gen2 = { .has_both_edge_trigger = true, + .needs_clk = true, }; static const struct of_device_id gpio_rcar_of_table[] = { @@ -371,6 +375,7 @@ static int gpio_rcar_parse_dt(struct gpio_rcar_priv *p, unsigned int *npins) ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0, &args); *npins = ret == 0 ? args.args[2] : RCAR_MAX_GPIO_PER_BANK; p->has_both_edge_trigger = info->has_both_edge_trigger; + p->needs_clk = info->needs_clk; if (*npins == 0 || *npins > RCAR_MAX_GPIO_PER_BANK) { dev_warn(&p->pdev->dev, @@ -409,7 +414,11 @@ static int gpio_rcar_probe(struct platform_device *pdev) p->clk = devm_clk_get(dev, NULL); if (IS_ERR(p->clk)) { - dev_warn(dev, "unable to get clock\n"); + if (p->needs_clk) { + dev_err(dev, "unable to get clock\n"); + ret = PTR_ERR(p->clk); + goto err0; + } p->clk = NULL; } -- cgit From 29ab875b7b4892af1a6cd0084faed37245b8dd2c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 22:45:10 +0100 Subject: gpio: forward-declare enum gpiod_flags This enum is used in the gpiolib.h header file, yet is not included so plainly including this file (and some drivers do) will raise compile problems. Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 2b87cbd68478..0a7c02d76909 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -16,7 +16,7 @@ #include enum of_gpio_flags; - +enum gpiod_flags; struct acpi_device; /** -- cgit From 3773c195d3874d38d1c5ac68868024b32a1f08c9 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 10 Dec 2015 12:10:12 +0100 Subject: gpio: zynq: Do PM initialization earlier to support gpio hogs GPIO hogs registration is call at the end of gpiochip_add() function. Calling sequence is: gpiochip_add -> of_gpiochip_add -> of_gpiochip_scan_hogs -> gpiod_hog -> gpiochip_request_own_desc -> __gpiod_request -> chip->request -> zynq_gpio_request which calls pm_runtime_get_sync() which returns -13 because PM is not initialized yet. Initialize PM before gpiochip_add is called to fix this issue. Signed-off-by: Michal Simek Signed-off-by: Soren Brinkmann Signed-off-by: Linus Walleij --- drivers/gpio/gpio-zynq.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c index 8a04e00bef32..ba1150744b61 100644 --- a/drivers/gpio/gpio-zynq.c +++ b/drivers/gpio/gpio-zynq.c @@ -708,23 +708,23 @@ static int zynq_gpio_probe(struct platform_device *pdev) chip->base = -1; chip->ngpio = gpio->p_data->ngpio; - /* Enable GPIO clock */ + /* Retrieve GPIO clock */ gpio->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(gpio->clk)) { dev_err(&pdev->dev, "input clock not found.\n"); return PTR_ERR(gpio->clk); } - ret = clk_prepare_enable(gpio->clk); - if (ret) { - dev_err(&pdev->dev, "Unable to enable clock.\n"); + + pm_runtime_enable(&pdev->dev); + ret = pm_runtime_get_sync(&pdev->dev); + if (ret < 0) return ret; - } /* report a bug if gpio chip registration fails */ ret = gpiochip_add(chip); if (ret) { dev_err(&pdev->dev, "Failed to add gpio chip\n"); - goto err_disable_clk; + goto err_pm_put; } /* disable interrupts for all banks */ @@ -742,15 +742,14 @@ static int zynq_gpio_probe(struct platform_device *pdev) gpiochip_set_chained_irqchip(chip, &zynq_gpio_edge_irqchip, gpio->irq, zynq_gpio_irqhandler); - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); + pm_runtime_put(&pdev->dev); return 0; err_rm_gpiochip: gpiochip_remove(chip); -err_disable_clk: - clk_disable_unprepare(gpio->clk); +err_pm_put: + pm_runtime_put(&pdev->dev); return ret; } -- cgit From 2f46205b4e4c1c2a4b72082f805753eb51fbfab5 Mon Sep 17 00:00:00 2001 From: Sudeep Holla Date: Fri, 27 Nov 2015 17:19:15 +0000 Subject: gpio: pl061: add support for wakeup configuration The PL061 supports interrupts and those can be wakeup interrupts. We need to provide support for configuring those interrupts as wakeup sources. This patch adds irq_set_wake callback for PL061 so that GPIO interrupts can be configured as wakeup. Cc: Linus Walleij Cc: Alexandre Courbot Signed-off-by: Sudeep Holla Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pl061.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index e041639adc14..f937bc7e42dd 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -269,12 +270,20 @@ static void pl061_irq_ack(struct irq_data *d) spin_unlock(&chip->lock); } +static int pl061_irq_set_wake(struct irq_data *d, unsigned int state) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + + return irq_set_irq_wake(gc->irq_parent, state); +} + static struct irq_chip pl061_irqchip = { .name = "pl061", .irq_ack = pl061_irq_ack, .irq_mask = pl061_irq_mask, .irq_unmask = pl061_irq_unmask, .irq_set_type = pl061_irq_type, + .irq_set_wake = pl061_irq_set_wake, }; static int pl061_probe(struct amba_device *adev, const struct amba_id *id) -- cgit From a770d946371ec7710cbbcf523fccf8e05ef3927e Mon Sep 17 00:00:00 2001 From: Robert Jarzmik Date: Sat, 12 Dec 2015 23:55:21 +0100 Subject: gpio: pxa: add pin control gpio direction and request If a pin control driver is available, use it to change the gpio direction. If not fallback to directly manipulating the gpio direction register. The reason to use the pin control driver first is that pin control in pxa2xx architecture implies changing the gpio direction, even for non gpio functions. In order to do it atomically, only one driver should control the gpio direction, and if a pin controller is available, it has to be him. There is a small catch : if CONFIG_PINCTRL is selected, then a pinctrl driver has to be probed. If not, gpio_request() will return -EPROBE_DEFER as pinctrl_request_gpio() returns it in that case. Signed-off-by: Robert Jarzmik Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pxa.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index ccc83faf9275..eacb4b9b2677 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -251,6 +252,11 @@ static int pxa_gpio_direction_input(struct gpio_chip *chip, unsigned offset) void __iomem *base = gpio_bank_base(chip, offset); uint32_t value, mask = GPIO_bit(offset); unsigned long flags; + int ret; + + ret = pinctrl_gpio_direction_input(chip->base + offset); + if (!ret) + return 0; spin_lock_irqsave(&gpio_lock, flags); @@ -271,9 +277,14 @@ static int pxa_gpio_direction_output(struct gpio_chip *chip, void __iomem *base = gpio_bank_base(chip, offset); uint32_t tmp, mask = GPIO_bit(offset); unsigned long flags; + int ret; writel_relaxed(mask, base + (value ? GPSR_OFFSET : GPCR_OFFSET)); + ret = pinctrl_gpio_direction_output(chip->base + offset); + if (!ret) + return 0; + spin_lock_irqsave(&gpio_lock, flags); tmp = readl_relaxed(base + GPDR_OFFSET); @@ -318,6 +329,16 @@ static int pxa_gpio_of_xlate(struct gpio_chip *gc, } #endif +static int pxa_gpio_request(struct gpio_chip *chip, unsigned int offset) +{ + return pinctrl_request_gpio(chip->base + offset); +} + +static void pxa_gpio_free(struct gpio_chip *chip, unsigned int offset) +{ + pinctrl_free_gpio(chip->base + offset); +} + static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, int ngpio, struct device_node *np, void __iomem *regbase) { @@ -336,6 +357,8 @@ static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, int ngpio, pchip->chip.set = pxa_gpio_set; pchip->chip.to_irq = pxa_gpio_to_irq; pchip->chip.ngpio = ngpio; + pchip->chip.request = pxa_gpio_request; + pchip->chip.free = pxa_gpio_free; #ifdef CONFIG_OF_GPIO pchip->chip.of_node = np; pchip->chip.of_xlate = pxa_gpio_of_xlate; -- cgit From a9f1a3e4c1c7dc82711bc22dc52c7b0d6912ed56 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 15 Dec 2015 14:41:44 +0100 Subject: gpio: pch: fix non-DT build commit 1cfadea8f395e3fb6a15ea548e3e86c8b6d64f98 "gpio: pch: allow use from device tree" makes the driver not compile unless CONFIG_OF_GPIO is set. Fix it. Cc: Paul Burton Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pch.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpio/gpio-pch.c b/drivers/gpio/gpio-pch.c index a650a6cc1312..af0715f8524b 100644 --- a/drivers/gpio/gpio-pch.c +++ b/drivers/gpio/gpio-pch.c @@ -394,7 +394,9 @@ static int pch_gpio_probe(struct pci_dev *pdev, pci_set_drvdata(pdev, chip); spin_lock_init(&chip->spinlock); pch_gpio_setup(chip); +#ifdef CONFIG_OF_GPIO chip->gpio.of_node = pdev->dev.of_node; +#endif ret = gpiochip_add(&chip->gpio); if (ret) { dev_err(&pdev->dev, "PCH gpio: Failed to register GPIO\n"); -- cgit From 46c32889f5898774fc523a6ce62012f81b659293 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 17 Dec 2015 14:50:45 +0100 Subject: pinctrl: fixup problematic flag This removes the set_irq_flags() call that unfortunately slipped into the BCM NSP driver. Reported-by: Stephen Rothwell Cc: Yendapally Reddy Dhananjaya Reddy Signed-off-by: Linus Walleij --- drivers/pinctrl/bcm/pinctrl-nsp-gpio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c index bb7891e786e3..34648f6a4826 100644 --- a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c +++ b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c @@ -696,7 +696,6 @@ static int nsp_gpio_probe(struct platform_device *pdev) irq_set_chip_and_handler(irq, &nsp_gpio_irq_chip, handle_simple_irq); - set_irq_flags(irq, IRQF_VALID); irq_set_chip_data(irq, chip); } -- cgit From 0440091be8e44fad91bd220abb07b114ba8f0b48 Mon Sep 17 00:00:00 2001 From: Robert Jarzmik Date: Fri, 18 Dec 2015 21:40:40 +0100 Subject: gpio: pxa: fixes non devicetree builds The commit "gpio: pxa: change the interrupt management" should have taken care of moving an ifdef to not englobe irqdomain related structures anymore, as they are used now for all builds. This repairs the broken builds where CONFIG_OF=n. Signed-off-by: Robert Jarzmik Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pxa.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index eacb4b9b2677..c2d1a47ae784 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c @@ -554,19 +554,6 @@ static int pxa_gpio_nums(struct platform_device *pdev) return count; } -#ifdef CONFIG_OF -static const struct of_device_id pxa_gpio_dt_ids[] = { - { .compatible = "intel,pxa25x-gpio", .data = &pxa25x_id, }, - { .compatible = "intel,pxa26x-gpio", .data = &pxa26x_id, }, - { .compatible = "intel,pxa27x-gpio", .data = &pxa27x_id, }, - { .compatible = "intel,pxa3xx-gpio", .data = &pxa3xx_id, }, - { .compatible = "marvell,pxa93x-gpio", .data = &pxa93x_id, }, - { .compatible = "marvell,mmp-gpio", .data = &mmp_id, }, - { .compatible = "marvell,mmp2-gpio", .data = &mmp2_id, }, - { .compatible = "marvell,pxa1928-gpio", .data = &pxa1928_id, }, - {} -}; - static int pxa_irq_domain_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw) { @@ -582,6 +569,19 @@ const struct irq_domain_ops pxa_irq_domain_ops = { .xlate = irq_domain_xlate_twocell, }; +#ifdef CONFIG_OF +static const struct of_device_id pxa_gpio_dt_ids[] = { + { .compatible = "intel,pxa25x-gpio", .data = &pxa25x_id, }, + { .compatible = "intel,pxa26x-gpio", .data = &pxa26x_id, }, + { .compatible = "intel,pxa27x-gpio", .data = &pxa27x_id, }, + { .compatible = "intel,pxa3xx-gpio", .data = &pxa3xx_id, }, + { .compatible = "marvell,pxa93x-gpio", .data = &pxa93x_id, }, + { .compatible = "marvell,mmp-gpio", .data = &mmp_id, }, + { .compatible = "marvell,mmp2-gpio", .data = &mmp2_id, }, + { .compatible = "marvell,pxa1928-gpio", .data = &pxa1928_id, }, + {} +}; + static int pxa_gpio_probe_dt(struct platform_device *pdev, struct pxa_gpio_chip *pchip) { -- cgit From f3154a46b64ca74be258e1e00b36596499ab6159 Mon Sep 17 00:00:00 2001 From: Robert Jarzmik Date: Fri, 18 Dec 2015 22:41:34 +0100 Subject: MAINTAINERS: add my-self as maintainer of gpio pxa driver Signed-off-by: Robert Jarzmik Signed-off-by: Linus Walleij --- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 400c142cf7e6..4d7d83ceff4e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8652,6 +8652,12 @@ F: include/sound/pxa2xx-lib.h F: sound/arm/pxa* F: sound/soc/pxa/ +PXA GPIO DRIVER +M: Robert Jarzmik +L: linux-gpio@vger.kernel.org +S: Maintained +F: drivers/gpio/gpio-pxa.c + PXA3xx NAND FLASH DRIVER M: Ezequiel Garcia L: linux-mtd@lists.infradead.org -- cgit From 9ae482104cb99076e007ae15792a3194fc1eedd8 Mon Sep 17 00:00:00 2001 From: William Breathitt Gray Date: Tue, 15 Dec 2015 18:52:44 -0500 Subject: gpio: 104-idi-48: Clear pending interrupt once in IRQ handler Performing a read operation on the IRQ Status register will clear the IRQ latch. Since a read operation on the IRQ Status register must be performed in the IRQ handler in order to determine if the IRQ was in fact generated by the device, the IRQ latch is consequently cleared by the IRQ handler. A spinlock is used to guarantee that each IRQ is serviced in the order it was received. Signed-off-by: William Breathitt Gray --- drivers/gpio/gpio-104-idi-48.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c index b5c693409a58..296dbd4cadd9 100644 --- a/drivers/gpio/gpio-104-idi-48.c +++ b/drivers/gpio/gpio-104-idi-48.c @@ -36,6 +36,7 @@ MODULE_PARM_DESC(idi_48_irq, "ACCES 104-IDI-48 interrupt line number"); * struct idi_48_gpio - GPIO device private data structure * @chip: instance of the gpio_chip * @lock: synchronization lock to prevent I/O race conditions + * @ack_lock: synchronization lock to prevent IRQ handler race conditions * @irq_mask: input bits affected by interrupts * @base: base port address of the GPIO device * @extent: extent of port address region of the GPIO device @@ -45,6 +46,7 @@ MODULE_PARM_DESC(idi_48_irq, "ACCES 104-IDI-48 interrupt line number"); struct idi_48_gpio { struct gpio_chip chip; spinlock_t lock; + spinlock_t ack_lock; unsigned char irq_mask[6]; unsigned base; unsigned extent; @@ -89,15 +91,6 @@ static int idi_48_gpio_get(struct gpio_chip *chip, unsigned offset) static void idi_48_irq_ack(struct irq_data *data) { - struct gpio_chip *chip = irq_data_get_irq_chip_data(data); - struct idi_48_gpio *const idi48gpio = to_idi48gpio(chip); - unsigned long flags; - - spin_lock_irqsave(&idi48gpio->lock, flags); - - inb(idi48gpio->base + 7); - - spin_unlock_irqrestore(&idi48gpio->lock, flags); } static void idi_48_irq_mask(struct irq_data *data) @@ -192,6 +185,8 @@ static irqreturn_t idi_48_irq_handler(int irq, void *dev_id) unsigned long gpio; struct gpio_chip *const chip = &idi48gpio->chip; + spin_lock(&idi48gpio->ack_lock); + spin_lock(&idi48gpio->lock); cos_status = inb(idi48gpio->base + 7); @@ -199,8 +194,10 @@ static irqreturn_t idi_48_irq_handler(int irq, void *dev_id) spin_unlock(&idi48gpio->lock); /* IRQ Status (bit 6) is active low (0 = IRQ generated by device) */ - if (cos_status & BIT(6)) + if (cos_status & BIT(6)) { + spin_unlock(&idi48gpio->ack_lock); return IRQ_NONE; + } /* Bit 0-5 indicate which Change-Of-State boundary triggered the IRQ */ cos_status &= 0x3F; @@ -216,6 +213,8 @@ static irqreturn_t idi_48_irq_handler(int irq, void *dev_id) } } + spin_unlock(&idi48gpio->ack_lock); + return IRQ_HANDLED; } -- cgit From 50e8df09e4baaad4fa563564dc04663f662a9b68 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Tue, 15 Dec 2015 23:01:34 +0100 Subject: gpio: sx150x: Add support for sx1502 Signed-off-by: Peter Rosin Acked-by: Rob Herring Signed-off-by: Linus Walleij --- .../devicetree/bindings/gpio/gpio-sx150x.txt | 3 +- drivers/gpio/gpio-sx150x.c | 53 ++++++++++++++++++++-- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/gpio/gpio-sx150x.txt b/Documentation/devicetree/bindings/gpio/gpio-sx150x.txt index ba2bb84eeac3..c809acb9c71b 100644 --- a/Documentation/devicetree/bindings/gpio/gpio-sx150x.txt +++ b/Documentation/devicetree/bindings/gpio/gpio-sx150x.txt @@ -5,7 +5,8 @@ Required properties: - compatible: should be "semtech,sx1506q", "semtech,sx1508q", - "semtech,sx1509q". + "semtech,sx1509q", + "semtech,sx1502q". - reg: The I2C slave address for this device. diff --git a/drivers/gpio/gpio-sx150x.c b/drivers/gpio/gpio-sx150x.c index cf12d8e3ce3e..2d882964b309 100644 --- a/drivers/gpio/gpio-sx150x.c +++ b/drivers/gpio/gpio-sx150x.c @@ -32,8 +32,19 @@ #define NO_UPDATE_PENDING -1 /* The chip models of sx150x */ -#define SX150X_456 0 -#define SX150X_789 1 +#define SX150X_123 0 +#define SX150X_456 1 +#define SX150X_789 2 + +struct sx150x_123_pri { + u8 reg_pld_mode; + u8 reg_pld_table0; + u8 reg_pld_table1; + u8 reg_pld_table2; + u8 reg_pld_table3; + u8 reg_pld_table4; + u8 reg_advance; +}; struct sx150x_456_pri { u8 reg_pld_mode; @@ -65,6 +76,7 @@ struct sx150x_device_data { u8 reg_sense; u8 ngpios; union { + struct sx150x_123_pri x123; struct sx150x_456_pri x456; struct sx150x_789_pri x789; } pri; @@ -142,12 +154,33 @@ static const struct sx150x_device_data sx150x_devices[] = { }, .ngpios = 16 }, + [3] = { /* sx1502q */ + .model = SX150X_123, + .reg_pullup = 0x02, + .reg_pulldn = 0x03, + .reg_dir = 0x01, + .reg_data = 0x00, + .reg_irq_mask = 0x05, + .reg_irq_src = 0x08, + .reg_sense = 0x07, + .pri.x123 = { + .reg_pld_mode = 0x10, + .reg_pld_table0 = 0x11, + .reg_pld_table1 = 0x12, + .reg_pld_table2 = 0x13, + .reg_pld_table3 = 0x14, + .reg_pld_table4 = 0x15, + .reg_advance = 0xad, + }, + .ngpios = 8, + }, }; static const struct i2c_device_id sx150x_id[] = { {"sx1508q", 0}, {"sx1509q", 1}, {"sx1506q", 2}, + {"sx1502q", 3}, {} }; MODULE_DEVICE_TABLE(i2c, sx150x_id); @@ -156,6 +189,7 @@ static const struct of_device_id sx150x_of_match[] = { { .compatible = "semtech,sx1508q" }, { .compatible = "semtech,sx1509q" }, { .compatible = "semtech,sx1506q" }, + { .compatible = "semtech,sx1502q" }, {}, }; MODULE_DEVICE_TABLE(of, sx150x_of_match); @@ -545,10 +579,14 @@ static int sx150x_init_hw(struct sx150x_chip *chip, err = sx150x_i2c_write(chip->client, chip->dev_cfg->pri.x789.reg_misc, 0x01); - else + else if (chip->dev_cfg->model == SX150X_456) err = sx150x_i2c_write(chip->client, chip->dev_cfg->pri.x456.reg_advance, 0x04); + else + err = sx150x_i2c_write(chip->client, + chip->dev_cfg->pri.x123.reg_advance, + 0x00); if (err < 0) return err; @@ -574,13 +612,20 @@ static int sx150x_init_hw(struct sx150x_chip *chip, pdata->io_polarity); if (err < 0) return err; - } else { + } else if (chip->dev_cfg->model == SX150X_456) { /* Set all pins to work in normal mode */ err = sx150x_init_io(chip, chip->dev_cfg->pri.x456.reg_pld_mode, 0); if (err < 0) return err; + } else { + /* Set all pins to work in normal mode */ + err = sx150x_init_io(chip, + chip->dev_cfg->pri.x123.reg_pld_mode, + 0); + if (err < 0) + return err; } -- cgit From 1f66adfb5eb81428bc1a5700cffd22ba8e772272 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 10:30:02 +0100 Subject: gpio: da9052: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Ashish Jangam Signed-off-by: Linus Walleij --- drivers/gpio/gpio-da9052.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-da9052.c b/drivers/gpio/gpio-da9052.c index 2e9578ec0ca1..38bd8f122bfc 100644 --- a/drivers/gpio/gpio-da9052.c +++ b/drivers/gpio/gpio-da9052.c @@ -89,15 +89,12 @@ static int da9052_gpio_get(struct gpio_chip *gc, unsigned offset) DA9052_STATUS_D_REG); if (ret < 0) return ret; - if (ret & (1 << DA9052_GPIO_SHIFT_COUNT(offset))) - return 1; - else - return 0; + return !!(ret & (1 << DA9052_GPIO_SHIFT_COUNT(offset))); case DA9052_OUTPUT_PUSHPULL: if (da9052_gpio_port_odd(offset)) - return ret & DA9052_GPIO_ODD_PORT_MODE; + return !!(ret & DA9052_GPIO_ODD_PORT_MODE); else - return ret & DA9052_GPIO_EVEN_PORT_MODE; + return !!(ret & DA9052_GPIO_EVEN_PORT_MODE); default: return -EINVAL; } -- cgit From 5b8d8fb0fc7412a4a7ec884b9d3b744aca2c462f Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 10:33:27 +0100 Subject: gpio: davinci: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Sekhar Nori Cc: Santosh Shilimkar Reviewed-by: Grygorii Strashko Signed-off-by: Linus Walleij --- drivers/gpio/gpio-davinci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 65ebaef935e1..1e3a617e0c10 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -125,7 +125,7 @@ static int davinci_gpio_get(struct gpio_chip *chip, unsigned offset) struct davinci_gpio_controller *d = chip2controller(chip); struct davinci_gpio_regs __iomem *g = d->regs; - return (1 << offset) & readl_relaxed(&g->in_data); + return !!((1 << offset) & readl_relaxed(&g->in_data)); } /* -- cgit From 8388f2909c7e54678a4fe350382725c7d8ccfd85 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 10:46:18 +0100 Subject: gpio: em: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Magnus Damm Acked-by: Geert Uytterhoeven Signed-off-by: Linus Walleij --- drivers/gpio/gpio-em.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c index c3ca2b1c1dfe..d726c68c4a65 100644 --- a/drivers/gpio/gpio-em.c +++ b/drivers/gpio/gpio-em.c @@ -203,7 +203,7 @@ static int em_gio_direction_input(struct gpio_chip *chip, unsigned offset) static int em_gio_get(struct gpio_chip *chip, unsigned offset) { - return (int)(em_gio_read(gpio_to_priv(chip), GIO_I) & BIT(offset)); + return !!(em_gio_read(gpio_to_priv(chip), GIO_I) & BIT(offset)); } static void __em_gio_set(struct gpio_chip *chip, unsigned int reg, -- cgit From 4c628f3de69f66f429c108b27de9f6e82311636c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 11:00:56 +0100 Subject: gpio: intel-mid: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Acked-by: David Cohen Signed-off-by: Linus Walleij --- drivers/gpio/gpio-intel-mid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c index 1c46a7ef2680..26d2083a5901 100644 --- a/drivers/gpio/gpio-intel-mid.c +++ b/drivers/gpio/gpio-intel-mid.c @@ -120,7 +120,7 @@ static int intel_gpio_get(struct gpio_chip *chip, unsigned offset) { void __iomem *gplr = gpio_reg(chip, offset, GPLR); - return readl(gplr) & BIT(offset % 32); + return !!(readl(gplr) & BIT(offset % 32)); } static void intel_gpio_set(struct gpio_chip *chip, unsigned offset, int value) -- cgit From 828240c27ad44dffc53d6d72794057297f58e28e Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 11:03:33 +0100 Subject: gpio: janz-ttl: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Ira W. Snyder Signed-off-by: Linus Walleij --- drivers/gpio/gpio-janz-ttl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-janz-ttl.c b/drivers/gpio/gpio-janz-ttl.c index e5f85cab0100..236d322a0b5e 100644 --- a/drivers/gpio/gpio-janz-ttl.c +++ b/drivers/gpio/gpio-janz-ttl.c @@ -76,7 +76,7 @@ static int ttl_get_value(struct gpio_chip *gpio, unsigned offset) spin_lock(&mod->lock); ret = *shadow & (1 << offset); spin_unlock(&mod->lock); - return ret; + return !!ret; } static void ttl_set_value(struct gpio_chip *gpio, unsigned offset, int value) -- cgit From e9639436091a5c65c391d9b5e218eb5fbf30173d Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 11:04:26 +0100 Subject: gpio: kempld: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Brunner Michael Reviewed-by: Guenter Roeck Signed-off-by: Linus Walleij --- drivers/gpio/gpio-kempld.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c index 35dd1e0af364..297f849af725 100644 --- a/drivers/gpio/gpio-kempld.c +++ b/drivers/gpio/gpio-kempld.c @@ -69,7 +69,7 @@ static int kempld_gpio_get(struct gpio_chip *chip, unsigned offset) = container_of(chip, struct kempld_gpio_data, chip); struct kempld_device_data *pld = gpio->pld; - return kempld_gpio_get_bit(pld, KEMPLD_GPIO_LVL_NUM(offset), offset); + return !!kempld_gpio_get_bit(pld, KEMPLD_GPIO_LVL_NUM(offset), offset); } static void kempld_gpio_set(struct gpio_chip *chip, unsigned offset, int value) -- cgit From 2e6d84564c07452ed10a7601484765d37880cc3a Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 11:10:06 +0100 Subject: gpio: lpc32xx: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Roland Stigge Cc: Vladimir Zapolskiy Signed-off-by: Linus Walleij --- drivers/gpio/gpio-lpc32xx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-lpc32xx.c b/drivers/gpio/gpio-lpc32xx.c index 47e2dde63734..e888b5fcd236 100644 --- a/drivers/gpio/gpio-lpc32xx.c +++ b/drivers/gpio/gpio-lpc32xx.c @@ -288,21 +288,21 @@ static int lpc32xx_gpio_get_value_p012(struct gpio_chip *chip, unsigned pin) { struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); - return __get_gpio_state_p012(group, pin); + return !!__get_gpio_state_p012(group, pin); } static int lpc32xx_gpio_get_value_p3(struct gpio_chip *chip, unsigned pin) { struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); - return __get_gpio_state_p3(group, pin); + return !!__get_gpio_state_p3(group, pin); } static int lpc32xx_gpi_get_value(struct gpio_chip *chip, unsigned pin) { struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); - return __get_gpi_state_p3(group, pin); + return !!__get_gpi_state_p3(group, pin); } static int lpc32xx_gpio_dir_output_p012(struct gpio_chip *chip, unsigned pin, @@ -364,7 +364,7 @@ static int lpc32xx_gpo_get_value(struct gpio_chip *chip, unsigned pin) { struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); - return __get_gpo_state_p3(group, pin); + return !!__get_gpo_state_p3(group, pin); } static int lpc32xx_gpio_request(struct gpio_chip *chip, unsigned pin) -- cgit From f96600873e368e9fae53c3485972db2252f9f12c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 11:12:55 +0100 Subject: gpio: max732x: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Also start to propagate the error code here as the end of the series fixes this to work for all drivers. Cc: Semen Protsenko Reviewed-by: Marek Vasut Reviewed-by:Nicholas Krause Signed-off-by: Linus Walleij --- drivers/gpio/gpio-max732x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-max732x.c b/drivers/gpio/gpio-max732x.c index a1094984b666..880ce94e6077 100644 --- a/drivers/gpio/gpio-max732x.c +++ b/drivers/gpio/gpio-max732x.c @@ -207,9 +207,9 @@ static int max732x_gpio_get_value(struct gpio_chip *gc, unsigned off) ret = max732x_readb(chip, is_group_a(chip, off), ®_val); if (ret < 0) - return 0; + return ret; - return reg_val & (1u << (off & 0x7)); + return !!(reg_val & (1u << (off & 0x7))); } static void max732x_gpio_set_mask(struct gpio_chip *gc, unsigned off, int mask, -- cgit From 6f14dd6964288ecb4cad7d14b966e6d347ce128b Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 11:18:44 +0100 Subject: gpio: ml-ioh: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Feng Tang Cc: Tomoya MORINAGA Signed-off-by: Linus Walleij --- drivers/gpio/gpio-ml-ioh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c index 5536108aa9db..7ef704343f05 100644 --- a/drivers/gpio/gpio-ml-ioh.c +++ b/drivers/gpio/gpio-ml-ioh.c @@ -124,7 +124,7 @@ static int ioh_gpio_get(struct gpio_chip *gpio, unsigned nr) { struct ioh_gpio *chip = container_of(gpio, struct ioh_gpio, gpio); - return ioread32(&chip->reg->regs[chip->ch].pi) & (1 << nr); + return !!(ioread32(&chip->reg->regs[chip->ch].pi) & (1 << nr)); } static int ioh_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, -- cgit From c759174e73ab4a2190244c903649032ac748586d Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 11:20:56 +0100 Subject: gpio: mpc8xxx: Be sure to clamp return value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Uwe Kleine-König Cc: Alexander Stein Signed-off-by: Linus Walleij --- drivers/gpio/gpio-mpc8xxx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c index 48ef368347ab..de4cd22a5014 100644 --- a/drivers/gpio/gpio-mpc8xxx.c +++ b/drivers/gpio/gpio-mpc8xxx.c @@ -79,7 +79,7 @@ static int mpc8572_gpio_get(struct gpio_chip *gc, unsigned int gpio) val = in_be32(mm->regs + GPIO_DAT) & ~out_mask; out_shadow = mpc8xxx_gc->data & out_mask; - return (val | out_shadow) & mpc8xxx_gpio2mask(gpio); + return !!((val | out_shadow) & mpc8xxx_gpio2mask(gpio)); } static int mpc8xxx_gpio_get(struct gpio_chip *gc, unsigned int gpio) -- cgit From db30aaef313b4d5a2f6151e61e4f3ab5e0affae4 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 11:21:47 +0100 Subject: gpio: msic: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Acked-by: Mathias Nyman Signed-off-by: Linus Walleij --- drivers/gpio/gpio-msic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-msic.c b/drivers/gpio/gpio-msic.c index fe9ef2bc981a..9a261acb0eed 100644 --- a/drivers/gpio/gpio-msic.c +++ b/drivers/gpio/gpio-msic.c @@ -143,7 +143,7 @@ static int msic_gpio_get(struct gpio_chip *chip, unsigned offset) if (ret < 0) return ret; - return r & MSIC_GPIO_DIN_MASK; + return !!(r & MSIC_GPIO_DIN_MASK); } static void msic_gpio_set(struct gpio_chip *chip, unsigned offset, int value) -- cgit From 40f805806dfb761650080ee008aeb96c012a0e03 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 11:32:53 +0100 Subject: gpio: pcf857x: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Also start returning the error code if something fails, as the end of the series augment the core to support this. Cc: Grygorii Strashko Cc: George Cherian Cc: Laurent Pinchart Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pcf857x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-pcf857x.c b/drivers/gpio/gpio-pcf857x.c index bf511c0efa48..f64380a7d004 100644 --- a/drivers/gpio/gpio-pcf857x.c +++ b/drivers/gpio/gpio-pcf857x.c @@ -154,7 +154,7 @@ static int pcf857x_get(struct gpio_chip *chip, unsigned offset) int value; value = gpio->read(gpio->client); - return (value < 0) ? 0 : (value & (1 << offset)); + return (value < 0) ? value : !!(value & (1 << offset)); } static int pcf857x_output(struct gpio_chip *chip, unsigned offset, int value) -- cgit From 5b818fd18c7b81bb41c8a18943e562407ac95952 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 11:34:11 +0100 Subject: gpio: pch: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Thierry Reding Cc: Daniel Krueger Cc: Jean Delvare Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-pch.c b/drivers/gpio/gpio-pch.c index af0715f8524b..8c45b74dcf21 100644 --- a/drivers/gpio/gpio-pch.c +++ b/drivers/gpio/gpio-pch.c @@ -127,7 +127,7 @@ static int pch_gpio_get(struct gpio_chip *gpio, unsigned nr) { struct pch_gpio *chip = container_of(gpio, struct pch_gpio, gpio); - return ioread32(&chip->reg->pi) & (1 << nr); + return !!(ioread32(&chip->reg->pi) & (1 << nr)); } static int pch_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, -- cgit From 6a681b61470e1daf4fd51581c21147f92fe7b75d Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 11:36:28 +0100 Subject: gpio: sa1100: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Russell King Cc: Dmitry Eremin-Solenikov Cc: Kristoffer Ericson Signed-off-by: Linus Walleij --- drivers/gpio/gpio-sa1100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c index 990fa9023e22..9d590166e952 100644 --- a/drivers/gpio/gpio-sa1100.c +++ b/drivers/gpio/gpio-sa1100.c @@ -17,7 +17,7 @@ static int sa1100_gpio_get(struct gpio_chip *chip, unsigned offset) { - return GPLR & GPIO_GPIO(offset); + return !!(GPLR & GPIO_GPIO(offset)); } static void sa1100_gpio_set(struct gpio_chip *chip, unsigned offset, int value) -- cgit From 8a240c311715c2e34f9a8d6e69d6f85a9f484c6d Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 11:38:50 +0100 Subject: gpio: sta2x11: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Alessandro Rubini Signed-off-by: Linus Walleij --- drivers/gpio/gpio-sta2x11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-sta2x11.c b/drivers/gpio/gpio-sta2x11.c index 55e47828ddfc..af0be81ad2b6 100644 --- a/drivers/gpio/gpio-sta2x11.c +++ b/drivers/gpio/gpio-sta2x11.c @@ -90,7 +90,7 @@ static int gsta_gpio_get(struct gpio_chip *gpio, unsigned nr) struct gsta_regs __iomem *regs = __regs(chip, nr); u32 bit = __bit(nr); - return readl(®s->dat) & bit; + return !!(readl(®s->dat) & bit); } static int gsta_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, -- cgit From f2e13d2f6aaef281716db1fbe94ecb54fbfe5083 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 11:41:06 +0100 Subject: gpio: sx150x: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. This also starts to propagate the error code from the I2C transaction as the end of the series adds support for that. Cc: Wei Chen Signed-off-by: Linus Walleij --- drivers/gpio/gpio-sx150x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-sx150x.c b/drivers/gpio/gpio-sx150x.c index 2d882964b309..04d4f2c2928a 100644 --- a/drivers/gpio/gpio-sx150x.c +++ b/drivers/gpio/gpio-sx150x.c @@ -344,7 +344,7 @@ static int sx150x_gpio_get(struct gpio_chip *gc, unsigned offset) mutex_unlock(&chip->lock); } - return status; + return (status < 0) ? status : !!status; } static void sx150x_gpio_set(struct gpio_chip *gc, unsigned offset, int val) -- cgit From 27ca226711d4bb438349fe0575660a60ad56b357 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 11:42:30 +0100 Subject: gpio: tc3589x: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tc3589x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c index 7c1537ed6dff..2896aef5aec4 100644 --- a/drivers/gpio/gpio-tc3589x.c +++ b/drivers/gpio/gpio-tc3589x.c @@ -51,7 +51,7 @@ static int tc3589x_gpio_get(struct gpio_chip *chip, unsigned offset) if (ret < 0) return ret; - return ret & mask; + return !!(ret & mask); } static void tc3589x_gpio_set(struct gpio_chip *chip, unsigned offset, int val) -- cgit From 9e8014fcaf80cd9e49db2e551c16a1b6aaaf048f Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 11:47:16 +0100 Subject: gpio: twl4030: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. This also makes the driver start to return the error code, as the end of the series make this work. Cc: Roger Quadros Cc: Tony Lindgren Signed-off-by: Linus Walleij --- drivers/gpio/gpio-twl4030.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c index 14f40bf64e34..f5590514838a 100644 --- a/drivers/gpio/gpio-twl4030.c +++ b/drivers/gpio/gpio-twl4030.c @@ -327,7 +327,7 @@ static int twl_get(struct gpio_chip *chip, unsigned offset) else status = twl4030_get_gpio_datain(offset); - ret = (status <= 0) ? 0 : 1; + ret = (status < 0) ? status : !!status; out: mutex_unlock(&priv->mutex); return ret; -- cgit From 9fa90796244aa6043d59c8e127845ff9e3b01485 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 11:48:48 +0100 Subject: gpio: tz1090: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Acked-by: James Hogan Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tz1090.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-tz1090.c b/drivers/gpio/gpio-tz1090.c index 79ef6e1ce568..a4a822542ac1 100644 --- a/drivers/gpio/gpio-tz1090.c +++ b/drivers/gpio/gpio-tz1090.c @@ -214,7 +214,7 @@ static int tz1090_gpio_get(struct gpio_chip *chip, unsigned int offset) { struct tz1090_gpio_bank *bank = to_bank(chip); - return tz1090_gpio_read_bit(bank, REG_GPIO_DIN, offset); + return !!tz1090_gpio_read_bit(bank, REG_GPIO_DIN, offset); } /* -- cgit From 18df16692d2ecfac1b48d2036bf4ff7200c191cd Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 14:54:59 +0100 Subject: gpio: tz1090-pdc: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Acked-by: James Hogan Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tz1090-pdc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-tz1090-pdc.c b/drivers/gpio/gpio-tz1090-pdc.c index 0a01c8736aff..b08b22b1b111 100644 --- a/drivers/gpio/gpio-tz1090-pdc.c +++ b/drivers/gpio/gpio-tz1090-pdc.c @@ -113,7 +113,7 @@ static int tz1090_pdc_gpio_direction_output(struct gpio_chip *chip, static int tz1090_pdc_gpio_get(struct gpio_chip *chip, unsigned int offset) { struct tz1090_pdc_gpio *priv = to_pdc(chip); - return pdc_read(priv, REG_SOC_GPIO_STATUS) & BIT(offset); + return !!(pdc_read(priv, REG_SOC_GPIO_STATUS) & BIT(offset)); } static void tz1090_pdc_gpio_set(struct gpio_chip *chip, unsigned int offset, -- cgit From c9d4ab030c6bdd3b7c7b0a9d4aeec7a8e1776fa5 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 14:56:04 +0100 Subject: gpio: ucb1400: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Signed-off-by: Linus Walleij --- drivers/gpio/gpio-ucb1400.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-ucb1400.c b/drivers/gpio/gpio-ucb1400.c index d502825159b9..cca78fb9b0df 100644 --- a/drivers/gpio/gpio-ucb1400.c +++ b/drivers/gpio/gpio-ucb1400.c @@ -33,7 +33,7 @@ static int ucb1400_gpio_get(struct gpio_chip *gc, unsigned off) { struct ucb1400_gpio *gpio; gpio = container_of(gc, struct ucb1400_gpio, gc); - return ucb1400_gpio_get_value(gpio->ac97, off); + return !!ucb1400_gpio_get_value(gpio->ac97, off); } static void ucb1400_gpio_set(struct gpio_chip *gc, unsigned off, int val) -- cgit From 80776df4f53e8e2463e57b7b9bc13298c443a393 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 14:58:52 +0100 Subject: gpio: viperboard: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Lars Poeschel Signed-off-by: Linus Walleij --- drivers/gpio/gpio-viperboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-viperboard.c b/drivers/gpio/gpio-viperboard.c index 26e7edb74f42..7667e77dd52e 100644 --- a/drivers/gpio/gpio-viperboard.c +++ b/drivers/gpio/gpio-viperboard.c @@ -95,7 +95,7 @@ static int vprbrd_gpioa_get(struct gpio_chip *chip, /* if io is set to output, just return the saved value */ if (gpio->gpioa_out & (1 << offset)) - return gpio->gpioa_val & (1 << offset); + return !!(gpio->gpioa_val & (1 << offset)); mutex_lock(&vb->lock); -- cgit From 3bde87714e79c7ff342e98ccafca07d69d91c7b8 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 16:17:20 +0100 Subject: pinctrl: baytrail: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Acked-by: Mika Westerberg Acked-by: Heikki Krogerus Signed-off-by: Linus Walleij --- drivers/pinctrl/intel/pinctrl-baytrail.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c index bb92f8ae6b33..1fe9c1989353 100644 --- a/drivers/pinctrl/intel/pinctrl-baytrail.c +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c @@ -281,7 +281,7 @@ static int byt_gpio_get(struct gpio_chip *chip, unsigned offset) val = readl(reg); raw_spin_unlock_irqrestore(&vg->lock, flags); - return val & BYT_LEVEL; + return !!(val & BYT_LEVEL); } static void byt_gpio_set(struct gpio_chip *chip, unsigned offset, int value) -- cgit From 01a62834f983455806b9e522c33d2670b83b1e52 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 16:25:11 +0100 Subject: pinctrl: coh901: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-coh901.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-coh901.c b/drivers/pinctrl/pinctrl-coh901.c index e1cbf56df4b2..ca0fa79a286c 100644 --- a/drivers/pinctrl/pinctrl-coh901.c +++ b/drivers/pinctrl/pinctrl-coh901.c @@ -221,7 +221,7 @@ static int u300_gpio_get(struct gpio_chip *chip, unsigned offset) { struct u300_gpio *gpio = to_u300_gpio(chip); - return readl(U300_PIN_REG(offset, dir)) & U300_PIN_BIT(offset); + return !!(readl(U300_PIN_REG(offset, dir)) & U300_PIN_BIT(offset)); } static void u300_gpio_set(struct gpio_chip *chip, unsigned offset, int value) -- cgit From e15736975955639daa8a913a5f2076ba1cef58a4 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 16:28:11 +0100 Subject: pinctrl: xway: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Pramod Gurav Cc: John Crispin Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-xway.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c index e56222eac96c..ebd867f50700 100644 --- a/drivers/pinctrl/pinctrl-xway.c +++ b/drivers/pinctrl/pinctrl-xway.c @@ -660,7 +660,7 @@ static int xway_gpio_get(struct gpio_chip *chip, unsigned int pin) { struct ltq_pinmux_info *info = dev_get_drvdata(chip->parent); - return gpio_getbit(info->membase[0], GPIO_IN(pin), PORT_PIN(pin)); + return !!gpio_getbit(info->membase[0], GPIO_IN(pin), PORT_PIN(pin)); } static int xway_gpio_dir_in(struct gpio_chip *chip, unsigned int pin) -- cgit From 86c1a219c256a471535e360efc31611e1ae73a92 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 16:29:50 +0100 Subject: pinctrl: spmi-gpio: Be sure to clamp return value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Ivan T. Ivanov Cc: Björn Andersson Signed-off-by: Linus Walleij --- drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c index 3e5ccc76d59c..4460b2c9c8bd 100644 --- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c @@ -533,7 +533,7 @@ static int pmic_gpio_get(struct gpio_chip *chip, unsigned pin) pad->out_value = ret & PMIC_MPP_REG_RT_STS_VAL_MASK; } - return pad->out_value; + return !!pad->out_value; } static void pmic_gpio_set(struct gpio_chip *chip, unsigned pin, int value) -- cgit From 59663a4cc5270f618e2b99d719b492bb1020deb8 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 16:31:06 +0100 Subject: pinctrl: spmi-mpp: Be sure to clamp return value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Björn Andersson Cc: Ivan T. Ivanov Signed-off-by: Linus Walleij --- drivers/pinctrl/qcom/pinctrl-spmi-mpp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c index 69c14ba177d0..ea1d2b2f6fd1 100644 --- a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c +++ b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c @@ -591,7 +591,7 @@ static int pmic_mpp_get(struct gpio_chip *chip, unsigned pin) pad->out_value = ret & PMIC_MPP_REG_RT_STS_VAL_MASK; } - return pad->out_value; + return !!pad->out_value; } static void pmic_mpp_set(struct gpio_chip *chip, unsigned pin, int value) -- cgit From 464231fb1fb1360399a2eb11479c47e39facb030 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 16:33:41 +0100 Subject: pinctrl: ssbi-gpio: Be sure to clamp return value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Also, this code was double-inverting a bool. That makes no sense whatsoever, so I removed the double-invert. Cc: Björn Andersson Signed-off-by: Linus Walleij --- drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c index 7bea0df06fb1..394ca34bec4a 100644 --- a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c +++ b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c @@ -487,10 +487,10 @@ static int pm8xxx_gpio_get(struct gpio_chip *chip, unsigned offset) } else { ret = irq_get_irqchip_state(pin->irq, IRQCHIP_STATE_LINE_LEVEL, &state); if (!ret) - ret = !!state; + ret = state; } - return ret; + return !!ret; } static void pm8xxx_gpio_set(struct gpio_chip *chip, unsigned offset, int value) -- cgit From b9164f049339006fafe8a52396e0f1997552214a Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 16:36:17 +0100 Subject: gpio: ssbi-mpp: Be sure to clamp return value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. This code was also double-inverting a bool which makes no sense so I removed that code and moved clamping toward the end. Cc: Björn Andersson Signed-off-by: Linus Walleij --- drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c b/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c index 8f5c96cbf94e..23089d541230 100644 --- a/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c +++ b/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c @@ -502,13 +502,13 @@ static int pm8xxx_mpp_get(struct gpio_chip *chip, unsigned offset) int ret; if (!pin->input) - return pin->output_value; + return !!pin->output_value; ret = irq_get_irqchip_state(pin->irq, IRQCHIP_STATE_LINE_LEVEL, &state); if (!ret) - ret = !!state; + ret = state; - return ret; + return !!ret; } static void pm8xxx_mpp_set(struct gpio_chip *chip, unsigned offset, int value) -- cgit From 39e24ac3c309545f1308f0a5d770322b426339ab Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 16:40:27 +0100 Subject: pinctrl: sunxi: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Maxime Ripard Acked-by: Chen-Yu Tsai Signed-off-by: Linus Walleij --- drivers/pinctrl/sunxi/pinctrl-sunxi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index a437e4f8628b..c53a2dbdb5cf 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -469,7 +469,7 @@ static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset) if (set_mux) sunxi_pmx_set(pctl->pctl_dev, offset, SUN4I_FUNC_IRQ); - return val; + return !!val; } static void sunxi_pinctrl_gpio_set(struct gpio_chip *chip, -- cgit From 723a63034eaf10ad36eff28496667f8e2a9f5da3 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 23:10:12 +0100 Subject: Revert "gpio: revert get() to non-errorprogating behaviour" This reverts commit 45ad7db90b42555c8107f18ec6d6a1e9bce34860. We have fixed all the drivers that were returning ambious values not clamped to [0,1] or an error code, so return the error propagating behaviour of the API. Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index d72ac1fdcd98..975a548bd71e 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1303,13 +1303,7 @@ static int _gpiod_get_raw_value(const struct gpio_desc *desc) chip = desc->chip; offset = gpio_chip_hwgpio(desc); value = chip->get ? chip->get(chip, offset) : -EIO; - /* - * FIXME: fix all drivers to clamp to [0,1] or return negative, - * then change this to: - * value = value < 0 ? value : !!value; - * so we can properly propagate error codes. - */ - value = !!value; + value = value < 0 ? value : !!value; trace_gpio_value(desc_to_gpio(desc), 1, value); return value; } -- cgit From 60befd2ea1c2061775838ea7bac5cc2b1353afd0 Mon Sep 17 00:00:00 2001 From: Vladimir Zapolskiy Date: Tue, 22 Dec 2015 16:37:28 +0200 Subject: gpio: update gpiochip .get() callback description Since gpiochip .get() callback may return a negative error value, it strictly limits the range of possible non-error returned values to a subset of [30:0] bitmask, however on practice on success all gpiochip drivers return either 0 for low signal or 1 for high signal, this is assured by "gpio: *: Be sure to clamp return value" series of changes. To avoid any confusion, misinterpretation and potential errors while developing gpiochip drivers in future convert this implicit assumption to a mandatory rule. For output signals with unknown output signal state gpiochip drivers should return a negative error instead of 0. Signed-off-by: Vladimir Zapolskiy Signed-off-by: Linus Walleij --- include/linux/gpio/driver.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index b02c43be7859..990797589408 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -32,8 +32,7 @@ struct seq_file; * (same as GPIOF_DIR_XXX), or negative error * @direction_input: configures signal "offset" as input, or returns error * @direction_output: configures signal "offset" as output, or returns error - * @get: returns value for signal "offset"; for output signals this - * returns either the value actually sensed, or zero + * @get: returns value for signal "offset", 0=low, 1=high, or negative error * @set: assigns output value for signal "offset" * @set_multiple: assigns output values for multiple signals defined by "mask" * @set_debounce: optional hook for setting debounce time for specified gpio in -- cgit From e28ecca6eac40646780b83edab81a496cea3d220 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Sun, 27 Dec 2015 19:06:50 +0530 Subject: gpio: fix warning about iterator We were getting build warning about "iterator" being used uninitialized. Use iterator properly to fix the build warning and in the process remove the variable "pos" which is not required now. Signed-off-by: Sudip Mukherjee Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 975a548bd71e..ca6630207c66 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -189,23 +189,21 @@ EXPORT_SYMBOL_GPL(gpiod_get_direction); */ static int gpiochip_add_to_list(struct gpio_chip *chip) { - struct list_head *pos; struct gpio_chip *iterator; struct gpio_chip *previous = NULL; if (list_empty(&gpio_chips)) { - pos = gpio_chips.next; - goto found; + list_add_tail(&chip->list, &gpio_chips); + return 0; } - list_for_each(pos, &gpio_chips) { - iterator = list_entry(pos, struct gpio_chip, list); + list_for_each_entry(iterator, &gpio_chips, list) { if (iterator->base >= chip->base + chip->ngpio) { /* * Iterator is the first GPIO chip so there is no * previous one */ - if (previous == NULL) { + if (!previous) { goto found; } else { /* @@ -221,7 +219,13 @@ static int gpiochip_add_to_list(struct gpio_chip *chip) previous = iterator; } - /* We are beyond the last chip in the list */ + /* + * We are beyond the last chip in the list and iterator now + * points to the head. + * Let iterator point to the last chip in the list. + */ + + iterator = list_last_entry(&gpio_chips, struct gpio_chip, list); if (iterator->base + iterator->ngpio <= chip->base) goto found; @@ -230,7 +234,7 @@ static int gpiochip_add_to_list(struct gpio_chip *chip) return -EBUSY; found: - list_add_tail(&chip->list, pos); + list_add_tail(&chip->list, &iterator->list); return 0; } -- cgit From 427e0dc57db7046385ed7618ab24aa5c58dccab1 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 1 Jan 2016 23:40:46 +0100 Subject: gpiolib: always initialize *flags from of_get_named_gpio_flags The of_get_named_gpio_flags() function does nothing other than returning an error when CONFIG_OF_GPIO is disabled, but that causes spurious warnings about possible use of uninitialized variables in any code that does not check the of_get_named_gpio_flags() return value before trying to use the flags: drivers/input/misc/rotary_encoder.c: In function 'rotary_encoder_probe': drivers/input/misc/rotary_encoder.c:223:28: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/power/bq24735-charger.c: In function 'bq24735_charger_probe': drivers/power/bq24735-charger.c:227:12: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/power/sbs-battery.c: In function 'sbs_probe': drivers/power/sbs-battery.c:782:17: warning: 'gpio_flags' may be used uninitialized in this function [-Wmaybe-uninitialized] This changes the behavior of the inline helper to set the flags to zero when OF_GPIO is disabled, to avoid the warnings. In all cases I've encountered, we don't actually get to the place that uses the flags if CONFIG_OF is disabled because we won't enter the DT parser code. Signed-off-by: Arnd Bergmann Signed-off-by: Linus Walleij --- include/linux/of_gpio.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index 87d6d1632dd4..bb85a8eeba6a 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h @@ -67,6 +67,9 @@ extern int of_gpio_simple_xlate(struct gpio_chip *gc, static inline int of_get_named_gpio_flags(struct device_node *np, const char *list_name, int index, enum of_gpio_flags *flags) { + if (flags) + *flags = 0; + return -ENOSYS; } -- cgit From 33203f5b94338564bceed3e0ce33028f4732ae5c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 5 Jan 2016 10:23:28 +0100 Subject: pinctrl: qcom: fix up errorpath MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes up: commit 464231fb1fb1360399a2eb11479c47e39facb030 "pinctrl: ssbi-gpio: Be sure to clamp return value" commit b9164f049339006fafe8a52396e0f1997552214a "gpio: ssbi-mpp: Be sure to clamp return value" as I managed to screw up some of the logic when clamping the return values. Cc: Björn Andersson Signed-off-by: Linus Walleij --- drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c | 4 ++-- drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c index 394ca34bec4a..7bea0df06fb1 100644 --- a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c +++ b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c @@ -487,10 +487,10 @@ static int pm8xxx_gpio_get(struct gpio_chip *chip, unsigned offset) } else { ret = irq_get_irqchip_state(pin->irq, IRQCHIP_STATE_LINE_LEVEL, &state); if (!ret) - ret = state; + ret = !!state; } - return !!ret; + return ret; } static void pm8xxx_gpio_set(struct gpio_chip *chip, unsigned offset, int value) diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c b/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c index 23089d541230..629642b73489 100644 --- a/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c +++ b/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c @@ -506,9 +506,9 @@ static int pm8xxx_mpp_get(struct gpio_chip *chip, unsigned offset) ret = irq_get_irqchip_state(pin->irq, IRQCHIP_STATE_LINE_LEVEL, &state); if (!ret) - ret = state; + ret = !!state; - return !!ret; + return ret; } static void pm8xxx_mpp_set(struct gpio_chip *chip, unsigned offset, int value) -- cgit From 13e676be085341c1161c3daf535e98ec6d5d6e3c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 21 Dec 2015 23:03:02 +0100 Subject: fbdev: via-gpio: Be sure to clamp return value As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Florian Tobias Schandinat Acked-by: Tomi Valkeinen Signed-off-by: Linus Walleij --- drivers/video/fbdev/via/via-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/via/via-gpio.c b/drivers/video/fbdev/via/via-gpio.c index 6f433b8cee12..3d3544036bc1 100644 --- a/drivers/video/fbdev/via/via-gpio.c +++ b/drivers/video/fbdev/via/via-gpio.c @@ -142,7 +142,7 @@ static int via_gpio_get(struct gpio_chip *chip, unsigned int nr) gpio = cfg->active_gpios[nr]; reg = via_read_reg(VIASR, gpio->vg_port_index); spin_unlock_irqrestore(&cfg->vdev->reg_lock, flags); - return reg & (0x04 << gpio->vg_mask_shift); + return !!(reg & (0x04 << gpio->vg_mask_shift)); } -- cgit From 4b63739efabc93d67d2b6812dd0cd41358fadf29 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 5 Jan 2016 11:13:28 +0100 Subject: gpio: generic: fix signedness bug found by cppcheck cppcheck reports this: (style) int result is returned as long value. If the return value is long to avoid loss of information, then you have loss of information. This can be fixed with (1UL << pin) but that is the same as using that already use 1UL so take this approach. Reported-by: David Binderman Signed-off-by: Linus Walleij --- drivers/gpio/gpio-generic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c index ea581dc23d44..053a7f0a83e6 100644 --- a/drivers/gpio/gpio-generic.c +++ b/drivers/gpio/gpio-generic.c @@ -58,6 +58,7 @@ o ` ~~~~\___/~~~~ ` controller in FPGA is ,.` #include #include #include +#include #include #include #include @@ -126,13 +127,13 @@ static unsigned long bgpio_read32be(void __iomem *reg) static unsigned long bgpio_pin2mask(struct bgpio_chip *bgc, unsigned int pin) { - return 1 << pin; + return BIT(pin); } static unsigned long bgpio_pin2mask_be(struct bgpio_chip *bgc, unsigned int pin) { - return 1 << (bgc->bits - 1 - pin); + return BIT(bgc->bits - 1 - pin); } static int bgpio_get_set(struct gpio_chip *gc, unsigned int gpio) -- cgit From 41d107ad92b4b8abf103b62269c34da80320f212 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 5 Jan 2016 12:56:37 +0300 Subject: gpio: pxa: checking IS_ERR() instead of NULL irq_domain_add_legacy() returns NULL on error, it doesn't return error pointers. Fixes: 384ca3c6a28d ('gpio: pxa: change the interrupt management') Signed-off-by: Dan Carpenter Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pxa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index c2d1a47ae784..415852d3ca8a 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c @@ -646,8 +646,8 @@ static int pxa_gpio_probe(struct platform_device *pdev) pchip->irqdomain = irq_domain_add_legacy(pdev->dev.of_node, pxa_last_gpio + 1, irq_base, 0, &pxa_irq_domain_ops, pchip); - if (IS_ERR(pchip->irqdomain)) - return PTR_ERR(pchip->irqdomain); + if (!pchip->irqdomain) + return -ENOMEM; irq0 = platform_get_irq_byname(pdev, "gpio0"); irq1 = platform_get_irq_byname(pdev, "gpio1"); -- cgit From b08ea35a3296ee25c4cb53a977b752266dafa2c2 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 3 Dec 2015 15:14:13 +0100 Subject: gpio: add a data pointer to gpio_chip This adds a void * pointer to gpio_chip so that driver can assign and retrieve some states. This is done to get rid of container_of() calls for gpio_chips embedded inside state containers, so we can remove the need to have the gpio_chip or later (planned) struct gpio_device be dynamically allocated at registration time, so that its struct device can be properly reference counted and not bound to its parent device (e.g. a platform_device) but instead live on after unregistration if it is opened by e.g. a char device or sysfs. The data is added with the new function gpiochip_add_data() and for compatibility we add static inline wrapper function gpiochip_add() that will call gpiochip_add_data() with NULL as argument. The latter will be removed once we have exorcised gpiochip_add() from the kernel. gpiochip_get_data() is added as a static inline accessor for drivers to quickly get their data out. Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 10 ++++++---- include/linux/gpio/driver.h | 14 +++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index ca6630207c66..905408b8d54b 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -301,7 +301,7 @@ static int gpiochip_set_desc_names(struct gpio_chip *gc) } /** - * gpiochip_add() - register a gpio_chip + * gpiochip_add_data() - register a gpio_chip * @chip: the chip to register, with chip->base initialized * Context: potentially before irqs will work * @@ -309,7 +309,7 @@ static int gpiochip_set_desc_names(struct gpio_chip *gc) * because the chip->base is invalid or already associated with a * different chip. Otherwise it returns zero as a success code. * - * When gpiochip_add() is called very early during boot, so that GPIOs + * When gpiochip_add_data() is called very early during boot, so that GPIOs * can be freely used, the chip->parent device must be registered before * the gpio framework's arch_initcall(). Otherwise sysfs initialization * for GPIOs will fail rudely. @@ -317,7 +317,7 @@ static int gpiochip_set_desc_names(struct gpio_chip *gc) * If chip->base is negative, this requests dynamic assignment of * a range of valid GPIOs. */ -int gpiochip_add(struct gpio_chip *chip) +int gpiochip_add_data(struct gpio_chip *chip, void *data) { unsigned long flags; int status = 0; @@ -329,6 +329,8 @@ int gpiochip_add(struct gpio_chip *chip) if (!descs) return -ENOMEM; + chip->data = data; + if (chip->ngpio == 0) { chip_err(chip, "tried to insert a GPIO chip with zero lines\n"); return -EINVAL; @@ -415,7 +417,7 @@ err_free_descs: chip->label ? : "generic"); return status; } -EXPORT_SYMBOL_GPL(gpiochip_add); +EXPORT_SYMBOL_GPL(gpiochip_add_data); /** * gpiochip_remove() - unregister a gpio_chip diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 990797589408..b833a5f9629a 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -23,6 +23,7 @@ struct seq_file; * @parent: optional parent device providing the GPIOs * @cdev: class device used by sysfs interface (may be NULL) * @owner: helps prevent removal of modules exporting active GPIOs + * @data: per-instance data assigned by the driver * @list: links gpio_chips together for traversal * @request: optional hook for chip-specific activation, such as * enabling module power and clock; may sleep @@ -91,6 +92,7 @@ struct gpio_chip { struct device *parent; struct device *cdev; struct module *owner; + void *data; struct list_head list; int (*request)(struct gpio_chip *chip, @@ -165,7 +167,11 @@ extern const char *gpiochip_is_requested(struct gpio_chip *chip, unsigned offset); /* add/remove chips */ -extern int gpiochip_add(struct gpio_chip *chip); +extern int gpiochip_add_data(struct gpio_chip *chip, void *data); +static inline int gpiochip_add(struct gpio_chip *chip) +{ + return gpiochip_add_data(chip, NULL); +} extern void gpiochip_remove(struct gpio_chip *chip); extern struct gpio_chip *gpiochip_find(void *data, int (*match)(struct gpio_chip *chip, void *data)); @@ -174,6 +180,12 @@ extern struct gpio_chip *gpiochip_find(void *data, int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset); void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset); +/* get driver data */ +static inline void *gpiochip_get_data(struct gpio_chip *chip) +{ + return chip->data; +} + struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc); #ifdef CONFIG_GPIOLIB_IRQCHIP -- cgit From 3208b0f0c010b26e4d461a3bca59989d03ed9087 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 15:13:53 +0100 Subject: gpio: of: provide optional of_mm_gpiochip_add_data() function In the same spirit as we add an optional void *data argument to the gpiochip_add_data() call, we need this also for of_mm_gpiochip_add(). Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib-of.c | 12 +++++++----- include/linux/of_gpio.h | 10 ++++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 6ed465ea2e12..42a4bb7cf49a 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -262,9 +262,10 @@ int of_gpio_simple_xlate(struct gpio_chip *gc, EXPORT_SYMBOL(of_gpio_simple_xlate); /** - * of_mm_gpiochip_add - Add memory mapped GPIO chip (bank) + * of_mm_gpiochip_add_data - Add memory mapped GPIO chip (bank) * @np: device node of the GPIO chip * @mm_gc: pointer to the of_mm_gpio_chip allocated structure + * @data: driver data to store in the struct gpio_chip * * To use this function you should allocate and fill mm_gc with: * @@ -280,8 +281,9 @@ EXPORT_SYMBOL(of_gpio_simple_xlate); * do all necessary work for you. Then you'll able to use .regs * to manage GPIOs from the callbacks. */ -int of_mm_gpiochip_add(struct device_node *np, - struct of_mm_gpio_chip *mm_gc) +int of_mm_gpiochip_add_data(struct device_node *np, + struct of_mm_gpio_chip *mm_gc, + void *data) { int ret = -ENOMEM; struct gpio_chip *gc = &mm_gc->gc; @@ -301,7 +303,7 @@ int of_mm_gpiochip_add(struct device_node *np, mm_gc->gc.of_node = np; - ret = gpiochip_add(gc); + ret = gpiochip_add_data(gc, data); if (ret) goto err2; @@ -315,7 +317,7 @@ err0: np->full_name, ret); return ret; } -EXPORT_SYMBOL(of_mm_gpiochip_add); +EXPORT_SYMBOL(of_mm_gpiochip_add_data); /** * of_mm_gpiochip_remove - Remove memory mapped GPIO chip (bank) diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index bb85a8eeba6a..092186c62ff4 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h @@ -51,8 +51,14 @@ static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc) extern int of_get_named_gpio_flags(struct device_node *np, const char *list_name, int index, enum of_gpio_flags *flags); -extern int of_mm_gpiochip_add(struct device_node *np, - struct of_mm_gpio_chip *mm_gc); +extern int of_mm_gpiochip_add_data(struct device_node *np, + struct of_mm_gpio_chip *mm_gc, + void *data); +static inline int of_mm_gpiochip_add(struct device_node *np, + struct of_mm_gpio_chip *mm_gc) +{ + return of_mm_gpiochip_add_data(np, mm_gc, NULL); +} extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc); extern int of_gpiochip_add(struct gpio_chip *gc); -- cgit From 0f4630f3720e7e6e921bf525c8357fea7ef3dbab Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 14:02:58 +0100 Subject: 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 , #ifdef:ed for CONFIG_GENERIC_GPIO, and get rid of the 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 Cc: Shawn Guo Cc: Sascha Hauer Cc: Kukjin Kim Cc: Alexandre Courbot Cc: Brian Norris Cc: Florian Fainelli Cc: Sudeep Holla Cc: Lorenzo Pieralisi Cc: Nicolas Pitre Cc: Olof Johansson Cc: Vladimir Zapolskiy Cc: Rabin Vincent 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 Acked-by: Liviu Dudau Acked-by: H Hartley Sweeten Acked-by: Tony Lindgren Acked-by: Krzysztof Kozlowski Acked-by: Lee Jones Signed-off-by: Linus Walleij --- arch/arm/mach-clps711x/board-autcpu12.c | 2 +- arch/arm/mach-clps711x/board-p720t.c | 2 +- arch/arm/mach-imx/mach-mx21ads.c | 2 +- arch/arm/mach-omap1/board-ams-delta.c | 2 +- arch/arm/mach-s3c64xx/mach-crag6410.c | 2 +- drivers/gpio/gpio-74xx-mmio.c | 37 ++-- drivers/gpio/gpio-brcmstb.c | 80 ++++----- drivers/gpio/gpio-clps711x.c | 28 +-- drivers/gpio/gpio-dwapb.c | 92 +++++----- drivers/gpio/gpio-ep93xx.c | 25 +-- drivers/gpio/gpio-etraxfs.c | 49 +++--- drivers/gpio/gpio-ge.c | 24 +-- drivers/gpio/gpio-generic.c | 292 +++++++++++++++----------------- drivers/gpio/gpio-grgpio.c | 73 ++++---- drivers/gpio/gpio-moxart.c | 29 ++-- drivers/gpio/gpio-mxc.c | 27 ++- drivers/gpio/gpio-mxs.c | 33 ++-- drivers/gpio/gpio-sodaville.c | 13 +- drivers/gpio/gpio-xgene-sb.c | 40 ++--- drivers/mfd/vexpress-sysreg.c | 8 +- include/linux/basic_mmio_gpio.h | 80 --------- include/linux/gpio/driver.h | 54 ++++++ 22 files changed, 442 insertions(+), 552 deletions(-) delete mode 100644 include/linux/basic_mmio_gpio.h diff --git a/arch/arm/mach-clps711x/board-autcpu12.c b/arch/arm/mach-clps711x/board-autcpu12.c index c3d964221767..ba3d7d1b28f8 100644 --- a/arch/arm/mach-clps711x/board-autcpu12.c +++ b/arch/arm/mach-clps711x/board-autcpu12.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/arm/mach-clps711x/board-p720t.c b/arch/arm/mach-clps711x/board-p720t.c index e68dd629bda2..80a16a8b3776 100644 --- a/arch/arm/mach-clps711x/board-p720t.c +++ b/arch/arm/mach-clps711x/board-p720t.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mach-imx/mach-mx21ads.c b/arch/arm/mach-imx/mach-mx21ads.c index 703ce31d7379..9986f9a697c8 100644 --- a/arch/arm/mach-imx/mach-mx21ads.c +++ b/arch/arm/mach-imx/mach-mx21ads.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index a95499ea8706..97e66558c238 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -11,7 +11,7 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ -#include +#include #include #include #include diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c b/arch/arm/mach-s3c64xx/mach-crag6410.c index f776adcdaee8..723f47fefc81 100644 --- a/arch/arm/mach-s3c64xx/mach-crag6410.c +++ b/arch/arm/mach-s3c64xx/mach-crag6410.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include diff --git a/drivers/gpio/gpio-74xx-mmio.c b/drivers/gpio/gpio-74xx-mmio.c index 6b186829087c..372b0e01adc6 100644 --- a/drivers/gpio/gpio-74xx-mmio.c +++ b/drivers/gpio/gpio-74xx-mmio.c @@ -10,10 +10,9 @@ */ #include -#include #include #include -#include +#include #include #define MMIO_74XX_DIR_IN (0 << 8) @@ -21,7 +20,7 @@ #define MMIO_74XX_BIT_CNT(x) ((x) & 0xff) struct mmio_74xx_gpio_priv { - struct bgpio_chip bgc; + struct gpio_chip gc; unsigned flags; }; @@ -78,30 +77,23 @@ static const struct of_device_id mmio_74xx_gpio_ids[] = { }; MODULE_DEVICE_TABLE(of, mmio_74xx_gpio_ids); -static inline struct mmio_74xx_gpio_priv *to_74xx_gpio(struct gpio_chip *gc) -{ - struct bgpio_chip *bgc = to_bgpio_chip(gc); - - return container_of(bgc, struct mmio_74xx_gpio_priv, bgc); -} - static int mmio_74xx_get_direction(struct gpio_chip *gc, unsigned offset) { - struct mmio_74xx_gpio_priv *priv = to_74xx_gpio(gc); + struct mmio_74xx_gpio_priv *priv = gpiochip_get_data(gc); - return (priv->flags & MMIO_74XX_DIR_OUT) ? GPIOF_DIR_OUT : GPIOF_DIR_IN; + return !(priv->flags & MMIO_74XX_DIR_OUT); } static int mmio_74xx_dir_in(struct gpio_chip *gc, unsigned int gpio) { - struct mmio_74xx_gpio_priv *priv = to_74xx_gpio(gc); + struct mmio_74xx_gpio_priv *priv = gpiochip_get_data(gc); return (priv->flags & MMIO_74XX_DIR_OUT) ? -ENOTSUPP : 0; } static int mmio_74xx_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) { - struct mmio_74xx_gpio_priv *priv = to_74xx_gpio(gc); + struct mmio_74xx_gpio_priv *priv = gpiochip_get_data(gc); if (priv->flags & MMIO_74XX_DIR_OUT) { gc->set(gc, gpio, val); @@ -134,28 +126,29 @@ static int mmio_74xx_gpio_probe(struct platform_device *pdev) priv->flags = (uintptr_t) of_id->data; - err = bgpio_init(&priv->bgc, &pdev->dev, + err = bgpio_init(&priv->gc, &pdev->dev, DIV_ROUND_UP(MMIO_74XX_BIT_CNT(priv->flags), 8), dat, NULL, NULL, NULL, NULL, 0); if (err) return err; - priv->bgc.gc.direction_input = mmio_74xx_dir_in; - priv->bgc.gc.direction_output = mmio_74xx_dir_out; - priv->bgc.gc.get_direction = mmio_74xx_get_direction; - priv->bgc.gc.ngpio = MMIO_74XX_BIT_CNT(priv->flags); - priv->bgc.gc.owner = THIS_MODULE; + priv->gc.direction_input = mmio_74xx_dir_in; + priv->gc.direction_output = mmio_74xx_dir_out; + priv->gc.get_direction = mmio_74xx_get_direction; + priv->gc.ngpio = MMIO_74XX_BIT_CNT(priv->flags); + priv->gc.owner = THIS_MODULE; platform_set_drvdata(pdev, priv); - return gpiochip_add(&priv->bgc.gc); + return gpiochip_add_data(&priv->gc, priv); } static int mmio_74xx_gpio_remove(struct platform_device *pdev) { struct mmio_74xx_gpio_priv *priv = platform_get_drvdata(pdev); - return bgpio_remove(&priv->bgc); + gpiochip_remove(&priv->gc); + return 0; } static struct platform_driver mmio_74xx_gpio_driver = { diff --git a/drivers/gpio/gpio-brcmstb.c b/drivers/gpio/gpio-brcmstb.c index 4c64627c6bb5..dc3f0395693b 100644 --- a/drivers/gpio/gpio-brcmstb.c +++ b/drivers/gpio/gpio-brcmstb.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -35,7 +34,7 @@ struct brcmstb_gpio_bank { struct list_head node; int id; - struct bgpio_chip bgc; + struct gpio_chip gc; struct brcmstb_gpio_priv *parent_priv; u32 width; struct irq_chip irq_chip; @@ -57,37 +56,30 @@ struct brcmstb_gpio_priv { /* assumes MAX_GPIO_PER_BANK is a multiple of 2 */ #define GPIO_BIT(gpio) ((gpio) & (MAX_GPIO_PER_BANK - 1)) -static inline struct brcmstb_gpio_bank * -brcmstb_gpio_gc_to_bank(struct gpio_chip *gc) -{ - struct bgpio_chip *bgc = to_bgpio_chip(gc); - return container_of(bgc, struct brcmstb_gpio_bank, bgc); -} - static inline struct brcmstb_gpio_priv * brcmstb_gpio_gc_to_priv(struct gpio_chip *gc) { - struct brcmstb_gpio_bank *bank = brcmstb_gpio_gc_to_bank(gc); + struct brcmstb_gpio_bank *bank = gpiochip_get_data(gc); return bank->parent_priv; } static void brcmstb_gpio_set_imask(struct brcmstb_gpio_bank *bank, unsigned int offset, bool enable) { - struct bgpio_chip *bgc = &bank->bgc; + struct gpio_chip *gc = &bank->gc; struct brcmstb_gpio_priv *priv = bank->parent_priv; - u32 mask = bgc->pin2mask(bgc, offset); + u32 mask = gc->pin2mask(gc, offset); u32 imask; unsigned long flags; - spin_lock_irqsave(&bgc->lock, flags); - imask = bgc->read_reg(priv->reg_base + GIO_MASK(bank->id)); + spin_lock_irqsave(&gc->bgpio_lock, flags); + imask = gc->read_reg(priv->reg_base + GIO_MASK(bank->id)); if (enable) imask |= mask; else imask &= ~mask; - bgc->write_reg(priv->reg_base + GIO_MASK(bank->id), imask); - spin_unlock_irqrestore(&bgc->lock, flags); + gc->write_reg(priv->reg_base + GIO_MASK(bank->id), imask); + spin_unlock_irqrestore(&gc->bgpio_lock, flags); } /* -------------------- IRQ chip functions -------------------- */ @@ -95,7 +87,7 @@ static void brcmstb_gpio_set_imask(struct brcmstb_gpio_bank *bank, static void brcmstb_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct brcmstb_gpio_bank *bank = brcmstb_gpio_gc_to_bank(gc); + struct brcmstb_gpio_bank *bank = gpiochip_get_data(gc); brcmstb_gpio_set_imask(bank, d->hwirq, false); } @@ -103,7 +95,7 @@ static void brcmstb_gpio_irq_mask(struct irq_data *d) static void brcmstb_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct brcmstb_gpio_bank *bank = brcmstb_gpio_gc_to_bank(gc); + struct brcmstb_gpio_bank *bank = gpiochip_get_data(gc); brcmstb_gpio_set_imask(bank, d->hwirq, true); } @@ -111,7 +103,7 @@ static void brcmstb_gpio_irq_unmask(struct irq_data *d) static int brcmstb_gpio_irq_set_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct brcmstb_gpio_bank *bank = brcmstb_gpio_gc_to_bank(gc); + struct brcmstb_gpio_bank *bank = gpiochip_get_data(gc); struct brcmstb_gpio_priv *priv = bank->parent_priv; u32 mask = BIT(d->hwirq); u32 edge_insensitive, iedge_insensitive; @@ -149,23 +141,23 @@ static int brcmstb_gpio_irq_set_type(struct irq_data *d, unsigned int type) return -EINVAL; } - spin_lock_irqsave(&bank->bgc.lock, flags); + spin_lock_irqsave(&bank->gc.bgpio_lock, flags); - iedge_config = bank->bgc.read_reg(priv->reg_base + + iedge_config = bank->gc.read_reg(priv->reg_base + GIO_EC(bank->id)) & ~mask; - iedge_insensitive = bank->bgc.read_reg(priv->reg_base + + iedge_insensitive = bank->gc.read_reg(priv->reg_base + GIO_EI(bank->id)) & ~mask; - ilevel = bank->bgc.read_reg(priv->reg_base + + ilevel = bank->gc.read_reg(priv->reg_base + GIO_LEVEL(bank->id)) & ~mask; - bank->bgc.write_reg(priv->reg_base + GIO_EC(bank->id), + bank->gc.write_reg(priv->reg_base + GIO_EC(bank->id), iedge_config | edge_config); - bank->bgc.write_reg(priv->reg_base + GIO_EI(bank->id), + bank->gc.write_reg(priv->reg_base + GIO_EI(bank->id), iedge_insensitive | edge_insensitive); - bank->bgc.write_reg(priv->reg_base + GIO_LEVEL(bank->id), + bank->gc.write_reg(priv->reg_base + GIO_LEVEL(bank->id), ilevel | level); - spin_unlock_irqrestore(&bank->bgc.lock, flags); + spin_unlock_irqrestore(&bank->gc.bgpio_lock, flags); return 0; } @@ -210,29 +202,29 @@ static irqreturn_t brcmstb_gpio_wake_irq_handler(int irq, void *data) static void brcmstb_gpio_irq_bank_handler(struct brcmstb_gpio_bank *bank) { struct brcmstb_gpio_priv *priv = bank->parent_priv; - struct irq_domain *irq_domain = bank->bgc.gc.irqdomain; + struct irq_domain *irq_domain = bank->gc.irqdomain; void __iomem *reg_base = priv->reg_base; unsigned long status; unsigned long flags; - spin_lock_irqsave(&bank->bgc.lock, flags); - while ((status = bank->bgc.read_reg(reg_base + GIO_STAT(bank->id)) & - bank->bgc.read_reg(reg_base + GIO_MASK(bank->id)))) { + spin_lock_irqsave(&bank->gc.bgpio_lock, flags); + while ((status = bank->gc.read_reg(reg_base + GIO_STAT(bank->id)) & + bank->gc.read_reg(reg_base + GIO_MASK(bank->id)))) { int bit; for_each_set_bit(bit, &status, 32) { - u32 stat = bank->bgc.read_reg(reg_base + + u32 stat = bank->gc.read_reg(reg_base + GIO_STAT(bank->id)); if (bit >= bank->width) dev_warn(&priv->pdev->dev, "IRQ for invalid GPIO (bank=%d, offset=%d)\n", bank->id, bit); - bank->bgc.write_reg(reg_base + GIO_STAT(bank->id), + bank->gc.write_reg(reg_base + GIO_STAT(bank->id), stat | BIT(bit)); generic_handle_irq(irq_find_mapping(irq_domain, bit)); } } - spin_unlock_irqrestore(&bank->bgc.lock, flags); + spin_unlock_irqrestore(&bank->gc.bgpio_lock, flags); } /* Each UPG GIO block has one IRQ for all banks */ @@ -303,9 +295,7 @@ static int brcmstb_gpio_remove(struct platform_device *pdev) */ list_for_each(pos, &priv->bank_list) { bank = list_entry(pos, struct brcmstb_gpio_bank, node); - ret = bgpio_remove(&bank->bgc); - if (ret) - dev_err(&pdev->dev, "gpiochip_remove fail in cleanup\n"); + gpiochip_remove(&bank->gc); } if (priv->reboot_notifier.notifier_call) { ret = unregister_reboot_notifier(&priv->reboot_notifier); @@ -320,7 +310,7 @@ static int brcmstb_gpio_of_xlate(struct gpio_chip *gc, const struct of_phandle_args *gpiospec, u32 *flags) { struct brcmstb_gpio_priv *priv = brcmstb_gpio_gc_to_priv(gc); - struct brcmstb_gpio_bank *bank = brcmstb_gpio_gc_to_bank(gc); + struct brcmstb_gpio_bank *bank = gpiochip_get_data(gc); int offset; if (gc->of_gpio_n_cells != 2) { @@ -398,9 +388,9 @@ static int brcmstb_gpio_irq_setup(struct platform_device *pdev, if (priv->can_wake) bank->irq_chip.irq_set_wake = brcmstb_gpio_irq_set_wake; - gpiochip_irqchip_add(&bank->bgc.gc, &bank->irq_chip, 0, + gpiochip_irqchip_add(&bank->gc, &bank->irq_chip, 0, handle_simple_irq, IRQ_TYPE_NONE); - gpiochip_set_chained_irqchip(&bank->bgc.gc, &bank->irq_chip, + gpiochip_set_chained_irqchip(&bank->gc, &bank->irq_chip, priv->parent_irq, brcmstb_gpio_irq_handler); return 0; @@ -451,7 +441,6 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) of_property_for_each_u32(np, "brcm,gpio-bank-widths", prop, p, bank_width) { struct brcmstb_gpio_bank *bank; - struct bgpio_chip *bgc; struct gpio_chip *gc; bank = devm_kzalloc(dev, sizeof(*bank), GFP_KERNEL); @@ -473,8 +462,8 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) * Regs are 4 bytes wide, have data reg, no set/clear regs, * and direction bits have 0 = output and 1 = input */ - bgc = &bank->bgc; - err = bgpio_init(bgc, dev, 4, + gc = &bank->gc; + err = bgpio_init(gc, dev, 4, reg_base + GIO_DATA(bank->id), NULL, NULL, NULL, reg_base + GIO_IODIR(bank->id), 0); @@ -483,7 +472,6 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) goto fail; } - gc = &bgc->gc; gc->of_node = np; gc->owner = THIS_MODULE; gc->label = np->full_name; @@ -497,9 +485,9 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) * Mask all interrupts by default, since wakeup interrupts may * be retained from S5 cold boot */ - bank->bgc.write_reg(reg_base + GIO_MASK(bank->id), 0); + gc->write_reg(reg_base + GIO_MASK(bank->id), 0); - err = gpiochip_add(gc); + err = gpiochip_add_data(gc, bank); if (err) { dev_err(dev, "Could not add gpiochip for bank %d\n", bank->id); diff --git a/drivers/gpio/gpio-clps711x.c b/drivers/gpio/gpio-clps711x.c index b6908f1ff1ab..c84f9551f108 100644 --- a/drivers/gpio/gpio-clps711x.c +++ b/drivers/gpio/gpio-clps711x.c @@ -10,24 +10,23 @@ */ #include -#include #include -#include +#include #include static int clps711x_gpio_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; void __iomem *dat, *dir; - struct bgpio_chip *bgc; + struct gpio_chip *gc; struct resource *res; int err, id = np ? of_alias_get_id(np, "gpio") : pdev->id; if ((id < 0) || (id > 4)) return -ENODEV; - bgc = devm_kzalloc(&pdev->dev, sizeof(*bgc), GFP_KERNEL); - if (!bgc) + gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL); + if (!gc) return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -43,11 +42,11 @@ static int clps711x_gpio_probe(struct platform_device *pdev) switch (id) { case 3: /* PORTD is inverted logic for direction register */ - err = bgpio_init(bgc, &pdev->dev, 1, dat, NULL, NULL, + err = bgpio_init(gc, &pdev->dev, 1, dat, NULL, NULL, NULL, dir, 0); break; default: - err = bgpio_init(bgc, &pdev->dev, 1, dat, NULL, NULL, + err = bgpio_init(gc, &pdev->dev, 1, dat, NULL, NULL, dir, NULL, 0); break; } @@ -58,24 +57,25 @@ static int clps711x_gpio_probe(struct platform_device *pdev) switch (id) { case 4: /* PORTE is 3 lines only */ - bgc->gc.ngpio = 3; + gc->ngpio = 3; break; default: break; } - bgc->gc.base = id * 8; - bgc->gc.owner = THIS_MODULE; - platform_set_drvdata(pdev, bgc); + gc->base = id * 8; + gc->owner = THIS_MODULE; + platform_set_drvdata(pdev, gc); - return gpiochip_add(&bgc->gc); + return gpiochip_add_data(gc, NULL); } static int clps711x_gpio_remove(struct platform_device *pdev) { - struct bgpio_chip *bgc = platform_get_drvdata(pdev); + struct gpio_chip *gc = platform_get_drvdata(pdev); - return bgpio_remove(bgc); + gpiochip_remove(gc); + return 0; } static const struct of_device_id __maybe_unused clps711x_gpio_ids[] = { diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index fcd5b0acfc72..597de1ef497b 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c @@ -7,7 +7,9 @@ * * All enquiries to support@picochip.com */ -#include +#include +/* FIXME: for gpio_get_value(), replace this with direct register read */ +#include #include #include #include @@ -66,7 +68,7 @@ struct dwapb_context { #endif struct dwapb_gpio_port { - struct bgpio_chip bgc; + struct gpio_chip gc; bool is_registered; struct dwapb_gpio *gpio; #ifdef CONFIG_PM_SLEEP @@ -83,33 +85,26 @@ struct dwapb_gpio { struct irq_domain *domain; }; -static inline struct dwapb_gpio_port * -to_dwapb_gpio_port(struct bgpio_chip *bgc) -{ - return container_of(bgc, struct dwapb_gpio_port, bgc); -} - static inline u32 dwapb_read(struct dwapb_gpio *gpio, unsigned int offset) { - struct bgpio_chip *bgc = &gpio->ports[0].bgc; + struct gpio_chip *gc = &gpio->ports[0].gc; void __iomem *reg_base = gpio->regs; - return bgc->read_reg(reg_base + offset); + return gc->read_reg(reg_base + offset); } static inline void dwapb_write(struct dwapb_gpio *gpio, unsigned int offset, u32 val) { - struct bgpio_chip *bgc = &gpio->ports[0].bgc; + struct gpio_chip *gc = &gpio->ports[0].gc; void __iomem *reg_base = gpio->regs; - bgc->write_reg(reg_base + offset, val); + gc->write_reg(reg_base + offset, val); } static int dwapb_gpio_to_irq(struct gpio_chip *gc, unsigned offset) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); - struct dwapb_gpio_port *port = to_dwapb_gpio_port(bgc); + struct dwapb_gpio_port *port = gpiochip_get_data(gc); struct dwapb_gpio *gpio = port->gpio; return irq_find_mapping(gpio->domain, offset); @@ -119,7 +114,7 @@ static void dwapb_toggle_trigger(struct dwapb_gpio *gpio, unsigned int offs) { u32 v = dwapb_read(gpio, GPIO_INT_POLARITY); - if (gpio_get_value(gpio->ports[0].bgc.gc.base + offs)) + if (gpio_get_value(gpio->ports[0].gc.base + offs)) v &= ~BIT(offs); else v |= BIT(offs); @@ -162,39 +157,39 @@ static void dwapb_irq_enable(struct irq_data *d) { struct irq_chip_generic *igc = irq_data_get_irq_chip_data(d); struct dwapb_gpio *gpio = igc->private; - struct bgpio_chip *bgc = &gpio->ports[0].bgc; + struct gpio_chip *gc = &gpio->ports[0].gc; unsigned long flags; u32 val; - spin_lock_irqsave(&bgc->lock, flags); + spin_lock_irqsave(&gc->bgpio_lock, flags); val = dwapb_read(gpio, GPIO_INTEN); val |= BIT(d->hwirq); dwapb_write(gpio, GPIO_INTEN, val); - spin_unlock_irqrestore(&bgc->lock, flags); + spin_unlock_irqrestore(&gc->bgpio_lock, flags); } static void dwapb_irq_disable(struct irq_data *d) { struct irq_chip_generic *igc = irq_data_get_irq_chip_data(d); struct dwapb_gpio *gpio = igc->private; - struct bgpio_chip *bgc = &gpio->ports[0].bgc; + struct gpio_chip *gc = &gpio->ports[0].gc; unsigned long flags; u32 val; - spin_lock_irqsave(&bgc->lock, flags); + spin_lock_irqsave(&gc->bgpio_lock, flags); val = dwapb_read(gpio, GPIO_INTEN); val &= ~BIT(d->hwirq); dwapb_write(gpio, GPIO_INTEN, val); - spin_unlock_irqrestore(&bgc->lock, flags); + spin_unlock_irqrestore(&gc->bgpio_lock, flags); } static int dwapb_irq_reqres(struct irq_data *d) { struct irq_chip_generic *igc = irq_data_get_irq_chip_data(d); struct dwapb_gpio *gpio = igc->private; - struct bgpio_chip *bgc = &gpio->ports[0].bgc; + struct gpio_chip *gc = &gpio->ports[0].gc; - if (gpiochip_lock_as_irq(&bgc->gc, irqd_to_hwirq(d))) { + if (gpiochip_lock_as_irq(gc, irqd_to_hwirq(d))) { dev_err(gpio->dev, "unable to lock HW IRQ %lu for IRQ\n", irqd_to_hwirq(d)); return -EINVAL; @@ -206,16 +201,16 @@ static void dwapb_irq_relres(struct irq_data *d) { struct irq_chip_generic *igc = irq_data_get_irq_chip_data(d); struct dwapb_gpio *gpio = igc->private; - struct bgpio_chip *bgc = &gpio->ports[0].bgc; + struct gpio_chip *gc = &gpio->ports[0].gc; - gpiochip_unlock_as_irq(&bgc->gc, irqd_to_hwirq(d)); + gpiochip_unlock_as_irq(gc, irqd_to_hwirq(d)); } static int dwapb_irq_set_type(struct irq_data *d, u32 type) { struct irq_chip_generic *igc = irq_data_get_irq_chip_data(d); struct dwapb_gpio *gpio = igc->private; - struct bgpio_chip *bgc = &gpio->ports[0].bgc; + struct gpio_chip *gc = &gpio->ports[0].gc; int bit = d->hwirq; unsigned long level, polarity, flags; @@ -223,7 +218,7 @@ static int dwapb_irq_set_type(struct irq_data *d, u32 type) IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) return -EINVAL; - spin_lock_irqsave(&bgc->lock, flags); + spin_lock_irqsave(&gc->bgpio_lock, flags); level = dwapb_read(gpio, GPIO_INTTYPE_LEVEL); polarity = dwapb_read(gpio, GPIO_INT_POLARITY); @@ -254,7 +249,7 @@ static int dwapb_irq_set_type(struct irq_data *d, u32 type) dwapb_write(gpio, GPIO_INTTYPE_LEVEL, level); dwapb_write(gpio, GPIO_INT_POLARITY, polarity); - spin_unlock_irqrestore(&bgc->lock, flags); + spin_unlock_irqrestore(&gc->bgpio_lock, flags); return 0; } @@ -262,13 +257,12 @@ static int dwapb_irq_set_type(struct irq_data *d, u32 type) static int dwapb_gpio_set_debounce(struct gpio_chip *gc, unsigned offset, unsigned debounce) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); - struct dwapb_gpio_port *port = to_dwapb_gpio_port(bgc); + struct dwapb_gpio_port *port = gpiochip_get_data(gc); struct dwapb_gpio *gpio = port->gpio; unsigned long flags, val_deb; - unsigned long mask = bgc->pin2mask(bgc, offset); + unsigned long mask = gc->pin2mask(gc, offset); - spin_lock_irqsave(&bgc->lock, flags); + spin_lock_irqsave(&gc->bgpio_lock, flags); val_deb = dwapb_read(gpio, GPIO_PORTA_DEBOUNCE); if (debounce) @@ -276,7 +270,7 @@ static int dwapb_gpio_set_debounce(struct gpio_chip *gc, else dwapb_write(gpio, GPIO_PORTA_DEBOUNCE, val_deb & ~mask); - spin_unlock_irqrestore(&bgc->lock, flags); + spin_unlock_irqrestore(&gc->bgpio_lock, flags); return 0; } @@ -295,7 +289,7 @@ static void dwapb_configure_irqs(struct dwapb_gpio *gpio, struct dwapb_gpio_port *port, struct dwapb_port_property *pp) { - struct gpio_chip *gc = &port->bgc.gc; + struct gpio_chip *gc = &port->gc; struct device_node *node = pp->node; struct irq_chip_generic *irq_gc = NULL; unsigned int hwirq, ngpio = gc->ngpio; @@ -369,13 +363,13 @@ static void dwapb_configure_irqs(struct dwapb_gpio *gpio, for (hwirq = 0 ; hwirq < ngpio ; hwirq++) irq_create_mapping(gpio->domain, hwirq); - port->bgc.gc.to_irq = dwapb_gpio_to_irq; + port->gc.to_irq = dwapb_gpio_to_irq; } static void dwapb_irq_teardown(struct dwapb_gpio *gpio) { struct dwapb_gpio_port *port = &gpio->ports[0]; - struct gpio_chip *gc = &port->bgc.gc; + struct gpio_chip *gc = &port->gc; unsigned int ngpio = gc->ngpio; irq_hw_number_t hwirq; @@ -412,7 +406,7 @@ static int dwapb_gpio_add_port(struct dwapb_gpio *gpio, dirout = gpio->regs + GPIO_SWPORTA_DDR + (pp->idx * GPIO_SWPORT_DDR_SIZE); - err = bgpio_init(&port->bgc, gpio->dev, 4, dat, set, NULL, dirout, + err = bgpio_init(&port->gc, gpio->dev, 4, dat, set, NULL, dirout, NULL, false); if (err) { dev_err(gpio->dev, "failed to init gpio chip for %s\n", @@ -421,19 +415,19 @@ static int dwapb_gpio_add_port(struct dwapb_gpio *gpio, } #ifdef CONFIG_OF_GPIO - port->bgc.gc.of_node = pp->node; + port->gc.of_node = pp->node; #endif - port->bgc.gc.ngpio = pp->ngpio; - port->bgc.gc.base = pp->gpio_base; + port->gc.ngpio = pp->ngpio; + port->gc.base = pp->gpio_base; /* Only port A support debounce */ if (pp->idx == 0) - port->bgc.gc.set_debounce = dwapb_gpio_set_debounce; + port->gc.set_debounce = dwapb_gpio_set_debounce; if (pp->irq) dwapb_configure_irqs(gpio, port, pp); - err = gpiochip_add(&port->bgc.gc); + err = gpiochip_add_data(&port->gc, port); if (err) dev_err(gpio->dev, "failed to register gpiochip for %s\n", pp->name); @@ -449,7 +443,7 @@ static void dwapb_gpio_unregister(struct dwapb_gpio *gpio) for (m = 0; m < gpio->nr_ports; ++m) if (gpio->ports[m].is_registered) - gpiochip_remove(&gpio->ports[m].bgc.gc); + gpiochip_remove(&gpio->ports[m].gc); } static struct dwapb_platform_data * @@ -591,11 +585,11 @@ static int dwapb_gpio_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct dwapb_gpio *gpio = platform_get_drvdata(pdev); - struct bgpio_chip *bgc = &gpio->ports[0].bgc; + struct gpio_chip *gc = &gpio->ports[0].gc; unsigned long flags; int i; - spin_lock_irqsave(&bgc->lock, flags); + spin_lock_irqsave(&gc->bgpio_lock, flags); for (i = 0; i < gpio->nr_ports; i++) { unsigned int offset; unsigned int idx = gpio->ports[i].idx; @@ -624,7 +618,7 @@ static int dwapb_gpio_suspend(struct device *dev) dwapb_write(gpio, GPIO_INTMASK, 0xffffffff); } } - spin_unlock_irqrestore(&bgc->lock, flags); + spin_unlock_irqrestore(&gc->bgpio_lock, flags); return 0; } @@ -633,11 +627,11 @@ static int dwapb_gpio_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct dwapb_gpio *gpio = platform_get_drvdata(pdev); - struct bgpio_chip *bgc = &gpio->ports[0].bgc; + struct gpio_chip *gc = &gpio->ports[0].gc; unsigned long flags; int i; - spin_lock_irqsave(&bgc->lock, flags); + spin_lock_irqsave(&gc->bgpio_lock, flags); for (i = 0; i < gpio->nr_ports; i++) { unsigned int offset; unsigned int idx = gpio->ports[i].idx; @@ -666,7 +660,7 @@ static int dwapb_gpio_resume(struct device *dev) dwapb_write(gpio, GPIO_PORTA_EOI, 0xffffffff); } } - spin_unlock_irqrestore(&bgc->lock, flags); + spin_unlock_irqrestore(&gc->bgpio_lock, flags); return 0; } diff --git a/drivers/gpio/gpio-ep93xx.c b/drivers/gpio/gpio-ep93xx.c index 3e3947b35c83..ad279078fed7 100644 --- a/drivers/gpio/gpio-ep93xx.c +++ b/drivers/gpio/gpio-ep93xx.c @@ -16,10 +16,11 @@ #include #include #include -#include #include #include -#include +#include +/* FIXME: this is here for gpio_to_irq() - get rid of this! */ +#include #include #include @@ -28,7 +29,7 @@ struct ep93xx_gpio { void __iomem *mmio_base; - struct bgpio_chip bgc[8]; + struct gpio_chip gc[8]; }; /************************************************************************* @@ -319,26 +320,26 @@ static int ep93xx_gpio_to_irq(struct gpio_chip *chip, unsigned offset) return 64 + gpio; } -static int ep93xx_gpio_add_bank(struct bgpio_chip *bgc, struct device *dev, +static int ep93xx_gpio_add_bank(struct gpio_chip *gc, struct device *dev, void __iomem *mmio_base, struct ep93xx_gpio_bank *bank) { void __iomem *data = mmio_base + bank->data; void __iomem *dir = mmio_base + bank->dir; int err; - err = bgpio_init(bgc, dev, 1, data, NULL, NULL, dir, NULL, 0); + err = bgpio_init(gc, dev, 1, data, NULL, NULL, dir, NULL, 0); if (err) return err; - bgc->gc.label = bank->label; - bgc->gc.base = bank->base; + gc->label = bank->label; + gc->base = bank->base; if (bank->has_debounce) { - bgc->gc.set_debounce = ep93xx_gpio_set_debounce; - bgc->gc.to_irq = ep93xx_gpio_to_irq; + gc->set_debounce = ep93xx_gpio_set_debounce; + gc->to_irq = ep93xx_gpio_to_irq; } - return gpiochip_add(&bgc->gc); + return gpiochip_add_data(gc, NULL); } static int ep93xx_gpio_probe(struct platform_device *pdev) @@ -358,10 +359,10 @@ static int ep93xx_gpio_probe(struct platform_device *pdev) return PTR_ERR(ep93xx_gpio->mmio_base); for (i = 0; i < ARRAY_SIZE(ep93xx_gpio_banks); i++) { - struct bgpio_chip *bgc = &ep93xx_gpio->bgc[i]; + struct gpio_chip *gc = &ep93xx_gpio->gc[i]; struct ep93xx_gpio_bank *bank = &ep93xx_gpio_banks[i]; - if (ep93xx_gpio_add_bank(bgc, &pdev->dev, + if (ep93xx_gpio_add_bank(gc, &pdev->dev, ep93xx_gpio->mmio_base, bank)) dev_warn(&pdev->dev, "Unable to add gpio bank %s\n", bank->label); 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 #include -#include #include #include #include #include #include -#include #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); } } diff --git a/drivers/gpio/gpio-ge.c b/drivers/gpio/gpio-ge.c index f9ac3f351753..cbbec838a9d1 100644 --- a/drivers/gpio/gpio-ge.c +++ b/drivers/gpio/gpio-ge.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #define GEF_GPIO_DIRECT 0x00 #define GEF_GPIO_IN 0x04 @@ -55,19 +55,19 @@ static int __init gef_gpio_probe(struct platform_device *pdev) { const struct of_device_id *of_id = of_match_device(gef_gpio_ids, &pdev->dev); - struct bgpio_chip *bgc; + struct gpio_chip *gc; void __iomem *regs; int ret; - bgc = devm_kzalloc(&pdev->dev, sizeof(*bgc), GFP_KERNEL); - if (!bgc) + gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL); + if (!gc) return -ENOMEM; regs = of_iomap(pdev->dev.of_node, 0); if (!regs) return -ENOMEM; - ret = bgpio_init(bgc, &pdev->dev, 4, regs + GEF_GPIO_IN, + ret = bgpio_init(gc, &pdev->dev, 4, regs + GEF_GPIO_IN, regs + GEF_GPIO_OUT, NULL, NULL, regs + GEF_GPIO_DIRECT, BGPIOF_BIG_ENDIAN_BYTE_ORDER); if (ret) { @@ -76,20 +76,20 @@ static int __init gef_gpio_probe(struct platform_device *pdev) } /* Setup pointers to chip functions */ - bgc->gc.label = devm_kstrdup(&pdev->dev, pdev->dev.of_node->full_name, + gc->label = devm_kstrdup(&pdev->dev, pdev->dev.of_node->full_name, GFP_KERNEL); - if (!bgc->gc.label) { + if (!gc->label) { ret = -ENOMEM; goto err0; } - bgc->gc.base = -1; - bgc->gc.ngpio = (u16)(uintptr_t)of_id->data; - bgc->gc.of_gpio_n_cells = 2; - bgc->gc.of_node = pdev->dev.of_node; + gc->base = -1; + gc->ngpio = (u16)(uintptr_t)of_id->data; + gc->of_gpio_n_cells = 2; + gc->of_node = pdev->dev.of_node; /* This function adds a memory mapped GPIO chip */ - ret = gpiochip_add(&bgc->gc); + ret = gpiochip_add_data(gc, NULL); if (ret) goto err0; diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c index 053a7f0a83e6..2a4f2333a50b 100644 --- a/drivers/gpio/gpio-generic.c +++ b/drivers/gpio/gpio-generic.c @@ -56,12 +56,11 @@ o ` ~~~~\___/~~~~ ` controller in FPGA is ,.` #include #include #include -#include +#include #include #include #include #include -#include static void bgpio_write8(void __iomem *reg, unsigned long data) { @@ -125,33 +124,30 @@ static unsigned long bgpio_read32be(void __iomem *reg) return ioread32be(reg); } -static unsigned long bgpio_pin2mask(struct bgpio_chip *bgc, unsigned int pin) +static unsigned long bgpio_pin2mask(struct gpio_chip *gc, unsigned int pin) { return BIT(pin); } -static unsigned long bgpio_pin2mask_be(struct bgpio_chip *bgc, +static unsigned long bgpio_pin2mask_be(struct gpio_chip *gc, unsigned int pin) { - return BIT(bgc->bits - 1 - pin); + return BIT(gc->bgpio_bits - 1 - pin); } static int bgpio_get_set(struct gpio_chip *gc, unsigned int gpio) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); - unsigned long pinmask = bgc->pin2mask(bgc, gpio); + unsigned long pinmask = gc->pin2mask(gc, gpio); - if (bgc->dir & pinmask) - return !!(bgc->read_reg(bgc->reg_set) & pinmask); + if (gc->bgpio_dir & pinmask) + return !!(gc->read_reg(gc->reg_set) & pinmask); else - return !!(bgc->read_reg(bgc->reg_dat) & pinmask); + return !!(gc->read_reg(gc->reg_dat) & pinmask); } static int bgpio_get(struct gpio_chip *gc, unsigned int gpio) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); - - return !!(bgc->read_reg(bgc->reg_dat) & bgc->pin2mask(bgc, gpio)); + return !!(gc->read_reg(gc->reg_dat) & gc->pin2mask(gc, gpio)); } static void bgpio_set_none(struct gpio_chip *gc, unsigned int gpio, int val) @@ -160,53 +156,50 @@ static void bgpio_set_none(struct gpio_chip *gc, unsigned int gpio, int val) static void bgpio_set(struct gpio_chip *gc, unsigned int gpio, int val) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); - unsigned long mask = bgc->pin2mask(bgc, gpio); + unsigned long mask = gc->pin2mask(gc, gpio); unsigned long flags; - spin_lock_irqsave(&bgc->lock, flags); + spin_lock_irqsave(&gc->bgpio_lock, flags); if (val) - bgc->data |= mask; + gc->bgpio_data |= mask; else - bgc->data &= ~mask; + gc->bgpio_data &= ~mask; - bgc->write_reg(bgc->reg_dat, bgc->data); + gc->write_reg(gc->reg_dat, gc->bgpio_data); - spin_unlock_irqrestore(&bgc->lock, flags); + spin_unlock_irqrestore(&gc->bgpio_lock, flags); } static void bgpio_set_with_clear(struct gpio_chip *gc, unsigned int gpio, int val) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); - unsigned long mask = bgc->pin2mask(bgc, gpio); + unsigned long mask = gc->pin2mask(gc, gpio); if (val) - bgc->write_reg(bgc->reg_set, mask); + gc->write_reg(gc->reg_set, mask); else - bgc->write_reg(bgc->reg_clr, mask); + gc->write_reg(gc->reg_clr, mask); } static void bgpio_set_set(struct gpio_chip *gc, unsigned int gpio, int val) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); - unsigned long mask = bgc->pin2mask(bgc, gpio); + unsigned long mask = gc->pin2mask(gc, gpio); unsigned long flags; - spin_lock_irqsave(&bgc->lock, flags); + spin_lock_irqsave(&gc->bgpio_lock, flags); if (val) - bgc->data |= mask; + gc->bgpio_data |= mask; else - bgc->data &= ~mask; + gc->bgpio_data &= ~mask; - bgc->write_reg(bgc->reg_set, bgc->data); + gc->write_reg(gc->reg_set, gc->bgpio_data); - spin_unlock_irqrestore(&bgc->lock, flags); + spin_unlock_irqrestore(&gc->bgpio_lock, flags); } -static void bgpio_multiple_get_masks(struct bgpio_chip *bgc, +static void bgpio_multiple_get_masks(struct gpio_chip *gc, unsigned long *mask, unsigned long *bits, unsigned long *set_mask, unsigned long *clear_mask) @@ -216,19 +209,19 @@ static void bgpio_multiple_get_masks(struct bgpio_chip *bgc, *set_mask = 0; *clear_mask = 0; - for (i = 0; i < bgc->bits; i++) { + for (i = 0; i < gc->bgpio_bits; i++) { if (*mask == 0) break; if (__test_and_clear_bit(i, mask)) { if (test_bit(i, bits)) - *set_mask |= bgc->pin2mask(bgc, i); + *set_mask |= gc->pin2mask(gc, i); else - *clear_mask |= bgc->pin2mask(bgc, i); + *clear_mask |= gc->pin2mask(gc, i); } } } -static void bgpio_set_multiple_single_reg(struct bgpio_chip *bgc, +static void bgpio_set_multiple_single_reg(struct gpio_chip *gc, unsigned long *mask, unsigned long *bits, void __iomem *reg) @@ -236,47 +229,42 @@ static void bgpio_set_multiple_single_reg(struct bgpio_chip *bgc, unsigned long flags; unsigned long set_mask, clear_mask; - spin_lock_irqsave(&bgc->lock, flags); + spin_lock_irqsave(&gc->bgpio_lock, flags); - bgpio_multiple_get_masks(bgc, mask, bits, &set_mask, &clear_mask); + bgpio_multiple_get_masks(gc, mask, bits, &set_mask, &clear_mask); - bgc->data |= set_mask; - bgc->data &= ~clear_mask; + gc->bgpio_data |= set_mask; + gc->bgpio_data &= ~clear_mask; - bgc->write_reg(reg, bgc->data); + gc->write_reg(reg, gc->bgpio_data); - spin_unlock_irqrestore(&bgc->lock, flags); + spin_unlock_irqrestore(&gc->bgpio_lock, flags); } static void bgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, unsigned long *bits) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); - - bgpio_set_multiple_single_reg(bgc, mask, bits, bgc->reg_dat); + bgpio_set_multiple_single_reg(gc, mask, bits, gc->reg_dat); } static void bgpio_set_multiple_set(struct gpio_chip *gc, unsigned long *mask, unsigned long *bits) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); - - bgpio_set_multiple_single_reg(bgc, mask, bits, bgc->reg_set); + bgpio_set_multiple_single_reg(gc, mask, bits, gc->reg_set); } static void bgpio_set_multiple_with_clear(struct gpio_chip *gc, unsigned long *mask, unsigned long *bits) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); unsigned long set_mask, clear_mask; - bgpio_multiple_get_masks(bgc, mask, bits, &set_mask, &clear_mask); + bgpio_multiple_get_masks(gc, mask, bits, &set_mask, &clear_mask); if (set_mask) - bgc->write_reg(bgc->reg_set, set_mask); + gc->write_reg(gc->reg_set, set_mask); if (clear_mask) - bgc->write_reg(bgc->reg_clr, clear_mask); + gc->write_reg(gc->reg_clr, clear_mask); } static int bgpio_simple_dir_in(struct gpio_chip *gc, unsigned int gpio) @@ -300,111 +288,103 @@ static int bgpio_simple_dir_out(struct gpio_chip *gc, unsigned int gpio, static int bgpio_dir_in(struct gpio_chip *gc, unsigned int gpio) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); unsigned long flags; - spin_lock_irqsave(&bgc->lock, flags); + spin_lock_irqsave(&gc->bgpio_lock, flags); - bgc->dir &= ~bgc->pin2mask(bgc, gpio); - bgc->write_reg(bgc->reg_dir, bgc->dir); + gc->bgpio_dir &= ~gc->pin2mask(gc, gpio); + gc->write_reg(gc->reg_dir, gc->bgpio_dir); - spin_unlock_irqrestore(&bgc->lock, flags); + spin_unlock_irqrestore(&gc->bgpio_lock, flags); return 0; } static int bgpio_get_dir(struct gpio_chip *gc, unsigned int gpio) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); - - return (bgc->read_reg(bgc->reg_dir) & bgc->pin2mask(bgc, gpio)) ? - GPIOF_DIR_OUT : GPIOF_DIR_IN; + /* Return 0 if output, 1 of input */ + return !(gc->read_reg(gc->reg_dir) & gc->pin2mask(gc, gpio)); } static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); unsigned long flags; gc->set(gc, gpio, val); - spin_lock_irqsave(&bgc->lock, flags); + spin_lock_irqsave(&gc->bgpio_lock, flags); - bgc->dir |= bgc->pin2mask(bgc, gpio); - bgc->write_reg(bgc->reg_dir, bgc->dir); + gc->bgpio_dir |= gc->pin2mask(gc, gpio); + gc->write_reg(gc->reg_dir, gc->bgpio_dir); - spin_unlock_irqrestore(&bgc->lock, flags); + spin_unlock_irqrestore(&gc->bgpio_lock, flags); return 0; } static int bgpio_dir_in_inv(struct gpio_chip *gc, unsigned int gpio) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); unsigned long flags; - spin_lock_irqsave(&bgc->lock, flags); + spin_lock_irqsave(&gc->bgpio_lock, flags); - bgc->dir |= bgc->pin2mask(bgc, gpio); - bgc->write_reg(bgc->reg_dir, bgc->dir); + gc->bgpio_dir |= gc->pin2mask(gc, gpio); + gc->write_reg(gc->reg_dir, gc->bgpio_dir); - spin_unlock_irqrestore(&bgc->lock, flags); + spin_unlock_irqrestore(&gc->bgpio_lock, flags); return 0; } static int bgpio_dir_out_inv(struct gpio_chip *gc, unsigned int gpio, int val) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); unsigned long flags; gc->set(gc, gpio, val); - spin_lock_irqsave(&bgc->lock, flags); + spin_lock_irqsave(&gc->bgpio_lock, flags); - bgc->dir &= ~bgc->pin2mask(bgc, gpio); - bgc->write_reg(bgc->reg_dir, bgc->dir); + gc->bgpio_dir &= ~gc->pin2mask(gc, gpio); + gc->write_reg(gc->reg_dir, gc->bgpio_dir); - spin_unlock_irqrestore(&bgc->lock, flags); + spin_unlock_irqrestore(&gc->bgpio_lock, flags); return 0; } static int bgpio_get_dir_inv(struct gpio_chip *gc, unsigned int gpio) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); - - return (bgc->read_reg(bgc->reg_dir) & bgc->pin2mask(bgc, gpio)) ? - GPIOF_DIR_IN : GPIOF_DIR_OUT; + /* Return 0 if output, 1 if input */ + return !!(gc->read_reg(gc->reg_dir) & gc->pin2mask(gc, gpio)); } static int bgpio_setup_accessors(struct device *dev, - struct bgpio_chip *bgc, + struct gpio_chip *gc, bool bit_be, bool byte_be) { - switch (bgc->bits) { + switch (gc->bgpio_bits) { case 8: - bgc->read_reg = bgpio_read8; - bgc->write_reg = bgpio_write8; + gc->read_reg = bgpio_read8; + gc->write_reg = bgpio_write8; break; case 16: if (byte_be) { - bgc->read_reg = bgpio_read16be; - bgc->write_reg = bgpio_write16be; + gc->read_reg = bgpio_read16be; + gc->write_reg = bgpio_write16be; } else { - bgc->read_reg = bgpio_read16; - bgc->write_reg = bgpio_write16; + gc->read_reg = bgpio_read16; + gc->write_reg = bgpio_write16; } break; case 32: if (byte_be) { - bgc->read_reg = bgpio_read32be; - bgc->write_reg = bgpio_write32be; + gc->read_reg = bgpio_read32be; + gc->write_reg = bgpio_write32be; } else { - bgc->read_reg = bgpio_read32; - bgc->write_reg = bgpio_write32; + gc->read_reg = bgpio_read32; + gc->write_reg = bgpio_write32; } break; #if BITS_PER_LONG >= 64 @@ -414,17 +394,17 @@ static int bgpio_setup_accessors(struct device *dev, "64 bit big endian byte order unsupported\n"); return -EINVAL; } else { - bgc->read_reg = bgpio_read64; - bgc->write_reg = bgpio_write64; + gc->read_reg = bgpio_read64; + gc->write_reg = bgpio_write64; } break; #endif /* BITS_PER_LONG >= 64 */ default: - dev_err(dev, "unsupported data width %u bits\n", bgc->bits); + dev_err(dev, "unsupported data width %u bits\n", gc->bgpio_bits); return -EINVAL; } - bgc->pin2mask = bit_be ? bgpio_pin2mask_be : bgpio_pin2mask; + gc->pin2mask = bit_be ? bgpio_pin2mask_be : bgpio_pin2mask; return 0; } @@ -451,44 +431,44 @@ static int bgpio_setup_accessors(struct device *dev, * - an input direction register (named "dirin") where a 1 bit indicates * the GPIO is an input. */ -static int bgpio_setup_io(struct bgpio_chip *bgc, +static int bgpio_setup_io(struct gpio_chip *gc, void __iomem *dat, void __iomem *set, void __iomem *clr, unsigned long flags) { - bgc->reg_dat = dat; - if (!bgc->reg_dat) + gc->reg_dat = dat; + if (!gc->reg_dat) return -EINVAL; if (set && clr) { - bgc->reg_set = set; - bgc->reg_clr = clr; - bgc->gc.set = bgpio_set_with_clear; - bgc->gc.set_multiple = bgpio_set_multiple_with_clear; + gc->reg_set = set; + gc->reg_clr = clr; + gc->set = bgpio_set_with_clear; + gc->set_multiple = bgpio_set_multiple_with_clear; } else if (set && !clr) { - bgc->reg_set = set; - bgc->gc.set = bgpio_set_set; - bgc->gc.set_multiple = bgpio_set_multiple_set; + gc->reg_set = set; + gc->set = bgpio_set_set; + gc->set_multiple = bgpio_set_multiple_set; } else if (flags & BGPIOF_NO_OUTPUT) { - bgc->gc.set = bgpio_set_none; - bgc->gc.set_multiple = NULL; + gc->set = bgpio_set_none; + gc->set_multiple = NULL; } else { - bgc->gc.set = bgpio_set; - bgc->gc.set_multiple = bgpio_set_multiple; + gc->set = bgpio_set; + gc->set_multiple = bgpio_set_multiple; } if (!(flags & BGPIOF_UNREADABLE_REG_SET) && (flags & BGPIOF_READ_OUTPUT_REG_SET)) - bgc->gc.get = bgpio_get_set; + gc->get = bgpio_get_set; else - bgc->gc.get = bgpio_get; + gc->get = bgpio_get; return 0; } -static int bgpio_setup_direction(struct bgpio_chip *bgc, +static int bgpio_setup_direction(struct gpio_chip *gc, void __iomem *dirout, void __iomem *dirin, unsigned long flags) @@ -496,21 +476,21 @@ static int bgpio_setup_direction(struct bgpio_chip *bgc, if (dirout && dirin) { return -EINVAL; } else if (dirout) { - bgc->reg_dir = dirout; - bgc->gc.direction_output = bgpio_dir_out; - bgc->gc.direction_input = bgpio_dir_in; - bgc->gc.get_direction = bgpio_get_dir; + gc->reg_dir = dirout; + gc->direction_output = bgpio_dir_out; + gc->direction_input = bgpio_dir_in; + gc->get_direction = bgpio_get_dir; } else if (dirin) { - bgc->reg_dir = dirin; - bgc->gc.direction_output = bgpio_dir_out_inv; - bgc->gc.direction_input = bgpio_dir_in_inv; - bgc->gc.get_direction = bgpio_get_dir_inv; + gc->reg_dir = dirin; + gc->direction_output = bgpio_dir_out_inv; + gc->direction_input = bgpio_dir_in_inv; + gc->get_direction = bgpio_get_dir_inv; } else { if (flags & BGPIOF_NO_OUTPUT) - bgc->gc.direction_output = bgpio_dir_out_err; + gc->direction_output = bgpio_dir_out_err; else - bgc->gc.direction_output = bgpio_simple_dir_out; - bgc->gc.direction_input = bgpio_simple_dir_in; + gc->direction_output = bgpio_simple_dir_out; + gc->direction_input = bgpio_simple_dir_in; } return 0; @@ -524,14 +504,7 @@ static int bgpio_request(struct gpio_chip *chip, unsigned gpio_pin) return -EINVAL; } -int bgpio_remove(struct bgpio_chip *bgc) -{ - gpiochip_remove(&bgc->gc); - return 0; -} -EXPORT_SYMBOL_GPL(bgpio_remove); - -int bgpio_init(struct bgpio_chip *bgc, struct device *dev, +int bgpio_init(struct gpio_chip *gc, struct device *dev, unsigned long sz, void __iomem *dat, void __iomem *set, void __iomem *clr, void __iomem *dirout, void __iomem *dirin, unsigned long flags) @@ -541,36 +514,36 @@ int bgpio_init(struct bgpio_chip *bgc, struct device *dev, if (!is_power_of_2(sz)) return -EINVAL; - bgc->bits = sz * 8; - if (bgc->bits > BITS_PER_LONG) + gc->bgpio_bits = sz * 8; + if (gc->bgpio_bits > BITS_PER_LONG) return -EINVAL; - spin_lock_init(&bgc->lock); - bgc->gc.parent = dev; - bgc->gc.label = dev_name(dev); - bgc->gc.base = -1; - bgc->gc.ngpio = bgc->bits; - bgc->gc.request = bgpio_request; + spin_lock_init(&gc->bgpio_lock); + gc->parent = dev; + gc->label = dev_name(dev); + gc->base = -1; + gc->ngpio = gc->bgpio_bits; + gc->request = bgpio_request; - ret = bgpio_setup_io(bgc, dat, set, clr, flags); + ret = bgpio_setup_io(gc, dat, set, clr, flags); if (ret) return ret; - ret = bgpio_setup_accessors(dev, bgc, flags & BGPIOF_BIG_ENDIAN, + ret = bgpio_setup_accessors(dev, gc, flags & BGPIOF_BIG_ENDIAN, flags & BGPIOF_BIG_ENDIAN_BYTE_ORDER); if (ret) return ret; - ret = bgpio_setup_direction(bgc, dirout, dirin, flags); + ret = bgpio_setup_direction(gc, dirout, dirin, flags); if (ret) return ret; - bgc->data = bgc->read_reg(bgc->reg_dat); - if (bgc->gc.set == bgpio_set_set && + gc->bgpio_data = gc->read_reg(gc->reg_dat); + if (gc->set == bgpio_set_set && !(flags & BGPIOF_UNREADABLE_REG_SET)) - bgc->data = bgc->read_reg(bgc->reg_set); - if (bgc->reg_dir && !(flags & BGPIOF_UNREADABLE_REG_DIR)) - bgc->dir = bgc->read_reg(bgc->reg_dir); + gc->bgpio_data = gc->read_reg(gc->reg_set); + if (gc->reg_dir && !(flags & BGPIOF_UNREADABLE_REG_DIR)) + gc->bgpio_dir = gc->read_reg(gc->reg_dir); return ret; } @@ -608,7 +581,7 @@ static int bgpio_pdev_probe(struct platform_device *pdev) unsigned long sz; unsigned long flags = pdev->id_entry->driver_data; int err; - struct bgpio_chip *bgc; + struct gpio_chip *gc; struct bgpio_pdata *pdata = dev_get_platdata(dev); r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dat"); @@ -637,32 +610,33 @@ static int bgpio_pdev_probe(struct platform_device *pdev) if (IS_ERR(dirin)) return PTR_ERR(dirin); - bgc = devm_kzalloc(&pdev->dev, sizeof(*bgc), GFP_KERNEL); - if (!bgc) + gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL); + if (!gc) return -ENOMEM; - err = bgpio_init(bgc, dev, sz, dat, set, clr, dirout, dirin, flags); + err = bgpio_init(gc, dev, sz, dat, set, clr, dirout, dirin, flags); if (err) return err; if (pdata) { if (pdata->label) - bgc->gc.label = pdata->label; - bgc->gc.base = pdata->base; + gc->label = pdata->label; + gc->base = pdata->base; if (pdata->ngpio > 0) - bgc->gc.ngpio = pdata->ngpio; + gc->ngpio = pdata->ngpio; } - platform_set_drvdata(pdev, bgc); + platform_set_drvdata(pdev, gc); - return gpiochip_add(&bgc->gc); + return gpiochip_add_data(gc, NULL); } static int bgpio_pdev_remove(struct platform_device *pdev) { - struct bgpio_chip *bgc = platform_get_drvdata(pdev); + struct gpio_chip *gc = platform_get_drvdata(pdev); - return bgpio_remove(bgc); + gpiochip_remove(gc); + return 0; } static const struct platform_device_id bgpio_id_table[] = { diff --git a/drivers/gpio/gpio-grgpio.c b/drivers/gpio/gpio-grgpio.c index 801423fe8143..7847dd34f86f 100644 --- a/drivers/gpio/gpio-grgpio.c +++ b/drivers/gpio/gpio-grgpio.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include @@ -63,7 +63,7 @@ struct grgpio_lirq { }; struct grgpio_priv { - struct bgpio_chip bgc; + struct gpio_chip gc; void __iomem *regs; struct device *dev; @@ -92,29 +92,22 @@ struct grgpio_priv { struct grgpio_lirq lirqs[GRGPIO_MAX_NGPIO]; }; -static inline struct grgpio_priv *grgpio_gc_to_priv(struct gpio_chip *gc) -{ - struct bgpio_chip *bgc = to_bgpio_chip(gc); - - return container_of(bgc, struct grgpio_priv, bgc); -} - static void grgpio_set_imask(struct grgpio_priv *priv, unsigned int offset, int val) { - struct bgpio_chip *bgc = &priv->bgc; - unsigned long mask = bgc->pin2mask(bgc, offset); + struct gpio_chip *gc = &priv->gc; + unsigned long mask = gc->pin2mask(gc, offset); if (val) priv->imask |= mask; else priv->imask &= ~mask; - bgc->write_reg(priv->regs + GRGPIO_IMASK, priv->imask); + gc->write_reg(priv->regs + GRGPIO_IMASK, priv->imask); } static int grgpio_to_irq(struct gpio_chip *gc, unsigned offset) { - struct grgpio_priv *priv = grgpio_gc_to_priv(gc); + struct grgpio_priv *priv = gpiochip_get_data(gc); if (offset >= gc->ngpio) return -ENXIO; @@ -158,15 +151,15 @@ static int grgpio_irq_set_type(struct irq_data *d, unsigned int type) return -EINVAL; } - spin_lock_irqsave(&priv->bgc.lock, flags); + spin_lock_irqsave(&priv->gc.bgpio_lock, flags); - ipol = priv->bgc.read_reg(priv->regs + GRGPIO_IPOL) & ~mask; - iedge = priv->bgc.read_reg(priv->regs + GRGPIO_IEDGE) & ~mask; + ipol = priv->gc.read_reg(priv->regs + GRGPIO_IPOL) & ~mask; + iedge = priv->gc.read_reg(priv->regs + GRGPIO_IEDGE) & ~mask; - priv->bgc.write_reg(priv->regs + GRGPIO_IPOL, ipol | pol); - priv->bgc.write_reg(priv->regs + GRGPIO_IEDGE, iedge | edge); + priv->gc.write_reg(priv->regs + GRGPIO_IPOL, ipol | pol); + priv->gc.write_reg(priv->regs + GRGPIO_IEDGE, iedge | edge); - spin_unlock_irqrestore(&priv->bgc.lock, flags); + spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags); return 0; } @@ -177,11 +170,11 @@ static void grgpio_irq_mask(struct irq_data *d) int offset = d->hwirq; unsigned long flags; - spin_lock_irqsave(&priv->bgc.lock, flags); + spin_lock_irqsave(&priv->gc.bgpio_lock, flags); grgpio_set_imask(priv, offset, 0); - spin_unlock_irqrestore(&priv->bgc.lock, flags); + spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags); } static void grgpio_irq_unmask(struct irq_data *d) @@ -190,11 +183,11 @@ static void grgpio_irq_unmask(struct irq_data *d) int offset = d->hwirq; unsigned long flags; - spin_lock_irqsave(&priv->bgc.lock, flags); + spin_lock_irqsave(&priv->gc.bgpio_lock, flags); grgpio_set_imask(priv, offset, 1); - spin_unlock_irqrestore(&priv->bgc.lock, flags); + spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags); } static struct irq_chip grgpio_irq_chip = { @@ -207,12 +200,12 @@ static struct irq_chip grgpio_irq_chip = { static irqreturn_t grgpio_irq_handler(int irq, void *dev) { struct grgpio_priv *priv = dev; - int ngpio = priv->bgc.gc.ngpio; + int ngpio = priv->gc.ngpio; unsigned long flags; int i; int match = 0; - spin_lock_irqsave(&priv->bgc.lock, flags); + spin_lock_irqsave(&priv->gc.bgpio_lock, flags); /* * For each gpio line, call its interrupt handler if it its underlying @@ -228,7 +221,7 @@ static irqreturn_t grgpio_irq_handler(int irq, void *dev) } } - spin_unlock_irqrestore(&priv->bgc.lock, flags); + spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags); if (!match) dev_warn(priv->dev, "No gpio line matched irq %d\n", irq); @@ -260,7 +253,7 @@ static int grgpio_irq_map(struct irq_domain *d, unsigned int irq, dev_dbg(priv->dev, "Mapping irq %d for gpio line %d\n", irq, offset); - spin_lock_irqsave(&priv->bgc.lock, flags); + spin_lock_irqsave(&priv->gc.bgpio_lock, flags); /* Request underlying irq if not already requested */ lirq->irq = irq; @@ -273,14 +266,14 @@ static int grgpio_irq_map(struct irq_domain *d, unsigned int irq, "Could not request underlying irq %d\n", uirq->uirq); - spin_unlock_irqrestore(&priv->bgc.lock, flags); + spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags); return ret; } } uirq->refcnt++; - spin_unlock_irqrestore(&priv->bgc.lock, flags); + spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags); /* Setup irq */ irq_set_chip_data(irq, priv); @@ -298,13 +291,13 @@ static void grgpio_irq_unmap(struct irq_domain *d, unsigned int irq) struct grgpio_lirq *lirq; struct grgpio_uirq *uirq; unsigned long flags; - int ngpio = priv->bgc.gc.ngpio; + int ngpio = priv->gc.ngpio; int i; irq_set_chip_and_handler(irq, NULL, NULL); irq_set_chip_data(irq, NULL); - spin_lock_irqsave(&priv->bgc.lock, flags); + spin_lock_irqsave(&priv->gc.bgpio_lock, flags); /* Free underlying irq if last user unmapped */ index = -1; @@ -326,7 +319,7 @@ static void grgpio_irq_unmap(struct irq_domain *d, unsigned int irq) free_irq(uirq->uirq, priv); } - spin_unlock_irqrestore(&priv->bgc.lock, flags); + spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags); } static const struct irq_domain_ops grgpio_irq_domain_ops = { @@ -341,7 +334,6 @@ static int grgpio_probe(struct platform_device *ofdev) struct device_node *np = ofdev->dev.of_node; void __iomem *regs; struct gpio_chip *gc; - struct bgpio_chip *bgc; struct grgpio_priv *priv; struct resource *res; int err; @@ -359,8 +351,8 @@ static int grgpio_probe(struct platform_device *ofdev) if (IS_ERR(regs)) return PTR_ERR(regs); - bgc = &priv->bgc; - err = bgpio_init(bgc, &ofdev->dev, 4, regs + GRGPIO_DATA, + gc = &priv->gc; + err = bgpio_init(gc, &ofdev->dev, 4, regs + GRGPIO_DATA, regs + GRGPIO_OUTPUT, NULL, regs + GRGPIO_DIR, NULL, BGPIOF_BIG_ENDIAN_BYTE_ORDER); if (err) { @@ -369,10 +361,9 @@ static int grgpio_probe(struct platform_device *ofdev) } priv->regs = regs; - priv->imask = bgc->read_reg(regs + GRGPIO_IMASK); + priv->imask = gc->read_reg(regs + GRGPIO_IMASK); priv->dev = &ofdev->dev; - gc = &bgc->gc; gc->of_node = np; gc->owner = THIS_MODULE; gc->to_irq = grgpio_to_irq; @@ -435,7 +426,7 @@ static int grgpio_probe(struct platform_device *ofdev) platform_set_drvdata(ofdev, priv); - err = gpiochip_add(gc); + err = gpiochip_add_data(gc, priv); if (err) { dev_err(&ofdev->dev, "Could not add gpiochip\n"); if (priv->domain) @@ -456,7 +447,7 @@ static int grgpio_remove(struct platform_device *ofdev) int i; int ret = 0; - spin_lock_irqsave(&priv->bgc.lock, flags); + spin_lock_irqsave(&priv->gc.bgpio_lock, flags); if (priv->domain) { for (i = 0; i < GRGPIO_MAX_NGPIO; i++) { @@ -467,13 +458,13 @@ static int grgpio_remove(struct platform_device *ofdev) } } - gpiochip_remove(&priv->bgc.gc); + gpiochip_remove(&priv->gc); if (priv->domain) irq_domain_remove(priv->domain); out: - spin_unlock_irqrestore(&priv->bgc.lock, flags); + spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags); return ret; } diff --git a/drivers/gpio/gpio-moxart.c b/drivers/gpio/gpio-moxart.c index 8942f4909a31..71c13c4e12b5 100644 --- a/drivers/gpio/gpio-moxart.c +++ b/drivers/gpio/gpio-moxart.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -23,7 +22,7 @@ #include #include #include -#include +#include #define GPIO_DATA_OUT 0x00 #define GPIO_DATA_IN 0x04 @@ -33,12 +32,12 @@ static int moxart_gpio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct resource *res; - struct bgpio_chip *bgc; + struct gpio_chip *gc; void __iomem *base; int ret; - bgc = devm_kzalloc(dev, sizeof(*bgc), GFP_KERNEL); - if (!bgc) + gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL); + if (!gc) return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -46,7 +45,7 @@ static int moxart_gpio_probe(struct platform_device *pdev) if (IS_ERR(base)) return PTR_ERR(base); - ret = bgpio_init(bgc, dev, 4, base + GPIO_DATA_IN, + ret = bgpio_init(gc, dev, 4, base + GPIO_DATA_IN, base + GPIO_DATA_OUT, NULL, base + GPIO_PIN_DIRECTION, NULL, BGPIOF_READ_OUTPUT_REG_SET); @@ -55,16 +54,16 @@ static int moxart_gpio_probe(struct platform_device *pdev) return ret; } - bgc->gc.label = "moxart-gpio"; - bgc->gc.request = gpiochip_generic_request; - bgc->gc.free = gpiochip_generic_free; - bgc->data = bgc->read_reg(bgc->reg_set); - bgc->gc.base = 0; - bgc->gc.ngpio = 32; - bgc->gc.parent = dev; - bgc->gc.owner = THIS_MODULE; + gc->label = "moxart-gpio"; + gc->request = gpiochip_generic_request; + gc->free = gpiochip_generic_free; + gc->bgpio_data = bgc->read_reg(bgc->reg_set); + gc->base = 0; + gc->ngpio = 32; + gc->parent = dev; + gc->owner = THIS_MODULE; - ret = gpiochip_add(&bgc->gc); + ret = gpiochip_add_data(gc, NULL); if (ret) { dev_err(dev, "%s: gpiochip_add failed\n", dev->of_node->full_name); diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c index 6ea8df6c7397..7fd21cb53c81 100644 --- a/drivers/gpio/gpio-mxc.c +++ b/drivers/gpio/gpio-mxc.c @@ -26,10 +26,11 @@ #include #include #include -#include #include #include -#include +#include +/* FIXME: for gpio_get_value() replace this with direct register read */ +#include #include #include #include @@ -64,7 +65,7 @@ struct mxc_gpio_port { int irq; int irq_high; struct irq_domain *domain; - struct bgpio_chip bgc; + struct gpio_chip gc; u32 both_edges; }; @@ -172,7 +173,7 @@ static int gpio_set_irq_type(struct irq_data *d, u32 type) struct mxc_gpio_port *port = gc->private; u32 bit, val; u32 gpio_idx = d->hwirq; - u32 gpio = port->bgc.gc.base + gpio_idx; + u32 gpio = port->gc.base + gpio_idx; int edge; void __iomem *reg = port->base; @@ -398,9 +399,7 @@ static void mxc_gpio_get_hw(struct platform_device *pdev) static int mxc_gpio_to_irq(struct gpio_chip *gc, unsigned offset) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); - struct mxc_gpio_port *port = - container_of(bgc, struct mxc_gpio_port, bgc); + struct mxc_gpio_port *port = gpiochip_get_data(gc); return irq_find_mapping(port->domain, offset); } @@ -451,7 +450,7 @@ static int mxc_gpio_probe(struct platform_device *pdev) port); } - err = bgpio_init(&port->bgc, &pdev->dev, 4, + err = bgpio_init(&port->gc, &pdev->dev, 4, port->base + GPIO_PSR, port->base + GPIO_DR, NULL, port->base + GPIO_GDIR, NULL, @@ -459,13 +458,13 @@ static int mxc_gpio_probe(struct platform_device *pdev) if (err) goto out_bgio; - port->bgc.gc.to_irq = mxc_gpio_to_irq; - port->bgc.gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 : + port->gc.to_irq = mxc_gpio_to_irq; + port->gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 : pdev->id * 32; - err = gpiochip_add(&port->bgc.gc); + err = gpiochip_add_data(&port->gc, port); if (err) - goto out_bgpio_remove; + goto out_bgio; irq_base = irq_alloc_descs(-1, 0, 32, numa_node_id()); if (irq_base < 0) { @@ -494,9 +493,7 @@ out_irqdomain_remove: out_irqdesc_free: irq_free_descs(irq_base, 32); out_gpiochip_remove: - gpiochip_remove(&port->bgc.gc); -out_bgpio_remove: - bgpio_remove(&port->bgc); + gpiochip_remove(&port->gc); out_bgio: dev_info(&pdev->dev, "%s failed with errno %d\n", __func__, err); return err; diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c index a4288f428819..b9daa0bf32a4 100644 --- a/drivers/gpio/gpio-mxs.c +++ b/drivers/gpio/gpio-mxs.c @@ -26,13 +26,14 @@ #include #include #include -#include #include #include #include #include #include -#include +#include +/* FIXME: for gpio_get_value(), replace this by direct register read */ +#include #include #define MXS_SET 0x4 @@ -64,7 +65,7 @@ struct mxs_gpio_port { int id; int irq; struct irq_domain *domain; - struct bgpio_chip bgc; + struct gpio_chip gc; enum mxs_gpio_id devid; u32 both_edges; }; @@ -93,7 +94,7 @@ static int mxs_gpio_set_irq_type(struct irq_data *d, unsigned int type) port->both_edges &= ~pin_mask; switch (type) { case IRQ_TYPE_EDGE_BOTH: - val = gpio_get_value(port->bgc.gc.base + d->hwirq); + val = gpio_get_value(port->gc.base + d->hwirq); if (val) edge = GPIO_INT_FALL_EDGE; else @@ -225,18 +226,14 @@ static int __init mxs_gpio_init_gc(struct mxs_gpio_port *port, int irq_base) static int mxs_gpio_to_irq(struct gpio_chip *gc, unsigned offset) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); - struct mxs_gpio_port *port = - container_of(bgc, struct mxs_gpio_port, bgc); + struct mxs_gpio_port *port = gpiochip_get_data(gc); return irq_find_mapping(port->domain, offset); } static int mxs_gpio_get_direction(struct gpio_chip *gc, unsigned offset) { - struct bgpio_chip *bgc = to_bgpio_chip(gc); - struct mxs_gpio_port *port = - container_of(bgc, struct mxs_gpio_port, bgc); + struct mxs_gpio_port *port = gpiochip_get_data(gc); u32 mask = 1 << offset; u32 dir; @@ -330,26 +327,24 @@ static int mxs_gpio_probe(struct platform_device *pdev) irq_set_chained_handler_and_data(port->irq, mxs_gpio_irq_handler, port); - err = bgpio_init(&port->bgc, &pdev->dev, 4, + err = bgpio_init(&port->gc, &pdev->dev, 4, port->base + PINCTRL_DIN(port), port->base + PINCTRL_DOUT(port) + MXS_SET, port->base + PINCTRL_DOUT(port) + MXS_CLR, port->base + PINCTRL_DOE(port), NULL, 0); if (err) - goto out_irqdesc_free; + goto out_irqdomain_remove; - port->bgc.gc.to_irq = mxs_gpio_to_irq; - port->bgc.gc.get_direction = mxs_gpio_get_direction; - port->bgc.gc.base = port->id * 32; + port->gc.to_irq = mxs_gpio_to_irq; + port->gc.get_direction = mxs_gpio_get_direction; + port->gc.base = port->id * 32; - err = gpiochip_add(&port->bgc.gc); + err = gpiochip_add_data(&port->gc, port); if (err) - goto out_bgpio_remove; + goto out_irqdomain_remove; return 0; -out_bgpio_remove: - bgpio_remove(&port->bgc); out_irqdomain_remove: irq_domain_remove(port->domain); out_irqdesc_free: diff --git a/drivers/gpio/gpio-sodaville.c b/drivers/gpio/gpio-sodaville.c index 34b02b42ab9e..e3cb6772f6ec 100644 --- a/drivers/gpio/gpio-sodaville.c +++ b/drivers/gpio/gpio-sodaville.c @@ -10,7 +10,6 @@ */ #include -#include #include #include #include @@ -20,7 +19,7 @@ #include #include #include -#include +#include #define DRV_NAME "sdv_gpio" #define SDV_NUM_PUB_GPIOS 12 @@ -43,7 +42,7 @@ struct sdv_gpio_chip_data { void __iomem *gpio_pub_base; struct irq_domain *id; struct irq_chip_generic *gc; - struct bgpio_chip bgpio; + struct gpio_chip chip; }; static int sdv_gpio_pub_set_type(struct irq_data *d, unsigned int type) @@ -226,14 +225,14 @@ static int sdv_gpio_probe(struct pci_dev *pdev, writel(mux_val, sd->gpio_pub_base + GPMUXCTL); } - ret = bgpio_init(&sd->bgpio, &pdev->dev, 4, + ret = bgpio_init(&sd->chip, &pdev->dev, 4, sd->gpio_pub_base + GPINR, sd->gpio_pub_base + GPOUTR, NULL, sd->gpio_pub_base + GPOER, NULL, 0); if (ret) goto unmap; - sd->bgpio.gc.ngpio = SDV_NUM_PUB_GPIOS; + sd->chip.ngpio = SDV_NUM_PUB_GPIOS; - ret = gpiochip_add(&sd->bgpio.gc); + ret = gpiochip_add_data(&sd->chip, sd); if (ret < 0) { dev_err(&pdev->dev, "gpiochip_add() failed.\n"); goto unmap; @@ -265,7 +264,7 @@ static void sdv_gpio_remove(struct pci_dev *pdev) free_irq(pdev->irq, sd); irq_free_descs(sd->irq_base, SDV_NUM_PUB_GPIOS); - gpiochip_remove(&sd->bgpio.gc); + gpiochip_remove(&sd->chip); pci_release_region(pdev, GPIO_BAR); iounmap(sd->gpio_pub_base); pci_disable_device(pdev); diff --git a/drivers/gpio/gpio-xgene-sb.c b/drivers/gpio/gpio-xgene-sb.c index d57068b9083e..282004deb5d4 100644 --- a/drivers/gpio/gpio-xgene-sb.c +++ b/drivers/gpio/gpio-xgene-sb.c @@ -23,10 +23,8 @@ #include #include #include -#include #include #include -#include #include "gpiolib.h" @@ -43,38 +41,31 @@ /** * struct xgene_gpio_sb - GPIO-Standby private data structure. - * @bgc: memory-mapped GPIO controllers. + * @gc: memory-mapped GPIO controllers. * @irq: Mapping GPIO pins and interrupt number * nirq: Number of GPIO pins that supports interrupt */ struct xgene_gpio_sb { - struct bgpio_chip bgc; + struct gpio_chip gc; u32 *irq; u32 nirq; }; -static inline struct xgene_gpio_sb *to_xgene_gpio_sb(struct gpio_chip *gc) -{ - struct bgpio_chip *bgc = to_bgpio_chip(gc); - - return container_of(bgc, struct xgene_gpio_sb, bgc); -} - -static void xgene_gpio_set_bit(struct bgpio_chip *bgc, void __iomem *reg, u32 gpio, int val) +static void xgene_gpio_set_bit(struct gpio_chip *gc, void __iomem *reg, u32 gpio, int val) { u32 data; - data = bgc->read_reg(reg); + data = gc->read_reg(reg); if (val) data |= GPIO_MASK(gpio); else data &= ~GPIO_MASK(gpio); - bgc->write_reg(reg, data); + gc->write_reg(reg, data); } static int apm_gpio_sb_to_irq(struct gpio_chip *gc, u32 gpio) { - struct xgene_gpio_sb *priv = to_xgene_gpio_sb(gc); + struct xgene_gpio_sb *priv = gpiochip_get_data(gc); if (priv->irq[gpio]) return priv->irq[gpio]; @@ -99,15 +90,15 @@ static int xgene_gpio_sb_probe(struct platform_device *pdev) if (IS_ERR(regs)) return PTR_ERR(regs); - ret = bgpio_init(&priv->bgc, &pdev->dev, 4, + ret = bgpio_init(&priv->gc, &pdev->dev, 4, regs + MPA_GPIO_IN_ADDR, regs + MPA_GPIO_OUT_ADDR, NULL, regs + MPA_GPIO_OE_ADDR, NULL, 0); if (ret) return ret; - priv->bgc.gc.to_irq = apm_gpio_sb_to_irq; - priv->bgc.gc.ngpio = XGENE_MAX_GPIO_DS; + priv->gc.to_irq = apm_gpio_sb_to_irq; + priv->gc.ngpio = XGENE_MAX_GPIO_DS; priv->nirq = XGENE_MAX_GPIO_DS_IRQ; @@ -118,14 +109,14 @@ static int xgene_gpio_sb_probe(struct platform_device *pdev) for (i = 0; i < priv->nirq; i++) { priv->irq[default_lines[i]] = platform_get_irq(pdev, i); - xgene_gpio_set_bit(&priv->bgc, regs + MPA_GPIO_SEL_LO, + xgene_gpio_set_bit(&priv->gc, regs + MPA_GPIO_SEL_LO, default_lines[i] * 2, 1); - xgene_gpio_set_bit(&priv->bgc, regs + MPA_GPIO_INT_LVL, i, 1); + xgene_gpio_set_bit(&priv->gc, regs + MPA_GPIO_INT_LVL, i, 1); } platform_set_drvdata(pdev, priv); - ret = gpiochip_add(&priv->bgc.gc); + ret = gpiochip_add_data(&priv->gc, priv); if (ret) dev_err(&pdev->dev, "failed to register X-Gene GPIO Standby driver\n"); else @@ -133,7 +124,7 @@ static int xgene_gpio_sb_probe(struct platform_device *pdev) if (priv->nirq > 0) { /* Register interrupt handlers for gpio signaled acpi events */ - acpi_gpiochip_request_interrupts(&priv->bgc.gc); + acpi_gpiochip_request_interrupts(&priv->gc); } return ret; @@ -144,10 +135,11 @@ static int xgene_gpio_sb_remove(struct platform_device *pdev) struct xgene_gpio_sb *priv = platform_get_drvdata(pdev); if (priv->nirq > 0) { - acpi_gpiochip_free_interrupts(&priv->bgc.gc); + acpi_gpiochip_free_interrupts(&priv->gc); } - return bgpio_remove(&priv->bgc); + gpiochip_remove(&priv->gc); + return 0; } static const struct of_device_id xgene_gpio_sb_of_match[] = { diff --git a/drivers/mfd/vexpress-sysreg.c b/drivers/mfd/vexpress-sysreg.c index 3e628df9280c..855c0204f09a 100644 --- a/drivers/mfd/vexpress-sysreg.c +++ b/drivers/mfd/vexpress-sysreg.c @@ -11,7 +11,7 @@ * Copyright (C) 2012 ARM Limited */ -#include +#include #include #include #include @@ -164,7 +164,7 @@ static int vexpress_sysreg_probe(struct platform_device *pdev) { struct resource *mem; void __iomem *base; - struct bgpio_chip *mmc_gpio_chip; + struct gpio_chip *mmc_gpio_chip; int master; u32 dt_hbi; @@ -201,8 +201,8 @@ static int vexpress_sysreg_probe(struct platform_device *pdev) return -ENOMEM; bgpio_init(mmc_gpio_chip, &pdev->dev, 0x4, base + SYS_MCI, NULL, NULL, NULL, NULL, 0); - mmc_gpio_chip->gc.ngpio = 2; - gpiochip_add(&mmc_gpio_chip->gc); + mmc_gpio_chip->ngpio = 2; + gpiochip_add(mmc_gpio_chip); return mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO, vexpress_sysreg_cells, diff --git a/include/linux/basic_mmio_gpio.h b/include/linux/basic_mmio_gpio.h deleted file mode 100644 index ed3768f4ecc7..000000000000 --- a/include/linux/basic_mmio_gpio.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Basic memory-mapped GPIO controllers. - * - * Copyright 2008 MontaVista Software, Inc. - * Copyright 2008,2010 Anton Vorontsov - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - */ - -#ifndef __BASIC_MMIO_GPIO_H -#define __BASIC_MMIO_GPIO_H - -#include -#include -#include -#include - -struct bgpio_pdata { - const char *label; - int base; - int ngpio; -}; - -struct device; - -struct bgpio_chip { - struct gpio_chip gc; - - unsigned long (*read_reg)(void __iomem *reg); - void (*write_reg)(void __iomem *reg, unsigned long data); - - void __iomem *reg_dat; - void __iomem *reg_set; - void __iomem *reg_clr; - void __iomem *reg_dir; - - /* Number of bits (GPIOs): * 8. */ - int bits; - - /* - * Some GPIO controllers work with the big-endian bits notation, - * e.g. in a 8-bits register, GPIO7 is the least significant bit. - */ - unsigned long (*pin2mask)(struct bgpio_chip *bgc, unsigned int pin); - - /* - * Used to lock bgpio_chip->data. Also, this is needed to keep - * shadowed and real data registers writes together. - */ - spinlock_t lock; - - /* Shadowed data register to clear/set bits safely. */ - unsigned long data; - - /* Shadowed direction registers to clear/set direction safely. */ - unsigned long dir; -}; - -static inline struct bgpio_chip *to_bgpio_chip(struct gpio_chip *gc) -{ - return container_of(gc, struct bgpio_chip, gc); -} - -int bgpio_remove(struct bgpio_chip *bgc); -int bgpio_init(struct bgpio_chip *bgc, struct device *dev, - unsigned long sz, void __iomem *dat, void __iomem *set, - void __iomem *clr, void __iomem *dirout, void __iomem *dirin, - unsigned long flags); - -#define BGPIOF_BIG_ENDIAN BIT(0) -#define BGPIOF_UNREADABLE_REG_SET BIT(1) /* reg_set is unreadable */ -#define BGPIOF_UNREADABLE_REG_DIR BIT(2) /* reg_dir is unreadable */ -#define BGPIOF_BIG_ENDIAN_BYTE_ORDER BIT(3) -#define BGPIOF_READ_OUTPUT_REG_SET BIT(4) /* reg_set stores output value */ -#define BGPIOF_NO_OUTPUT BIT(5) /* only input */ - -#endif /* __BASIC_MMIO_GPIO_H */ diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index b833a5f9629a..e2d05fd0e6e3 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -8,6 +8,7 @@ #include #include #include +#include struct device; struct gpio_desc; @@ -65,6 +66,23 @@ struct seq_file; * registers. * @irq_not_threaded: flag must be set if @can_sleep is set but the * IRQs don't need to be threaded + * @read_reg: reader function for generic GPIO + * @write_reg: writer function for generic GPIO + * @pin2mask: some generic GPIO controllers work with the big-endian bits + * notation, e.g. in a 8-bits register, GPIO7 is the least significant + * bit. This callback assigns the right bit mask. + * @reg_dat: data (in) register for generic GPIO + * @reg_set: output set register (out=high) for generic GPIO + * @reg_clk: output clear register (out=low) for generic GPIO + * @reg_dir: direction setting register for generic GPIO + * @bgpio_bits: number of register bits used for a generic GPIO i.e. + * * 8 + * @bgpio_lock: used to lock chip->bgpio_data. Also, this is needed to keep + * shadowed and real data registers writes together. + * @bgpio_data: shadowed data register for generic GPIO to clear/set bits + * safely. + * @bgpio_dir: shadowed direction register for generic GPIO to clear/set + * direction safely. * @irqchip: GPIO IRQ chip impl, provided by GPIO driver * @irqdomain: Interrupt translation domain; responsible for mapping * between GPIO hwirq number and linux irq number @@ -128,6 +146,20 @@ struct gpio_chip { bool can_sleep; bool irq_not_threaded; +#if IS_ENABLED(CONFIG_GPIO_GENERIC) + unsigned long (*read_reg)(void __iomem *reg); + void (*write_reg)(void __iomem *reg, unsigned long data); + unsigned long (*pin2mask)(struct gpio_chip *gc, unsigned int pin); + void __iomem *reg_dat; + void __iomem *reg_set; + void __iomem *reg_clr; + void __iomem *reg_dir; + int bgpio_bits; + spinlock_t bgpio_lock; + unsigned long bgpio_data; + unsigned long bgpio_dir; +#endif + #ifdef CONFIG_GPIOLIB_IRQCHIP /* * With CONFIG_GPIOLIB_IRQCHIP we get an irqchip inside the gpiolib @@ -188,6 +220,28 @@ static inline void *gpiochip_get_data(struct gpio_chip *chip) struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc); +#if IS_ENABLED(CONFIG_GPIO_GENERIC) + +struct bgpio_pdata { + const char *label; + int base; + int ngpio; +}; + +int bgpio_init(struct gpio_chip *gc, struct device *dev, + unsigned long sz, void __iomem *dat, void __iomem *set, + void __iomem *clr, void __iomem *dirout, void __iomem *dirin, + unsigned long flags); + +#define BGPIOF_BIG_ENDIAN BIT(0) +#define BGPIOF_UNREADABLE_REG_SET BIT(1) /* reg_set is unreadable */ +#define BGPIOF_UNREADABLE_REG_DIR BIT(2) /* reg_dir is unreadable */ +#define BGPIOF_BIG_ENDIAN_BYTE_ORDER BIT(3) +#define BGPIOF_READ_OUTPUT_REG_SET BIT(4) /* reg_set stores output value */ +#define BGPIOF_NO_OUTPUT BIT(5) /* only input */ + +#endif + #ifdef CONFIG_GPIOLIB_IRQCHIP void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip, -- cgit From 1f36bec53f045c72707b40723d70d39ba1099122 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 3 Dec 2015 15:31:48 +0100 Subject: gpio: 104-idi-48: 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(). Acked-by: William Breathitt Gray Signed-off-by: Linus Walleij --- drivers/gpio/gpio-104-idi-48.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c index 296dbd4cadd9..52eed328ce99 100644 --- a/drivers/gpio/gpio-104-idi-48.c +++ b/drivers/gpio/gpio-104-idi-48.c @@ -64,14 +64,9 @@ static int idi_48_gpio_direction_input(struct gpio_chip *chip, unsigned offset) return 0; } -static struct idi_48_gpio *to_idi48gpio(struct gpio_chip *gc) -{ - return container_of(gc, struct idi_48_gpio, chip); -} - static int idi_48_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct idi_48_gpio *const idi48gpio = to_idi48gpio(chip); + struct idi_48_gpio *const idi48gpio = gpiochip_get_data(chip); unsigned i; const unsigned register_offset[6] = { 0, 1, 2, 4, 5, 6 }; unsigned base_offset; @@ -96,7 +91,7 @@ static void idi_48_irq_ack(struct irq_data *data) static void idi_48_irq_mask(struct irq_data *data) { struct gpio_chip *chip = irq_data_get_irq_chip_data(data); - struct idi_48_gpio *const idi48gpio = to_idi48gpio(chip); + struct idi_48_gpio *const idi48gpio = gpiochip_get_data(chip); const unsigned offset = irqd_to_hwirq(data); unsigned i; unsigned mask; @@ -127,7 +122,7 @@ static void idi_48_irq_mask(struct irq_data *data) static void idi_48_irq_unmask(struct irq_data *data) { struct gpio_chip *chip = irq_data_get_irq_chip_data(data); - struct idi_48_gpio *const idi48gpio = to_idi48gpio(chip); + struct idi_48_gpio *const idi48gpio = gpiochip_get_data(chip); const unsigned offset = irqd_to_hwirq(data); unsigned i; unsigned mask; @@ -255,7 +250,7 @@ static int __init idi_48_probe(struct platform_device *pdev) dev_set_drvdata(dev, idi48gpio); - err = gpiochip_add(&idi48gpio->chip); + err = gpiochip_add_data(&idi48gpio->chip, idi48gpio); if (err) { dev_err(dev, "GPIO registering failed (%d)\n", err); goto err_gpio_register; -- cgit From d602ae90a35e66c418189e917395408dd2e85e20 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 3 Dec 2015 18:18:06 +0100 Subject: gpio: 104-idio-16: 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(). Acked-by: William Breathitt Gray Signed-off-by: Linus Walleij --- drivers/gpio/gpio-104-idio-16.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c index 91c8b5b17f64..4d69b50b2d84 100644 --- a/drivers/gpio/gpio-104-idio-16.c +++ b/drivers/gpio/gpio-104-idio-16.c @@ -72,14 +72,9 @@ static int idio_16_gpio_direction_output(struct gpio_chip *chip, return 0; } -static struct idio_16_gpio *to_idio16gpio(struct gpio_chip *gc) -{ - return container_of(gc, struct idio_16_gpio, chip); -} - static int idio_16_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct idio_16_gpio *const idio16gpio = to_idio16gpio(chip); + struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); const unsigned mask = BIT(offset-16); if (offset < 16) @@ -93,7 +88,7 @@ static int idio_16_gpio_get(struct gpio_chip *chip, unsigned offset) static void idio_16_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct idio_16_gpio *const idio16gpio = to_idio16gpio(chip); + struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); const unsigned mask = BIT(offset); unsigned long flags; @@ -122,7 +117,7 @@ static void idio_16_irq_ack(struct irq_data *data) static void idio_16_irq_mask(struct irq_data *data) { struct gpio_chip *chip = irq_data_get_irq_chip_data(data); - struct idio_16_gpio *const idio16gpio = to_idio16gpio(chip); + struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); const unsigned long mask = BIT(irqd_to_hwirq(data)); unsigned long flags; @@ -140,7 +135,7 @@ static void idio_16_irq_mask(struct irq_data *data) static void idio_16_irq_unmask(struct irq_data *data) { struct gpio_chip *chip = irq_data_get_irq_chip_data(data); - struct idio_16_gpio *const idio16gpio = to_idio16gpio(chip); + struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); const unsigned long mask = BIT(irqd_to_hwirq(data)); const unsigned long prev_irq_mask = idio16gpio->irq_mask; unsigned long flags; @@ -232,7 +227,7 @@ static int __init idio_16_probe(struct platform_device *pdev) dev_set_drvdata(dev, idio16gpio); - err = gpiochip_add(&idio16gpio->chip); + err = gpiochip_add_data(&idio16gpio->chip, idio16gpio); if (err) { dev_err(dev, "GPIO registering failed (%d)\n", err); goto err_gpio_register; -- cgit From b2afc6f3522c8f49a420cb77f5a9c51fe1d50e33 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 3 Dec 2015 18:20:29 +0100 Subject: gpio: 74x164: 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: Alexander Shiyan Signed-off-by: Linus Walleij --- drivers/gpio/gpio-74x164.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index 54a4147fba52..c81224ff2dca 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -33,11 +33,6 @@ struct gen_74x164_chip { u8 buffer[0]; }; -static struct gen_74x164_chip *gpio_to_74x164_chip(struct gpio_chip *gc) -{ - return container_of(gc, struct gen_74x164_chip, gpio_chip); -} - static int __gen_74x164_write_config(struct gen_74x164_chip *chip) { struct spi_transfer xfer = { @@ -51,7 +46,7 @@ static int __gen_74x164_write_config(struct gen_74x164_chip *chip) static int gen_74x164_get_value(struct gpio_chip *gc, unsigned offset) { - struct gen_74x164_chip *chip = gpio_to_74x164_chip(gc); + struct gen_74x164_chip *chip = gpiochip_get_data(gc); u8 bank = chip->registers - 1 - offset / 8; u8 pin = offset % 8; int ret; @@ -66,7 +61,7 @@ static int gen_74x164_get_value(struct gpio_chip *gc, unsigned offset) static void gen_74x164_set_value(struct gpio_chip *gc, unsigned offset, int val) { - struct gen_74x164_chip *chip = gpio_to_74x164_chip(gc); + struct gen_74x164_chip *chip = gpiochip_get_data(gc); u8 bank = chip->registers - 1 - offset / 8; u8 pin = offset % 8; @@ -136,7 +131,7 @@ static int gen_74x164_probe(struct spi_device *spi) goto exit_destroy; } - ret = gpiochip_add(&chip->gpio_chip); + ret = gpiochip_add_data(&chip->gpio_chip, chip); if (!ret) return 0; -- cgit 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(-) 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 From 5060e0e8934ca6685ea8bf185cbe0fa2118a946e Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 15:01:50 +0100 Subject: gpio: adp5520: 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-adp5520.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-adp5520.c b/drivers/gpio/gpio-adp5520.c index caff711ca5a9..4fa7ff1fec9a 100644 --- a/drivers/gpio/gpio-adp5520.c +++ b/drivers/gpio/gpio-adp5520.c @@ -27,7 +27,7 @@ static int adp5520_gpio_get_value(struct gpio_chip *chip, unsigned off) struct adp5520_gpio *dev; uint8_t reg_val; - dev = container_of(chip, struct adp5520_gpio, gpio_chip); + dev = gpiochip_get_data(chip); /* * There are dedicated registers for GPIO IN/OUT. @@ -46,7 +46,7 @@ static void adp5520_gpio_set_value(struct gpio_chip *chip, unsigned off, int val) { struct adp5520_gpio *dev; - dev = container_of(chip, struct adp5520_gpio, gpio_chip); + dev = gpiochip_get_data(chip); if (val) adp5520_set_bits(dev->master, ADP5520_GPIO_OUT, dev->lut[off]); @@ -57,7 +57,7 @@ static void adp5520_gpio_set_value(struct gpio_chip *chip, static int adp5520_gpio_direction_input(struct gpio_chip *chip, unsigned off) { struct adp5520_gpio *dev; - dev = container_of(chip, struct adp5520_gpio, gpio_chip); + dev = gpiochip_get_data(chip); clear_bit(off, &dev->output); @@ -70,7 +70,7 @@ static int adp5520_gpio_direction_output(struct gpio_chip *chip, { struct adp5520_gpio *dev; int ret = 0; - dev = container_of(chip, struct adp5520_gpio, gpio_chip); + dev = gpiochip_get_data(chip); set_bit(off, &dev->output); @@ -153,7 +153,7 @@ static int adp5520_gpio_probe(struct platform_device *pdev) goto err; } - ret = gpiochip_add(&dev->gpio_chip); + ret = gpiochip_add_data(&dev->gpio_chip, dev); if (ret) goto err; -- cgit From f69255ce67b6e6f496d165b48231075262c9a225 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 15:05:34 +0100 Subject: gpio: adp5588: 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-Francois Dagenais Signed-off-by: Linus Walleij --- drivers/gpio/gpio-adp5588.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-adp5588.c b/drivers/gpio/gpio-adp5588.c index 984186ee58a0..19a0eba1e942 100644 --- a/drivers/gpio/gpio-adp5588.c +++ b/drivers/gpio/gpio-adp5588.c @@ -65,8 +65,7 @@ static int adp5588_gpio_write(struct i2c_client *client, u8 reg, u8 val) static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off) { - struct adp5588_gpio *dev = - container_of(chip, struct adp5588_gpio, gpio_chip); + struct adp5588_gpio *dev = gpiochip_get_data(chip); unsigned bank = ADP5588_BANK(off); unsigned bit = ADP5588_BIT(off); int val; @@ -87,8 +86,7 @@ static void adp5588_gpio_set_value(struct gpio_chip *chip, unsigned off, int val) { unsigned bank, bit; - struct adp5588_gpio *dev = - container_of(chip, struct adp5588_gpio, gpio_chip); + struct adp5588_gpio *dev = gpiochip_get_data(chip); bank = ADP5588_BANK(off); bit = ADP5588_BIT(off); @@ -108,8 +106,7 @@ static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned off) { int ret; unsigned bank; - struct adp5588_gpio *dev = - container_of(chip, struct adp5588_gpio, gpio_chip); + struct adp5588_gpio *dev = gpiochip_get_data(chip); bank = ADP5588_BANK(off); @@ -126,8 +123,7 @@ static int adp5588_gpio_direction_output(struct gpio_chip *chip, { int ret; unsigned bank, bit; - struct adp5588_gpio *dev = - container_of(chip, struct adp5588_gpio, gpio_chip); + struct adp5588_gpio *dev = gpiochip_get_data(chip); bank = ADP5588_BANK(off); bit = ADP5588_BIT(off); @@ -152,8 +148,8 @@ static int adp5588_gpio_direction_output(struct gpio_chip *chip, #ifdef CONFIG_GPIO_ADP5588_IRQ static int adp5588_gpio_to_irq(struct gpio_chip *chip, unsigned off) { - struct adp5588_gpio *dev = - container_of(chip, struct adp5588_gpio, gpio_chip); + struct adp5588_gpio *dev = gpiochip_get_data(chip); + return dev->irq_base + off; } @@ -418,7 +414,7 @@ static int adp5588_gpio_probe(struct i2c_client *client, } } - ret = gpiochip_add(&dev->gpio_chip); + ret = gpiochip_add_data(&dev->gpio_chip, dev); if (ret) goto err_irq; -- cgit From 397d0773a9044c8df1be87e53840ab374932d80c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 15:16:43 +0100 Subject: gpio: altera: 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: Tien Hock Loh Signed-off-by: Linus Walleij --- drivers/gpio/gpio-altera.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c index 84a20af01a9a..2aeaebd1c6e7 100644 --- a/drivers/gpio/gpio-altera.c +++ b/drivers/gpio/gpio-altera.c @@ -42,11 +42,6 @@ struct altera_gpio_chip { int mapped_irq; }; -static struct altera_gpio_chip *to_altera(struct gpio_chip *gc) -{ - return container_of(gc, struct altera_gpio_chip, mmchip.gc); -} - static void altera_gpio_irq_unmask(struct irq_data *d) { struct altera_gpio_chip *altera_gc; @@ -54,7 +49,7 @@ static void altera_gpio_irq_unmask(struct irq_data *d) unsigned long flags; u32 intmask; - altera_gc = to_altera(irq_data_get_irq_chip_data(d)); + altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d)); mm_gc = &altera_gc->mmchip; spin_lock_irqsave(&altera_gc->gpio_lock, flags); @@ -72,7 +67,7 @@ static void altera_gpio_irq_mask(struct irq_data *d) unsigned long flags; u32 intmask; - altera_gc = to_altera(irq_data_get_irq_chip_data(d)); + altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d)); mm_gc = &altera_gc->mmchip; spin_lock_irqsave(&altera_gc->gpio_lock, flags); @@ -92,7 +87,7 @@ static int altera_gpio_irq_set_type(struct irq_data *d, { struct altera_gpio_chip *altera_gc; - altera_gc = to_altera(irq_data_get_irq_chip_data(d)); + altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d)); if (type == IRQ_TYPE_NONE) return 0; @@ -145,7 +140,7 @@ static void altera_gpio_set(struct gpio_chip *gc, unsigned offset, int value) unsigned int data_reg; mm_gc = to_of_mm_gpio_chip(gc); - chip = container_of(mm_gc, struct altera_gpio_chip, mmchip); + chip = gpiochip_get_data(gc); spin_lock_irqsave(&chip->gpio_lock, flags); data_reg = readl(mm_gc->regs + ALTERA_GPIO_DATA); @@ -165,7 +160,7 @@ static int altera_gpio_direction_input(struct gpio_chip *gc, unsigned offset) unsigned int gpio_ddr; mm_gc = to_of_mm_gpio_chip(gc); - chip = container_of(mm_gc, struct altera_gpio_chip, mmchip); + chip = gpiochip_get_data(gc); spin_lock_irqsave(&chip->gpio_lock, flags); /* Set pin as input, assumes software controlled IP */ @@ -186,7 +181,7 @@ static int altera_gpio_direction_output(struct gpio_chip *gc, unsigned int data_reg, gpio_ddr; mm_gc = to_of_mm_gpio_chip(gc); - chip = container_of(mm_gc, struct altera_gpio_chip, mmchip); + chip = gpiochip_get_data(gc); spin_lock_irqsave(&chip->gpio_lock, flags); /* Sets the GPIO value */ @@ -215,7 +210,7 @@ static void altera_gpio_irq_edge_handler(struct irq_desc *desc) unsigned long status; int i; - altera_gc = to_altera(irq_desc_get_handler_data(desc)); + altera_gc = gpiochip_get_data(irq_desc_get_handler_data(desc)); chip = irq_desc_get_chip(desc); mm_gc = &altera_gc->mmchip; irqdomain = altera_gc->mmchip.gc.irqdomain; @@ -244,7 +239,7 @@ static void altera_gpio_irq_leveL_high_handler(struct irq_desc *desc) unsigned long status; int i; - altera_gc = to_altera(irq_desc_get_handler_data(desc)); + altera_gc = gpiochip_get_data(irq_desc_get_handler_data(desc)); chip = irq_desc_get_chip(desc); mm_gc = &altera_gc->mmchip; irqdomain = altera_gc->mmchip.gc.irqdomain; @@ -292,7 +287,7 @@ static int altera_gpio_probe(struct platform_device *pdev) altera_gc->mmchip.gc.owner = THIS_MODULE; altera_gc->mmchip.gc.parent = &pdev->dev; - ret = of_mm_gpiochip_add(node, &altera_gc->mmchip); + ret = of_mm_gpiochip_add_data(node, &altera_gc->mmchip, altera_gc); if (ret) { dev_err(&pdev->dev, "Failed adding memory mapped gpiochip\n"); return ret; -- cgit From 57683ec203a642e8fc8befac94c8341d237f5d54 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 15:26:35 +0100 Subject: gpio: amd8111: 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: Dmitry Eremin-Solenikov Signed-off-by: Linus Walleij --- drivers/gpio/gpio-amd8111.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-amd8111.c b/drivers/gpio/gpio-amd8111.c index 5c378e9f53a0..c7040fffc5b4 100644 --- a/drivers/gpio/gpio-amd8111.c +++ b/drivers/gpio/gpio-amd8111.c @@ -75,11 +75,9 @@ struct amd_gpio { u8 orig[32]; }; -#define to_agp(chip) container_of(chip, struct amd_gpio, chip) - static int amd_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); agp->orig[offset] = ioread8(agp->pm + AMD_REG_GPIO(offset)) & (AMD_GPIO_DEBOUNCE | AMD_GPIO_MODE_MASK | AMD_GPIO_X_MASK); @@ -91,7 +89,7 @@ static int amd_gpio_request(struct gpio_chip *chip, unsigned offset) static void amd_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); dev_dbg(&agp->pdev->dev, "Freed gpio %d, data %x\n", offset, agp->orig[offset]); @@ -100,7 +98,7 @@ static void amd_gpio_free(struct gpio_chip *chip, unsigned offset) static void amd_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); u8 temp; unsigned long flags; @@ -115,7 +113,7 @@ static void amd_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int amd_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); u8 temp; temp = ioread8(agp->pm + AMD_REG_GPIO(offset)); @@ -127,7 +125,7 @@ static int amd_gpio_get(struct gpio_chip *chip, unsigned offset) static int amd_gpio_dirout(struct gpio_chip *chip, unsigned offset, int value) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); u8 temp; unsigned long flags; @@ -144,7 +142,7 @@ static int amd_gpio_dirout(struct gpio_chip *chip, unsigned offset, int value) static int amd_gpio_dirin(struct gpio_chip *chip, unsigned offset) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); u8 temp; unsigned long flags; @@ -225,7 +223,7 @@ found: spin_lock_init(&gp.lock); printk(KERN_INFO "AMD-8111 GPIO detected\n"); - err = gpiochip_add(&gp.chip); + err = gpiochip_add_data(&gp.chip, &gp); if (err) { printk(KERN_ERR "GPIO registering failed (%d)\n", err); -- cgit From fb7228879a5a6552c9cd91561ca7c9b565a102aa Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 15:29:41 +0100 Subject: gpio: amdpt: 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: YD Tseng Signed-off-by: Linus Walleij --- drivers/gpio/gpio-amdpt.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-amdpt.c b/drivers/gpio/gpio-amdpt.c index f842ccc45e64..c2484046e8e9 100644 --- a/drivers/gpio/gpio-amdpt.c +++ b/drivers/gpio/gpio-amdpt.c @@ -31,11 +31,9 @@ struct pt_gpio_chip { spinlock_t lock; }; -#define to_pt_gpio(c) container_of(c, struct pt_gpio_chip, gc) - static int pt_gpio_request(struct gpio_chip *gc, unsigned offset) { - struct pt_gpio_chip *pt_gpio = to_pt_gpio(gc); + struct pt_gpio_chip *pt_gpio = gpiochip_get_data(gc); unsigned long flags; u32 using_pins; @@ -60,7 +58,7 @@ static int pt_gpio_request(struct gpio_chip *gc, unsigned offset) static void pt_gpio_free(struct gpio_chip *gc, unsigned offset) { - struct pt_gpio_chip *pt_gpio = to_pt_gpio(gc); + struct pt_gpio_chip *pt_gpio = gpiochip_get_data(gc); unsigned long flags; u32 using_pins; @@ -77,7 +75,7 @@ static void pt_gpio_free(struct gpio_chip *gc, unsigned offset) static void pt_gpio_set_value(struct gpio_chip *gc, unsigned offset, int value) { - struct pt_gpio_chip *pt_gpio = to_pt_gpio(gc); + struct pt_gpio_chip *pt_gpio = gpiochip_get_data(gc); unsigned long flags; u32 data; @@ -97,7 +95,7 @@ static void pt_gpio_set_value(struct gpio_chip *gc, unsigned offset, int value) static int pt_gpio_get_value(struct gpio_chip *gc, unsigned offset) { - struct pt_gpio_chip *pt_gpio = to_pt_gpio(gc); + struct pt_gpio_chip *pt_gpio = gpiochip_get_data(gc); unsigned long flags; u32 data; @@ -124,7 +122,7 @@ static int pt_gpio_get_value(struct gpio_chip *gc, unsigned offset) static int pt_gpio_direction_input(struct gpio_chip *gc, unsigned offset) { - struct pt_gpio_chip *pt_gpio = to_pt_gpio(gc); + struct pt_gpio_chip *pt_gpio = gpiochip_get_data(gc); unsigned long flags; u32 data; @@ -144,7 +142,7 @@ static int pt_gpio_direction_input(struct gpio_chip *gc, unsigned offset) static int pt_gpio_direction_output(struct gpio_chip *gc, unsigned offset, int value) { - struct pt_gpio_chip *pt_gpio = to_pt_gpio(gc); + struct pt_gpio_chip *pt_gpio = gpiochip_get_data(gc); unsigned long flags; u32 data; @@ -214,7 +212,7 @@ static int pt_gpio_probe(struct platform_device *pdev) #if defined(CONFIG_OF_GPIO) pt_gpio->gc.of_node = pdev->dev.of_node; #endif - ret = gpiochip_add(&pt_gpio->gc); + ret = gpiochip_add_data(&pt_gpio->gc, pt_gpio); if (ret) { dev_err(&pdev->dev, "Failed to register GPIO lib\n"); return ret; -- cgit From 18992d4ee577838e0fa006bad46d83cafccffbb3 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 15:31:31 +0100 Subject: gpio: arizona: 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: Richard Fitzgerald Cc: Mark Brown Reviewed-by: Richard Fitzgerald Signed-off-by: Linus Walleij --- drivers/gpio/gpio-arizona.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-arizona.c b/drivers/gpio/gpio-arizona.c index 412d131b513d..c729fee1dcdf 100644 --- a/drivers/gpio/gpio-arizona.c +++ b/drivers/gpio/gpio-arizona.c @@ -28,14 +28,9 @@ struct arizona_gpio { struct gpio_chip gpio_chip; }; -static inline struct arizona_gpio *to_arizona_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct arizona_gpio, gpio_chip); -} - static int arizona_gpio_direction_in(struct gpio_chip *chip, unsigned offset) { - struct arizona_gpio *arizona_gpio = to_arizona_gpio(chip); + struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip); struct arizona *arizona = arizona_gpio->arizona; return regmap_update_bits(arizona->regmap, ARIZONA_GPIO1_CTRL + offset, @@ -44,7 +39,7 @@ static int arizona_gpio_direction_in(struct gpio_chip *chip, unsigned offset) static int arizona_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct arizona_gpio *arizona_gpio = to_arizona_gpio(chip); + struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip); struct arizona *arizona = arizona_gpio->arizona; unsigned int val; int ret; @@ -62,7 +57,7 @@ static int arizona_gpio_get(struct gpio_chip *chip, unsigned offset) static int arizona_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { - struct arizona_gpio *arizona_gpio = to_arizona_gpio(chip); + struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip); struct arizona *arizona = arizona_gpio->arizona; if (value) @@ -74,7 +69,7 @@ static int arizona_gpio_direction_out(struct gpio_chip *chip, static void arizona_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct arizona_gpio *arizona_gpio = to_arizona_gpio(chip); + struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip); struct arizona *arizona = arizona_gpio->arizona; if (value) @@ -133,7 +128,7 @@ static int arizona_gpio_probe(struct platform_device *pdev) else arizona_gpio->gpio_chip.base = -1; - ret = gpiochip_add(&arizona_gpio->gpio_chip); + ret = gpiochip_add_data(&arizona_gpio->gpio_chip, arizona_gpio); if (ret < 0) { dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); -- cgit From b4e97a61255cde7e5b2f2484140547ba37c7292c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 15:36:14 +0100 Subject: gpio: ath79: 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(). Acked-by: Alban Bedel Signed-off-by: Linus Walleij --- drivers/gpio/gpio-ath79.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c index 6e678121ab12..d13dd133a907 100644 --- a/drivers/gpio/gpio-ath79.c +++ b/drivers/gpio/gpio-ath79.c @@ -24,12 +24,10 @@ struct ath79_gpio_ctrl { spinlock_t lock; }; -#define to_ath79_gpio_ctrl(c) container_of(c, struct ath79_gpio_ctrl, chip) - static void ath79_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value) { - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); if (value) __raw_writel(BIT(gpio), ctrl->base + AR71XX_GPIO_REG_SET); @@ -39,7 +37,7 @@ static void ath79_gpio_set_value(struct gpio_chip *chip, static int ath79_gpio_get_value(struct gpio_chip *chip, unsigned gpio) { - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); return (__raw_readl(ctrl->base + AR71XX_GPIO_REG_IN) >> gpio) & 1; } @@ -47,7 +45,7 @@ static int ath79_gpio_get_value(struct gpio_chip *chip, unsigned gpio) static int ath79_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); unsigned long flags; spin_lock_irqsave(&ctrl->lock, flags); @@ -64,7 +62,7 @@ static int ath79_gpio_direction_input(struct gpio_chip *chip, static int ath79_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); unsigned long flags; spin_lock_irqsave(&ctrl->lock, flags); @@ -85,7 +83,7 @@ static int ath79_gpio_direction_output(struct gpio_chip *chip, static int ar934x_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); unsigned long flags; spin_lock_irqsave(&ctrl->lock, flags); @@ -102,7 +100,7 @@ static int ar934x_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int ar934x_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); unsigned long flags; spin_lock_irqsave(&ctrl->lock, flags); @@ -184,7 +182,7 @@ static int ath79_gpio_probe(struct platform_device *pdev) ctrl->chip.direction_output = ar934x_gpio_direction_output; } - err = gpiochip_add(&ctrl->chip); + err = gpiochip_add_data(&ctrl->chip, ctrl); if (err) { dev_err(&pdev->dev, "cannot add AR71xx GPIO chip, error=%d", err); -- cgit From ba4a74485a32c1a5ea04e9ce9318cd73ed746fe2 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 15:39:50 +0100 Subject: gpio: bcm-kona: 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: Markus Mayer Cc: Tim Kryger Cc: Matt Porter Signed-off-by: Linus Walleij --- drivers/gpio/gpio-bcm-kona.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c index 21c3280d66e1..b6c5abe85daf 100644 --- a/drivers/gpio/gpio-bcm-kona.c +++ b/drivers/gpio/gpio-bcm-kona.c @@ -78,11 +78,6 @@ struct bcm_kona_gpio_bank { struct bcm_kona_gpio *kona_gpio; }; -static inline struct bcm_kona_gpio *to_kona_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct bcm_kona_gpio, gpio_chip); -} - static inline void bcm_kona_gpio_write_lock_regs(void __iomem *reg_base, int bank_id, u32 lockcode) { @@ -124,7 +119,7 @@ static void bcm_kona_gpio_unlock_gpio(struct bcm_kona_gpio *kona_gpio, static int bcm_kona_gpio_get_dir(struct gpio_chip *chip, unsigned gpio) { - struct bcm_kona_gpio *kona_gpio = to_kona_gpio(chip); + struct bcm_kona_gpio *kona_gpio = gpiochip_get_data(chip); void __iomem *reg_base = kona_gpio->reg_base; u32 val; @@ -141,7 +136,7 @@ static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value) u32 val, reg_offset; unsigned long flags; - kona_gpio = to_kona_gpio(chip); + kona_gpio = gpiochip_get_data(chip); reg_base = kona_gpio->reg_base; spin_lock_irqsave(&kona_gpio->lock, flags); @@ -168,7 +163,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio) u32 val, reg_offset; unsigned long flags; - kona_gpio = to_kona_gpio(chip); + kona_gpio = gpiochip_get_data(chip); reg_base = kona_gpio->reg_base; spin_lock_irqsave(&kona_gpio->lock, flags); @@ -188,7 +183,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio) static int bcm_kona_gpio_request(struct gpio_chip *chip, unsigned gpio) { - struct bcm_kona_gpio *kona_gpio = to_kona_gpio(chip); + struct bcm_kona_gpio *kona_gpio = gpiochip_get_data(chip); bcm_kona_gpio_unlock_gpio(kona_gpio, gpio); return 0; @@ -196,7 +191,7 @@ static int bcm_kona_gpio_request(struct gpio_chip *chip, unsigned gpio) static void bcm_kona_gpio_free(struct gpio_chip *chip, unsigned gpio) { - struct bcm_kona_gpio *kona_gpio = to_kona_gpio(chip); + struct bcm_kona_gpio *kona_gpio = gpiochip_get_data(chip); bcm_kona_gpio_lock_gpio(kona_gpio, gpio); } @@ -208,7 +203,7 @@ static int bcm_kona_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) u32 val; unsigned long flags; - kona_gpio = to_kona_gpio(chip); + kona_gpio = gpiochip_get_data(chip); reg_base = kona_gpio->reg_base; spin_lock_irqsave(&kona_gpio->lock, flags); @@ -232,7 +227,7 @@ static int bcm_kona_gpio_direction_output(struct gpio_chip *chip, u32 val, reg_offset; unsigned long flags; - kona_gpio = to_kona_gpio(chip); + kona_gpio = gpiochip_get_data(chip); reg_base = kona_gpio->reg_base; spin_lock_irqsave(&kona_gpio->lock, flags); @@ -255,7 +250,7 @@ static int bcm_kona_gpio_to_irq(struct gpio_chip *chip, unsigned gpio) { struct bcm_kona_gpio *kona_gpio; - kona_gpio = to_kona_gpio(chip); + kona_gpio = gpiochip_get_data(chip); if (gpio >= kona_gpio->gpio_chip.ngpio) return -ENXIO; return irq_create_mapping(kona_gpio->irq_domain, gpio); @@ -269,7 +264,7 @@ static int bcm_kona_gpio_set_debounce(struct gpio_chip *chip, unsigned gpio, u32 val, res; unsigned long flags; - kona_gpio = to_kona_gpio(chip); + kona_gpio = gpiochip_get_data(chip); reg_base = kona_gpio->reg_base; /* debounce must be 1-128ms (or 0) */ if ((debounce > 0 && debounce < 1000) || debounce > 128000) { @@ -635,7 +630,7 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev) bcm_kona_gpio_reset(kona_gpio); - ret = gpiochip_add(chip); + ret = gpiochip_add_data(chip, kona_gpio); if (ret < 0) { dev_err(dev, "Couldn't add GPIO chip -- %d\n", ret); goto err_irq_domain; -- cgit From e51b55236ca61a87bf8d1d61e8366726f7ea704c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 15:44:16 +0100 Subject: gpio: bt8xx: 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: Michael Buesch Signed-off-by: Linus Walleij --- drivers/gpio/gpio-bt8xx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-bt8xx.c b/drivers/gpio/gpio-bt8xx.c index 7e4c43c18960..acefb25e8eca 100644 --- a/drivers/gpio/gpio-bt8xx.c +++ b/drivers/gpio/gpio-bt8xx.c @@ -80,7 +80,7 @@ MODULE_PARM_DESC(gpiobase, "The GPIO number base. -1 means dynamic, which is the static int bt8xxgpio_gpio_direction_input(struct gpio_chip *gpio, unsigned nr) { - struct bt8xxgpio *bg = container_of(gpio, struct bt8xxgpio, gpio); + struct bt8xxgpio *bg = gpiochip_get_data(gpio); unsigned long flags; u32 outen, data; @@ -101,7 +101,7 @@ static int bt8xxgpio_gpio_direction_input(struct gpio_chip *gpio, unsigned nr) static int bt8xxgpio_gpio_get(struct gpio_chip *gpio, unsigned nr) { - struct bt8xxgpio *bg = container_of(gpio, struct bt8xxgpio, gpio); + struct bt8xxgpio *bg = gpiochip_get_data(gpio); unsigned long flags; u32 val; @@ -115,7 +115,7 @@ static int bt8xxgpio_gpio_get(struct gpio_chip *gpio, unsigned nr) static int bt8xxgpio_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, int val) { - struct bt8xxgpio *bg = container_of(gpio, struct bt8xxgpio, gpio); + struct bt8xxgpio *bg = gpiochip_get_data(gpio); unsigned long flags; u32 outen, data; @@ -140,7 +140,7 @@ static int bt8xxgpio_gpio_direction_output(struct gpio_chip *gpio, static void bt8xxgpio_gpio_set(struct gpio_chip *gpio, unsigned nr, int val) { - struct bt8xxgpio *bg = container_of(gpio, struct bt8xxgpio, gpio); + struct bt8xxgpio *bg = gpiochip_get_data(gpio); unsigned long flags; u32 data; @@ -217,7 +217,7 @@ static int bt8xxgpio_probe(struct pci_dev *dev, bgwrite(0, BT848_GPIO_OUT_EN); bt8xxgpio_gpio_setup(bg); - err = gpiochip_add(&bg->gpio); + err = gpiochip_add_data(&bg->gpio, bg); if (err) { printk(KERN_ERR "bt8xxgpio: Failed to register GPIOs\n"); goto err_disable; -- cgit From 435cc3d4286566c904c5ff63475ba9eb1e61e3e6 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 15:47:54 +0100 Subject: gpio: crystalcove: 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: Shobhit Kumar Cc: Zhu, Lejun Signed-off-by: Linus Walleij --- drivers/gpio/gpio-crystalcove.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/gpio/gpio-crystalcove.c b/drivers/gpio/gpio-crystalcove.c index 141093a8cd3f..7865ef0d3352 100644 --- a/drivers/gpio/gpio-crystalcove.c +++ b/drivers/gpio/gpio-crystalcove.c @@ -86,11 +86,6 @@ struct crystalcove_gpio { bool set_irq_mask; }; -static inline struct crystalcove_gpio *to_cg(struct gpio_chip *gc) -{ - return container_of(gc, struct crystalcove_gpio, chip); -} - static inline int to_reg(int gpio, enum ctrl_register reg_type) { int reg; @@ -134,7 +129,7 @@ static void crystalcove_update_irq_ctrl(struct crystalcove_gpio *cg, int gpio) static int crystalcove_gpio_dir_in(struct gpio_chip *chip, unsigned gpio) { - struct crystalcove_gpio *cg = to_cg(chip); + struct crystalcove_gpio *cg = gpiochip_get_data(chip); if (gpio > CRYSTALCOVE_VGPIO_NUM) return 0; @@ -146,7 +141,7 @@ static int crystalcove_gpio_dir_in(struct gpio_chip *chip, unsigned gpio) static int crystalcove_gpio_dir_out(struct gpio_chip *chip, unsigned gpio, int value) { - struct crystalcove_gpio *cg = to_cg(chip); + struct crystalcove_gpio *cg = gpiochip_get_data(chip); if (gpio > CRYSTALCOVE_VGPIO_NUM) return 0; @@ -157,7 +152,7 @@ static int crystalcove_gpio_dir_out(struct gpio_chip *chip, unsigned gpio, static int crystalcove_gpio_get(struct gpio_chip *chip, unsigned gpio) { - struct crystalcove_gpio *cg = to_cg(chip); + struct crystalcove_gpio *cg = gpiochip_get_data(chip); int ret; unsigned int val; @@ -174,7 +169,7 @@ static int crystalcove_gpio_get(struct gpio_chip *chip, unsigned gpio) static void crystalcove_gpio_set(struct gpio_chip *chip, unsigned gpio, int value) { - struct crystalcove_gpio *cg = to_cg(chip); + struct crystalcove_gpio *cg = gpiochip_get_data(chip); if (gpio > CRYSTALCOVE_VGPIO_NUM) return; @@ -187,7 +182,8 @@ static void crystalcove_gpio_set(struct gpio_chip *chip, static int crystalcove_irq_type(struct irq_data *data, unsigned type) { - struct crystalcove_gpio *cg = to_cg(irq_data_get_irq_chip_data(data)); + struct crystalcove_gpio *cg = + gpiochip_get_data(irq_data_get_irq_chip_data(data)); switch (type) { case IRQ_TYPE_NONE: @@ -213,14 +209,16 @@ static int crystalcove_irq_type(struct irq_data *data, unsigned type) static void crystalcove_bus_lock(struct irq_data *data) { - struct crystalcove_gpio *cg = to_cg(irq_data_get_irq_chip_data(data)); + struct crystalcove_gpio *cg = + gpiochip_get_data(irq_data_get_irq_chip_data(data)); mutex_lock(&cg->buslock); } static void crystalcove_bus_sync_unlock(struct irq_data *data) { - struct crystalcove_gpio *cg = to_cg(irq_data_get_irq_chip_data(data)); + struct crystalcove_gpio *cg = + gpiochip_get_data(irq_data_get_irq_chip_data(data)); int gpio = data->hwirq; if (cg->update & UPDATE_IRQ_TYPE) @@ -234,7 +232,8 @@ static void crystalcove_bus_sync_unlock(struct irq_data *data) static void crystalcove_irq_unmask(struct irq_data *data) { - struct crystalcove_gpio *cg = to_cg(irq_data_get_irq_chip_data(data)); + struct crystalcove_gpio *cg = + gpiochip_get_data(irq_data_get_irq_chip_data(data)); cg->set_irq_mask = false; cg->update |= UPDATE_IRQ_MASK; @@ -242,7 +241,8 @@ static void crystalcove_irq_unmask(struct irq_data *data) static void crystalcove_irq_mask(struct irq_data *data) { - struct crystalcove_gpio *cg = to_cg(irq_data_get_irq_chip_data(data)); + struct crystalcove_gpio *cg = + gpiochip_get_data(irq_data_get_irq_chip_data(data)); cg->set_irq_mask = true; cg->update |= UPDATE_IRQ_MASK; @@ -288,7 +288,7 @@ static irqreturn_t crystalcove_gpio_irq_handler(int irq, void *data) static void crystalcove_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { - struct crystalcove_gpio *cg = to_cg(chip); + struct crystalcove_gpio *cg = gpiochip_get_data(chip); int gpio, offset; unsigned int ctlo, ctli, mirqs0, mirqsx, irq; @@ -345,7 +345,7 @@ static int crystalcove_gpio_probe(struct platform_device *pdev) cg->chip.dbg_show = crystalcove_gpio_dbg_show; cg->regmap = pmic->regmap; - retval = gpiochip_add(&cg->chip); + retval = gpiochip_add_data(&cg->chip, cg); if (retval) { dev_warn(&pdev->dev, "add gpio chip error: %d\n", retval); return retval; -- cgit From c634fc19fe39f49a00d0e8e922a60ae24b8855b1 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 15:53:04 +0100 Subject: gpio: cs5535: 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: Fabian Frederick Signed-off-by: Linus Walleij --- drivers/gpio/gpio-cs5535.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpio-cs5535.c b/drivers/gpio/gpio-cs5535.c index 7b0b198a563d..eccb712e09fb 100644 --- a/drivers/gpio/gpio-cs5535.c +++ b/drivers/gpio/gpio-cs5535.c @@ -42,6 +42,10 @@ static ulong mask = GPIO_DEFAULT_MASK; module_param_named(mask, mask, ulong, 0444); MODULE_PARM_DESC(mask, "GPIO channel mask."); +/* + * FIXME: convert this singleton driver to use the state container + * design pattern, see Documentation/driver-model/design-patterns.txt + */ static struct cs5535_gpio_chip { struct gpio_chip chip; resource_size_t base; @@ -201,8 +205,7 @@ EXPORT_SYMBOL_GPL(cs5535_gpio_setup_event); static int chip_gpio_request(struct gpio_chip *c, unsigned offset) { - struct cs5535_gpio_chip *chip = - container_of(c, struct cs5535_gpio_chip, chip); + struct cs5535_gpio_chip *chip = gpiochip_get_data(c); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -242,8 +245,7 @@ static void chip_gpio_set(struct gpio_chip *chip, unsigned offset, int val) static int chip_direction_input(struct gpio_chip *c, unsigned offset) { - struct cs5535_gpio_chip *chip = - container_of(c, struct cs5535_gpio_chip, chip); + struct cs5535_gpio_chip *chip = gpiochip_get_data(c); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -256,8 +258,7 @@ static int chip_direction_input(struct gpio_chip *c, unsigned offset) static int chip_direction_output(struct gpio_chip *c, unsigned offset, int val) { - struct cs5535_gpio_chip *chip = - container_of(c, struct cs5535_gpio_chip, chip); + struct cs5535_gpio_chip *chip = gpiochip_get_data(c); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -347,7 +348,7 @@ static int cs5535_gpio_probe(struct platform_device *pdev) mask_orig, mask); /* finally, register with the generic GPIO API */ - err = gpiochip_add(&cs5535_gpio_chip.chip); + err = gpiochip_add_data(&cs5535_gpio_chip.chip, &cs5535_gpio_chip); if (err) goto done; -- cgit From 0f6082d2b811ec56c4f7ecdde80410e17cf04452 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 16:19:52 +0100 Subject: gpio: da9052: 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: Ashish Jangam Signed-off-by: Linus Walleij --- drivers/gpio/gpio-da9052.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-da9052.c b/drivers/gpio/gpio-da9052.c index 38bd8f122bfc..f9b3247ad14b 100644 --- a/drivers/gpio/gpio-da9052.c +++ b/drivers/gpio/gpio-da9052.c @@ -51,11 +51,6 @@ struct da9052_gpio { struct gpio_chip gp; }; -static inline struct da9052_gpio *to_da9052_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct da9052_gpio, gp); -} - static unsigned char da9052_gpio_port_odd(unsigned offset) { return offset % 2; @@ -63,7 +58,7 @@ static unsigned char da9052_gpio_port_odd(unsigned offset) static int da9052_gpio_get(struct gpio_chip *gc, unsigned offset) { - struct da9052_gpio *gpio = to_da9052_gpio(gc); + struct da9052_gpio *gpio = gpiochip_get_data(gc); int da9052_port_direction = 0; int ret; @@ -102,7 +97,7 @@ static int da9052_gpio_get(struct gpio_chip *gc, unsigned offset) static void da9052_gpio_set(struct gpio_chip *gc, unsigned offset, int value) { - struct da9052_gpio *gpio = to_da9052_gpio(gc); + struct da9052_gpio *gpio = gpiochip_get_data(gc); int ret; if (da9052_gpio_port_odd(offset)) { @@ -128,7 +123,7 @@ static void da9052_gpio_set(struct gpio_chip *gc, unsigned offset, int value) static int da9052_gpio_direction_input(struct gpio_chip *gc, unsigned offset) { - struct da9052_gpio *gpio = to_da9052_gpio(gc); + struct da9052_gpio *gpio = gpiochip_get_data(gc); unsigned char register_value; int ret; @@ -154,7 +149,7 @@ static int da9052_gpio_direction_input(struct gpio_chip *gc, unsigned offset) static int da9052_gpio_direction_output(struct gpio_chip *gc, unsigned offset, int value) { - struct da9052_gpio *gpio = to_da9052_gpio(gc); + struct da9052_gpio *gpio = gpiochip_get_data(gc); unsigned char register_value; int ret; @@ -179,7 +174,7 @@ static int da9052_gpio_direction_output(struct gpio_chip *gc, static int da9052_gpio_to_irq(struct gpio_chip *gc, u32 offset) { - struct da9052_gpio *gpio = to_da9052_gpio(gc); + struct da9052_gpio *gpio = gpiochip_get_data(gc); struct da9052 *da9052 = gpio->da9052; int irq; @@ -219,7 +214,7 @@ static int da9052_gpio_probe(struct platform_device *pdev) if (pdata && pdata->gpio_base) gpio->gp.base = pdata->gpio_base; - ret = gpiochip_add(&gpio->gp); + ret = gpiochip_add_data(&gpio->gp, gpio); if (ret < 0) { dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); return ret; -- cgit From 552dd7959c7d2c4f60ea4fc1f06985db76ec2beb Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 16:21:53 +0100 Subject: gpio: da9055: 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: Ashish Jangam Signed-off-by: Linus Walleij --- drivers/gpio/gpio-da9055.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-da9055.c b/drivers/gpio/gpio-da9055.c index 7227e6ed3cb9..18210fb2cb13 100644 --- a/drivers/gpio/gpio-da9055.c +++ b/drivers/gpio/gpio-da9055.c @@ -35,14 +35,9 @@ struct da9055_gpio { struct gpio_chip gp; }; -static inline struct da9055_gpio *to_da9055_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct da9055_gpio, gp); -} - static int da9055_gpio_get(struct gpio_chip *gc, unsigned offset) { - struct da9055_gpio *gpio = to_da9055_gpio(gc); + struct da9055_gpio *gpio = gpiochip_get_data(gc); int gpio_direction = 0; int ret; @@ -71,7 +66,7 @@ static int da9055_gpio_get(struct gpio_chip *gc, unsigned offset) static void da9055_gpio_set(struct gpio_chip *gc, unsigned offset, int value) { - struct da9055_gpio *gpio = to_da9055_gpio(gc); + struct da9055_gpio *gpio = gpiochip_get_data(gc); da9055_reg_update(gpio->da9055, DA9055_REG_GPIO_MODE0_2, @@ -81,7 +76,7 @@ static void da9055_gpio_set(struct gpio_chip *gc, unsigned offset, int value) static int da9055_gpio_direction_input(struct gpio_chip *gc, unsigned offset) { - struct da9055_gpio *gpio = to_da9055_gpio(gc); + struct da9055_gpio *gpio = gpiochip_get_data(gc); unsigned char reg_byte; reg_byte = (DA9055_ACT_LOW | DA9055_GPI) @@ -97,7 +92,7 @@ static int da9055_gpio_direction_input(struct gpio_chip *gc, unsigned offset) static int da9055_gpio_direction_output(struct gpio_chip *gc, unsigned offset, int value) { - struct da9055_gpio *gpio = to_da9055_gpio(gc); + struct da9055_gpio *gpio = gpiochip_get_data(gc); unsigned char reg_byte; int ret; @@ -119,7 +114,7 @@ static int da9055_gpio_direction_output(struct gpio_chip *gc, static int da9055_gpio_to_irq(struct gpio_chip *gc, u32 offset) { - struct da9055_gpio *gpio = to_da9055_gpio(gc); + struct da9055_gpio *gpio = gpiochip_get_data(gc); struct da9055 *da9055 = gpio->da9055; return regmap_irq_get_virq(da9055->irq_data, @@ -156,7 +151,7 @@ static int da9055_gpio_probe(struct platform_device *pdev) if (pdata && pdata->gpio_base) gpio->gp.base = pdata->gpio_base; - ret = gpiochip_add(&gpio->gp); + ret = gpiochip_add_data(&gpio->gp, gpio); if (ret < 0) { dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); goto err_mem; -- cgit From 72a1ca2cb9f415e01c2e6c1b84f172f188daf8d4 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 4 Dec 2015 16:25:04 +0100 Subject: gpio: davinci: 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: Grygorii Strashko Cc: Sekhar Nori Cc: Santosh Shilimkar Signed-off-by: Linus Walleij --- drivers/gpio/gpio-davinci.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 1e3a617e0c10..ec58f4288649 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -41,9 +41,6 @@ typedef struct irq_chip *(*gpio_get_irq_chip_cb_t)(unsigned int irq); #define BINTEN 0x8 /* GPIO Interrupt Per-Bank Enable Register */ -#define chip2controller(chip) \ - container_of(chip, struct davinci_gpio_controller, chip) - static void __iomem *gpio_base; static struct davinci_gpio_regs __iomem *gpio2regs(unsigned gpio) @@ -82,7 +79,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev); static inline int __davinci_direction(struct gpio_chip *chip, unsigned offset, bool out, int value) { - struct davinci_gpio_controller *d = chip2controller(chip); + struct davinci_gpio_controller *d = gpiochip_get_data(chip); struct davinci_gpio_regs __iomem *g = d->regs; unsigned long flags; u32 temp; @@ -122,7 +119,7 @@ davinci_direction_out(struct gpio_chip *chip, unsigned offset, int value) */ static int davinci_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct davinci_gpio_controller *d = chip2controller(chip); + struct davinci_gpio_controller *d = gpiochip_get_data(chip); struct davinci_gpio_regs __iomem *g = d->regs; return !!((1 << offset) & readl_relaxed(&g->in_data)); @@ -134,7 +131,7 @@ static int davinci_gpio_get(struct gpio_chip *chip, unsigned offset) static void davinci_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct davinci_gpio_controller *d = chip2controller(chip); + struct davinci_gpio_controller *d = gpiochip_get_data(chip); struct davinci_gpio_regs __iomem *g = d->regs; writel_relaxed((1 << offset), value ? &g->set_data : &g->clr_data); @@ -265,7 +262,7 @@ static int davinci_gpio_probe(struct platform_device *pdev) chips[i].clr_data = ®s->clr_data; chips[i].in_data = ®s->in_data; - gpiochip_add(&chips[i].chip); + gpiochip_add_data(&chips[i].chip, &chips[i]); } platform_set_drvdata(pdev, chips); @@ -368,7 +365,7 @@ static void gpio_irq_handler(struct irq_desc *desc) static int gpio_to_irq_banked(struct gpio_chip *chip, unsigned offset) { - struct davinci_gpio_controller *d = chip2controller(chip); + struct davinci_gpio_controller *d = gpiochip_get_data(chip); if (d->irq_domain) return irq_create_mapping(d->irq_domain, d->chip.base + offset); @@ -378,7 +375,7 @@ static int gpio_to_irq_banked(struct gpio_chip *chip, unsigned offset) static int gpio_to_irq_unbanked(struct gpio_chip *chip, unsigned offset) { - struct davinci_gpio_controller *d = chip2controller(chip); + struct davinci_gpio_controller *d = gpiochip_get_data(chip); /* * NOTE: we assume for now that only irqs in the first gpio_chip -- cgit From 1880657a15842d2e617789f98a7a68f61c870592 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sun, 6 Dec 2015 00:32:16 +0100 Subject: gpio: dln2: 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: Octavian Purdila Cc: Daniel Baluta Signed-off-by: Linus Walleij --- drivers/gpio/gpio-dln2.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/gpio/gpio-dln2.c b/drivers/gpio/gpio-dln2.c index e541af03dd45..e11a7d126e74 100644 --- a/drivers/gpio/gpio-dln2.c +++ b/drivers/gpio/gpio-dln2.c @@ -153,7 +153,7 @@ static int dln2_gpio_pin_set_out_val(struct dln2_gpio *dln2, static int dln2_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); struct dln2_gpio_pin req = { .pin = cpu_to_le16(offset), }; @@ -194,14 +194,14 @@ out_disable: static void dln2_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); dln2_gpio_pin_cmd(dln2, DLN2_GPIO_PIN_DISABLE, offset); } static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); if (test_bit(offset, dln2->output_enabled)) return GPIOF_DIR_OUT; @@ -211,7 +211,7 @@ static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset) static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); int dir; dir = dln2_gpio_get_direction(chip, offset); @@ -226,7 +226,7 @@ static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset) static void dln2_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); dln2_gpio_pin_set_out_val(dln2, offset, value); } @@ -234,7 +234,7 @@ static void dln2_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int dln2_gpio_set_direction(struct gpio_chip *chip, unsigned offset, unsigned dir) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); struct dln2_gpio_pin_val req = { .pin = cpu_to_le16(offset), .value = dir, @@ -262,7 +262,7 @@ static int dln2_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int dln2_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); int ret; ret = dln2_gpio_pin_set_out_val(dln2, offset, value); @@ -275,7 +275,7 @@ static int dln2_gpio_direction_output(struct gpio_chip *chip, unsigned offset, static int dln2_gpio_set_debounce(struct gpio_chip *chip, unsigned offset, unsigned debounce) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); __le32 duration = cpu_to_le32(debounce); return dln2_transfer_tx(dln2->pdev, DLN2_GPIO_SET_DEBOUNCE, @@ -302,7 +302,7 @@ static int dln2_gpio_set_event_cfg(struct dln2_gpio *dln2, unsigned pin, static void dln2_irq_unmask(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); - struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(gc); int pin = irqd_to_hwirq(irqd); set_bit(pin, dln2->unmasked_irqs); @@ -311,7 +311,7 @@ static void dln2_irq_unmask(struct irq_data *irqd) static void dln2_irq_mask(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); - struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(gc); int pin = irqd_to_hwirq(irqd); clear_bit(pin, dln2->unmasked_irqs); @@ -320,7 +320,7 @@ static void dln2_irq_mask(struct irq_data *irqd) static int dln2_irq_set_type(struct irq_data *irqd, unsigned type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); - struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(gc); int pin = irqd_to_hwirq(irqd); switch (type) { @@ -349,7 +349,7 @@ static int dln2_irq_set_type(struct irq_data *irqd, unsigned type) static void dln2_irq_bus_lock(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); - struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(gc); mutex_lock(&dln2->irq_lock); } @@ -357,7 +357,7 @@ static void dln2_irq_bus_lock(struct irq_data *irqd) static void dln2_irq_bus_unlock(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); - struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(gc); int pin = irqd_to_hwirq(irqd); int enabled, unmasked; unsigned type; @@ -479,7 +479,7 @@ static int dln2_gpio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, dln2); - ret = gpiochip_add(&dln2->gpio); + ret = gpiochip_add_data(&dln2->gpio, dln2); if (ret < 0) { dev_err(dev, "failed to add gpio chip: %d\n", ret); goto out; -- cgit From 6219e7bba9d52ea5d40cd50d0cfe6059c2630fab Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sun, 6 Dec 2015 00:36:39 +0100 Subject: gpio: em: 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: Geert Uytterhoeven Cc: Magnus Damm Signed-off-by: Linus Walleij --- drivers/gpio/gpio-em.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c index d726c68c4a65..8d32ccc980d9 100644 --- a/drivers/gpio/gpio-em.c +++ b/drivers/gpio/gpio-em.c @@ -192,7 +192,7 @@ static irqreturn_t em_gio_irq_handler(int irq, void *dev_id) static inline struct em_gio_priv *gpio_to_priv(struct gpio_chip *chip) { - return container_of(chip, struct em_gio_priv, gpio_chip); + return gpiochip_get_data(chip); } static int em_gio_direction_input(struct gpio_chip *chip, unsigned offset) @@ -368,7 +368,7 @@ static int em_gio_probe(struct platform_device *pdev) goto err1; } - ret = gpiochip_add(gpio_chip); + ret = gpiochip_add_data(gpio_chip, p); if (ret) { dev_err(&pdev->dev, "failed to add GPIO controller\n"); goto err1; -- cgit From f372d5f59cc4879eee3efe19e309f95c4078d748 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sun, 6 Dec 2015 10:51:13 +0100 Subject: gpio: f7188: 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: Andreas Bofjall Cc: Simon Guinot Signed-off-by: Linus Walleij --- drivers/gpio/gpio-f7188x.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio-f7188x.c index 2be7337cf4ae..d62fd6bbaf82 100644 --- a/drivers/gpio/gpio-f7188x.c +++ b/drivers/gpio/gpio-f7188x.c @@ -193,8 +193,7 @@ static struct f7188x_gpio_bank f71889_gpio_bank[] = { static int f7188x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) { int err; - struct f7188x_gpio_bank *bank = - container_of(chip, struct f7188x_gpio_bank, chip); + struct f7188x_gpio_bank *bank = gpiochip_get_data(chip); struct f7188x_sio *sio = bank->data->sio; u8 dir; @@ -215,8 +214,7 @@ static int f7188x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) static int f7188x_gpio_get(struct gpio_chip *chip, unsigned offset) { int err; - struct f7188x_gpio_bank *bank = - container_of(chip, struct f7188x_gpio_bank, chip); + struct f7188x_gpio_bank *bank = gpiochip_get_data(chip); struct f7188x_sio *sio = bank->data->sio; u8 dir, data; @@ -241,8 +239,7 @@ static int f7188x_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { int err; - struct f7188x_gpio_bank *bank = - container_of(chip, struct f7188x_gpio_bank, chip); + struct f7188x_gpio_bank *bank = gpiochip_get_data(chip); struct f7188x_sio *sio = bank->data->sio; u8 dir, data_out; @@ -270,8 +267,7 @@ static int f7188x_gpio_direction_out(struct gpio_chip *chip, static void f7188x_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { int err; - struct f7188x_gpio_bank *bank = - container_of(chip, struct f7188x_gpio_bank, chip); + struct f7188x_gpio_bank *bank = gpiochip_get_data(chip); struct f7188x_sio *sio = bank->data->sio; u8 data_out; @@ -336,7 +332,7 @@ static int f7188x_gpio_probe(struct platform_device *pdev) bank->chip.parent = &pdev->dev; bank->data = data; - err = gpiochip_add(&bank->chip); + err = gpiochip_add_data(&bank->chip, bank); if (err) { dev_err(&pdev->dev, "Failed to register gpiochip %d: %d\n", -- cgit From 5c77c0212b97693219ead6dcddf7e036421012d7 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sun, 6 Dec 2015 10:55:28 +0100 Subject: gpio: intel-mid: 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: David Cohen Signed-off-by: Linus Walleij --- drivers/gpio/gpio-intel-mid.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c index 26d2083a5901..cdaba13cb8e8 100644 --- a/drivers/gpio/gpio-intel-mid.c +++ b/drivers/gpio/gpio-intel-mid.c @@ -78,15 +78,10 @@ struct intel_mid_gpio { struct pci_dev *pdev; }; -static inline struct intel_mid_gpio *to_intel_gpio_priv(struct gpio_chip *gc) -{ - return container_of(gc, struct intel_mid_gpio, chip); -} - static void __iomem *gpio_reg(struct gpio_chip *chip, unsigned offset, enum GPIO_REG reg_type) { - struct intel_mid_gpio *priv = to_intel_gpio_priv(chip); + struct intel_mid_gpio *priv = gpiochip_get_data(chip); unsigned nreg = chip->ngpio / 32; u8 reg = offset / 32; @@ -96,7 +91,7 @@ static void __iomem *gpio_reg(struct gpio_chip *chip, unsigned offset, static void __iomem *gpio_reg_2bit(struct gpio_chip *chip, unsigned offset, enum GPIO_REG reg_type) { - struct intel_mid_gpio *priv = to_intel_gpio_priv(chip); + struct intel_mid_gpio *priv = gpiochip_get_data(chip); unsigned nreg = chip->ngpio / 32; u8 reg = offset / 16; @@ -138,7 +133,7 @@ static void intel_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int intel_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct intel_mid_gpio *priv = to_intel_gpio_priv(chip); + struct intel_mid_gpio *priv = gpiochip_get_data(chip); void __iomem *gpdr = gpio_reg(chip, offset, GPDR); u32 value; unsigned long flags; @@ -161,7 +156,7 @@ static int intel_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int intel_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct intel_mid_gpio *priv = to_intel_gpio_priv(chip); + struct intel_mid_gpio *priv = gpiochip_get_data(chip); void __iomem *gpdr = gpio_reg(chip, offset, GPDR); unsigned long flags; @@ -185,7 +180,7 @@ static int intel_gpio_direction_output(struct gpio_chip *chip, static int intel_mid_irq_type(struct irq_data *d, unsigned type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct intel_mid_gpio *priv = to_intel_gpio_priv(gc); + struct intel_mid_gpio *priv = gpiochip_get_data(gc); u32 gpio = irqd_to_hwirq(d); unsigned long flags; u32 value; @@ -304,7 +299,7 @@ MODULE_DEVICE_TABLE(pci, intel_gpio_ids); static void intel_mid_irq_handler(struct irq_desc *desc) { struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct intel_mid_gpio *priv = to_intel_gpio_priv(gc); + struct intel_mid_gpio *priv = gpiochip_get_data(gc); struct irq_data *data = irq_desc_get_irq_data(desc); struct irq_chip *chip = irq_data_get_irq_chip(data); u32 base, gpio, mask; @@ -406,7 +401,7 @@ static int intel_gpio_probe(struct pci_dev *pdev, spin_lock_init(&priv->lock); pci_set_drvdata(pdev, priv); - retval = gpiochip_add(&priv->chip); + retval = gpiochip_add_data(&priv->chip, priv); if (retval) { dev_err(&pdev->dev, "gpiochip_add error %d\n", retval); return retval; -- cgit From 0a38fd94c20e6636c22630200a9cece122a89f0e Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 09:03:09 +0100 Subject: gpio: it87: use gpiochip data pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Diego Elio Pettenò Signed-off-by: Linus Walleij --- drivers/gpio/gpio-it87.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-it87.c b/drivers/gpio/gpio-it87.c index 21f6f7c0eb34..b219c82414bf 100644 --- a/drivers/gpio/gpio-it87.c +++ b/drivers/gpio/gpio-it87.c @@ -77,11 +77,6 @@ static struct it87_gpio it87_gpio_chip = { .lock = __SPIN_LOCK_UNLOCKED(it87_gpio_chip.lock), }; -static inline struct it87_gpio *to_it87_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct it87_gpio, chip); -} - /* Superio chip access functions; copied from wdt_it87 */ static inline int superio_enter(void) @@ -165,7 +160,7 @@ static int it87_gpio_request(struct gpio_chip *chip, unsigned gpio_num) { u8 mask, group; int rc = 0; - struct it87_gpio *it87_gpio = to_it87_gpio(chip); + struct it87_gpio *it87_gpio = gpiochip_get_data(chip); mask = 1 << (gpio_num % 8); group = (gpio_num / 8); @@ -198,7 +193,7 @@ static int it87_gpio_get(struct gpio_chip *chip, unsigned gpio_num) { u16 reg; u8 mask; - struct it87_gpio *it87_gpio = to_it87_gpio(chip); + struct it87_gpio *it87_gpio = gpiochip_get_data(chip); mask = 1 << (gpio_num % 8); reg = (gpio_num / 8) + it87_gpio->io_base; @@ -210,7 +205,7 @@ static int it87_gpio_direction_in(struct gpio_chip *chip, unsigned gpio_num) { u8 mask, group; int rc = 0; - struct it87_gpio *it87_gpio = to_it87_gpio(chip); + struct it87_gpio *it87_gpio = gpiochip_get_data(chip); mask = 1 << (gpio_num % 8); group = (gpio_num / 8); @@ -236,7 +231,7 @@ static void it87_gpio_set(struct gpio_chip *chip, { u8 mask, curr_vals; u16 reg; - struct it87_gpio *it87_gpio = to_it87_gpio(chip); + struct it87_gpio *it87_gpio = gpiochip_get_data(chip); mask = 1 << (gpio_num % 8); reg = (gpio_num / 8) + it87_gpio->io_base; @@ -253,7 +248,7 @@ static int it87_gpio_direction_out(struct gpio_chip *chip, { u8 mask, group; int rc = 0; - struct it87_gpio *it87_gpio = to_it87_gpio(chip); + struct it87_gpio *it87_gpio = gpiochip_get_data(chip); mask = 1 << (gpio_num % 8); group = (gpio_num / 8); @@ -380,7 +375,7 @@ static int __init it87_gpio_init(void) it87_gpio->chip.names = (const char *const*)labels_table; - rc = gpiochip_add(&it87_gpio->chip); + rc = gpiochip_add_data(&it87_gpio->chip, it87_gpio); if (rc) goto labels_free; -- cgit From 1f89bccd7fe4f27b05b6404f24a35dcc5426817d Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 09:06:22 +0100 Subject: gpio: kempld: 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: Brunner Michael Cc: Guenter Roeck Signed-off-by: Linus Walleij --- drivers/gpio/gpio-kempld.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c index 297f849af725..01117747b965 100644 --- a/drivers/gpio/gpio-kempld.c +++ b/drivers/gpio/gpio-kempld.c @@ -65,8 +65,7 @@ static int kempld_gpio_get_bit(struct kempld_device_data *pld, u8 reg, u8 bit) static int kempld_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct kempld_gpio_data *gpio - = container_of(chip, struct kempld_gpio_data, chip); + struct kempld_gpio_data *gpio = gpiochip_get_data(chip); struct kempld_device_data *pld = gpio->pld; return !!kempld_gpio_get_bit(pld, KEMPLD_GPIO_LVL_NUM(offset), offset); @@ -74,8 +73,7 @@ static int kempld_gpio_get(struct gpio_chip *chip, unsigned offset) static void kempld_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct kempld_gpio_data *gpio - = container_of(chip, struct kempld_gpio_data, chip); + struct kempld_gpio_data *gpio = gpiochip_get_data(chip); struct kempld_device_data *pld = gpio->pld; kempld_get_mutex(pld); @@ -85,8 +83,7 @@ static void kempld_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int kempld_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct kempld_gpio_data *gpio - = container_of(chip, struct kempld_gpio_data, chip); + struct kempld_gpio_data *gpio = gpiochip_get_data(chip); struct kempld_device_data *pld = gpio->pld; kempld_get_mutex(pld); @@ -99,8 +96,7 @@ static int kempld_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int kempld_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct kempld_gpio_data *gpio - = container_of(chip, struct kempld_gpio_data, chip); + struct kempld_gpio_data *gpio = gpiochip_get_data(chip); struct kempld_device_data *pld = gpio->pld; kempld_get_mutex(pld); @@ -113,8 +109,7 @@ static int kempld_gpio_direction_output(struct gpio_chip *chip, unsigned offset, static int kempld_gpio_get_direction(struct gpio_chip *chip, unsigned offset) { - struct kempld_gpio_data *gpio - = container_of(chip, struct kempld_gpio_data, chip); + struct kempld_gpio_data *gpio = gpiochip_get_data(chip); struct kempld_device_data *pld = gpio->pld; return !kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset); @@ -183,7 +178,7 @@ static int kempld_gpio_probe(struct platform_device *pdev) return -ENODEV; } - ret = gpiochip_add(chip); + ret = gpiochip_add_data(chip, gpio); if (ret) { dev_err(dev, "Could not register GPIO chip\n"); return ret; -- cgit From a2f33804657dbd347c4ae23c4e75dbfe950d89d4 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 09:10:13 +0100 Subject: gpio: lp3943: 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: Milo Kim Signed-off-by: Linus Walleij --- drivers/gpio/gpio-lp3943.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/gpio/gpio-lp3943.c b/drivers/gpio/gpio-lp3943.c index f979c3be217f..1c8e2ae26938 100644 --- a/drivers/gpio/gpio-lp3943.c +++ b/drivers/gpio/gpio-lp3943.c @@ -45,14 +45,9 @@ struct lp3943_gpio { u16 input_mask; /* 1 = GPIO is input direction, 0 = output */ }; -static inline struct lp3943_gpio *to_lp3943_gpio(struct gpio_chip *_chip) -{ - return container_of(_chip, struct lp3943_gpio, chip); -} - static int lp3943_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); + struct lp3943_gpio *lp3943_gpio = gpiochip_get_data(chip); struct lp3943 *lp3943 = lp3943_gpio->lp3943; /* Return an error if the pin is already assigned */ @@ -64,7 +59,7 @@ static int lp3943_gpio_request(struct gpio_chip *chip, unsigned offset) static void lp3943_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); + struct lp3943_gpio *lp3943_gpio = gpiochip_get_data(chip); struct lp3943 *lp3943 = lp3943_gpio->lp3943; clear_bit(offset, &lp3943->pin_used); @@ -82,7 +77,7 @@ static int lp3943_gpio_set_mode(struct lp3943_gpio *lp3943_gpio, u8 offset, static int lp3943_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); + struct lp3943_gpio *lp3943_gpio = gpiochip_get_data(chip); lp3943_gpio->input_mask |= BIT(offset); @@ -138,7 +133,7 @@ static int lp3943_get_gpio_out_status(struct lp3943_gpio *lp3943_gpio, static int lp3943_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); + struct lp3943_gpio *lp3943_gpio = gpiochip_get_data(chip); /* * Limitation: @@ -157,7 +152,7 @@ static int lp3943_gpio_get(struct gpio_chip *chip, unsigned offset) static void lp3943_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); + struct lp3943_gpio *lp3943_gpio = gpiochip_get_data(chip); u8 data; if (value) @@ -171,7 +166,7 @@ static void lp3943_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int lp3943_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); + struct lp3943_gpio *lp3943_gpio = gpiochip_get_data(chip); lp3943_gpio_set(chip, offset, value); lp3943_gpio->input_mask &= ~BIT(offset); @@ -209,7 +204,7 @@ static int lp3943_gpio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, lp3943_gpio); - return gpiochip_add(&lp3943_gpio->chip); + return gpiochip_add_data(&lp3943_gpio->chip, lp3943_gpio); } static int lp3943_gpio_remove(struct platform_device *pdev) -- cgit From d3de31d467a13d50b4fc23407972cce61b2120a8 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 09:13:57 +0100 Subject: gpio: lpc18xx: 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(). Acked-by: Joachim Eastwood Signed-off-by: Linus Walleij --- drivers/gpio/gpio-lpc18xx.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-lpc18xx.c b/drivers/gpio/gpio-lpc18xx.c index b01fbc9db7cd..98832c9f614a 100644 --- a/drivers/gpio/gpio-lpc18xx.c +++ b/drivers/gpio/gpio-lpc18xx.c @@ -31,27 +31,22 @@ struct lpc18xx_gpio_chip { spinlock_t lock; }; -static inline struct lpc18xx_gpio_chip *to_lpc18xx_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct lpc18xx_gpio_chip, gpio); -} - static void lpc18xx_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct lpc18xx_gpio_chip *gc = to_lpc18xx_gpio(chip); + struct lpc18xx_gpio_chip *gc = gpiochip_get_data(chip); writeb(value ? 1 : 0, gc->base + offset); } static int lpc18xx_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct lpc18xx_gpio_chip *gc = to_lpc18xx_gpio(chip); + struct lpc18xx_gpio_chip *gc = gpiochip_get_data(chip); return !!readb(gc->base + offset); } static int lpc18xx_gpio_direction(struct gpio_chip *chip, unsigned offset, bool out) { - struct lpc18xx_gpio_chip *gc = to_lpc18xx_gpio(chip); + struct lpc18xx_gpio_chip *gc = gpiochip_get_data(chip); unsigned long flags; u32 port, pin, dir; @@ -129,7 +124,7 @@ static int lpc18xx_gpio_probe(struct platform_device *pdev) gc->gpio.parent = &pdev->dev; - ret = gpiochip_add(&gc->gpio); + ret = gpiochip_add_data(&gc->gpio, gc); if (ret) { dev_err(&pdev->dev, "failed to add gpio chip\n"); clk_disable_unprepare(gc->clk); -- cgit From a9bc97e43f56c0cf9a3f7528f0ed012fe352207c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 09:18:23 +0100 Subject: gpio: lpc32xx: 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: Roland Stigge Acked-by: Vladimir Zapolskiy Signed-off-by: Linus Walleij --- drivers/gpio/gpio-lpc32xx.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/drivers/gpio/gpio-lpc32xx.c b/drivers/gpio/gpio-lpc32xx.c index e888b5fcd236..4cecf4ce96c1 100644 --- a/drivers/gpio/gpio-lpc32xx.c +++ b/drivers/gpio/gpio-lpc32xx.c @@ -165,12 +165,6 @@ struct lpc32xx_gpio_chip { struct gpio_regs *gpio_grp; }; -static inline struct lpc32xx_gpio_chip *to_lpc32xx_gpio( - struct gpio_chip *gpc) -{ - return container_of(gpc, struct lpc32xx_gpio_chip, chip); -} - static void __set_gpio_dir_p012(struct lpc32xx_gpio_chip *group, unsigned pin, int input) { @@ -261,7 +255,7 @@ static int __get_gpo_state_p3(struct lpc32xx_gpio_chip *group, static int lpc32xx_gpio_dir_input_p012(struct gpio_chip *chip, unsigned pin) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); __set_gpio_dir_p012(group, pin, 1); @@ -271,7 +265,7 @@ static int lpc32xx_gpio_dir_input_p012(struct gpio_chip *chip, static int lpc32xx_gpio_dir_input_p3(struct gpio_chip *chip, unsigned pin) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); __set_gpio_dir_p3(group, pin, 1); @@ -286,21 +280,21 @@ static int lpc32xx_gpio_dir_in_always(struct gpio_chip *chip, static int lpc32xx_gpio_get_value_p012(struct gpio_chip *chip, unsigned pin) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); return !!__get_gpio_state_p012(group, pin); } static int lpc32xx_gpio_get_value_p3(struct gpio_chip *chip, unsigned pin) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); return !!__get_gpio_state_p3(group, pin); } static int lpc32xx_gpi_get_value(struct gpio_chip *chip, unsigned pin) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); return !!__get_gpi_state_p3(group, pin); } @@ -308,7 +302,7 @@ static int lpc32xx_gpi_get_value(struct gpio_chip *chip, unsigned pin) static int lpc32xx_gpio_dir_output_p012(struct gpio_chip *chip, unsigned pin, int value) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); __set_gpio_level_p012(group, pin, value); __set_gpio_dir_p012(group, pin, 0); @@ -319,7 +313,7 @@ static int lpc32xx_gpio_dir_output_p012(struct gpio_chip *chip, unsigned pin, static int lpc32xx_gpio_dir_output_p3(struct gpio_chip *chip, unsigned pin, int value) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); __set_gpio_level_p3(group, pin, value); __set_gpio_dir_p3(group, pin, 0); @@ -330,7 +324,7 @@ static int lpc32xx_gpio_dir_output_p3(struct gpio_chip *chip, unsigned pin, static int lpc32xx_gpio_dir_out_always(struct gpio_chip *chip, unsigned pin, int value) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); __set_gpo_level_p3(group, pin, value); return 0; @@ -339,7 +333,7 @@ static int lpc32xx_gpio_dir_out_always(struct gpio_chip *chip, unsigned pin, static void lpc32xx_gpio_set_value_p012(struct gpio_chip *chip, unsigned pin, int value) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); __set_gpio_level_p012(group, pin, value); } @@ -347,7 +341,7 @@ static void lpc32xx_gpio_set_value_p012(struct gpio_chip *chip, unsigned pin, static void lpc32xx_gpio_set_value_p3(struct gpio_chip *chip, unsigned pin, int value) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); __set_gpio_level_p3(group, pin, value); } @@ -355,14 +349,14 @@ static void lpc32xx_gpio_set_value_p3(struct gpio_chip *chip, unsigned pin, static void lpc32xx_gpo_set_value(struct gpio_chip *chip, unsigned pin, int value) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); __set_gpo_level_p3(group, pin, value); } static int lpc32xx_gpo_get_value(struct gpio_chip *chip, unsigned pin) { - struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); + struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip); return !!__get_gpo_state_p3(group, pin); } @@ -553,7 +547,8 @@ static int lpc32xx_gpio_probe(struct platform_device *pdev) lpc32xx_gpiochip[i].chip.of_gpio_n_cells = 3; lpc32xx_gpiochip[i].chip.of_node = pdev->dev.of_node; } - gpiochip_add(&lpc32xx_gpiochip[i].chip); + gpiochip_add_data(&lpc32xx_gpiochip[i].chip, + &lpc32xx_gpiochip[i]); } return 0; -- cgit From f291e0063ba6c19ec3b60cce08293f78c0faf969 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 09:21:55 +0100 Subject: gpio: lynxpoint: 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: Mathias Nyman Acked-by: Mika Westerberg Signed-off-by: Linus Walleij --- drivers/gpio/gpio-lynxpoint.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-lynxpoint.c b/drivers/gpio/gpio-lynxpoint.c index 6a48ffd6e0db..13107772be4f 100644 --- a/drivers/gpio/gpio-lynxpoint.c +++ b/drivers/gpio/gpio-lynxpoint.c @@ -97,7 +97,7 @@ struct lp_gpio { static unsigned long lp_gpio_reg(struct gpio_chip *chip, unsigned offset, int reg) { - struct lp_gpio *lg = container_of(chip, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(chip); int reg_offset; if (reg == LP_CONFIG1 || reg == LP_CONFIG2) @@ -112,7 +112,7 @@ static unsigned long lp_gpio_reg(struct gpio_chip *chip, unsigned offset, static int lp_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct lp_gpio *lg = container_of(chip, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(chip); unsigned long reg = lp_gpio_reg(chip, offset, LP_CONFIG1); unsigned long conf2 = lp_gpio_reg(chip, offset, LP_CONFIG2); unsigned long acpi_use = lp_gpio_reg(chip, offset, LP_ACPI_OWNED); @@ -137,7 +137,7 @@ static int lp_gpio_request(struct gpio_chip *chip, unsigned offset) static void lp_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct lp_gpio *lg = container_of(chip, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(chip); unsigned long conf2 = lp_gpio_reg(chip, offset, LP_CONFIG2); /* disable input sensing */ @@ -149,7 +149,7 @@ static void lp_gpio_free(struct gpio_chip *chip, unsigned offset) static int lp_irq_type(struct irq_data *d, unsigned type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct lp_gpio *lg = container_of(gc, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(gc); u32 hwirq = irqd_to_hwirq(d); unsigned long flags; u32 value; @@ -191,7 +191,7 @@ static int lp_gpio_get(struct gpio_chip *chip, unsigned offset) static void lp_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct lp_gpio *lg = container_of(chip, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(chip); unsigned long reg = lp_gpio_reg(chip, offset, LP_CONFIG1); unsigned long flags; @@ -207,7 +207,7 @@ static void lp_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int lp_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct lp_gpio *lg = container_of(chip, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(chip); unsigned long reg = lp_gpio_reg(chip, offset, LP_CONFIG1); unsigned long flags; @@ -221,7 +221,7 @@ static int lp_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int lp_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct lp_gpio *lg = container_of(chip, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(chip); unsigned long reg = lp_gpio_reg(chip, offset, LP_CONFIG1); unsigned long flags; @@ -238,7 +238,7 @@ static void lp_gpio_irq_handler(struct irq_desc *desc) { struct irq_data *data = irq_desc_get_irq_data(desc); struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct lp_gpio *lg = container_of(gc, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(gc); struct irq_chip *chip = irq_data_get_irq_chip(data); u32 base, pin, mask; unsigned long reg, ena, pending; @@ -273,7 +273,7 @@ static void lp_irq_mask(struct irq_data *d) static void lp_irq_enable(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct lp_gpio *lg = container_of(gc, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(gc); u32 hwirq = irqd_to_hwirq(d); unsigned long reg = lp_gpio_reg(&lg->chip, hwirq, LP_INT_ENABLE); unsigned long flags; @@ -286,7 +286,7 @@ static void lp_irq_enable(struct irq_data *d) static void lp_irq_disable(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct lp_gpio *lg = container_of(gc, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(gc); u32 hwirq = irqd_to_hwirq(d); unsigned long reg = lp_gpio_reg(&lg->chip, hwirq, LP_INT_ENABLE); unsigned long flags; @@ -370,7 +370,7 @@ static int lp_gpio_probe(struct platform_device *pdev) gc->can_sleep = false; gc->parent = dev; - ret = gpiochip_add(gc); + ret = gpiochip_add_data(gc, lg); if (ret) { dev_err(dev, "failed adding lp-gpio chip\n"); return ret; -- cgit From 5e45e019161977c70e236a043133cfa106cebbd9 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 09:27:05 +0100 Subject: gpio: max730x: 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: Roland Stigge Signed-off-by: Linus Walleij --- drivers/gpio/gpio-max730x.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-max730x.c b/drivers/gpio/gpio-max730x.c index 5d6a723cb414..08807368f007 100644 --- a/drivers/gpio/gpio-max730x.c +++ b/drivers/gpio/gpio-max730x.c @@ -50,7 +50,7 @@ static int max7301_direction_input(struct gpio_chip *chip, unsigned offset) { - struct max7301 *ts = container_of(chip, struct max7301, chip); + struct max7301 *ts = gpiochip_get_data(chip); u8 *config; u8 offset_bits, pin_config; int ret; @@ -92,7 +92,7 @@ static int __max7301_set(struct max7301 *ts, unsigned offset, int value) static int max7301_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct max7301 *ts = container_of(chip, struct max7301, chip); + struct max7301 *ts = gpiochip_get_data(chip); u8 *config; u8 offset_bits; int ret; @@ -120,7 +120,7 @@ static int max7301_direction_output(struct gpio_chip *chip, unsigned offset, static int max7301_get(struct gpio_chip *chip, unsigned offset) { - struct max7301 *ts = container_of(chip, struct max7301, chip); + struct max7301 *ts = gpiochip_get_data(chip); int config, level = -EINVAL; /* First 4 pins are unused in the controller */ @@ -148,7 +148,7 @@ static int max7301_get(struct gpio_chip *chip, unsigned offset) static void max7301_set(struct gpio_chip *chip, unsigned offset, int value) { - struct max7301 *ts = container_of(chip, struct max7301, chip); + struct max7301 *ts = gpiochip_get_data(chip); /* First 4 pins are unused in the controller */ offset += 4; @@ -213,7 +213,7 @@ int __max730x_probe(struct max7301 *ts) } } - ret = gpiochip_add(&ts->chip); + ret = gpiochip_add_data(&ts->chip, ts); if (ret) goto exit_destroy; -- cgit From 0788b6448067f51c53ef0514a82e3d89f91dfabd Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 09:58:28 +0100 Subject: gpio: max732x: 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: Nicholas Krause Cc: Marek Vasut Cc: Semen Protsenko Signed-off-by: Linus Walleij --- drivers/gpio/gpio-max732x.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/gpio/gpio-max732x.c b/drivers/gpio/gpio-max732x.c index 880ce94e6077..a9aaf9d822b4 100644 --- a/drivers/gpio/gpio-max732x.c +++ b/drivers/gpio/gpio-max732x.c @@ -158,11 +158,6 @@ struct max732x_chip { #endif }; -static inline struct max732x_chip *to_max732x(struct gpio_chip *gc) -{ - return container_of(gc, struct max732x_chip, gpio_chip); -} - static int max732x_writeb(struct max732x_chip *chip, int group_a, uint8_t val) { struct i2c_client *client; @@ -201,7 +196,7 @@ static inline int is_group_a(struct max732x_chip *chip, unsigned off) static int max732x_gpio_get_value(struct gpio_chip *gc, unsigned off) { - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); uint8_t reg_val; int ret; @@ -215,7 +210,7 @@ static int max732x_gpio_get_value(struct gpio_chip *gc, unsigned off) static void max732x_gpio_set_mask(struct gpio_chip *gc, unsigned off, int mask, int val) { - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); uint8_t reg_out; int ret; @@ -259,7 +254,7 @@ static void max732x_gpio_set_multiple(struct gpio_chip *gc, static int max732x_gpio_direction_input(struct gpio_chip *gc, unsigned off) { - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); unsigned int mask = 1u << off; if ((mask & chip->dir_input) == 0) { @@ -281,7 +276,7 @@ static int max732x_gpio_direction_input(struct gpio_chip *gc, unsigned off) static int max732x_gpio_direction_output(struct gpio_chip *gc, unsigned off, int val) { - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); unsigned int mask = 1u << off; if ((mask & chip->dir_output) == 0) { @@ -356,7 +351,7 @@ static void max732x_irq_update_mask(struct max732x_chip *chip) static void max732x_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); chip->irq_mask_cur &= ~(1 << d->hwirq); } @@ -364,7 +359,7 @@ static void max732x_irq_mask(struct irq_data *d) static void max732x_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); chip->irq_mask_cur |= 1 << d->hwirq; } @@ -372,7 +367,7 @@ static void max732x_irq_unmask(struct irq_data *d) static void max732x_irq_bus_lock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); mutex_lock(&chip->irq_lock); chip->irq_mask_cur = chip->irq_mask; @@ -381,7 +376,7 @@ static void max732x_irq_bus_lock(struct irq_data *d) static void max732x_irq_bus_sync_unlock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); uint16_t new_irqs; uint16_t level; @@ -400,7 +395,7 @@ static void max732x_irq_bus_sync_unlock(struct irq_data *d) static int max732x_irq_set_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); uint16_t off = d->hwirq; uint16_t mask = 1 << off; @@ -694,7 +689,7 @@ static int max732x_probe(struct i2c_client *client, goto out_failed; } - ret = gpiochip_add(&chip->gpio_chip); + ret = gpiochip_add_data(&chip->gpio_chip, chip); if (ret) goto out_failed; -- cgit From 01f76b267bdfaae5ead2fff5de7c80c81ffff1b4 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 10:01:36 +0100 Subject: gpio: mb86s7x: 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(). Acked-By: Jassi Brar Signed-off-by: Linus Walleij --- drivers/gpio/gpio-mb86s7x.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/gpio/gpio-mb86s7x.c b/drivers/gpio/gpio-mb86s7x.c index 93d61a5be0d4..7fffc1d6c055 100644 --- a/drivers/gpio/gpio-mb86s7x.c +++ b/drivers/gpio/gpio-mb86s7x.c @@ -44,14 +44,9 @@ struct mb86s70_gpio_chip { spinlock_t lock; }; -static inline struct mb86s70_gpio_chip *chip_to_mb86s70(struct gpio_chip *gc) -{ - return container_of(gc, struct mb86s70_gpio_chip, gc); -} - static int mb86s70_gpio_request(struct gpio_chip *gc, unsigned gpio) { - struct mb86s70_gpio_chip *gchip = chip_to_mb86s70(gc); + struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc); unsigned long flags; u32 val; @@ -73,7 +68,7 @@ static int mb86s70_gpio_request(struct gpio_chip *gc, unsigned gpio) static void mb86s70_gpio_free(struct gpio_chip *gc, unsigned gpio) { - struct mb86s70_gpio_chip *gchip = chip_to_mb86s70(gc); + struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc); unsigned long flags; u32 val; @@ -88,7 +83,7 @@ static void mb86s70_gpio_free(struct gpio_chip *gc, unsigned gpio) static int mb86s70_gpio_direction_input(struct gpio_chip *gc, unsigned gpio) { - struct mb86s70_gpio_chip *gchip = chip_to_mb86s70(gc); + struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc); unsigned long flags; unsigned char val; @@ -106,7 +101,7 @@ static int mb86s70_gpio_direction_input(struct gpio_chip *gc, unsigned gpio) static int mb86s70_gpio_direction_output(struct gpio_chip *gc, unsigned gpio, int value) { - struct mb86s70_gpio_chip *gchip = chip_to_mb86s70(gc); + struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc); unsigned long flags; unsigned char val; @@ -130,14 +125,14 @@ static int mb86s70_gpio_direction_output(struct gpio_chip *gc, static int mb86s70_gpio_get(struct gpio_chip *gc, unsigned gpio) { - struct mb86s70_gpio_chip *gchip = chip_to_mb86s70(gc); + struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc); return !!(readl(gchip->base + PDR(gpio)) & OFFSET(gpio)); } static void mb86s70_gpio_set(struct gpio_chip *gc, unsigned gpio, int value) { - struct mb86s70_gpio_chip *gchip = chip_to_mb86s70(gc); + struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc); unsigned long flags; unsigned char val; @@ -192,7 +187,7 @@ static int mb86s70_gpio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, gchip); - ret = gpiochip_add(&gchip->gc); + ret = gpiochip_add_data(&gchip->gc, gchip); if (ret) { dev_err(&pdev->dev, "couldn't register gpio driver\n"); clk_disable_unprepare(gchip->clk); -- cgit From 609f9692ccd7034aaf620a6cd4ec1b6fb9ba4c7b Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 10:04:32 +0100 Subject: gpio: mc33880: 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-mc33880.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-mc33880.c b/drivers/gpio/gpio-mc33880.c index b46b9e522e8c..0f0df7956264 100644 --- a/drivers/gpio/gpio-mc33880.c +++ b/drivers/gpio/gpio-mc33880.c @@ -71,7 +71,7 @@ static int __mc33880_set(struct mc33880 *mc, unsigned offset, int value) static void mc33880_set(struct gpio_chip *chip, unsigned offset, int value) { - struct mc33880 *mc = container_of(chip, struct mc33880, chip); + struct mc33880 *mc = gpiochip_get_data(chip); mutex_lock(&mc->lock); @@ -135,7 +135,7 @@ static int mc33880_probe(struct spi_device *spi) goto exit_destroy; } - ret = gpiochip_add(&mc->chip); + ret = gpiochip_add_data(&mc->chip, mc); if (ret) goto exit_destroy; -- cgit From cf90c9e35be883d8ebcca3d4a2b1044a234f24d8 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 10:07:07 +0100 Subject: gpio: mc9s08dz60: 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: wu guoxing Signed-off-by: Linus Walleij --- drivers/gpio/gpio-mc9s08dz60.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-mc9s08dz60.c b/drivers/gpio/gpio-mc9s08dz60.c index 45f176018378..ba22fb92a6e7 100644 --- a/drivers/gpio/gpio-mc9s08dz60.c +++ b/drivers/gpio/gpio-mc9s08dz60.c @@ -29,12 +29,6 @@ struct mc9s08dz60 { struct gpio_chip chip; }; -static inline struct mc9s08dz60 *to_mc9s08dz60(struct gpio_chip *gc) -{ - return container_of(gc, struct mc9s08dz60, chip); -} - - static void mc9s_gpio_to_reg_and_bit(int offset, u8 *reg, u8 *bit) { *reg = 0x20 + offset / GPIO_NUM_PER_GROUP; @@ -45,7 +39,7 @@ static int mc9s08dz60_get_value(struct gpio_chip *gc, unsigned offset) { u8 reg, bit; s32 value; - struct mc9s08dz60 *mc9s = to_mc9s08dz60(gc); + struct mc9s08dz60 *mc9s = gpiochip_get_data(gc); mc9s_gpio_to_reg_and_bit(offset, ®, &bit); value = i2c_smbus_read_byte_data(mc9s->client, reg); @@ -75,7 +69,7 @@ static int mc9s08dz60_set(struct mc9s08dz60 *mc9s, unsigned offset, int val) static void mc9s08dz60_set_value(struct gpio_chip *gc, unsigned offset, int val) { - struct mc9s08dz60 *mc9s = to_mc9s08dz60(gc); + struct mc9s08dz60 *mc9s = gpiochip_get_data(gc); mc9s08dz60_set(mc9s, offset, val); } @@ -83,7 +77,7 @@ static void mc9s08dz60_set_value(struct gpio_chip *gc, unsigned offset, int val) static int mc9s08dz60_direction_output(struct gpio_chip *gc, unsigned offset, int val) { - struct mc9s08dz60 *mc9s = to_mc9s08dz60(gc); + struct mc9s08dz60 *mc9s = gpiochip_get_data(gc); return mc9s08dz60_set(mc9s, offset, val); } @@ -109,7 +103,7 @@ static int mc9s08dz60_probe(struct i2c_client *client, mc9s->client = client; i2c_set_clientdata(client, mc9s); - return gpiochip_add(&mc9s->chip); + return gpiochip_add_data(&mc9s->chip, mc9s); } static int mc9s08dz60_remove(struct i2c_client *client) -- cgit From 9e03cf0b12f19ef5dd8f113350e26b6d425ebbcb Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 10:09:36 +0100 Subject: gpio: mcp: 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: Sonic Zhang Acked-by: Alexander Stein Signed-off-by: Linus Walleij --- drivers/gpio/gpio-mcp23s08.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c index 13cace0ca6f7..c767879e4dd9 100644 --- a/drivers/gpio/gpio-mcp23s08.c +++ b/drivers/gpio/gpio-mcp23s08.c @@ -269,7 +269,7 @@ static const struct mcp23s08_ops mcp23s17_ops = { static int mcp23s08_direction_input(struct gpio_chip *chip, unsigned offset) { - struct mcp23s08 *mcp = container_of(chip, struct mcp23s08, chip); + struct mcp23s08 *mcp = gpiochip_get_data(chip); int status; mutex_lock(&mcp->lock); @@ -281,7 +281,7 @@ static int mcp23s08_direction_input(struct gpio_chip *chip, unsigned offset) static int mcp23s08_get(struct gpio_chip *chip, unsigned offset) { - struct mcp23s08 *mcp = container_of(chip, struct mcp23s08, chip); + struct mcp23s08 *mcp = gpiochip_get_data(chip); int status; mutex_lock(&mcp->lock); @@ -312,7 +312,7 @@ static int __mcp23s08_set(struct mcp23s08 *mcp, unsigned mask, int value) static void mcp23s08_set(struct gpio_chip *chip, unsigned offset, int value) { - struct mcp23s08 *mcp = container_of(chip, struct mcp23s08, chip); + struct mcp23s08 *mcp = gpiochip_get_data(chip); unsigned mask = 1 << offset; mutex_lock(&mcp->lock); @@ -323,7 +323,7 @@ static void mcp23s08_set(struct gpio_chip *chip, unsigned offset, int value) static int mcp23s08_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct mcp23s08 *mcp = container_of(chip, struct mcp23s08, chip); + struct mcp23s08 *mcp = gpiochip_get_data(chip); unsigned mask = 1 << offset; int status; @@ -377,7 +377,7 @@ static irqreturn_t mcp23s08_irq(int irq, void *data) static int mcp23s08_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct mcp23s08 *mcp = container_of(chip, struct mcp23s08, chip); + struct mcp23s08 *mcp = gpiochip_get_data(chip); return irq_find_mapping(mcp->irq_domain, offset); } @@ -544,7 +544,7 @@ static void mcp23s08_dbg_show(struct seq_file *s, struct gpio_chip *chip) int t; unsigned mask; - mcp = container_of(chip, struct mcp23s08, chip); + mcp = gpiochip_get_data(chip); /* NOTE: we only handle one bank for now ... */ bank = '0' + ((mcp->addr >> 1) & 0x7); @@ -704,7 +704,7 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, goto fail; } - status = gpiochip_add(&mcp->chip); + status = gpiochip_add_data(&mcp->chip, mcp); if (status < 0) goto fail; -- cgit From 47315578b9894140bef11e2b0fab55d2706e055c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 10:12:05 +0100 Subject: gpio: ml-ioh: 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: Feng Tang Cc: Tomoya MORINAGA Signed-off-by: Linus Walleij --- drivers/gpio/gpio-ml-ioh.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c index 7ef704343f05..796a5a4bc4f5 100644 --- a/drivers/gpio/gpio-ml-ioh.c +++ b/drivers/gpio/gpio-ml-ioh.c @@ -106,7 +106,7 @@ static const int num_ports[] = {6, 12, 16, 16, 15, 16, 16, 12}; static void ioh_gpio_set(struct gpio_chip *gpio, unsigned nr, int val) { u32 reg_val; - struct ioh_gpio *chip = container_of(gpio, struct ioh_gpio, gpio); + struct ioh_gpio *chip = gpiochip_get_data(gpio); unsigned long flags; spin_lock_irqsave(&chip->spinlock, flags); @@ -122,7 +122,7 @@ static void ioh_gpio_set(struct gpio_chip *gpio, unsigned nr, int val) static int ioh_gpio_get(struct gpio_chip *gpio, unsigned nr) { - struct ioh_gpio *chip = container_of(gpio, struct ioh_gpio, gpio); + struct ioh_gpio *chip = gpiochip_get_data(gpio); return !!(ioread32(&chip->reg->regs[chip->ch].pi) & (1 << nr)); } @@ -130,7 +130,7 @@ static int ioh_gpio_get(struct gpio_chip *gpio, unsigned nr) static int ioh_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, int val) { - struct ioh_gpio *chip = container_of(gpio, struct ioh_gpio, gpio); + struct ioh_gpio *chip = gpiochip_get_data(gpio); u32 pm; u32 reg_val; unsigned long flags; @@ -155,7 +155,7 @@ static int ioh_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, static int ioh_gpio_direction_input(struct gpio_chip *gpio, unsigned nr) { - struct ioh_gpio *chip = container_of(gpio, struct ioh_gpio, gpio); + struct ioh_gpio *chip = gpiochip_get_data(gpio); u32 pm; unsigned long flags; @@ -225,7 +225,7 @@ static void ioh_gpio_restore_reg_conf(struct ioh_gpio *chip) static int ioh_gpio_to_irq(struct gpio_chip *gpio, unsigned offset) { - struct ioh_gpio *chip = container_of(gpio, struct ioh_gpio, gpio); + struct ioh_gpio *chip = gpiochip_get_data(gpio); return chip->irq_base + offset; } @@ -450,7 +450,7 @@ static int ioh_gpio_probe(struct pci_dev *pdev, chip->ch = i; spin_lock_init(&chip->spinlock); ioh_gpio_setup(chip, num_ports[i]); - ret = gpiochip_add(&chip->gpio); + ret = gpiochip_add_data(&chip->gpio, chip); if (ret) { dev_err(&pdev->dev, "IOH gpio: Failed to register GPIO\n"); goto err_gpiochip_add; -- cgit From 6aa7dbfa28775189c53f6ac7f1bc4adf76c9d2ec Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 10:19:29 +0100 Subject: gpio: mm-lantiq: 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: Ricardo Ribalda Delgado Cc: John Crispin Signed-off-by: Linus Walleij --- drivers/gpio/gpio-mm-lantiq.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-mm-lantiq.c b/drivers/gpio/gpio-mm-lantiq.c index f67ef2283d64..a2071ed69f79 100644 --- a/drivers/gpio/gpio-mm-lantiq.c +++ b/drivers/gpio/gpio-mm-lantiq.c @@ -61,9 +61,7 @@ static void ltq_mm_apply(struct ltq_mm *chip) */ static void ltq_mm_set(struct gpio_chip *gc, unsigned offset, int value) { - struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct ltq_mm *chip = - container_of(mm_gc, struct ltq_mm, mmchip); + struct ltq_mm *chip = gpiochip_get_data(gc); if (value) chip->shadow |= (1 << offset); @@ -93,8 +91,7 @@ static int ltq_mm_dir_out(struct gpio_chip *gc, unsigned offset, int value) */ static void ltq_mm_save_regs(struct of_mm_gpio_chip *mm_gc) { - struct ltq_mm *chip = - container_of(mm_gc, struct ltq_mm, mmchip); + struct ltq_mm *chip = gpiochip_get_data(&mm_gc->gc); /* tell the ebu controller which memory address we will be using */ ltq_ebu_w32(CPHYSADDR(chip->mmchip.regs) | 0x1, LTQ_EBU_ADDRSEL1); @@ -122,7 +119,7 @@ static int ltq_mm_probe(struct platform_device *pdev) if (!of_property_read_u32(pdev->dev.of_node, "lantiq,shadow", &shadow)) chip->shadow = shadow; - return of_mm_gpiochip_add(pdev->dev.of_node, &chip->mmchip); + return of_mm_gpiochip_add_data(pdev->dev.of_node, &chip->mmchip, chip); } static int ltq_mm_remove(struct platform_device *pdev) -- cgit From 837c2705a3d5adca3ff5532d9cb6215803bea5f2 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 10:25:36 +0100 Subject: gpio: mpc5200: 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-mpc5200.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/gpio/gpio-mpc5200.c b/drivers/gpio/gpio-mpc5200.c index 044bbbb747f2..0e5a6709f27d 100644 --- a/drivers/gpio/gpio-mpc5200.c +++ b/drivers/gpio/gpio-mpc5200.c @@ -71,8 +71,7 @@ static inline void __mpc52xx_wkup_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct mpc52xx_gpiochip *chip = container_of(mm_gc, - struct mpc52xx_gpiochip, mmchip); + struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc); struct mpc52xx_gpio_wkup __iomem *regs = mm_gc->regs; if (val) @@ -100,8 +99,7 @@ mpc52xx_wkup_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) static int mpc52xx_wkup_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct mpc52xx_gpiochip *chip = container_of(mm_gc, - struct mpc52xx_gpiochip, mmchip); + struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc); struct mpc52xx_gpio_wkup __iomem *regs = mm_gc->regs; unsigned long flags; @@ -125,8 +123,7 @@ mpc52xx_wkup_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct mpc52xx_gpio_wkup __iomem *regs = mm_gc->regs; - struct mpc52xx_gpiochip *chip = container_of(mm_gc, - struct mpc52xx_gpiochip, mmchip); + struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&gpio_lock, flags); @@ -169,7 +166,7 @@ static int mpc52xx_wkup_gpiochip_probe(struct platform_device *ofdev) gc->get = mpc52xx_wkup_gpio_get; gc->set = mpc52xx_wkup_gpio_set; - ret = of_mm_gpiochip_add(ofdev->dev.of_node, &chip->mmchip); + ret = of_mm_gpiochip_add_data(ofdev->dev.of_node, &chip->mmchip, chip); if (ret) return ret; @@ -236,8 +233,7 @@ static inline void __mpc52xx_simple_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct mpc52xx_gpiochip *chip = container_of(mm_gc, - struct mpc52xx_gpiochip, mmchip); + struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc); struct mpc52xx_gpio __iomem *regs = mm_gc->regs; if (val) @@ -264,8 +260,7 @@ mpc52xx_simple_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) static int mpc52xx_simple_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct mpc52xx_gpiochip *chip = container_of(mm_gc, - struct mpc52xx_gpiochip, mmchip); + struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc); struct mpc52xx_gpio __iomem *regs = mm_gc->regs; unsigned long flags; @@ -288,8 +283,7 @@ static int mpc52xx_simple_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct mpc52xx_gpiochip *chip = container_of(mm_gc, - struct mpc52xx_gpiochip, mmchip); + struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc); struct mpc52xx_gpio __iomem *regs = mm_gc->regs; unsigned long flags; @@ -334,7 +328,7 @@ static int mpc52xx_simple_gpiochip_probe(struct platform_device *ofdev) gc->get = mpc52xx_simple_gpio_get; gc->set = mpc52xx_simple_gpio_set; - ret = of_mm_gpiochip_add(ofdev->dev.of_node, &chip->mmchip); + ret = of_mm_gpiochip_add_data(ofdev->dev.of_node, &chip->mmchip, chip); if (ret) return ret; -- cgit From 709d71a17c3383eca79ce9142b8d4ddc0f8028d0 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 10:34:28 +0100 Subject: gpio: mpc8xxx: use gpiochip data pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Uwe Kleine-König Acked-by: Alexander Stein Signed-off-by: Linus Walleij --- drivers/gpio/gpio-mpc8xxx.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c index de4cd22a5014..21eff0e1df87 100644 --- a/drivers/gpio/gpio-mpc8xxx.c +++ b/drivers/gpio/gpio-mpc8xxx.c @@ -49,15 +49,9 @@ static inline u32 mpc8xxx_gpio2mask(unsigned int gpio) return 1u << (MPC8XXX_GPIO_PINS - 1 - gpio); } -static inline struct mpc8xxx_gpio_chip * -to_mpc8xxx_gpio_chip(struct of_mm_gpio_chip *mm) -{ - return container_of(mm, struct mpc8xxx_gpio_chip, mm_gc); -} - static void mpc8xxx_gpio_save_regs(struct of_mm_gpio_chip *mm) { - struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); + struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(&mm->gc); mpc8xxx_gc->data = in_be32(mm->regs + GPIO_DAT); } @@ -71,7 +65,7 @@ static int mpc8572_gpio_get(struct gpio_chip *gc, unsigned int gpio) { u32 val; struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); - struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); + struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(gc); u32 out_mask, out_shadow; out_mask = in_be32(mm->regs + GPIO_DIR); @@ -92,7 +86,7 @@ static int mpc8xxx_gpio_get(struct gpio_chip *gc, unsigned int gpio) static void mpc8xxx_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) { struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); - struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); + struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(gc); unsigned long flags; raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); @@ -111,7 +105,7 @@ static void mpc8xxx_gpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, unsigned long *bits) { struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); - struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); + struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(gc); unsigned long flags; int i; @@ -136,7 +130,7 @@ static void mpc8xxx_gpio_set_multiple(struct gpio_chip *gc, static int mpc8xxx_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) { struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); - struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); + struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(gc); unsigned long flags; raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); @@ -151,7 +145,7 @@ static int mpc8xxx_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) static int mpc8xxx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) { struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); - struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); + struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(gc); unsigned long flags; mpc8xxx_gpio_set(gc, gpio, val); @@ -185,8 +179,7 @@ static int mpc5125_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val static int mpc8xxx_gpio_to_irq(struct gpio_chip *gc, unsigned offset) { - struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); - struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); + struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(gc); if (mpc8xxx_gc->irq && offset < MPC8XXX_GPIO_PINS) return irq_create_mapping(mpc8xxx_gc->irq, offset); @@ -417,7 +410,7 @@ static int mpc8xxx_probe(struct platform_device *pdev) gc->set_multiple = mpc8xxx_gpio_set_multiple; gc->to_irq = mpc8xxx_gpio_to_irq; - ret = of_mm_gpiochip_add(np, mm_gc); + ret = of_mm_gpiochip_add_data(np, mm_gc, mpc8xxx_gc); if (ret) return ret; -- cgit From a772a26da7cf605ed33382d7822ebfac18c6b1ef Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 10:37:39 +0100 Subject: gpio: msic: 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(). Acked-by: Mathias Nyman Signed-off-by: Linus Walleij --- drivers/gpio/gpio-msic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-msic.c b/drivers/gpio/gpio-msic.c index 9a261acb0eed..d75649787e6c 100644 --- a/drivers/gpio/gpio-msic.c +++ b/drivers/gpio/gpio-msic.c @@ -179,7 +179,7 @@ static int msic_irq_type(struct irq_data *data, unsigned type) static int msic_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct msic_gpio *mg = container_of(chip, struct msic_gpio, chip); + struct msic_gpio *mg = gpiochip_get_data(chip); return mg->irq_base + offset; } @@ -297,7 +297,7 @@ static int platform_msic_gpio_probe(struct platform_device *pdev) mutex_init(&mg->buslock); - retval = gpiochip_add(&mg->chip); + retval = gpiochip_add_data(&mg->chip, mg); if (retval) { dev_err(dev, "Adding MSIC gpio chip failed\n"); goto err; -- cgit From bbe760041a05d51746f1b1cd658aaef91466bafc Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 11:09:24 +0100 Subject: gpio: mvebu: 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: Gregory CLEMENT Cc: Thomas Petazzoni Signed-off-by: Linus Walleij --- drivers/gpio/gpio-mvebu.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index 6acedf4e9b1c..a5eacc1dff09 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c @@ -187,8 +187,7 @@ static void __iomem *mvebu_gpioreg_level_mask(struct mvebu_gpio_chip *mvchip) static void mvebu_gpio_set(struct gpio_chip *chip, unsigned pin, int value) { - struct mvebu_gpio_chip *mvchip = - container_of(chip, struct mvebu_gpio_chip, chip); + struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); unsigned long flags; u32 u; @@ -204,8 +203,7 @@ static void mvebu_gpio_set(struct gpio_chip *chip, unsigned pin, int value) static int mvebu_gpio_get(struct gpio_chip *chip, unsigned pin) { - struct mvebu_gpio_chip *mvchip = - container_of(chip, struct mvebu_gpio_chip, chip); + struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); u32 u; if (readl_relaxed(mvebu_gpioreg_io_conf(mvchip)) & (1 << pin)) { @@ -220,8 +218,7 @@ static int mvebu_gpio_get(struct gpio_chip *chip, unsigned pin) static void mvebu_gpio_blink(struct gpio_chip *chip, unsigned pin, int value) { - struct mvebu_gpio_chip *mvchip = - container_of(chip, struct mvebu_gpio_chip, chip); + struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); unsigned long flags; u32 u; @@ -237,8 +234,7 @@ static void mvebu_gpio_blink(struct gpio_chip *chip, unsigned pin, int value) static int mvebu_gpio_direction_input(struct gpio_chip *chip, unsigned pin) { - struct mvebu_gpio_chip *mvchip = - container_of(chip, struct mvebu_gpio_chip, chip); + struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); unsigned long flags; int ret; u32 u; @@ -261,8 +257,7 @@ static int mvebu_gpio_direction_input(struct gpio_chip *chip, unsigned pin) static int mvebu_gpio_direction_output(struct gpio_chip *chip, unsigned pin, int value) { - struct mvebu_gpio_chip *mvchip = - container_of(chip, struct mvebu_gpio_chip, chip); + struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); unsigned long flags; int ret; u32 u; @@ -287,8 +282,7 @@ static int mvebu_gpio_direction_output(struct gpio_chip *chip, unsigned pin, static int mvebu_gpio_to_irq(struct gpio_chip *chip, unsigned pin) { - struct mvebu_gpio_chip *mvchip = - container_of(chip, struct mvebu_gpio_chip, chip); + struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); return irq_create_mapping(mvchip->domain, pin); } @@ -494,8 +488,7 @@ static void mvebu_gpio_irq_handler(struct irq_desc *desc) static void mvebu_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { - struct mvebu_gpio_chip *mvchip = - container_of(chip, struct mvebu_gpio_chip, chip); + struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); u32 out, io_conf, blink, in_pol, data_in, cause, edg_msk, lvl_msk; int i; @@ -763,7 +756,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev) BUG(); } - gpiochip_add(&mvchip->chip); + gpiochip_add_data(&mvchip->chip, mvchip); /* Some gpio controllers do not provide irq support */ if (!of_irq_count(np)) -- cgit From f5cc554e1cf17482781069b671090d3a35d5413b Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 11:13:27 +0100 Subject: gpio: octeon: 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(). Reviewed-by: David Daney Signed-off-by: Linus Walleij --- drivers/gpio/gpio-octeon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-octeon.c b/drivers/gpio/gpio-octeon.c index afbb2417dfbc..7665ebcd0c1d 100644 --- a/drivers/gpio/gpio-octeon.c +++ b/drivers/gpio/gpio-octeon.c @@ -41,7 +41,7 @@ struct octeon_gpio { static int octeon_gpio_dir_in(struct gpio_chip *chip, unsigned offset) { - struct octeon_gpio *gpio = container_of(chip, struct octeon_gpio, chip); + struct octeon_gpio *gpio = gpiochip_get_data(chip); cvmx_write_csr(gpio->register_base + bit_cfg_reg(offset), 0); return 0; @@ -49,7 +49,7 @@ static int octeon_gpio_dir_in(struct gpio_chip *chip, unsigned offset) static void octeon_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct octeon_gpio *gpio = container_of(chip, struct octeon_gpio, chip); + struct octeon_gpio *gpio = gpiochip_get_data(chip); u64 mask = 1ull << offset; u64 reg = gpio->register_base + (value ? TX_SET : TX_CLEAR); cvmx_write_csr(reg, mask); @@ -58,7 +58,7 @@ static void octeon_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int octeon_gpio_dir_out(struct gpio_chip *chip, unsigned offset, int value) { - struct octeon_gpio *gpio = container_of(chip, struct octeon_gpio, chip); + struct octeon_gpio *gpio = gpiochip_get_data(chip); union cvmx_gpio_bit_cfgx cfgx; octeon_gpio_set(chip, offset, value); @@ -72,7 +72,7 @@ static int octeon_gpio_dir_out(struct gpio_chip *chip, unsigned offset, static int octeon_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct octeon_gpio *gpio = container_of(chip, struct octeon_gpio, chip); + struct octeon_gpio *gpio = gpiochip_get_data(chip); u64 read_bits = cvmx_read_csr(gpio->register_base + RX_DAT); return ((1ull << offset) & read_bits) != 0; @@ -117,7 +117,7 @@ static int octeon_gpio_probe(struct platform_device *pdev) chip->get = octeon_gpio_get; chip->direction_output = octeon_gpio_dir_out; chip->set = octeon_gpio_set; - err = gpiochip_add(chip); + err = gpiochip_add_data(chip, gpio); if (err) goto out; -- cgit From d99f7aec6e8b4ffe10d6df71d17d2c5cbef2ac65 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 11:16:00 +0100 Subject: gpio: omap: 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: Grygorii Strashko Cc: Tony Lindgren Acked-by: Santosh Shilimkar Signed-off-by: Linus Walleij --- drivers/gpio/gpio-omap.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index e183351d047c..189f672bebc1 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -93,7 +93,7 @@ static void omap_gpio_unmask_irq(struct irq_data *d); static inline struct gpio_bank *omap_irq_data_get_bank(struct irq_data *d) { struct gpio_chip *chip = irq_data_get_irq_chip_data(d); - return container_of(chip, struct gpio_bank, chip); + return gpiochip_get_data(chip); } static void omap_set_gpio_direction(struct gpio_bank *bank, int gpio, @@ -661,7 +661,7 @@ static int omap_gpio_wake_enable(struct irq_data *d, unsigned int enable) static int omap_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip); + struct gpio_bank *bank = gpiochip_get_data(chip); unsigned long flags; /* @@ -681,7 +681,7 @@ static int omap_gpio_request(struct gpio_chip *chip, unsigned offset) static void omap_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip); + struct gpio_bank *bank = gpiochip_get_data(chip); unsigned long flags; raw_spin_lock_irqsave(&bank->lock, flags); @@ -954,7 +954,7 @@ static int omap_gpio_get_direction(struct gpio_chip *chip, unsigned offset) void __iomem *reg; int dir; - bank = container_of(chip, struct gpio_bank, chip); + bank = gpiochip_get_data(chip); reg = bank->base + bank->regs->direction; raw_spin_lock_irqsave(&bank->lock, flags); dir = !!(readl_relaxed(reg) & BIT(offset)); @@ -967,7 +967,7 @@ static int omap_gpio_input(struct gpio_chip *chip, unsigned offset) struct gpio_bank *bank; unsigned long flags; - bank = container_of(chip, struct gpio_bank, chip); + bank = gpiochip_get_data(chip); raw_spin_lock_irqsave(&bank->lock, flags); omap_set_gpio_direction(bank, offset, 1); raw_spin_unlock_irqrestore(&bank->lock, flags); @@ -978,7 +978,7 @@ static int omap_gpio_get(struct gpio_chip *chip, unsigned offset) { struct gpio_bank *bank; - bank = container_of(chip, struct gpio_bank, chip); + bank = gpiochip_get_data(chip); if (omap_gpio_is_input(bank, offset)) return omap_get_gpio_datain(bank, offset); @@ -991,7 +991,7 @@ static int omap_gpio_output(struct gpio_chip *chip, unsigned offset, int value) struct gpio_bank *bank; unsigned long flags; - bank = container_of(chip, struct gpio_bank, chip); + bank = gpiochip_get_data(chip); raw_spin_lock_irqsave(&bank->lock, flags); bank->set_dataout(bank, offset, value); omap_set_gpio_direction(bank, offset, 0); @@ -1005,7 +1005,7 @@ static int omap_gpio_debounce(struct gpio_chip *chip, unsigned offset, struct gpio_bank *bank; unsigned long flags; - bank = container_of(chip, struct gpio_bank, chip); + bank = gpiochip_get_data(chip); raw_spin_lock_irqsave(&bank->lock, flags); omap2_set_gpio_debounce(bank, offset, debounce); @@ -1019,7 +1019,7 @@ static void omap_gpio_set(struct gpio_chip *chip, unsigned offset, int value) struct gpio_bank *bank; unsigned long flags; - bank = container_of(chip, struct gpio_bank, chip); + bank = gpiochip_get_data(chip); raw_spin_lock_irqsave(&bank->lock, flags); bank->set_dataout(bank, offset, value); raw_spin_unlock_irqrestore(&bank->lock, flags); @@ -1098,7 +1098,7 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) } bank->chip.ngpio = bank->width; - ret = gpiochip_add(&bank->chip); + ret = gpiochip_add_data(&bank->chip, bank); if (ret) { dev_err(bank->dev, "Could not register gpio chip %d\n", ret); return ret; -- cgit From 5b68cc2d5963e2241d36f07c5f5964d54fa7bc6f Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 11:18:17 +0100 Subject: gpio: palmas: 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: Andrew Chew Cc: Stephen Warren Acked-by: Laxman Dewangan Signed-off-by: Linus Walleij --- drivers/gpio/gpio-palmas.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-palmas.c b/drivers/gpio/gpio-palmas.c index ddd1a00c839d..fdfb3b1e0def 100644 --- a/drivers/gpio/gpio-palmas.c +++ b/drivers/gpio/gpio-palmas.c @@ -35,14 +35,9 @@ struct palmas_device_data { int ngpio; }; -static inline struct palmas_gpio *to_palmas_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct palmas_gpio, gpio_chip); -} - static int palmas_gpio_get(struct gpio_chip *gc, unsigned offset) { - struct palmas_gpio *pg = to_palmas_gpio(gc); + struct palmas_gpio *pg = gpiochip_get_data(gc); struct palmas *palmas = pg->palmas; unsigned int val; int ret; @@ -74,7 +69,7 @@ static int palmas_gpio_get(struct gpio_chip *gc, unsigned offset) static void palmas_gpio_set(struct gpio_chip *gc, unsigned offset, int value) { - struct palmas_gpio *pg = to_palmas_gpio(gc); + struct palmas_gpio *pg = gpiochip_get_data(gc); struct palmas *palmas = pg->palmas; int ret; unsigned int reg; @@ -96,7 +91,7 @@ static void palmas_gpio_set(struct gpio_chip *gc, unsigned offset, static int palmas_gpio_output(struct gpio_chip *gc, unsigned offset, int value) { - struct palmas_gpio *pg = to_palmas_gpio(gc); + struct palmas_gpio *pg = gpiochip_get_data(gc); struct palmas *palmas = pg->palmas; int ret; unsigned int reg; @@ -118,7 +113,7 @@ static int palmas_gpio_output(struct gpio_chip *gc, unsigned offset, static int palmas_gpio_input(struct gpio_chip *gc, unsigned offset) { - struct palmas_gpio *pg = to_palmas_gpio(gc); + struct palmas_gpio *pg = gpiochip_get_data(gc); struct palmas *palmas = pg->palmas; int ret; unsigned int reg; @@ -136,7 +131,7 @@ static int palmas_gpio_input(struct gpio_chip *gc, unsigned offset) static int palmas_gpio_to_irq(struct gpio_chip *gc, unsigned offset) { - struct palmas_gpio *pg = to_palmas_gpio(gc); + struct palmas_gpio *pg = gpiochip_get_data(gc); struct palmas *palmas = pg->palmas; return palmas_irq_get_virq(palmas, PALMAS_GPIO_0_IRQ + offset); @@ -200,7 +195,7 @@ static int palmas_gpio_probe(struct platform_device *pdev) else palmas_gpio->gpio_chip.base = -1; - ret = gpiochip_add(&palmas_gpio->gpio_chip); + ret = gpiochip_add_data(&palmas_gpio->gpio_chip, palmas_gpio); if (ret < 0) { dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); return ret; -- cgit From 468e67f6eb7494e3c4d4d644f281d0ba0cc265c6 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 11:20:54 +0100 Subject: gpio: pca953x: 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: Grygorii Strashko Cc: Markus Pargmann Cc: Toby Smith Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pca953x.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index be3e3b903ff0..23196c5fc17c 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -107,11 +107,6 @@ struct pca953x_chip { unsigned long driver_data; }; -static inline struct pca953x_chip *to_pca(struct gpio_chip *gc) -{ - return container_of(gc, struct pca953x_chip, gpio_chip); -} - static int pca953x_read_single(struct pca953x_chip *chip, int reg, u32 *val, int off) { @@ -214,7 +209,7 @@ static int pca953x_read_regs(struct pca953x_chip *chip, int reg, u8 *val) static int pca953x_gpio_direction_input(struct gpio_chip *gc, unsigned off) { - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); u8 reg_val; int ret, offset = 0; @@ -243,7 +238,7 @@ exit: static int pca953x_gpio_direction_output(struct gpio_chip *gc, unsigned off, int val) { - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); u8 reg_val; int ret, offset = 0; @@ -293,7 +288,7 @@ exit: static int pca953x_gpio_get_value(struct gpio_chip *gc, unsigned off) { - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); u32 reg_val; int ret, offset = 0; @@ -321,7 +316,7 @@ static int pca953x_gpio_get_value(struct gpio_chip *gc, unsigned off) static void pca953x_gpio_set_value(struct gpio_chip *gc, unsigned off, int val) { - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); u8 reg_val; int ret, offset = 0; @@ -354,7 +349,7 @@ exit: static void pca953x_gpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, unsigned long *bits) { - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); u8 reg_val[MAX_BANK]; int ret, offset = 0; int bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ); @@ -412,7 +407,7 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios) static void pca953x_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); chip->irq_mask[d->hwirq / BANK_SZ] &= ~(1 << (d->hwirq % BANK_SZ)); } @@ -420,7 +415,7 @@ static void pca953x_irq_mask(struct irq_data *d) static void pca953x_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); chip->irq_mask[d->hwirq / BANK_SZ] |= 1 << (d->hwirq % BANK_SZ); } @@ -428,7 +423,7 @@ static void pca953x_irq_unmask(struct irq_data *d) static void pca953x_irq_bus_lock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); mutex_lock(&chip->irq_lock); } @@ -436,7 +431,7 @@ static void pca953x_irq_bus_lock(struct irq_data *d) static void pca953x_irq_bus_sync_unlock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); u8 new_irqs; int level, i; @@ -459,7 +454,7 @@ static void pca953x_irq_bus_sync_unlock(struct irq_data *d) static int pca953x_irq_set_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); int bank_nb = d->hwirq / BANK_SZ; u8 mask = 1 << (d->hwirq % BANK_SZ); @@ -759,7 +754,7 @@ static int pca953x_probe(struct i2c_client *client, if (ret) return ret; - ret = gpiochip_add(&chip->gpio_chip); + ret = gpiochip_add_data(&chip->gpio_chip, chip); if (ret) return ret; -- cgit From 597358e41070e03479a7724b16eb3c6c7ea50027 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 11:24:05 +0100 Subject: gpio: pcf857x: 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: Grygorii Strashko Cc: George Cherian Cc: Laurent Pinchart Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pcf857x.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-pcf857x.c b/drivers/gpio/gpio-pcf857x.c index f64380a7d004..709cd3fc2a70 100644 --- a/drivers/gpio/gpio-pcf857x.c +++ b/drivers/gpio/gpio-pcf857x.c @@ -137,7 +137,7 @@ static int i2c_read_le16(struct i2c_client *client) static int pcf857x_input(struct gpio_chip *chip, unsigned offset) { - struct pcf857x *gpio = container_of(chip, struct pcf857x, chip); + struct pcf857x *gpio = gpiochip_get_data(chip); int status; mutex_lock(&gpio->lock); @@ -150,7 +150,7 @@ static int pcf857x_input(struct gpio_chip *chip, unsigned offset) static int pcf857x_get(struct gpio_chip *chip, unsigned offset) { - struct pcf857x *gpio = container_of(chip, struct pcf857x, chip); + struct pcf857x *gpio = gpiochip_get_data(chip); int value; value = gpio->read(gpio->client); @@ -159,7 +159,7 @@ static int pcf857x_get(struct gpio_chip *chip, unsigned offset) static int pcf857x_output(struct gpio_chip *chip, unsigned offset, int value) { - struct pcf857x *gpio = container_of(chip, struct pcf857x, chip); + struct pcf857x *gpio = gpiochip_get_data(chip); unsigned bit = 1 << offset; int status; @@ -372,7 +372,7 @@ static int pcf857x_probe(struct i2c_client *client, gpio->out = ~n_latch; gpio->status = gpio->out; - status = gpiochip_add(&gpio->chip); + status = gpiochip_add_data(&gpio->chip, gpio); if (status < 0) goto fail; -- cgit From 510f48713711abed9a79aa405147687dd256d072 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 11:34:53 +0100 Subject: gpio: pch: 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: Thierry Reding Cc: Daniel Krueger Reviewed-by: Jean Delvare Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pch.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-pch.c b/drivers/gpio/gpio-pch.c index 8c45b74dcf21..0475782a7e88 100644 --- a/drivers/gpio/gpio-pch.c +++ b/drivers/gpio/gpio-pch.c @@ -109,7 +109,7 @@ struct pch_gpio { static void pch_gpio_set(struct gpio_chip *gpio, unsigned nr, int val) { u32 reg_val; - struct pch_gpio *chip = container_of(gpio, struct pch_gpio, gpio); + struct pch_gpio *chip = gpiochip_get_data(gpio); unsigned long flags; spin_lock_irqsave(&chip->spinlock, flags); @@ -125,7 +125,7 @@ static void pch_gpio_set(struct gpio_chip *gpio, unsigned nr, int val) static int pch_gpio_get(struct gpio_chip *gpio, unsigned nr) { - struct pch_gpio *chip = container_of(gpio, struct pch_gpio, gpio); + struct pch_gpio *chip = gpiochip_get_data(gpio); return !!(ioread32(&chip->reg->pi) & (1 << nr)); } @@ -133,7 +133,7 @@ static int pch_gpio_get(struct gpio_chip *gpio, unsigned nr) static int pch_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, int val) { - struct pch_gpio *chip = container_of(gpio, struct pch_gpio, gpio); + struct pch_gpio *chip = gpiochip_get_data(gpio); u32 pm; u32 reg_val; unsigned long flags; @@ -158,7 +158,7 @@ static int pch_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, static int pch_gpio_direction_input(struct gpio_chip *gpio, unsigned nr) { - struct pch_gpio *chip = container_of(gpio, struct pch_gpio, gpio); + struct pch_gpio *chip = gpiochip_get_data(gpio); u32 pm; unsigned long flags; @@ -211,7 +211,7 @@ static void pch_gpio_restore_reg_conf(struct pch_gpio *chip) static int pch_gpio_to_irq(struct gpio_chip *gpio, unsigned offset) { - struct pch_gpio *chip = container_of(gpio, struct pch_gpio, gpio); + struct pch_gpio *chip = gpiochip_get_data(gpio); return chip->irq_base + offset; } @@ -397,7 +397,7 @@ static int pch_gpio_probe(struct pci_dev *pdev, #ifdef CONFIG_OF_GPIO chip->gpio.of_node = pdev->dev.of_node; #endif - ret = gpiochip_add(&chip->gpio); + ret = gpiochip_add_data(&chip->gpio, chip); if (ret) { dev_err(&pdev->dev, "PCH gpio: Failed to register GPIO\n"); goto err_gpiochip_add; -- cgit From d81b37fcad764c7babd7dd858aeb1b9afd2df5cc Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 11:37:33 +0100 Subject: gpio: pl061: 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: Haojian Zhuang Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pl061.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index f937bc7e42dd..5cb38212bbc0 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c @@ -61,7 +61,7 @@ struct pl061_gpio { static int pl061_direction_input(struct gpio_chip *gc, unsigned offset) { - struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); + struct pl061_gpio *chip = gpiochip_get_data(gc); unsigned long flags; unsigned char gpiodir; @@ -80,7 +80,7 @@ static int pl061_direction_input(struct gpio_chip *gc, unsigned offset) static int pl061_direction_output(struct gpio_chip *gc, unsigned offset, int value) { - struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); + struct pl061_gpio *chip = gpiochip_get_data(gc); unsigned long flags; unsigned char gpiodir; @@ -105,14 +105,14 @@ static int pl061_direction_output(struct gpio_chip *gc, unsigned offset, static int pl061_get_value(struct gpio_chip *gc, unsigned offset) { - struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); + struct pl061_gpio *chip = gpiochip_get_data(gc); return !!readb(chip->base + (BIT(offset + 2))); } static void pl061_set_value(struct gpio_chip *gc, unsigned offset, int value) { - struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); + struct pl061_gpio *chip = gpiochip_get_data(gc); writeb(!!value << offset, chip->base + (BIT(offset + 2))); } @@ -120,7 +120,7 @@ static void pl061_set_value(struct gpio_chip *gc, unsigned offset, int value) static int pl061_irq_type(struct irq_data *d, unsigned trigger) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); + struct pl061_gpio *chip = gpiochip_get_data(gc); int offset = irqd_to_hwirq(d); unsigned long flags; u8 gpiois, gpioibe, gpioiev; @@ -210,7 +210,7 @@ static void pl061_irq_handler(struct irq_desc *desc) unsigned long pending; int offset; struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); + struct pl061_gpio *chip = gpiochip_get_data(gc); struct irq_chip *irqchip = irq_desc_get_chip(desc); chained_irq_enter(irqchip, desc); @@ -228,7 +228,7 @@ static void pl061_irq_handler(struct irq_desc *desc) static void pl061_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); + struct pl061_gpio *chip = gpiochip_get_data(gc); u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); u8 gpioie; @@ -241,7 +241,7 @@ static void pl061_irq_mask(struct irq_data *d) static void pl061_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); + struct pl061_gpio *chip = gpiochip_get_data(gc); u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); u8 gpioie; @@ -262,7 +262,7 @@ static void pl061_irq_unmask(struct irq_data *d) static void pl061_irq_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); + struct pl061_gpio *chip = gpiochip_get_data(gc); u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); spin_lock(&chip->lock); @@ -328,7 +328,7 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) chip->gc.parent = dev; chip->gc.owner = THIS_MODULE; - ret = gpiochip_add(&chip->gc); + ret = gpiochip_add_data(&chip->gc, chip); if (ret) return ret; -- cgit From 81d0c31d11846f282f08ff81219ff6b7230a78b1 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 11:42:22 +0100 Subject: gpio: pxa: 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: Daniel Mack Acked-by: Robert Jarzmik Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pxa.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index 415852d3ca8a..b2b7b78664b8 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c @@ -155,14 +155,15 @@ static struct pxa_gpio_id pxa1928_id = { static inline struct pxa_gpio_chip *chip_to_pxachip(struct gpio_chip *c) { - struct pxa_gpio_chip *pxa_chip = - container_of(c, struct pxa_gpio_chip, chip); + struct pxa_gpio_chip *pxa_chip = gpiochip_get_data(c); return pxa_chip; } + static inline void __iomem *gpio_bank_base(struct gpio_chip *c, int gpio) { - struct pxa_gpio_bank *bank = chip_to_pxachip(c)->banks + (gpio / 32); + struct pxa_gpio_chip *p = gpiochip_get_data(c); + struct pxa_gpio_bank *bank = p->banks + (gpio / 32); return bank->regbase; } @@ -370,7 +371,7 @@ static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, int ngpio, bank->regbase = regbase + BANK_OFF(i); } - return gpiochip_add(&pchip->chip); + return gpiochip_add_data(&pchip->chip, pchip); } /* Update only those GRERx and GFERx edge detection register bits if those -- cgit From d660c68eb5b24051a4765d473765d9021a720975 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:08:12 +0100 Subject: gpio: rc5t583: 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(). Acked-by: Laxman Dewangan Signed-off-by: Linus Walleij --- drivers/gpio/gpio-rc5t583.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/gpio/gpio-rc5t583.c b/drivers/gpio/gpio-rc5t583.c index f26d9f7d8cdd..1e2d210b3369 100644 --- a/drivers/gpio/gpio-rc5t583.c +++ b/drivers/gpio/gpio-rc5t583.c @@ -34,14 +34,9 @@ struct rc5t583_gpio { struct rc5t583 *rc5t583; }; -static inline struct rc5t583_gpio *to_rc5t583_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct rc5t583_gpio, gpio_chip); -} - static int rc5t583_gpio_get(struct gpio_chip *gc, unsigned int offset) { - struct rc5t583_gpio *rc5t583_gpio = to_rc5t583_gpio(gc); + struct rc5t583_gpio *rc5t583_gpio = gpiochip_get_data(gc); struct device *parent = rc5t583_gpio->rc5t583->dev; uint8_t val = 0; int ret; @@ -55,7 +50,7 @@ static int rc5t583_gpio_get(struct gpio_chip *gc, unsigned int offset) static void rc5t583_gpio_set(struct gpio_chip *gc, unsigned int offset, int val) { - struct rc5t583_gpio *rc5t583_gpio = to_rc5t583_gpio(gc); + struct rc5t583_gpio *rc5t583_gpio = gpiochip_get_data(gc); struct device *parent = rc5t583_gpio->rc5t583->dev; if (val) rc5t583_set_bits(parent, RC5T583_GPIO_IOOUT, BIT(offset)); @@ -65,7 +60,7 @@ static void rc5t583_gpio_set(struct gpio_chip *gc, unsigned int offset, int val) static int rc5t583_gpio_dir_input(struct gpio_chip *gc, unsigned int offset) { - struct rc5t583_gpio *rc5t583_gpio = to_rc5t583_gpio(gc); + struct rc5t583_gpio *rc5t583_gpio = gpiochip_get_data(gc); struct device *parent = rc5t583_gpio->rc5t583->dev; int ret; @@ -80,7 +75,7 @@ static int rc5t583_gpio_dir_input(struct gpio_chip *gc, unsigned int offset) static int rc5t583_gpio_dir_output(struct gpio_chip *gc, unsigned offset, int value) { - struct rc5t583_gpio *rc5t583_gpio = to_rc5t583_gpio(gc); + struct rc5t583_gpio *rc5t583_gpio = gpiochip_get_data(gc); struct device *parent = rc5t583_gpio->rc5t583->dev; int ret; @@ -95,7 +90,7 @@ static int rc5t583_gpio_dir_output(struct gpio_chip *gc, unsigned offset, static int rc5t583_gpio_to_irq(struct gpio_chip *gc, unsigned offset) { - struct rc5t583_gpio *rc5t583_gpio = to_rc5t583_gpio(gc); + struct rc5t583_gpio *rc5t583_gpio = gpiochip_get_data(gc); if (offset < RC5T583_MAX_GPIO) return rc5t583_gpio->rc5t583->irq_base + @@ -105,7 +100,7 @@ static int rc5t583_gpio_to_irq(struct gpio_chip *gc, unsigned offset) static void rc5t583_gpio_free(struct gpio_chip *gc, unsigned offset) { - struct rc5t583_gpio *rc5t583_gpio = to_rc5t583_gpio(gc); + struct rc5t583_gpio *rc5t583_gpio = gpiochip_get_data(gc); struct device *parent = rc5t583_gpio->rc5t583->dev; rc5t583_set_bits(parent, RC5T583_GPIO_PGSEL, BIT(offset)); @@ -141,7 +136,7 @@ static int rc5t583_gpio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, rc5t583_gpio); - return gpiochip_add(&rc5t583_gpio->gpio_chip); + return gpiochip_add_data(&rc5t583_gpio->gpio_chip, rc5t583_gpio); } static int rc5t583_gpio_remove(struct platform_device *pdev) -- cgit From c7b6f457cb53bceece484f4c528d1c149995e6c7 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:12:45 +0100 Subject: gpio: rcar: 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: Ulrich Hecht Cc: Geert Uytterhoeven Cc: Hisashi Nakamura Signed-off-by: Linus Walleij --- drivers/gpio/gpio-rcar.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index 624a435e6988..cf41440aff91 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -84,8 +84,7 @@ static void gpio_rcar_modify_bit(struct gpio_rcar_priv *p, int offs, static void gpio_rcar_irq_disable(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct gpio_rcar_priv *p = container_of(gc, struct gpio_rcar_priv, - gpio_chip); + struct gpio_rcar_priv *p = gpiochip_get_data(gc); gpio_rcar_write(p, INTMSK, ~BIT(irqd_to_hwirq(d))); } @@ -93,8 +92,7 @@ static void gpio_rcar_irq_disable(struct irq_data *d) static void gpio_rcar_irq_enable(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct gpio_rcar_priv *p = container_of(gc, struct gpio_rcar_priv, - gpio_chip); + struct gpio_rcar_priv *p = gpiochip_get_data(gc); gpio_rcar_write(p, MSKCLR, BIT(irqd_to_hwirq(d))); } @@ -137,8 +135,7 @@ static void gpio_rcar_config_interrupt_input_mode(struct gpio_rcar_priv *p, static int gpio_rcar_irq_set_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct gpio_rcar_priv *p = container_of(gc, struct gpio_rcar_priv, - gpio_chip); + struct gpio_rcar_priv *p = gpiochip_get_data(gc); unsigned int hwirq = irqd_to_hwirq(d); dev_dbg(&p->pdev->dev, "sense irq = %d, type = %d\n", hwirq, type); @@ -175,8 +172,7 @@ static int gpio_rcar_irq_set_type(struct irq_data *d, unsigned int type) static int gpio_rcar_irq_set_wake(struct irq_data *d, unsigned int on) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct gpio_rcar_priv *p = container_of(gc, struct gpio_rcar_priv, - gpio_chip); + struct gpio_rcar_priv *p = gpiochip_get_data(gc); int error; if (p->irq_parent) { @@ -218,16 +214,11 @@ static irqreturn_t gpio_rcar_irq_handler(int irq, void *dev_id) return irqs_handled ? IRQ_HANDLED : IRQ_NONE; } -static inline struct gpio_rcar_priv *gpio_to_priv(struct gpio_chip *chip) -{ - return container_of(chip, struct gpio_rcar_priv, gpio_chip); -} - static void gpio_rcar_config_general_input_output_mode(struct gpio_chip *chip, unsigned int gpio, bool output) { - struct gpio_rcar_priv *p = gpio_to_priv(chip); + struct gpio_rcar_priv *p = gpiochip_get_data(chip); unsigned long flags; /* follow steps in the GPIO documentation for @@ -251,7 +242,7 @@ static void gpio_rcar_config_general_input_output_mode(struct gpio_chip *chip, static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset) { - struct gpio_rcar_priv *p = gpio_to_priv(chip); + struct gpio_rcar_priv *p = gpiochip_get_data(chip); int error; error = pm_runtime_get_sync(&p->pdev->dev); @@ -267,7 +258,7 @@ static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset) static void gpio_rcar_free(struct gpio_chip *chip, unsigned offset) { - struct gpio_rcar_priv *p = gpio_to_priv(chip); + struct gpio_rcar_priv *p = gpiochip_get_data(chip); pinctrl_free_gpio(chip->base + offset); @@ -291,15 +282,15 @@ static int gpio_rcar_get(struct gpio_chip *chip, unsigned offset) /* testing on r8a7790 shows that INDT does not show correct pin state * when configured as output, so use OUTDT in case of output pins */ - if (gpio_rcar_read(gpio_to_priv(chip), INOUTSEL) & bit) - return !!(gpio_rcar_read(gpio_to_priv(chip), OUTDT) & bit); + if (gpio_rcar_read(gpiochip_get_data(chip), INOUTSEL) & bit) + return !!(gpio_rcar_read(gpiochip_get_data(chip), OUTDT) & bit); else - return !!(gpio_rcar_read(gpio_to_priv(chip), INDT) & bit); + return !!(gpio_rcar_read(gpiochip_get_data(chip), INDT) & bit); } static void gpio_rcar_set(struct gpio_chip *chip, unsigned offset, int value) { - struct gpio_rcar_priv *p = gpio_to_priv(chip); + struct gpio_rcar_priv *p = gpiochip_get_data(chip); unsigned long flags; spin_lock_irqsave(&p->lock, flags); @@ -461,7 +452,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) irq_chip->irq_set_wake = gpio_rcar_irq_set_wake; irq_chip->flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND; - ret = gpiochip_add(gpio_chip); + ret = gpiochip_add_data(gpio_chip, p); if (ret) { dev_err(dev, "failed to add GPIO controller\n"); goto err0; -- cgit From 78132252cc4c6cecec25491a7bcfb6567bf29147 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:16:19 +0100 Subject: gpio: rdc321x: 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-rdc321x.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-rdc321x.c b/drivers/gpio/gpio-rdc321x.c index d729bc8a554d..96ddee3f464a 100644 --- a/drivers/gpio/gpio-rdc321x.c +++ b/drivers/gpio/gpio-rdc321x.c @@ -47,7 +47,7 @@ static int rdc_gpio_get_value(struct gpio_chip *chip, unsigned gpio) u32 value = 0; int reg; - gpch = container_of(chip, struct rdc321x_gpio, chip); + gpch = gpiochip_get_data(chip); reg = gpio < 32 ? gpch->reg1_data_base : gpch->reg2_data_base; spin_lock(&gpch->lock); @@ -65,7 +65,7 @@ static void rdc_gpio_set_value_impl(struct gpio_chip *chip, struct rdc321x_gpio *gpch; int reg = (gpio < 32) ? 0 : 1; - gpch = container_of(chip, struct rdc321x_gpio, chip); + gpch = gpiochip_get_data(chip); if (value) gpch->data_reg[reg] |= 1 << (gpio & 0x1f); @@ -83,7 +83,7 @@ static void rdc_gpio_set_value(struct gpio_chip *chip, { struct rdc321x_gpio *gpch; - gpch = container_of(chip, struct rdc321x_gpio, chip); + gpch = gpiochip_get_data(chip); spin_lock(&gpch->lock); rdc_gpio_set_value_impl(chip, gpio, value); spin_unlock(&gpch->lock); @@ -96,7 +96,7 @@ static int rdc_gpio_config(struct gpio_chip *chip, int err; u32 reg; - gpch = container_of(chip, struct rdc321x_gpio, chip); + gpch = gpiochip_get_data(chip); spin_lock(&gpch->lock); err = pci_read_config_dword(gpch->sb_pdev, gpio < 32 ? @@ -194,7 +194,7 @@ static int rdc321x_gpio_probe(struct platform_device *pdev) dev_info(&pdev->dev, "registering %d GPIOs\n", rdc321x_gpio_dev->chip.ngpio); - return gpiochip_add(&rdc321x_gpio_dev->chip); + return gpiochip_add_data(&rdc321x_gpio_dev->chip, rdc321x_gpio_dev); } static int rdc321x_gpio_remove(struct platform_device *pdev) -- cgit From ff4cd029c184f5dabdfe9e115bf657ebd6a2c0f3 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:19:19 +0100 Subject: gpio: samsung: 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: Paul Bolle Cc: Kukjin Kim Acked-by: Tomasz Figa Signed-off-by: Linus Walleij --- drivers/gpio/gpio-samsung.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-samsung.c b/drivers/gpio/gpio-samsung.c index 7c288ba4dc87..4cb4a314c02b 100644 --- a/drivers/gpio/gpio-samsung.c +++ b/drivers/gpio/gpio-samsung.c @@ -753,7 +753,7 @@ static void __init samsung_gpiolib_add(struct samsung_gpio_chip *chip) #endif /* gpiochip_add() prints own failure message on error. */ - ret = gpiochip_add(gc); + ret = gpiochip_add_data(gc, chip); if (ret >= 0) s3c_gpiolib_track(chip); } @@ -862,7 +862,7 @@ static void __init samsung_gpiolib_add_4bit2_chips(struct samsung_gpio_chip *chi int samsung_gpiolib_to_irq(struct gpio_chip *chip, unsigned int offset) { - struct samsung_gpio_chip *samsung_chip = container_of(chip, struct samsung_gpio_chip, chip); + struct samsung_gpio_chip *samsung_chip = gpiochip_get_data(chip); return samsung_chip->irq_base + offset; } -- cgit 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(-) 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 From 8ca7f1fab866a0ce22c878cb824ba5f73c3e0556 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:24:24 +0100 Subject: gpio: sch311x: 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(). Acked-by: Bruno Randolf Signed-off-by: Linus Walleij --- drivers/gpio/gpio-sch311x.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c index b454792de778..1cbd77a04e7b 100644 --- a/drivers/gpio/gpio-sch311x.c +++ b/drivers/gpio/gpio-sch311x.c @@ -93,13 +93,6 @@ static struct sch311x_gpio_block_def sch311x_gpio_blocks[] = { }, }; -static inline struct sch311x_gpio_block * -to_sch311x_gpio_block(struct gpio_chip *chip) -{ - return container_of(chip, struct sch311x_gpio_block, chip); -} - - /* * Super-IO functions */ @@ -142,7 +135,7 @@ static inline void sch311x_sio_outb(int sio_config_port, int reg, int val) static int sch311x_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip); + struct sch311x_gpio_block *block = gpiochip_get_data(chip); if (block->config_regs[offset] == 0) /* GPIO is not available */ return -ENODEV; @@ -158,7 +151,7 @@ static int sch311x_gpio_request(struct gpio_chip *chip, unsigned offset) static void sch311x_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip); + struct sch311x_gpio_block *block = gpiochip_get_data(chip); if (block->config_regs[offset] == 0) /* GPIO is not available */ return; @@ -168,7 +161,7 @@ static void sch311x_gpio_free(struct gpio_chip *chip, unsigned offset) static int sch311x_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip); + struct sch311x_gpio_block *block = gpiochip_get_data(chip); unsigned char data; spin_lock(&block->lock); @@ -192,7 +185,7 @@ static void __sch311x_gpio_set(struct sch311x_gpio_block *block, static void sch311x_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip); + struct sch311x_gpio_block *block = gpiochip_get_data(chip); spin_lock(&block->lock); __sch311x_gpio_set(block, offset, value); @@ -201,7 +194,7 @@ static void sch311x_gpio_set(struct gpio_chip *chip, unsigned offset, static int sch311x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) { - struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip); + struct sch311x_gpio_block *block = gpiochip_get_data(chip); spin_lock(&block->lock); outb(SCH311X_GPIO_CONF_IN, block->runtime_reg + @@ -214,7 +207,7 @@ static int sch311x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) static int sch311x_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { - struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip); + struct sch311x_gpio_block *block = gpiochip_get_data(chip); spin_lock(&block->lock); @@ -267,7 +260,7 @@ static int sch311x_gpio_probe(struct platform_device *pdev) block->data_reg = sch311x_gpio_blocks[i].data_reg; block->runtime_reg = pdata->runtime_reg; - err = gpiochip_add(&block->chip); + err = gpiochip_add_data(&block->chip, block); if (err < 0) { dev_err(&pdev->dev, "Could not register gpiochip, %d\n", err); -- cgit From c0ad184adb74d30b9010ecdec955d63481f79101 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:26:58 +0100 Subject: gpio: spear-spics: 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: Shiraz Hashim Signed-off-by: Linus Walleij --- drivers/gpio/gpio-spear-spics.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpio-spear-spics.c b/drivers/gpio/gpio-spear-spics.c index bd436b7f86e1..50fb09080a6b 100644 --- a/drivers/gpio/gpio-spear-spics.c +++ b/drivers/gpio/gpio-spear-spics.c @@ -62,8 +62,7 @@ static int spics_get_value(struct gpio_chip *chip, unsigned offset) static void spics_set_value(struct gpio_chip *chip, unsigned offset, int value) { - struct spear_spics *spics = container_of(chip, struct spear_spics, - chip); + struct spear_spics *spics = gpiochip_get_data(chip); u32 tmp; /* select chip select from register */ @@ -94,8 +93,7 @@ static int spics_direction_output(struct gpio_chip *chip, unsigned offset, static int spics_request(struct gpio_chip *chip, unsigned offset) { - struct spear_spics *spics = container_of(chip, struct spear_spics, - chip); + struct spear_spics *spics = gpiochip_get_data(chip); u32 tmp; if (!spics->use_count++) { @@ -110,8 +108,7 @@ static int spics_request(struct gpio_chip *chip, unsigned offset) static void spics_free(struct gpio_chip *chip, unsigned offset) { - struct spear_spics *spics = container_of(chip, struct spear_spics, - chip); + struct spear_spics *spics = gpiochip_get_data(chip); u32 tmp; if (!--spics->use_count) { @@ -168,7 +165,7 @@ static int spics_gpio_probe(struct platform_device *pdev) spics->chip.owner = THIS_MODULE; spics->last_off = -1; - ret = gpiochip_add(&spics->chip); + ret = gpiochip_add_data(&spics->chip, spics); if (ret) { dev_err(&pdev->dev, "unable to add gpio chip\n"); return ret; -- cgit From 0b2c529a3b4d78d700c616e146411594a60cab18 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:29:48 +0100 Subject: gpio: sta2x11: 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: Alessandro Rubini Signed-off-by: Linus Walleij --- drivers/gpio/gpio-sta2x11.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-sta2x11.c b/drivers/gpio/gpio-sta2x11.c index af0be81ad2b6..83af1cb36333 100644 --- a/drivers/gpio/gpio-sta2x11.c +++ b/drivers/gpio/gpio-sta2x11.c @@ -74,7 +74,7 @@ static inline u32 __bit(int nr) static void gsta_gpio_set(struct gpio_chip *gpio, unsigned nr, int val) { - struct gsta_gpio *chip = container_of(gpio, struct gsta_gpio, gpio); + struct gsta_gpio *chip = gpiochip_get_data(gpio); struct gsta_regs __iomem *regs = __regs(chip, nr); u32 bit = __bit(nr); @@ -86,7 +86,7 @@ static void gsta_gpio_set(struct gpio_chip *gpio, unsigned nr, int val) static int gsta_gpio_get(struct gpio_chip *gpio, unsigned nr) { - struct gsta_gpio *chip = container_of(gpio, struct gsta_gpio, gpio); + struct gsta_gpio *chip = gpiochip_get_data(gpio); struct gsta_regs __iomem *regs = __regs(chip, nr); u32 bit = __bit(nr); @@ -96,7 +96,7 @@ static int gsta_gpio_get(struct gpio_chip *gpio, unsigned nr) static int gsta_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, int val) { - struct gsta_gpio *chip = container_of(gpio, struct gsta_gpio, gpio); + struct gsta_gpio *chip = gpiochip_get_data(gpio); struct gsta_regs __iomem *regs = __regs(chip, nr); u32 bit = __bit(nr); @@ -111,7 +111,7 @@ static int gsta_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, static int gsta_gpio_direction_input(struct gpio_chip *gpio, unsigned nr) { - struct gsta_gpio *chip = container_of(gpio, struct gsta_gpio, gpio); + struct gsta_gpio *chip = gpiochip_get_data(gpio); struct gsta_regs __iomem *regs = __regs(chip, nr); u32 bit = __bit(nr); @@ -121,7 +121,7 @@ static int gsta_gpio_direction_input(struct gpio_chip *gpio, unsigned nr) static int gsta_gpio_to_irq(struct gpio_chip *gpio, unsigned offset) { - struct gsta_gpio *chip = container_of(gpio, struct gsta_gpio, gpio); + struct gsta_gpio *chip = gpiochip_get_data(gpio); return chip->irq_base + offset; } @@ -409,7 +409,7 @@ static int gsta_probe(struct platform_device *dev) goto err_free_descs; } - err = gpiochip_add(&chip->gpio); + err = gpiochip_add_data(&chip->gpio, chip); if (err < 0) { dev_err(&dev->dev, "sta2x11 gpio: Can't register (%i)\n", -err); -- cgit From b03c04a0aab1715ca8c501d41f9175a9047ef79f Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:32:13 +0100 Subject: gpio: stmpe: 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: Bhupesh Sharma Signed-off-by: Linus Walleij --- drivers/gpio/gpio-stmpe.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c index 9e471979aa9e..5197edf1acfd 100644 --- a/drivers/gpio/gpio-stmpe.c +++ b/drivers/gpio/gpio-stmpe.c @@ -36,14 +36,9 @@ struct stmpe_gpio { u8 oldregs[CACHE_NR_REGS][CACHE_NR_BANKS]; }; -static inline struct stmpe_gpio *to_stmpe_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct stmpe_gpio, chip); -} - static int stmpe_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); struct stmpe *stmpe = stmpe_gpio->stmpe; u8 reg = stmpe->regs[STMPE_IDX_GPMR_LSB] - (offset / 8); u8 mask = 1 << (offset % 8); @@ -58,7 +53,7 @@ static int stmpe_gpio_get(struct gpio_chip *chip, unsigned offset) static void stmpe_gpio_set(struct gpio_chip *chip, unsigned offset, int val) { - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); struct stmpe *stmpe = stmpe_gpio->stmpe; int which = val ? STMPE_IDX_GPSR_LSB : STMPE_IDX_GPCR_LSB; u8 reg = stmpe->regs[which] - (offset / 8); @@ -77,7 +72,7 @@ static void stmpe_gpio_set(struct gpio_chip *chip, unsigned offset, int val) static int stmpe_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int val) { - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); struct stmpe *stmpe = stmpe_gpio->stmpe; u8 reg = stmpe->regs[STMPE_IDX_GPDR_LSB] - (offset / 8); u8 mask = 1 << (offset % 8); @@ -90,7 +85,7 @@ static int stmpe_gpio_direction_output(struct gpio_chip *chip, static int stmpe_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); struct stmpe *stmpe = stmpe_gpio->stmpe; u8 reg = stmpe->regs[STMPE_IDX_GPDR_LSB] - (offset / 8); u8 mask = 1 << (offset % 8); @@ -100,7 +95,7 @@ static int stmpe_gpio_direction_input(struct gpio_chip *chip, static int stmpe_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); struct stmpe *stmpe = stmpe_gpio->stmpe; if (stmpe_gpio->norequest_mask & (1 << offset)) @@ -123,7 +118,7 @@ static struct gpio_chip template_chip = { static int stmpe_gpio_irq_set_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(gc); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); int offset = d->hwirq; int regoffset = offset / 8; int mask = 1 << (offset % 8); @@ -151,7 +146,7 @@ static int stmpe_gpio_irq_set_type(struct irq_data *d, unsigned int type) static void stmpe_gpio_irq_lock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(gc); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); mutex_lock(&stmpe_gpio->irq_lock); } @@ -159,7 +154,7 @@ static void stmpe_gpio_irq_lock(struct irq_data *d) static void stmpe_gpio_irq_sync_unlock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(gc); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); struct stmpe *stmpe = stmpe_gpio->stmpe; int num_banks = DIV_ROUND_UP(stmpe->num_gpios, 8); static const u8 regmap[] = { @@ -193,7 +188,7 @@ static void stmpe_gpio_irq_sync_unlock(struct irq_data *d) static void stmpe_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(gc); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); int offset = d->hwirq; int regoffset = offset / 8; int mask = 1 << (offset % 8); @@ -204,7 +199,7 @@ static void stmpe_gpio_irq_mask(struct irq_data *d) static void stmpe_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(gc); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); int offset = d->hwirq; int regoffset = offset / 8; int mask = 1 << (offset % 8); @@ -216,7 +211,7 @@ static void stmpe_dbg_show_one(struct seq_file *s, struct gpio_chip *gc, unsigned offset, unsigned gpio) { - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(gc); + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); struct stmpe *stmpe = stmpe_gpio->stmpe; const char *label = gpiochip_is_requested(gc, offset); int num_banks = DIV_ROUND_UP(stmpe->num_gpios, 8); @@ -375,7 +370,7 @@ static int stmpe_gpio_probe(struct platform_device *pdev) if (ret) goto out_free; - ret = gpiochip_add(&stmpe_gpio->chip); + ret = gpiochip_add_data(&stmpe_gpio->chip, stmpe_gpio); if (ret) { dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret); goto out_disable; -- cgit From c63b30b08971ad5894061841a2c7f012eea747c0 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:34:33 +0100 Subject: gpio: stp-xway: 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: Martin Blumenstingl Signed-off-by: Linus Walleij --- drivers/gpio/gpio-stp-xway.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-stp-xway.c b/drivers/gpio/gpio-stp-xway.c index c250f21b9e40..d11dd48570b2 100644 --- a/drivers/gpio/gpio-stp-xway.c +++ b/drivers/gpio/gpio-stp-xway.c @@ -100,8 +100,7 @@ struct xway_stp { */ static void xway_stp_set(struct gpio_chip *gc, unsigned gpio, int val) { - struct xway_stp *chip = - container_of(gc, struct xway_stp, gc); + struct xway_stp *chip = gpiochip_get_data(gc); if (val) chip->shadow |= BIT(gpio); @@ -135,8 +134,7 @@ static int xway_stp_dir_out(struct gpio_chip *gc, unsigned gpio, int val) */ static int xway_stp_request(struct gpio_chip *gc, unsigned gpio) { - struct xway_stp *chip = - container_of(gc, struct xway_stp, gc); + struct xway_stp *chip = gpiochip_get_data(gc); if ((gpio < 8) && (chip->reserved & BIT(gpio))) { dev_err(gc->parent, "GPIO %d is driven by hardware\n", gpio); @@ -260,7 +258,7 @@ static int xway_stp_probe(struct platform_device *pdev) ret = xway_stp_hw_init(chip); if (!ret) - ret = gpiochip_add(&chip->gc); + ret = gpiochip_add_data(&chip->gc, chip); if (!ret) dev_info(&pdev->dev, "Init done\n"); -- cgit From 5b90b8c217e92ce9f027af5aa2cb12bdbbd2127a Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:36:31 +0100 Subject: gpio: sx150x: 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: Wei Chen Signed-off-by: Linus Walleij --- drivers/gpio/gpio-sx150x.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/gpio/gpio-sx150x.c b/drivers/gpio/gpio-sx150x.c index 04d4f2c2928a..e6cff1cabd0c 100644 --- a/drivers/gpio/gpio-sx150x.c +++ b/drivers/gpio/gpio-sx150x.c @@ -194,11 +194,6 @@ static const struct of_device_id sx150x_of_match[] = { }; MODULE_DEVICE_TABLE(of, sx150x_of_match); -struct sx150x_chip *to_sx150x(struct gpio_chip *gc) -{ - return container_of(gc, struct sx150x_chip, gpio_chip); -} - static s32 sx150x_i2c_write(struct i2c_client *client, u8 reg, u8 val) { s32 err = i2c_smbus_write_byte_data(client, reg, val); @@ -335,7 +330,7 @@ static int sx150x_io_output(struct sx150x_chip *chip, unsigned offset, int val) static int sx150x_gpio_get(struct gpio_chip *gc, unsigned offset) { - struct sx150x_chip *chip = to_sx150x(gc); + struct sx150x_chip *chip = gpiochip_get_data(gc); int status = -EINVAL; if (!offset_is_oscio(chip, offset)) { @@ -349,7 +344,7 @@ static int sx150x_gpio_get(struct gpio_chip *gc, unsigned offset) static void sx150x_gpio_set(struct gpio_chip *gc, unsigned offset, int val) { - struct sx150x_chip *chip = to_sx150x(gc); + struct sx150x_chip *chip = gpiochip_get_data(gc); mutex_lock(&chip->lock); if (offset_is_oscio(chip, offset)) @@ -361,7 +356,7 @@ static void sx150x_gpio_set(struct gpio_chip *gc, unsigned offset, int val) static int sx150x_gpio_direction_input(struct gpio_chip *gc, unsigned offset) { - struct sx150x_chip *chip = to_sx150x(gc); + struct sx150x_chip *chip = gpiochip_get_data(gc); int status = -EINVAL; if (!offset_is_oscio(chip, offset)) { @@ -376,7 +371,7 @@ static int sx150x_gpio_direction_output(struct gpio_chip *gc, unsigned offset, int val) { - struct sx150x_chip *chip = to_sx150x(gc); + struct sx150x_chip *chip = gpiochip_get_data(gc); int status = 0; if (!offset_is_oscio(chip, offset)) { @@ -389,7 +384,7 @@ static int sx150x_gpio_direction_output(struct gpio_chip *gc, static void sx150x_irq_mask(struct irq_data *d) { - struct sx150x_chip *chip = to_sx150x(irq_data_get_irq_chip_data(d)); + struct sx150x_chip *chip = gpiochip_get_data(irq_data_get_irq_chip_data(d)); unsigned n = d->hwirq; chip->irq_masked |= (1 << n); @@ -398,7 +393,7 @@ static void sx150x_irq_mask(struct irq_data *d) static void sx150x_irq_unmask(struct irq_data *d) { - struct sx150x_chip *chip = to_sx150x(irq_data_get_irq_chip_data(d)); + struct sx150x_chip *chip = gpiochip_get_data(irq_data_get_irq_chip_data(d)); unsigned n = d->hwirq; chip->irq_masked &= ~(1 << n); @@ -407,7 +402,7 @@ static void sx150x_irq_unmask(struct irq_data *d) static int sx150x_irq_set_type(struct irq_data *d, unsigned int flow_type) { - struct sx150x_chip *chip = to_sx150x(irq_data_get_irq_chip_data(d)); + struct sx150x_chip *chip = gpiochip_get_data(irq_data_get_irq_chip_data(d)); unsigned n, val = 0; if (flow_type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) @@ -462,14 +457,14 @@ static irqreturn_t sx150x_irq_thread_fn(int irq, void *dev_id) static void sx150x_irq_bus_lock(struct irq_data *d) { - struct sx150x_chip *chip = to_sx150x(irq_data_get_irq_chip_data(d)); + struct sx150x_chip *chip = gpiochip_get_data(irq_data_get_irq_chip_data(d)); mutex_lock(&chip->lock); } static void sx150x_irq_bus_sync_unlock(struct irq_data *d) { - struct sx150x_chip *chip = to_sx150x(irq_data_get_irq_chip_data(d)); + struct sx150x_chip *chip = gpiochip_get_data(irq_data_get_irq_chip_data(d)); unsigned n; if (chip->irq_update == NO_UPDATE_PENDING) @@ -692,7 +687,7 @@ static int sx150x_probe(struct i2c_client *client, if (rc < 0) return rc; - rc = gpiochip_add(&chip->gpio_chip); + rc = gpiochip_add_data(&chip->gpio_chip, chip); if (rc) return rc; -- cgit From d27ad7a833443fe0c4247129ab97105f1d845cda Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:38:36 +0100 Subject: gpio: syscon: 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: Alexander Shiyan Signed-off-by: Linus Walleij --- drivers/gpio/gpio-syscon.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-syscon.c b/drivers/gpio/gpio-syscon.c index 333d5af4abd1..e5c5b6205886 100644 --- a/drivers/gpio/gpio-syscon.c +++ b/drivers/gpio/gpio-syscon.c @@ -59,14 +59,9 @@ struct syscon_gpio_priv { u32 dir_reg_offset; }; -static inline struct syscon_gpio_priv *to_syscon_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct syscon_gpio_priv, chip); -} - static int syscon_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct syscon_gpio_priv *priv = to_syscon_gpio(chip); + struct syscon_gpio_priv *priv = gpiochip_get_data(chip); unsigned int val, offs; int ret; @@ -82,7 +77,7 @@ static int syscon_gpio_get(struct gpio_chip *chip, unsigned offset) static void syscon_gpio_set(struct gpio_chip *chip, unsigned offset, int val) { - struct syscon_gpio_priv *priv = to_syscon_gpio(chip); + struct syscon_gpio_priv *priv = gpiochip_get_data(chip); unsigned int offs; offs = priv->dreg_offset + priv->data->dat_bit_offset + offset; @@ -95,7 +90,7 @@ static void syscon_gpio_set(struct gpio_chip *chip, unsigned offset, int val) static int syscon_gpio_dir_in(struct gpio_chip *chip, unsigned offset) { - struct syscon_gpio_priv *priv = to_syscon_gpio(chip); + struct syscon_gpio_priv *priv = gpiochip_get_data(chip); if (priv->data->flags & GPIO_SYSCON_FEAT_DIR) { unsigned int offs; @@ -113,7 +108,7 @@ static int syscon_gpio_dir_in(struct gpio_chip *chip, unsigned offset) static int syscon_gpio_dir_out(struct gpio_chip *chip, unsigned offset, int val) { - struct syscon_gpio_priv *priv = to_syscon_gpio(chip); + struct syscon_gpio_priv *priv = gpiochip_get_data(chip); if (priv->data->flags & GPIO_SYSCON_FEAT_DIR) { unsigned int offs; @@ -144,7 +139,7 @@ static const struct syscon_gpio_data clps711x_mctrl_gpio = { static void keystone_gpio_set(struct gpio_chip *chip, unsigned offset, int val) { - struct syscon_gpio_priv *priv = to_syscon_gpio(chip); + struct syscon_gpio_priv *priv = gpiochip_get_data(chip); unsigned int offs; int ret; @@ -243,7 +238,7 @@ static int syscon_gpio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, priv); - return gpiochip_add(&priv->chip); + return gpiochip_add_data(&priv->chip, priv); } static int syscon_gpio_remove(struct platform_device *pdev) -- cgit From 0ca8c5c4af758b2a8d763b33508f99a3116c3c01 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:41:02 +0100 Subject: gpio: tb10x: 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: Christian Ruppert Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tb10x.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c index 1a7c3efae5d8..5eaec20ddbc7 100644 --- a/drivers/gpio/gpio-tb10x.c +++ b/drivers/gpio/gpio-tb10x.c @@ -87,14 +87,9 @@ static inline void tb10x_set_bits(struct tb10x_gpio *gpio, unsigned int offs, spin_unlock_irqrestore(&gpio->spinlock, flags); } -static inline struct tb10x_gpio *to_tb10x_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct tb10x_gpio, gc); -} - static int tb10x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) { - struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); + struct tb10x_gpio *tb10x_gpio = gpiochip_get_data(chip); int mask = BIT(offset); int val = TB10X_GPIO_DIR_IN << offset; @@ -105,7 +100,7 @@ static int tb10x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) static int tb10x_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); + struct tb10x_gpio *tb10x_gpio = gpiochip_get_data(chip); int val; val = tb10x_reg_read(tb10x_gpio, OFFSET_TO_REG_DATA); @@ -118,7 +113,7 @@ static int tb10x_gpio_get(struct gpio_chip *chip, unsigned offset) static void tb10x_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); + struct tb10x_gpio *tb10x_gpio = gpiochip_get_data(chip); int mask = BIT(offset); int val = value << offset; @@ -128,7 +123,7 @@ static void tb10x_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int tb10x_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { - struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); + struct tb10x_gpio *tb10x_gpio = gpiochip_get_data(chip); int mask = BIT(offset); int val = TB10X_GPIO_DIR_OUT << offset; @@ -140,7 +135,7 @@ static int tb10x_gpio_direction_out(struct gpio_chip *chip, static int tb10x_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); + struct tb10x_gpio *tb10x_gpio = gpiochip_get_data(chip); return irq_create_mapping(tb10x_gpio->domain, offset); } @@ -210,7 +205,7 @@ static int tb10x_gpio_probe(struct platform_device *pdev) tb10x_gpio->gc.can_sleep = false; - ret = gpiochip_add(&tb10x_gpio->gc); + ret = gpiochip_add_data(&tb10x_gpio->gc, tb10x_gpio); if (ret < 0) { dev_err(&pdev->dev, "Could not add gpiochip.\n"); goto fail_gpiochip_registration; -- cgit From b0d384733c05906b807cbb9a1b732ad12b521dbe Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 3 Dec 2015 15:37:29 +0100 Subject: gpio: tc3589x: 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-tc3589x.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c index 2896aef5aec4..05a27ec55add 100644 --- a/drivers/gpio/gpio-tc3589x.c +++ b/drivers/gpio/gpio-tc3589x.c @@ -34,14 +34,9 @@ struct tc3589x_gpio { u8 oldregs[CACHE_NR_REGS][CACHE_NR_BANKS]; }; -static inline struct tc3589x_gpio *to_tc3589x_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct tc3589x_gpio, chip); -} - static int tc3589x_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(chip); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; u8 reg = TC3589x_GPIODATA0 + (offset / 8) * 2; u8 mask = 1 << (offset % 8); @@ -56,7 +51,7 @@ static int tc3589x_gpio_get(struct gpio_chip *chip, unsigned offset) static void tc3589x_gpio_set(struct gpio_chip *chip, unsigned offset, int val) { - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(chip); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; u8 reg = TC3589x_GPIODATA0 + (offset / 8) * 2; unsigned pos = offset % 8; @@ -68,7 +63,7 @@ static void tc3589x_gpio_set(struct gpio_chip *chip, unsigned offset, int val) static int tc3589x_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int val) { - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(chip); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; u8 reg = TC3589x_GPIODIR0 + offset / 8; unsigned pos = offset % 8; @@ -81,7 +76,7 @@ static int tc3589x_gpio_direction_output(struct gpio_chip *chip, static int tc3589x_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(chip); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; u8 reg = TC3589x_GPIODIR0 + offset / 8; unsigned pos = offset % 8; @@ -102,7 +97,7 @@ static struct gpio_chip template_chip = { static int tc3589x_gpio_irq_set_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(gc); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(gc); int offset = d->hwirq; int regoffset = offset / 8; int mask = 1 << (offset % 8); @@ -130,7 +125,7 @@ static int tc3589x_gpio_irq_set_type(struct irq_data *d, unsigned int type) static void tc3589x_gpio_irq_lock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(gc); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(gc); mutex_lock(&tc3589x_gpio->irq_lock); } @@ -138,7 +133,7 @@ static void tc3589x_gpio_irq_lock(struct irq_data *d) static void tc3589x_gpio_irq_sync_unlock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(gc); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(gc); struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; static const u8 regmap[] = { [REG_IBE] = TC3589x_GPIOIBE0, @@ -167,7 +162,7 @@ static void tc3589x_gpio_irq_sync_unlock(struct irq_data *d) static void tc3589x_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(gc); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(gc); int offset = d->hwirq; int regoffset = offset / 8; int mask = 1 << (offset % 8); @@ -178,7 +173,7 @@ static void tc3589x_gpio_irq_mask(struct irq_data *d) static void tc3589x_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(gc); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(gc); int offset = d->hwirq; int regoffset = offset / 8; int mask = 1 << (offset % 8); @@ -277,7 +272,7 @@ static int tc3589x_gpio_probe(struct platform_device *pdev) return ret; } - ret = gpiochip_add(&tc3589x_gpio->chip); + ret = gpiochip_add_data(&tc3589x_gpio->chip, tc3589x_gpio); if (ret) { dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret); return ret; -- cgit From 92a41e2f73879373a4ce2df4b2137d03ba1289ec Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:43:28 +0100 Subject: gpio: timberdale: 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-timberdale.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-timberdale.c b/drivers/gpio/gpio-timberdale.c index dda8f21811eb..a6de10c5275b 100644 --- a/drivers/gpio/gpio-timberdale.c +++ b/drivers/gpio/gpio-timberdale.c @@ -53,7 +53,7 @@ struct timbgpio { static int timbgpio_update_bit(struct gpio_chip *gpio, unsigned index, unsigned offset, bool enabled) { - struct timbgpio *tgpio = container_of(gpio, struct timbgpio, gpio); + struct timbgpio *tgpio = gpiochip_get_data(gpio); u32 reg; spin_lock(&tgpio->lock); @@ -77,7 +77,7 @@ static int timbgpio_gpio_direction_input(struct gpio_chip *gpio, unsigned nr) static int timbgpio_gpio_get(struct gpio_chip *gpio, unsigned nr) { - struct timbgpio *tgpio = container_of(gpio, struct timbgpio, gpio); + struct timbgpio *tgpio = gpiochip_get_data(gpio); u32 value; value = ioread32(tgpio->membase + TGPIOVAL); @@ -98,7 +98,7 @@ static void timbgpio_gpio_set(struct gpio_chip *gpio, static int timbgpio_to_irq(struct gpio_chip *gpio, unsigned offset) { - struct timbgpio *tgpio = container_of(gpio, struct timbgpio, gpio); + struct timbgpio *tgpio = gpiochip_get_data(gpio); if (tgpio->irq_base <= 0) return -EINVAL; @@ -279,7 +279,7 @@ static int timbgpio_probe(struct platform_device *pdev) gc->ngpio = pdata->nr_pins; gc->can_sleep = false; - err = gpiochip_add(gc); + err = gpiochip_add_data(gc, tgpio); if (err) return err; -- cgit From 94a90370427fb927442c0a00180ddbaf08f577df Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:46:45 +0100 Subject: gpio: tps6586x: 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(). Acked-by: Laxman Dewangan Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tps6586x.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-tps6586x.c b/drivers/gpio/gpio-tps6586x.c index 89b2249100b0..87de5486a29e 100644 --- a/drivers/gpio/gpio-tps6586x.c +++ b/drivers/gpio/gpio-tps6586x.c @@ -38,14 +38,9 @@ struct tps6586x_gpio { struct device *parent; }; -static inline struct tps6586x_gpio *to_tps6586x_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct tps6586x_gpio, gpio_chip); -} - static int tps6586x_gpio_get(struct gpio_chip *gc, unsigned offset) { - struct tps6586x_gpio *tps6586x_gpio = to_tps6586x_gpio(gc); + struct tps6586x_gpio *tps6586x_gpio = gpiochip_get_data(gc); uint8_t val; int ret; @@ -59,7 +54,7 @@ static int tps6586x_gpio_get(struct gpio_chip *gc, unsigned offset) static void tps6586x_gpio_set(struct gpio_chip *gc, unsigned offset, int value) { - struct tps6586x_gpio *tps6586x_gpio = to_tps6586x_gpio(gc); + struct tps6586x_gpio *tps6586x_gpio = gpiochip_get_data(gc); tps6586x_update(tps6586x_gpio->parent, TPS6586X_GPIOSET2, value << offset, 1 << offset); @@ -68,7 +63,7 @@ static void tps6586x_gpio_set(struct gpio_chip *gc, unsigned offset, static int tps6586x_gpio_output(struct gpio_chip *gc, unsigned offset, int value) { - struct tps6586x_gpio *tps6586x_gpio = to_tps6586x_gpio(gc); + struct tps6586x_gpio *tps6586x_gpio = gpiochip_get_data(gc); uint8_t val, mask; tps6586x_gpio_set(gc, offset, value); @@ -82,7 +77,7 @@ static int tps6586x_gpio_output(struct gpio_chip *gc, unsigned offset, static int tps6586x_gpio_to_irq(struct gpio_chip *gc, unsigned offset) { - struct tps6586x_gpio *tps6586x_gpio = to_tps6586x_gpio(gc); + struct tps6586x_gpio *tps6586x_gpio = gpiochip_get_data(gc); return tps6586x_irq_get_virq(tps6586x_gpio->parent, TPS6586X_INT_PLDO_0 + offset); @@ -122,7 +117,7 @@ static int tps6586x_gpio_probe(struct platform_device *pdev) else tps6586x_gpio->gpio_chip.base = -1; - ret = gpiochip_add(&tps6586x_gpio->gpio_chip); + ret = gpiochip_add_data(&tps6586x_gpio->gpio_chip, tps6586x_gpio); if (ret < 0) { dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); return ret; -- cgit From b7c17b1b97d3b5cbbcc0e902823b7ade5dbb4c4a Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:48:49 +0100 Subject: gpio: tps65910: 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(). Acked-By: Rhyland Klein Acked-by: Laxman Dewangan Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tps65910.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-tps65910.c b/drivers/gpio/gpio-tps65910.c index 83894c0387fb..e81eee7627a3 100644 --- a/drivers/gpio/gpio-tps65910.c +++ b/drivers/gpio/gpio-tps65910.c @@ -27,14 +27,9 @@ struct tps65910_gpio { struct tps65910 *tps65910; }; -static inline struct tps65910_gpio *to_tps65910_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct tps65910_gpio, gpio_chip); -} - static int tps65910_gpio_get(struct gpio_chip *gc, unsigned offset) { - struct tps65910_gpio *tps65910_gpio = to_tps65910_gpio(gc); + struct tps65910_gpio *tps65910_gpio = gpiochip_get_data(gc); struct tps65910 *tps65910 = tps65910_gpio->tps65910; unsigned int val; @@ -49,7 +44,7 @@ static int tps65910_gpio_get(struct gpio_chip *gc, unsigned offset) static void tps65910_gpio_set(struct gpio_chip *gc, unsigned offset, int value) { - struct tps65910_gpio *tps65910_gpio = to_tps65910_gpio(gc); + struct tps65910_gpio *tps65910_gpio = gpiochip_get_data(gc); struct tps65910 *tps65910 = tps65910_gpio->tps65910; if (value) @@ -63,7 +58,7 @@ static void tps65910_gpio_set(struct gpio_chip *gc, unsigned offset, static int tps65910_gpio_output(struct gpio_chip *gc, unsigned offset, int value) { - struct tps65910_gpio *tps65910_gpio = to_tps65910_gpio(gc); + struct tps65910_gpio *tps65910_gpio = gpiochip_get_data(gc); struct tps65910 *tps65910 = tps65910_gpio->tps65910; /* Set the initial value */ @@ -75,7 +70,7 @@ static int tps65910_gpio_output(struct gpio_chip *gc, unsigned offset, static int tps65910_gpio_input(struct gpio_chip *gc, unsigned offset) { - struct tps65910_gpio *tps65910_gpio = to_tps65910_gpio(gc); + struct tps65910_gpio *tps65910_gpio = gpiochip_get_data(gc); struct tps65910 *tps65910 = tps65910_gpio->tps65910; return tps65910_reg_clear_bits(tps65910, TPS65910_GPIO0 + offset, @@ -175,7 +170,7 @@ static int tps65910_gpio_probe(struct platform_device *pdev) } skip_init: - ret = gpiochip_add(&tps65910_gpio->gpio_chip); + ret = gpiochip_add_data(&tps65910_gpio->gpio_chip, tps65910_gpio); if (ret < 0) { dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); return ret; -- cgit From ad8dd23c458fcc06c0b9045a6b7b8357f3e717b9 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:50:42 +0100 Subject: gpio: tps65912: 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: Nicolas Saenz Julienne Cc: Margarita Olaya Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tps65912.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c index 0f073ffa74cf..4f2029c7da3a 100644 --- a/drivers/gpio/gpio-tps65912.c +++ b/drivers/gpio/gpio-tps65912.c @@ -26,11 +26,9 @@ struct tps65912_gpio_data { struct gpio_chip gpio_chip; }; -#define to_tgd(gc) container_of(gc, struct tps65912_gpio_data, gpio_chip) - static int tps65912_gpio_get(struct gpio_chip *gc, unsigned offset) { - struct tps65912_gpio_data *tps65912_gpio = to_tgd(gc); + struct tps65912_gpio_data *tps65912_gpio = gpiochip_get_data(gc); struct tps65912 *tps65912 = tps65912_gpio->tps65912; int val; @@ -45,7 +43,7 @@ static int tps65912_gpio_get(struct gpio_chip *gc, unsigned offset) static void tps65912_gpio_set(struct gpio_chip *gc, unsigned offset, int value) { - struct tps65912_gpio_data *tps65912_gpio = to_tgd(gc); + struct tps65912_gpio_data *tps65912_gpio = gpiochip_get_data(gc); struct tps65912 *tps65912 = tps65912_gpio->tps65912; if (value) @@ -59,7 +57,7 @@ static void tps65912_gpio_set(struct gpio_chip *gc, unsigned offset, static int tps65912_gpio_output(struct gpio_chip *gc, unsigned offset, int value) { - struct tps65912_gpio_data *tps65912_gpio = to_tgd(gc); + struct tps65912_gpio_data *tps65912_gpio = gpiochip_get_data(gc); struct tps65912 *tps65912 = tps65912_gpio->tps65912; /* Set the initial value */ @@ -71,7 +69,7 @@ static int tps65912_gpio_output(struct gpio_chip *gc, unsigned offset, static int tps65912_gpio_input(struct gpio_chip *gc, unsigned offset) { - struct tps65912_gpio_data *tps65912_gpio = to_tgd(gc); + struct tps65912_gpio_data *tps65912_gpio = gpiochip_get_data(gc); struct tps65912 *tps65912 = tps65912_gpio->tps65912; return tps65912_clear_bits(tps65912, TPS65912_GPIO1 + offset, @@ -108,7 +106,7 @@ static int tps65912_gpio_probe(struct platform_device *pdev) if (pdata && pdata->gpio_base) tps65912_gpio->gpio_chip.base = pdata->gpio_base; - ret = gpiochip_add(&tps65912_gpio->gpio_chip); + ret = gpiochip_add_data(&tps65912_gpio->gpio_chip, tps65912_gpio); if (ret < 0) { dev_err(&pdev->dev, "Failed to register gpiochip, %d\n", ret); return ret; -- cgit From 11ab89ac4d9f3fad9737e32f40f475fb9d301232 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:52:55 +0100 Subject: gpio: ts5500: 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(). Acked-by: Vivien Didelot Signed-off-by: Linus Walleij --- drivers/gpio/gpio-ts5500.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-ts5500.c b/drivers/gpio/gpio-ts5500.c index aafe7910e030..5f945083f9d8 100644 --- a/drivers/gpio/gpio-ts5500.c +++ b/drivers/gpio/gpio-ts5500.c @@ -185,11 +185,6 @@ static const struct ts5500_dio ts5500_lcd[] = { TS5500_DIO_IN_IRQ(0x73, 7, 1), }; -static inline struct ts5500_priv *ts5500_gc_to_priv(struct gpio_chip *chip) -{ - return container_of(chip, struct ts5500_priv, gpio_chip); -} - static inline void ts5500_set_mask(u8 mask, u8 addr) { u8 val = inb(addr); @@ -206,7 +201,7 @@ static inline void ts5500_clear_mask(u8 mask, u8 addr) static int ts5500_gpio_input(struct gpio_chip *chip, unsigned offset) { - struct ts5500_priv *priv = ts5500_gc_to_priv(chip); + struct ts5500_priv *priv = gpiochip_get_data(chip); const struct ts5500_dio line = priv->pinout[offset]; unsigned long flags; @@ -225,7 +220,7 @@ static int ts5500_gpio_input(struct gpio_chip *chip, unsigned offset) static int ts5500_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct ts5500_priv *priv = ts5500_gc_to_priv(chip); + struct ts5500_priv *priv = gpiochip_get_data(chip); const struct ts5500_dio line = priv->pinout[offset]; return !!(inb(line.value_addr) & line.value_mask); @@ -233,7 +228,7 @@ static int ts5500_gpio_get(struct gpio_chip *chip, unsigned offset) static int ts5500_gpio_output(struct gpio_chip *chip, unsigned offset, int val) { - struct ts5500_priv *priv = ts5500_gc_to_priv(chip); + struct ts5500_priv *priv = gpiochip_get_data(chip); const struct ts5500_dio line = priv->pinout[offset]; unsigned long flags; @@ -255,7 +250,7 @@ static int ts5500_gpio_output(struct gpio_chip *chip, unsigned offset, int val) static void ts5500_gpio_set(struct gpio_chip *chip, unsigned offset, int val) { - struct ts5500_priv *priv = ts5500_gc_to_priv(chip); + struct ts5500_priv *priv = gpiochip_get_data(chip); const struct ts5500_dio line = priv->pinout[offset]; unsigned long flags; @@ -269,7 +264,7 @@ static void ts5500_gpio_set(struct gpio_chip *chip, unsigned offset, int val) static int ts5500_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct ts5500_priv *priv = ts5500_gc_to_priv(chip); + struct ts5500_priv *priv = gpiochip_get_data(chip); const struct ts5500_dio *block = priv->pinout; const struct ts5500_dio line = block[offset]; @@ -414,7 +409,7 @@ static int ts5500_dio_probe(struct platform_device *pdev) break; } - ret = gpiochip_add(&priv->gpio_chip); + ret = gpiochip_add_data(&priv->gpio_chip, priv); if (ret) { dev_err(dev, "failed to register the gpio chip\n"); return ret; -- cgit From 231a8680b78260f5d9905beaf36741fcf9940a29 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:55:07 +0100 Subject: gpio: twl4030: 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: Roger Quadros Acked-by: Tony Lindgren Signed-off-by: Linus Walleij --- drivers/gpio/gpio-twl4030.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c index f5590514838a..4b807b0e0c8e 100644 --- a/drivers/gpio/gpio-twl4030.c +++ b/drivers/gpio/gpio-twl4030.c @@ -76,11 +76,6 @@ struct gpio_twl4030_priv { /*----------------------------------------------------------------------*/ -static inline struct gpio_twl4030_priv *to_gpio_twl4030(struct gpio_chip *chip) -{ - return container_of(chip, struct gpio_twl4030_priv, gpio_chip); -} - /* * To configure TWL4030 GPIO module registers */ @@ -205,7 +200,7 @@ static int twl4030_get_gpio_datain(int gpio) static int twl_request(struct gpio_chip *chip, unsigned offset) { - struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip); + struct gpio_twl4030_priv *priv = gpiochip_get_data(chip); int status = 0; mutex_lock(&priv->mutex); @@ -273,7 +268,7 @@ done: static void twl_free(struct gpio_chip *chip, unsigned offset) { - struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip); + struct gpio_twl4030_priv *priv = gpiochip_get_data(chip); mutex_lock(&priv->mutex); if (offset >= TWL4030_GPIO_MAX) { @@ -293,7 +288,7 @@ out: static int twl_direction_in(struct gpio_chip *chip, unsigned offset) { - struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip); + struct gpio_twl4030_priv *priv = gpiochip_get_data(chip); int ret; mutex_lock(&priv->mutex); @@ -312,7 +307,7 @@ static int twl_direction_in(struct gpio_chip *chip, unsigned offset) static int twl_get(struct gpio_chip *chip, unsigned offset) { - struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip); + struct gpio_twl4030_priv *priv = gpiochip_get_data(chip); int ret; int status = 0; @@ -335,7 +330,7 @@ out: static void twl_set(struct gpio_chip *chip, unsigned offset, int value) { - struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip); + struct gpio_twl4030_priv *priv = gpiochip_get_data(chip); mutex_lock(&priv->mutex); if (offset < TWL4030_GPIO_MAX) @@ -353,7 +348,7 @@ static void twl_set(struct gpio_chip *chip, unsigned offset, int value) static int twl_direction_out(struct gpio_chip *chip, unsigned offset, int value) { - struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip); + struct gpio_twl4030_priv *priv = gpiochip_get_data(chip); int ret = 0; mutex_lock(&priv->mutex); @@ -379,7 +374,7 @@ static int twl_direction_out(struct gpio_chip *chip, unsigned offset, int value) static int twl_to_irq(struct gpio_chip *chip, unsigned offset) { - struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip); + struct gpio_twl4030_priv *priv = gpiochip_get_data(chip); return (priv->irq_base && (offset < TWL4030_GPIO_MAX)) ? (priv->irq_base + offset) @@ -544,7 +539,7 @@ no_irqs: if (pdata->use_leds) priv->gpio_chip.ngpio += 2; - ret = gpiochip_add(&priv->gpio_chip); + ret = gpiochip_add_data(&priv->gpio_chip, priv); if (ret < 0) { dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret); priv->gpio_chip.ngpio = 0; -- cgit From 059e3972d00760e7d6dda54789fbbe05acf186a1 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:57:25 +0100 Subject: gpio: tz1090-pdc: 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: James Hogan Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tz1090-pdc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpio-tz1090-pdc.c b/drivers/gpio/gpio-tz1090-pdc.c index b08b22b1b111..5b7781741ee9 100644 --- a/drivers/gpio/gpio-tz1090-pdc.c +++ b/drivers/gpio/gpio-tz1090-pdc.c @@ -49,7 +49,6 @@ struct tz1090_pdc_gpio { void __iomem *reg; int irq[GPIO_PDC_NIRQ]; }; -#define to_pdc(c) container_of(c, struct tz1090_pdc_gpio, chip) /* Register accesses into the PDC MMIO area */ @@ -70,7 +69,7 @@ static inline unsigned int pdc_read(struct tz1090_pdc_gpio *priv, static int tz1090_pdc_gpio_direction_input(struct gpio_chip *chip, unsigned int offset) { - struct tz1090_pdc_gpio *priv = to_pdc(chip); + struct tz1090_pdc_gpio *priv = gpiochip_get_data(chip); u32 value; int lstat; @@ -87,7 +86,7 @@ static int tz1090_pdc_gpio_direction_output(struct gpio_chip *chip, unsigned int offset, int output_value) { - struct tz1090_pdc_gpio *priv = to_pdc(chip); + struct tz1090_pdc_gpio *priv = gpiochip_get_data(chip); u32 value; int lstat; @@ -112,14 +111,14 @@ static int tz1090_pdc_gpio_direction_output(struct gpio_chip *chip, static int tz1090_pdc_gpio_get(struct gpio_chip *chip, unsigned int offset) { - struct tz1090_pdc_gpio *priv = to_pdc(chip); + struct tz1090_pdc_gpio *priv = gpiochip_get_data(chip); return !!(pdc_read(priv, REG_SOC_GPIO_STATUS) & BIT(offset)); } static void tz1090_pdc_gpio_set(struct gpio_chip *chip, unsigned int offset, int output_value) { - struct tz1090_pdc_gpio *priv = to_pdc(chip); + struct tz1090_pdc_gpio *priv = gpiochip_get_data(chip); u32 value; int lstat; @@ -139,7 +138,7 @@ static void tz1090_pdc_gpio_set(struct gpio_chip *chip, unsigned int offset, static int tz1090_pdc_gpio_to_irq(struct gpio_chip *chip, unsigned int offset) { - struct tz1090_pdc_gpio *priv = to_pdc(chip); + struct tz1090_pdc_gpio *priv = gpiochip_get_data(chip); unsigned int syswake = offset - GPIO_PDC_IRQ_FIRST; int irq; @@ -207,7 +206,7 @@ static int tz1090_pdc_gpio_probe(struct platform_device *pdev) priv->irq[i] = irq_of_parse_and_map(np, i); /* Add the GPIO bank */ - gpiochip_add(&priv->chip); + gpiochip_add_data(&priv->chip, priv); return 0; } -- cgit From 7020e7c513e91a2e18ab67935e657c4de17e9043 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 14:58:56 +0100 Subject: gpio: tz1090: 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: James Hogan Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tz1090.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-tz1090.c b/drivers/gpio/gpio-tz1090.c index a4a822542ac1..ca958e0f6909 100644 --- a/drivers/gpio/gpio-tz1090.c +++ b/drivers/gpio/gpio-tz1090.c @@ -62,7 +62,6 @@ struct tz1090_gpio_bank { int irq; char label[16]; }; -#define to_bank(c) container_of(c, struct tz1090_gpio_bank, chip) /** * struct tz1090_gpio - Overall GPIO device private data @@ -187,7 +186,7 @@ static inline int tz1090_gpio_read_bit(struct tz1090_gpio_bank *bank, static int tz1090_gpio_direction_input(struct gpio_chip *chip, unsigned int offset) { - struct tz1090_gpio_bank *bank = to_bank(chip); + struct tz1090_gpio_bank *bank = gpiochip_get_data(chip); tz1090_gpio_set_bit(bank, REG_GPIO_DIR, offset); return 0; @@ -196,7 +195,7 @@ static int tz1090_gpio_direction_input(struct gpio_chip *chip, static int tz1090_gpio_direction_output(struct gpio_chip *chip, unsigned int offset, int output_value) { - struct tz1090_gpio_bank *bank = to_bank(chip); + struct tz1090_gpio_bank *bank = gpiochip_get_data(chip); int lstat; __global_lock2(lstat); @@ -212,7 +211,7 @@ static int tz1090_gpio_direction_output(struct gpio_chip *chip, */ static int tz1090_gpio_get(struct gpio_chip *chip, unsigned int offset) { - struct tz1090_gpio_bank *bank = to_bank(chip); + struct tz1090_gpio_bank *bank = gpiochip_get_data(chip); return !!tz1090_gpio_read_bit(bank, REG_GPIO_DIN, offset); } @@ -223,14 +222,14 @@ static int tz1090_gpio_get(struct gpio_chip *chip, unsigned int offset) static void tz1090_gpio_set(struct gpio_chip *chip, unsigned int offset, int output_value) { - struct tz1090_gpio_bank *bank = to_bank(chip); + struct tz1090_gpio_bank *bank = gpiochip_get_data(chip); tz1090_gpio_mod_bit(bank, REG_GPIO_DOUT, offset, output_value); } static int tz1090_gpio_request(struct gpio_chip *chip, unsigned int offset) { - struct tz1090_gpio_bank *bank = to_bank(chip); + struct tz1090_gpio_bank *bank = gpiochip_get_data(chip); int ret; ret = pinctrl_request_gpio(chip->base + offset); @@ -245,7 +244,7 @@ static int tz1090_gpio_request(struct gpio_chip *chip, unsigned int offset) static void tz1090_gpio_free(struct gpio_chip *chip, unsigned int offset) { - struct tz1090_gpio_bank *bank = to_bank(chip); + struct tz1090_gpio_bank *bank = gpiochip_get_data(chip); pinctrl_free_gpio(chip->base + offset); @@ -254,7 +253,7 @@ static void tz1090_gpio_free(struct gpio_chip *chip, unsigned int offset) static int tz1090_gpio_to_irq(struct gpio_chip *chip, unsigned int offset) { - struct tz1090_gpio_bank *bank = to_bank(chip); + struct tz1090_gpio_bank *bank = gpiochip_get_data(chip); if (!bank->domain) return -EINVAL; @@ -440,7 +439,7 @@ static int tz1090_gpio_bank_probe(struct tz1090_gpio_bank_info *info) bank->chip.ngpio = 30; /* Add the GPIO bank */ - gpiochip_add(&bank->chip); + gpiochip_add_data(&bank->chip, bank); /* Get the GPIO bank IRQ if provided */ bank->irq = irq_of_parse_and_map(np, 0); -- cgit From 9af4f0ab8af889cebbfd4dd70d2aa469c4f161da Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 15:01:14 +0100 Subject: gpio: ucb1400: 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-ucb1400.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-ucb1400.c b/drivers/gpio/gpio-ucb1400.c index cca78fb9b0df..2c5cd46bfa6e 100644 --- a/drivers/gpio/gpio-ucb1400.c +++ b/drivers/gpio/gpio-ucb1400.c @@ -15,7 +15,7 @@ static int ucb1400_gpio_dir_in(struct gpio_chip *gc, unsigned off) { struct ucb1400_gpio *gpio; - gpio = container_of(gc, struct ucb1400_gpio, gc); + gpio = gpiochip_get_data(gc); ucb1400_gpio_set_direction(gpio->ac97, off, 0); return 0; } @@ -23,7 +23,7 @@ static int ucb1400_gpio_dir_in(struct gpio_chip *gc, unsigned off) static int ucb1400_gpio_dir_out(struct gpio_chip *gc, unsigned off, int val) { struct ucb1400_gpio *gpio; - gpio = container_of(gc, struct ucb1400_gpio, gc); + gpio = gpiochip_get_data(gc); ucb1400_gpio_set_direction(gpio->ac97, off, 1); ucb1400_gpio_set_value(gpio->ac97, off, val); return 0; @@ -32,14 +32,15 @@ static int ucb1400_gpio_dir_out(struct gpio_chip *gc, unsigned off, int val) static int ucb1400_gpio_get(struct gpio_chip *gc, unsigned off) { struct ucb1400_gpio *gpio; - gpio = container_of(gc, struct ucb1400_gpio, gc); + + gpio = gpiochip_get_data(gc); return !!ucb1400_gpio_get_value(gpio->ac97, off); } static void ucb1400_gpio_set(struct gpio_chip *gc, unsigned off, int val) { struct ucb1400_gpio *gpio; - gpio = container_of(gc, struct ucb1400_gpio, gc); + gpio = gpiochip_get_data(gc); ucb1400_gpio_set_value(gpio->ac97, off, val); } @@ -66,7 +67,7 @@ static int ucb1400_gpio_probe(struct platform_device *dev) ucb->gc.set = ucb1400_gpio_set; ucb->gc.can_sleep = true; - err = gpiochip_add(&ucb->gc); + err = gpiochip_add_data(&ucb->gc, ucb); if (err) goto err; -- cgit From 65389b490089fa387052b5946a4dc2f637eaeb9a Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 15:03:30 +0100 Subject: gpio: vf610: 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: Stefan Agner Signed-off-by: Linus Walleij --- drivers/gpio/gpio-vf610.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c index 9031e60c815c..6284bdbe1e0c 100644 --- a/drivers/gpio/gpio-vf610.c +++ b/drivers/gpio/gpio-vf610.c @@ -62,11 +62,6 @@ struct vf610_gpio_port { static struct irq_chip vf610_gpio_irq_chip; -static struct vf610_gpio_port *to_vf610_gp(struct gpio_chip *gc) -{ - return container_of(gc, struct vf610_gpio_port, gc); -} - static const struct of_device_id vf610_gpio_dt_ids[] = { { .compatible = "fsl,vf610-gpio" }, { /* sentinel */ } @@ -84,14 +79,14 @@ static inline u32 vf610_gpio_readl(void __iomem *reg) static int vf610_gpio_get(struct gpio_chip *gc, unsigned int gpio) { - struct vf610_gpio_port *port = to_vf610_gp(gc); + struct vf610_gpio_port *port = gpiochip_get_data(gc); return !!(vf610_gpio_readl(port->gpio_base + GPIO_PDIR) & BIT(gpio)); } static void vf610_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) { - struct vf610_gpio_port *port = to_vf610_gp(gc); + struct vf610_gpio_port *port = gpiochip_get_data(gc); unsigned long mask = BIT(gpio); if (val) @@ -116,7 +111,7 @@ static int vf610_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, static void vf610_gpio_irq_handler(struct irq_desc *desc) { struct vf610_gpio_port *port = - to_vf610_gp(irq_desc_get_handler_data(desc)); + gpiochip_get_data(irq_desc_get_handler_data(desc)); struct irq_chip *chip = irq_desc_get_chip(desc); int pin; unsigned long irq_isfr; @@ -137,7 +132,7 @@ static void vf610_gpio_irq_handler(struct irq_desc *desc) static void vf610_gpio_irq_ack(struct irq_data *d) { struct vf610_gpio_port *port = - to_vf610_gp(irq_data_get_irq_chip_data(d)); + gpiochip_get_data(irq_data_get_irq_chip_data(d)); int gpio = d->hwirq; vf610_gpio_writel(BIT(gpio), port->base + PORT_ISFR); @@ -146,7 +141,7 @@ static void vf610_gpio_irq_ack(struct irq_data *d) static int vf610_gpio_irq_set_type(struct irq_data *d, u32 type) { struct vf610_gpio_port *port = - to_vf610_gp(irq_data_get_irq_chip_data(d)); + gpiochip_get_data(irq_data_get_irq_chip_data(d)); u8 irqc; switch (type) { @@ -182,7 +177,7 @@ static int vf610_gpio_irq_set_type(struct irq_data *d, u32 type) static void vf610_gpio_irq_mask(struct irq_data *d) { struct vf610_gpio_port *port = - to_vf610_gp(irq_data_get_irq_chip_data(d)); + gpiochip_get_data(irq_data_get_irq_chip_data(d)); void __iomem *pcr_base = port->base + PORT_PCR(d->hwirq); vf610_gpio_writel(0, pcr_base); @@ -191,7 +186,7 @@ static void vf610_gpio_irq_mask(struct irq_data *d) static void vf610_gpio_irq_unmask(struct irq_data *d) { struct vf610_gpio_port *port = - to_vf610_gp(irq_data_get_irq_chip_data(d)); + gpiochip_get_data(irq_data_get_irq_chip_data(d)); void __iomem *pcr_base = port->base + PORT_PCR(d->hwirq); vf610_gpio_writel(port->irqc[d->hwirq] << PORT_PCR_IRQC_OFFSET, @@ -201,7 +196,7 @@ static void vf610_gpio_irq_unmask(struct irq_data *d) static int vf610_gpio_irq_set_wake(struct irq_data *d, u32 enable) { struct vf610_gpio_port *port = - to_vf610_gp(irq_data_get_irq_chip_data(d)); + gpiochip_get_data(irq_data_get_irq_chip_data(d)); if (enable) enable_irq_wake(port->irq); @@ -261,7 +256,7 @@ static int vf610_gpio_probe(struct platform_device *pdev) gc->direction_output = vf610_gpio_direction_output; gc->set = vf610_gpio_set; - ret = gpiochip_add(gc); + ret = gpiochip_add_data(gc, port); if (ret < 0) return ret; -- cgit From 2a873c8d623023ecfde33542729bfb682fcd0f12 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 15:08:00 +0100 Subject: gpio: viperboard: 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: Lars Poeschel Signed-off-by: Linus Walleij --- drivers/gpio/gpio-viperboard.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/gpio/gpio-viperboard.c b/drivers/gpio/gpio-viperboard.c index 7667e77dd52e..1170b035cb92 100644 --- a/drivers/gpio/gpio-viperboard.c +++ b/drivers/gpio/gpio-viperboard.c @@ -88,8 +88,7 @@ static int vprbrd_gpioa_get(struct gpio_chip *chip, unsigned offset) { int ret, answer, error = 0; - struct vprbrd_gpio *gpio = - container_of(chip, struct vprbrd_gpio, gpioa); + struct vprbrd_gpio *gpio = gpiochip_get_data(chip); struct vprbrd *vb = gpio->vb; struct vprbrd_gpioa_msg *gamsg = (struct vprbrd_gpioa_msg *)vb->buf; @@ -139,8 +138,7 @@ static void vprbrd_gpioa_set(struct gpio_chip *chip, unsigned offset, int value) { int ret; - struct vprbrd_gpio *gpio = - container_of(chip, struct vprbrd_gpio, gpioa); + struct vprbrd_gpio *gpio = gpiochip_get_data(chip); struct vprbrd *vb = gpio->vb; struct vprbrd_gpioa_msg *gamsg = (struct vprbrd_gpioa_msg *)vb->buf; @@ -181,8 +179,7 @@ static int vprbrd_gpioa_direction_input(struct gpio_chip *chip, unsigned offset) { int ret; - struct vprbrd_gpio *gpio = - container_of(chip, struct vprbrd_gpio, gpioa); + struct vprbrd_gpio *gpio = gpiochip_get_data(chip); struct vprbrd *vb = gpio->vb; struct vprbrd_gpioa_msg *gamsg = (struct vprbrd_gpioa_msg *)vb->buf; @@ -219,8 +216,7 @@ static int vprbrd_gpioa_direction_output(struct gpio_chip *chip, unsigned offset, int value) { int ret; - struct vprbrd_gpio *gpio = - container_of(chip, struct vprbrd_gpio, gpioa); + struct vprbrd_gpio *gpio = gpiochip_get_data(chip); struct vprbrd *vb = gpio->vb; struct vprbrd_gpioa_msg *gamsg = (struct vprbrd_gpioa_msg *)vb->buf; @@ -287,8 +283,7 @@ static int vprbrd_gpiob_get(struct gpio_chip *chip, { int ret; u16 val; - struct vprbrd_gpio *gpio = - container_of(chip, struct vprbrd_gpio, gpiob); + struct vprbrd_gpio *gpio = gpiochip_get_data(chip); struct vprbrd *vb = gpio->vb; struct vprbrd_gpiob_msg *gbmsg = (struct vprbrd_gpiob_msg *)vb->buf; @@ -319,8 +314,7 @@ static void vprbrd_gpiob_set(struct gpio_chip *chip, unsigned offset, int value) { int ret; - struct vprbrd_gpio *gpio = - container_of(chip, struct vprbrd_gpio, gpiob); + struct vprbrd_gpio *gpio = gpiochip_get_data(chip); struct vprbrd *vb = gpio->vb; struct vprbrd_gpiob_msg *gbmsg = (struct vprbrd_gpiob_msg *)vb->buf; @@ -353,8 +347,7 @@ static int vprbrd_gpiob_direction_input(struct gpio_chip *chip, unsigned offset) { int ret; - struct vprbrd_gpio *gpio = - container_of(chip, struct vprbrd_gpio, gpiob); + struct vprbrd_gpio *gpio = gpiochip_get_data(chip); struct vprbrd *vb = gpio->vb; gpio->gpiob_out &= ~(1 << offset); @@ -375,8 +368,7 @@ static int vprbrd_gpiob_direction_output(struct gpio_chip *chip, unsigned offset, int value) { int ret; - struct vprbrd_gpio *gpio = - container_of(chip, struct vprbrd_gpio, gpiob); + struct vprbrd_gpio *gpio = gpiochip_get_data(chip); struct vprbrd *vb = gpio->vb; gpio->gpiob_out |= (1 << offset); @@ -418,7 +410,7 @@ static int vprbrd_gpio_probe(struct platform_device *pdev) vb_gpio->gpioa.get = vprbrd_gpioa_get; vb_gpio->gpioa.direction_input = vprbrd_gpioa_direction_input; vb_gpio->gpioa.direction_output = vprbrd_gpioa_direction_output; - ret = gpiochip_add(&vb_gpio->gpioa); + ret = gpiochip_add_data(&vb_gpio->gpioa, vb_gpio); if (ret < 0) { dev_err(vb_gpio->gpioa.parent, "could not add gpio a"); goto err_gpioa; @@ -435,7 +427,7 @@ static int vprbrd_gpio_probe(struct platform_device *pdev) vb_gpio->gpiob.get = vprbrd_gpiob_get; vb_gpio->gpiob.direction_input = vprbrd_gpiob_direction_input; vb_gpio->gpiob.direction_output = vprbrd_gpiob_direction_output; - ret = gpiochip_add(&vb_gpio->gpiob); + ret = gpiochip_add_data(&vb_gpio->gpiob, vb_gpio); if (ret < 0) { dev_err(vb_gpio->gpiob.parent, "could not add gpio b"); goto err_gpiob; -- cgit From 9355879ea42b84914ab27064df6760b2a7db0883 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 15:09:57 +0100 Subject: gpio: vx855: 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-vx855.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-vx855.c b/drivers/gpio/gpio-vx855.c index 57b470d5b39e..764999cc0794 100644 --- a/drivers/gpio/gpio-vx855.c +++ b/drivers/gpio/gpio-vx855.c @@ -96,7 +96,7 @@ static inline u_int32_t gpio_o_bit(int i) static int vx855gpio_direction_input(struct gpio_chip *gpio, unsigned int nr) { - struct vx855_gpio *vg = container_of(gpio, struct vx855_gpio, gpio); + struct vx855_gpio *vg = gpiochip_get_data(gpio); unsigned long flags; u_int32_t reg_out; @@ -120,7 +120,7 @@ static int vx855gpio_direction_input(struct gpio_chip *gpio, static int vx855gpio_get(struct gpio_chip *gpio, unsigned int nr) { - struct vx855_gpio *vg = container_of(gpio, struct vx855_gpio, gpio); + struct vx855_gpio *vg = gpiochip_get_data(gpio); u_int32_t reg_in; int ret = 0; @@ -146,7 +146,7 @@ static int vx855gpio_get(struct gpio_chip *gpio, unsigned int nr) static void vx855gpio_set(struct gpio_chip *gpio, unsigned int nr, int val) { - struct vx855_gpio *vg = container_of(gpio, struct vx855_gpio, gpio); + struct vx855_gpio *vg = gpiochip_get_data(gpio); unsigned long flags; u_int32_t reg_out; @@ -259,7 +259,7 @@ static int vx855gpio_probe(struct platform_device *pdev) vx855gpio_gpio_setup(vg); - return gpiochip_add(&vg->gpio); + return gpiochip_add_data(&vg->gpio, vg); } static int vx855gpio_remove(struct platform_device *pdev) -- cgit From 9b3c817b529e0bbe0d5a0a45e86e8647a729640c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 15:11:34 +0100 Subject: gpio: wm831x: 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: patches@opensource.wolfsonmicro.com Cc: Mark Brown Acked-by: Charles Keepax Signed-off-by: Linus Walleij --- drivers/gpio/gpio-wm831x.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/gpio/gpio-wm831x.c b/drivers/gpio/gpio-wm831x.c index 2e73e4b52c69..98390070fb64 100644 --- a/drivers/gpio/gpio-wm831x.c +++ b/drivers/gpio/gpio-wm831x.c @@ -30,14 +30,9 @@ struct wm831x_gpio { struct gpio_chip gpio_chip; }; -static inline struct wm831x_gpio *to_wm831x_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct wm831x_gpio, gpio_chip); -} - static int wm831x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) { - struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); + struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip); struct wm831x *wm831x = wm831x_gpio->wm831x; int val = WM831X_GPN_DIR; @@ -51,7 +46,7 @@ static int wm831x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) static int wm831x_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); + struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip); struct wm831x *wm831x = wm831x_gpio->wm831x; int ret; @@ -67,7 +62,7 @@ static int wm831x_gpio_get(struct gpio_chip *chip, unsigned offset) static void wm831x_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); + struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip); struct wm831x *wm831x = wm831x_gpio->wm831x; wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, 1 << offset, @@ -77,7 +72,7 @@ static void wm831x_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int wm831x_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { - struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); + struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip); struct wm831x *wm831x = wm831x_gpio->wm831x; int val = 0; int ret; @@ -99,7 +94,7 @@ static int wm831x_gpio_direction_out(struct gpio_chip *chip, static int wm831x_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); + struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip); struct wm831x *wm831x = wm831x_gpio->wm831x; return irq_create_mapping(wm831x->irq_domain, @@ -109,7 +104,7 @@ static int wm831x_gpio_to_irq(struct gpio_chip *chip, unsigned offset) static int wm831x_gpio_set_debounce(struct gpio_chip *chip, unsigned offset, unsigned debounce) { - struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); + struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip); struct wm831x *wm831x = wm831x_gpio->wm831x; int reg = WM831X_GPIO1_CONTROL + offset; int ret, fn; @@ -140,7 +135,7 @@ static int wm831x_gpio_set_debounce(struct gpio_chip *chip, unsigned offset, #ifdef CONFIG_DEBUG_FS static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { - struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); + struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip); struct wm831x *wm831x = wm831x_gpio->wm831x; int i, tristated; @@ -264,7 +259,7 @@ static int wm831x_gpio_probe(struct platform_device *pdev) else wm831x_gpio->gpio_chip.base = -1; - ret = gpiochip_add(&wm831x_gpio->gpio_chip); + ret = gpiochip_add_data(&wm831x_gpio->gpio_chip, wm831x_gpio); if (ret < 0) { dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); return ret; -- cgit From dfcdf7214ec921d792d93a4f5602da2073043073 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 15:13:39 +0100 Subject: gpio: wm8350: 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: patches@opensource.wolfsonmicro.com Cc: Mark Brown Acked-by: Charles Keepax Signed-off-by: Linus Walleij --- drivers/gpio/gpio-wm8350.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-wm8350.c b/drivers/gpio/gpio-wm8350.c index 1e3d8da61ff3..0a306b4baa73 100644 --- a/drivers/gpio/gpio-wm8350.c +++ b/drivers/gpio/gpio-wm8350.c @@ -28,14 +28,9 @@ struct wm8350_gpio_data { struct gpio_chip gpio_chip; }; -static inline struct wm8350_gpio_data *to_wm8350_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct wm8350_gpio_data, gpio_chip); -} - static int wm8350_gpio_direction_in(struct gpio_chip *chip, unsigned offset) { - struct wm8350_gpio_data *wm8350_gpio = to_wm8350_gpio(chip); + struct wm8350_gpio_data *wm8350_gpio = gpiochip_get_data(chip); struct wm8350 *wm8350 = wm8350_gpio->wm8350; return wm8350_set_bits(wm8350, WM8350_GPIO_CONFIGURATION_I_O, @@ -44,7 +39,7 @@ static int wm8350_gpio_direction_in(struct gpio_chip *chip, unsigned offset) static int wm8350_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct wm8350_gpio_data *wm8350_gpio = to_wm8350_gpio(chip); + struct wm8350_gpio_data *wm8350_gpio = gpiochip_get_data(chip); struct wm8350 *wm8350 = wm8350_gpio->wm8350; int ret; @@ -60,7 +55,7 @@ static int wm8350_gpio_get(struct gpio_chip *chip, unsigned offset) static void wm8350_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct wm8350_gpio_data *wm8350_gpio = to_wm8350_gpio(chip); + struct wm8350_gpio_data *wm8350_gpio = gpiochip_get_data(chip); struct wm8350 *wm8350 = wm8350_gpio->wm8350; if (value) @@ -72,7 +67,7 @@ static void wm8350_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int wm8350_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { - struct wm8350_gpio_data *wm8350_gpio = to_wm8350_gpio(chip); + struct wm8350_gpio_data *wm8350_gpio = gpiochip_get_data(chip); struct wm8350 *wm8350 = wm8350_gpio->wm8350; int ret; @@ -89,7 +84,7 @@ static int wm8350_gpio_direction_out(struct gpio_chip *chip, static int wm8350_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct wm8350_gpio_data *wm8350_gpio = to_wm8350_gpio(chip); + struct wm8350_gpio_data *wm8350_gpio = gpiochip_get_data(chip); struct wm8350 *wm8350 = wm8350_gpio->wm8350; if (!wm8350->irq_base) @@ -130,7 +125,7 @@ static int wm8350_gpio_probe(struct platform_device *pdev) else wm8350_gpio->gpio_chip.base = -1; - ret = gpiochip_add(&wm8350_gpio->gpio_chip); + ret = gpiochip_add_data(&wm8350_gpio->gpio_chip, wm8350_gpio); if (ret < 0) { dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); return ret; -- cgit From 765aa58778a5726a026a72773dda4d97036d3d1d Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 15:15:30 +0100 Subject: gpio: wm8994: 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: patches@opensource.wolfsonmicro.com Cc: Mark Brown Acked-by: Charles Keepax Signed-off-by: Linus Walleij --- drivers/gpio/gpio-wm8994.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/gpio/gpio-wm8994.c b/drivers/gpio/gpio-wm8994.c index de73c80163c1..3ae4c1597494 100644 --- a/drivers/gpio/gpio-wm8994.c +++ b/drivers/gpio/gpio-wm8994.c @@ -31,14 +31,9 @@ struct wm8994_gpio { struct gpio_chip gpio_chip; }; -static inline struct wm8994_gpio *to_wm8994_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct wm8994_gpio, gpio_chip); -} - static int wm8994_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip); + struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); struct wm8994 *wm8994 = wm8994_gpio->wm8994; switch (wm8994->type) { @@ -61,7 +56,7 @@ static int wm8994_gpio_request(struct gpio_chip *chip, unsigned offset) static int wm8994_gpio_direction_in(struct gpio_chip *chip, unsigned offset) { - struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip); + struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); struct wm8994 *wm8994 = wm8994_gpio->wm8994; return wm8994_set_bits(wm8994, WM8994_GPIO_1 + offset, @@ -70,7 +65,7 @@ static int wm8994_gpio_direction_in(struct gpio_chip *chip, unsigned offset) static int wm8994_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip); + struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); struct wm8994 *wm8994 = wm8994_gpio->wm8994; int ret; @@ -87,7 +82,7 @@ static int wm8994_gpio_get(struct gpio_chip *chip, unsigned offset) static int wm8994_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { - struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip); + struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); struct wm8994 *wm8994 = wm8994_gpio->wm8994; if (value) @@ -99,7 +94,7 @@ static int wm8994_gpio_direction_out(struct gpio_chip *chip, static void wm8994_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip); + struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); struct wm8994 *wm8994 = wm8994_gpio->wm8994; if (value) @@ -110,7 +105,7 @@ static void wm8994_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int wm8994_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip); + struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); struct wm8994 *wm8994 = wm8994_gpio->wm8994; return regmap_irq_get_virq(wm8994->irq_data, offset); @@ -174,7 +169,7 @@ static const char *wm8994_gpio_fn(u16 fn) static void wm8994_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { - struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip); + struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); struct wm8994 *wm8994 = wm8994_gpio->wm8994; int i; @@ -266,7 +261,7 @@ static int wm8994_gpio_probe(struct platform_device *pdev) else wm8994_gpio->gpio_chip.base = -1; - ret = gpiochip_add(&wm8994_gpio->gpio_chip); + ret = gpiochip_add_data(&wm8994_gpio->gpio_chip, wm8994_gpio); if (ret < 0) { dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); -- cgit From ac9dc85eeaf2e8f19a1846979c4dc700d4fb54dc Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 15:16:50 +0100 Subject: gpio: xgene: 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: Feng Kan Signed-off-by: Linus Walleij --- drivers/gpio/gpio-xgene.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-xgene.c b/drivers/gpio/gpio-xgene.c index b8ceb71885f6..592e9cdf9c53 100644 --- a/drivers/gpio/gpio-xgene.c +++ b/drivers/gpio/gpio-xgene.c @@ -47,14 +47,9 @@ struct xgene_gpio { #endif }; -static inline struct xgene_gpio *to_xgene_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct xgene_gpio, chip); -} - static int xgene_gpio_get(struct gpio_chip *gc, unsigned int offset) { - struct xgene_gpio *chip = to_xgene_gpio(gc); + struct xgene_gpio *chip = gpiochip_get_data(gc); unsigned long bank_offset; u32 bit_offset; @@ -65,7 +60,7 @@ static int xgene_gpio_get(struct gpio_chip *gc, unsigned int offset) static void __xgene_gpio_set(struct gpio_chip *gc, unsigned int offset, int val) { - struct xgene_gpio *chip = to_xgene_gpio(gc); + struct xgene_gpio *chip = gpiochip_get_data(gc); unsigned long bank_offset; u32 setval, bit_offset; @@ -82,7 +77,7 @@ static void __xgene_gpio_set(struct gpio_chip *gc, unsigned int offset, int val) static void xgene_gpio_set(struct gpio_chip *gc, unsigned int offset, int val) { - struct xgene_gpio *chip = to_xgene_gpio(gc); + struct xgene_gpio *chip = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -92,7 +87,7 @@ static void xgene_gpio_set(struct gpio_chip *gc, unsigned int offset, int val) static int xgene_gpio_dir_in(struct gpio_chip *gc, unsigned int offset) { - struct xgene_gpio *chip = to_xgene_gpio(gc); + struct xgene_gpio *chip = gpiochip_get_data(gc); unsigned long flags, bank_offset; u32 dirval, bit_offset; @@ -113,7 +108,7 @@ static int xgene_gpio_dir_in(struct gpio_chip *gc, unsigned int offset) static int xgene_gpio_dir_out(struct gpio_chip *gc, unsigned int offset, int val) { - struct xgene_gpio *chip = to_xgene_gpio(gc); + struct xgene_gpio *chip = gpiochip_get_data(gc); unsigned long flags, bank_offset; u32 dirval, bit_offset; @@ -198,7 +193,7 @@ static int xgene_gpio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, gpio); - err = gpiochip_add(&gpio->chip); + err = gpiochip_add_data(&gpio->chip, gpio); if (err) { dev_err(&pdev->dev, "failed to register gpiochip.\n"); -- cgit From 097d88e94c44112327011f572c7fff82a44c1d54 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 15:20:17 +0100 Subject: gpio: xilinx: use gpiochip data pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Michal Simek Cc: Sören Brinkmann Signed-off-by: Linus Walleij --- drivers/gpio/gpio-xilinx.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index 5c2971e1cb08..3345ab0ba1b3 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -92,8 +92,7 @@ static inline int xgpio_offset(struct xgpio_instance *chip, int gpio) static int xgpio_get(struct gpio_chip *gc, unsigned int gpio) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct xgpio_instance *chip = - container_of(mm_gc, struct xgpio_instance, mmchip); + struct xgpio_instance *chip = gpiochip_get_data(gc); u32 val; val = xgpio_readreg(mm_gc->regs + XGPIO_DATA_OFFSET + @@ -115,8 +114,7 @@ static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val) { unsigned long flags; struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct xgpio_instance *chip = - container_of(mm_gc, struct xgpio_instance, mmchip); + struct xgpio_instance *chip = gpiochip_get_data(gc); int index = xgpio_index(chip, gpio); int offset = xgpio_offset(chip, gpio); @@ -147,8 +145,7 @@ static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio) { unsigned long flags; struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct xgpio_instance *chip = - container_of(mm_gc, struct xgpio_instance, mmchip); + struct xgpio_instance *chip = gpiochip_get_data(gc); int index = xgpio_index(chip, gpio); int offset = xgpio_offset(chip, gpio); @@ -180,8 +177,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) { unsigned long flags; struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct xgpio_instance *chip = - container_of(mm_gc, struct xgpio_instance, mmchip); + struct xgpio_instance *chip = gpiochip_get_data(gc); int index = xgpio_index(chip, gpio); int offset = xgpio_offset(chip, gpio); @@ -211,8 +207,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) */ static void xgpio_save_regs(struct of_mm_gpio_chip *mm_gc) { - struct xgpio_instance *chip = - container_of(mm_gc, struct xgpio_instance, mmchip); + struct xgpio_instance *chip = gpiochip_get_data(&mm_gc->gc); xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET, chip->gpio_state[0]); xgpio_writereg(mm_gc->regs + XGPIO_TRI_OFFSET, chip->gpio_dir[0]); @@ -314,7 +309,7 @@ static int xgpio_probe(struct platform_device *pdev) chip->mmchip.save_regs = xgpio_save_regs; /* Call the OF gpio helper to setup and register the GPIO device */ - status = of_mm_gpiochip_add(np, &chip->mmchip); + status = of_mm_gpiochip_add_data(np, &chip->mmchip, chip); if (status) { pr_err("%s: error in probe function with status %d\n", np->full_name, status); -- cgit From e730a5953af4c54a50fb7712af4dd9468dedcd22 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 15:22:31 +0100 Subject: gpio: xlp: 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: Kamlakant Patel Signed-off-by: Linus Walleij --- drivers/gpio/gpio-xlp.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/gpio/gpio-xlp.c b/drivers/gpio/gpio-xlp.c index 3f31aac2ba3c..aa5813d2deb1 100644 --- a/drivers/gpio/gpio-xlp.c +++ b/drivers/gpio/gpio-xlp.c @@ -100,11 +100,6 @@ struct xlp_gpio_priv { spinlock_t lock; }; -static struct xlp_gpio_priv *gpio_chip_to_xlp_priv(struct gpio_chip *gc) -{ - return container_of(gc, struct xlp_gpio_priv, chip); -} - static int xlp_gpio_get_reg(void __iomem *addr, unsigned gpio) { u32 pos, regset; @@ -133,7 +128,7 @@ static void xlp_gpio_set_reg(void __iomem *addr, unsigned gpio, int state) static void xlp_gpio_irq_disable(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); + struct xlp_gpio_priv *priv = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&priv->lock, flags); @@ -145,7 +140,7 @@ static void xlp_gpio_irq_disable(struct irq_data *d) static void xlp_gpio_irq_mask_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); + struct xlp_gpio_priv *priv = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&priv->lock, flags); @@ -158,7 +153,7 @@ static void xlp_gpio_irq_mask_ack(struct irq_data *d) static void xlp_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); + struct xlp_gpio_priv *priv = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&priv->lock, flags); @@ -170,7 +165,7 @@ static void xlp_gpio_irq_unmask(struct irq_data *d) static int xlp_gpio_set_irq_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); + struct xlp_gpio_priv *priv = gpiochip_get_data(gc); int pol, irq_type; switch (type) { @@ -235,7 +230,7 @@ static void xlp_gpio_generic_handler(struct irq_desc *desc) static int xlp_gpio_dir_output(struct gpio_chip *gc, unsigned gpio, int state) { - struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); + struct xlp_gpio_priv *priv = gpiochip_get_data(gc); BUG_ON(gpio >= gc->ngpio); xlp_gpio_set_reg(priv->gpio_out_en, gpio, 0x1); @@ -245,7 +240,7 @@ static int xlp_gpio_dir_output(struct gpio_chip *gc, unsigned gpio, int state) static int xlp_gpio_dir_input(struct gpio_chip *gc, unsigned gpio) { - struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); + struct xlp_gpio_priv *priv = gpiochip_get_data(gc); BUG_ON(gpio >= gc->ngpio); xlp_gpio_set_reg(priv->gpio_out_en, gpio, 0x0); @@ -255,7 +250,7 @@ static int xlp_gpio_dir_input(struct gpio_chip *gc, unsigned gpio) static int xlp_gpio_get(struct gpio_chip *gc, unsigned gpio) { - struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); + struct xlp_gpio_priv *priv = gpiochip_get_data(gc); BUG_ON(gpio >= gc->ngpio); return xlp_gpio_get_reg(priv->gpio_paddrv, gpio); @@ -263,7 +258,7 @@ static int xlp_gpio_get(struct gpio_chip *gc, unsigned gpio) static void xlp_gpio_set(struct gpio_chip *gc, unsigned gpio, int state) { - struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); + struct xlp_gpio_priv *priv = gpiochip_get_data(gc); BUG_ON(gpio >= gc->ngpio); xlp_gpio_set_reg(priv->gpio_paddrv, gpio, state); @@ -388,7 +383,7 @@ static int xlp_gpio_probe(struct platform_device *pdev) return -ENODEV; } - err = gpiochip_add(gc); + err = gpiochip_add_data(gc, priv); if (err < 0) goto out_free_desc; -- cgit From 9a3ad668a081163ad5108a6f5d3a7ddaa0390098 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 15:26:02 +0100 Subject: gpio: zevio: 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: Fabian Vogt Signed-off-by: Linus Walleij --- drivers/gpio/gpio-zevio.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/gpio-zevio.c b/drivers/gpio/gpio-zevio.c index 65b61dcc6268..cda6d922be98 100644 --- a/drivers/gpio/gpio-zevio.c +++ b/drivers/gpio/gpio-zevio.c @@ -52,9 +52,6 @@ #define ZEVIO_GPIO_INPUT 0x18 #define ZEVIO_GPIO_INT_STICKY 0x20 -#define to_zevio_gpio(chip) container_of(to_of_mm_gpio_chip(chip), \ - struct zevio_gpio, chip) - /* Bit number of GPIO in its section */ #define ZEVIO_GPIO_BIT(gpio) (gpio&7) @@ -80,7 +77,7 @@ static inline void zevio_gpio_port_set(struct zevio_gpio *c, unsigned pin, /* Functions for struct gpio_chip */ static int zevio_gpio_get(struct gpio_chip *chip, unsigned pin) { - struct zevio_gpio *controller = to_zevio_gpio(chip); + struct zevio_gpio *controller = gpiochip_get_data(chip); u32 val, dir; spin_lock(&controller->lock); @@ -96,7 +93,7 @@ static int zevio_gpio_get(struct gpio_chip *chip, unsigned pin) static void zevio_gpio_set(struct gpio_chip *chip, unsigned pin, int value) { - struct zevio_gpio *controller = to_zevio_gpio(chip); + struct zevio_gpio *controller = gpiochip_get_data(chip); u32 val; spin_lock(&controller->lock); @@ -112,7 +109,7 @@ static void zevio_gpio_set(struct gpio_chip *chip, unsigned pin, int value) static int zevio_gpio_direction_input(struct gpio_chip *chip, unsigned pin) { - struct zevio_gpio *controller = to_zevio_gpio(chip); + struct zevio_gpio *controller = gpiochip_get_data(chip); u32 val; spin_lock(&controller->lock); @@ -129,7 +126,7 @@ static int zevio_gpio_direction_input(struct gpio_chip *chip, unsigned pin) static int zevio_gpio_direction_output(struct gpio_chip *chip, unsigned pin, int value) { - struct zevio_gpio *controller = to_zevio_gpio(chip); + struct zevio_gpio *controller = gpiochip_get_data(chip); u32 val; spin_lock(&controller->lock); @@ -187,7 +184,9 @@ static int zevio_gpio_probe(struct platform_device *pdev) controller->chip.gc = zevio_gpio_chip; controller->chip.gc.parent = &pdev->dev; - status = of_mm_gpiochip_add(pdev->dev.of_node, &(controller->chip)); + status = of_mm_gpiochip_add_data(pdev->dev.of_node, + &(controller->chip), + controller); if (status) { dev_err(&pdev->dev, "failed to add gpiochip: %d\n", status); return status; -- cgit From 17758b0490e6ce100648f80cd611ef360a69432a Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 15:27:49 +0100 Subject: gpio: zx: 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: Jun Nie Signed-off-by: Linus Walleij --- drivers/gpio/gpio-zx.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/gpio/gpio-zx.c b/drivers/gpio/gpio-zx.c index ab2e54fa46cf..47c79fa65670 100644 --- a/drivers/gpio/gpio-zx.c +++ b/drivers/gpio/gpio-zx.c @@ -43,14 +43,9 @@ struct zx_gpio { struct gpio_chip gc; }; -static inline struct zx_gpio *to_zx(struct gpio_chip *gc) -{ - return container_of(gc, struct zx_gpio, gc); -} - static int zx_direction_input(struct gpio_chip *gc, unsigned offset) { - struct zx_gpio *chip = to_zx(gc); + struct zx_gpio *chip = gpiochip_get_data(gc); unsigned long flags; u16 gpiodir; @@ -69,7 +64,7 @@ static int zx_direction_input(struct gpio_chip *gc, unsigned offset) static int zx_direction_output(struct gpio_chip *gc, unsigned offset, int value) { - struct zx_gpio *chip = to_zx(gc); + struct zx_gpio *chip = gpiochip_get_data(gc); unsigned long flags; u16 gpiodir; @@ -92,14 +87,14 @@ static int zx_direction_output(struct gpio_chip *gc, unsigned offset, static int zx_get_value(struct gpio_chip *gc, unsigned offset) { - struct zx_gpio *chip = to_zx(gc); + struct zx_gpio *chip = gpiochip_get_data(gc); return !!(readw_relaxed(chip->base + ZX_GPIO_DI) & BIT(offset)); } static void zx_set_value(struct gpio_chip *gc, unsigned offset, int value) { - struct zx_gpio *chip = to_zx(gc); + struct zx_gpio *chip = gpiochip_get_data(gc); if (value) writew_relaxed(BIT(offset), chip->base + ZX_GPIO_DO1); @@ -110,7 +105,7 @@ static void zx_set_value(struct gpio_chip *gc, unsigned offset, int value) static int zx_irq_type(struct irq_data *d, unsigned trigger) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct zx_gpio *chip = to_zx(gc); + struct zx_gpio *chip = gpiochip_get_data(gc); int offset = irqd_to_hwirq(d); unsigned long flags; u16 gpiois, gpioi_epos, gpioi_eneg, gpioiev; @@ -162,7 +157,7 @@ static void zx_irq_handler(struct irq_desc *desc) unsigned long pending; int offset; struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct zx_gpio *chip = to_zx(gc); + struct zx_gpio *chip = gpiochip_get_data(gc); struct irq_chip *irqchip = irq_desc_get_chip(desc); chained_irq_enter(irqchip, desc); @@ -181,7 +176,7 @@ static void zx_irq_handler(struct irq_desc *desc) static void zx_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct zx_gpio *chip = to_zx(gc); + struct zx_gpio *chip = gpiochip_get_data(gc); u16 mask = BIT(irqd_to_hwirq(d) % ZX_GPIO_NR); u16 gpioie; @@ -196,7 +191,7 @@ static void zx_irq_mask(struct irq_data *d) static void zx_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct zx_gpio *chip = to_zx(gc); + struct zx_gpio *chip = gpiochip_get_data(gc); u16 mask = BIT(irqd_to_hwirq(d) % ZX_GPIO_NR); u16 gpioie; @@ -248,7 +243,7 @@ static int zx_gpio_probe(struct platform_device *pdev) chip->gc.parent = dev; chip->gc.owner = THIS_MODULE; - ret = gpiochip_add(&chip->gc); + ret = gpiochip_add_data(&chip->gc, chip); if (ret) return ret; -- cgit From 31a8944752f8a91d8591148f60cd6dfb08c4e415 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 15:29:53 +0100 Subject: gpio: zynq: use gpiochip data pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Michal Simek Cc: Sören Brinkmann Signed-off-by: Linus Walleij --- drivers/gpio/gpio-zynq.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c index ba1150744b61..66d3d247d76d 100644 --- a/drivers/gpio/gpio-zynq.c +++ b/drivers/gpio/gpio-zynq.c @@ -131,11 +131,6 @@ struct zynq_platform_data { static struct irq_chip zynq_gpio_level_irqchip; static struct irq_chip zynq_gpio_edge_irqchip; -static struct zynq_gpio *to_zynq_gpio(struct gpio_chip *gc) -{ - return container_of(gc, struct zynq_gpio, chip); -} - /** * zynq_gpio_get_bank_pin - Get the bank number and pin number within that bank * for a given pin in the GPIO device @@ -183,7 +178,7 @@ static int zynq_gpio_get_value(struct gpio_chip *chip, unsigned int pin) { u32 data; unsigned int bank_num, bank_pin_num; - struct zynq_gpio *gpio = to_zynq_gpio(chip); + struct zynq_gpio *gpio = gpiochip_get_data(chip); zynq_gpio_get_bank_pin(pin, &bank_num, &bank_pin_num, gpio); @@ -207,7 +202,7 @@ static void zynq_gpio_set_value(struct gpio_chip *chip, unsigned int pin, int state) { unsigned int reg_offset, bank_num, bank_pin_num; - struct zynq_gpio *gpio = to_zynq_gpio(chip); + struct zynq_gpio *gpio = gpiochip_get_data(chip); zynq_gpio_get_bank_pin(pin, &bank_num, &bank_pin_num, gpio); @@ -244,7 +239,7 @@ static int zynq_gpio_dir_in(struct gpio_chip *chip, unsigned int pin) { u32 reg; unsigned int bank_num, bank_pin_num; - struct zynq_gpio *gpio = to_zynq_gpio(chip); + struct zynq_gpio *gpio = gpiochip_get_data(chip); zynq_gpio_get_bank_pin(pin, &bank_num, &bank_pin_num, gpio); @@ -277,7 +272,7 @@ static int zynq_gpio_dir_out(struct gpio_chip *chip, unsigned int pin, { u32 reg; unsigned int bank_num, bank_pin_num; - struct zynq_gpio *gpio = to_zynq_gpio(chip); + struct zynq_gpio *gpio = gpiochip_get_data(chip); zynq_gpio_get_bank_pin(pin, &bank_num, &bank_pin_num, gpio); @@ -308,7 +303,7 @@ static void zynq_gpio_irq_mask(struct irq_data *irq_data) { unsigned int device_pin_num, bank_num, bank_pin_num; struct zynq_gpio *gpio = - to_zynq_gpio(irq_data_get_irq_chip_data(irq_data)); + gpiochip_get_data(irq_data_get_irq_chip_data(irq_data)); device_pin_num = irq_data->hwirq; zynq_gpio_get_bank_pin(device_pin_num, &bank_num, &bank_pin_num, gpio); @@ -329,7 +324,7 @@ static void zynq_gpio_irq_unmask(struct irq_data *irq_data) { unsigned int device_pin_num, bank_num, bank_pin_num; struct zynq_gpio *gpio = - to_zynq_gpio(irq_data_get_irq_chip_data(irq_data)); + gpiochip_get_data(irq_data_get_irq_chip_data(irq_data)); device_pin_num = irq_data->hwirq; zynq_gpio_get_bank_pin(device_pin_num, &bank_num, &bank_pin_num, gpio); @@ -349,7 +344,7 @@ static void zynq_gpio_irq_ack(struct irq_data *irq_data) { unsigned int device_pin_num, bank_num, bank_pin_num; struct zynq_gpio *gpio = - to_zynq_gpio(irq_data_get_irq_chip_data(irq_data)); + gpiochip_get_data(irq_data_get_irq_chip_data(irq_data)); device_pin_num = irq_data->hwirq; zynq_gpio_get_bank_pin(device_pin_num, &bank_num, &bank_pin_num, gpio); @@ -400,7 +395,7 @@ static int zynq_gpio_set_irq_type(struct irq_data *irq_data, unsigned int type) u32 int_type, int_pol, int_any; unsigned int device_pin_num, bank_num, bank_pin_num; struct zynq_gpio *gpio = - to_zynq_gpio(irq_data_get_irq_chip_data(irq_data)); + gpiochip_get_data(irq_data_get_irq_chip_data(irq_data)); device_pin_num = irq_data->hwirq; zynq_gpio_get_bank_pin(device_pin_num, &bank_num, &bank_pin_num, gpio); @@ -464,7 +459,7 @@ static int zynq_gpio_set_irq_type(struct irq_data *irq_data, unsigned int type) static int zynq_gpio_set_wake(struct irq_data *data, unsigned int on) { struct zynq_gpio *gpio = - to_zynq_gpio(irq_data_get_irq_chip_data(data)); + gpiochip_get_data(irq_data_get_irq_chip_data(data)); irq_set_irq_wake(gpio->irq, on); @@ -530,7 +525,7 @@ static void zynq_gpio_irqhandler(struct irq_desc *desc) u32 int_sts, int_enb; unsigned int bank_num; struct zynq_gpio *gpio = - to_zynq_gpio(irq_desc_get_handler_data(desc)); + gpiochip_get_data(irq_desc_get_handler_data(desc)); struct irq_chip *irqchip = irq_desc_get_chip(desc); chained_irq_enter(irqchip, desc); @@ -721,7 +716,7 @@ static int zynq_gpio_probe(struct platform_device *pdev) return ret; /* report a bug if gpio chip registration fails */ - ret = gpiochip_add(chip); + ret = gpiochip_add_data(chip, gpio); if (ret) { dev_err(&pdev->dev, "Failed to add gpio chip\n"); goto err_pm_put; -- cgit From 4eab22e748b550045b8a98be3b72f31e22557605 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 10:41:44 +0100 Subject: gpio: convert remaining users to gpiochip_add_data() For completion, sweep the floor from all gpiochip_add() usage so we can remove that function and get rid of the function wrapper gpiochip_add(). Signed-off-by: Linus Walleij --- drivers/gpio/gpio-ich.c | 2 +- drivers/gpio/gpio-iop.c | 2 +- drivers/gpio/gpio-janz-ttl.c | 2 +- drivers/gpio/gpio-ks8695.c | 2 +- drivers/gpio/gpio-loongson.c | 2 +- drivers/gpio/gpio-sa1100.c | 2 +- drivers/gpio/gpio-tegra.c | 2 +- drivers/gpio/gpio-twl6040.c | 2 +- drivers/gpio/gpio-vr41xx.c | 2 +- drivers/gpio/gpio-xtensa.c | 4 ++-- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c index 8623d12e23c1..a4893386abbf 100644 --- a/drivers/gpio/gpio-ich.c +++ b/drivers/gpio/gpio-ich.c @@ -499,7 +499,7 @@ static int ichx_gpio_probe(struct platform_device *pdev) init: ichx_gpiolib_setup(&ichx_priv.chip); - err = gpiochip_add(&ichx_priv.chip); + err = gpiochip_add_data(&ichx_priv.chip, NULL); if (err) { pr_err("Failed to register GPIOs\n"); goto add_err; diff --git a/drivers/gpio/gpio-iop.c b/drivers/gpio/gpio-iop.c index 2ed0237a8baf..fb65e5850e0c 100644 --- a/drivers/gpio/gpio-iop.c +++ b/drivers/gpio/gpio-iop.c @@ -114,7 +114,7 @@ static int iop3xx_gpio_probe(struct platform_device *pdev) if (IS_ERR(base)) return PTR_ERR(base); - return gpiochip_add(&iop3xx_chip); + return gpiochip_add_data(&iop3xx_chip, NULL); } static struct platform_driver iop3xx_gpio_driver = { diff --git a/drivers/gpio/gpio-janz-ttl.c b/drivers/gpio/gpio-janz-ttl.c index 236d322a0b5e..482aa0353868 100644 --- a/drivers/gpio/gpio-janz-ttl.c +++ b/drivers/gpio/gpio-janz-ttl.c @@ -182,7 +182,7 @@ static int ttl_probe(struct platform_device *pdev) gpio->base = -1; gpio->ngpio = 20; - ret = gpiochip_add(gpio); + ret = gpiochip_add_data(gpio, NULL); if (ret) { dev_err(dev, "unable to add GPIO chip\n"); return ret; diff --git a/drivers/gpio/gpio-ks8695.c b/drivers/gpio/gpio-ks8695.c index cc09b237e88c..9f86ed9c753b 100644 --- a/drivers/gpio/gpio-ks8695.c +++ b/drivers/gpio/gpio-ks8695.c @@ -234,7 +234,7 @@ static struct gpio_chip ks8695_gpio_chip = { /* Register the GPIOs */ void ks8695_register_gpios(void) { - if (gpiochip_add(&ks8695_gpio_chip)) + if (gpiochip_add_data(&ks8695_gpio_chip, NULL)) printk(KERN_ERR "Unable to register core GPIOs\n"); } diff --git a/drivers/gpio/gpio-loongson.c b/drivers/gpio/gpio-loongson.c index ccc65a1aea88..92c4fe7b2677 100644 --- a/drivers/gpio/gpio-loongson.c +++ b/drivers/gpio/gpio-loongson.c @@ -110,6 +110,6 @@ static struct gpio_chip loongson_chip = { static int __init loongson_gpio_setup(void) { - return gpiochip_add(&loongson_chip); + return gpiochip_add_data(&loongson_chip, NULL); } postcore_initcall(loongson_gpio_setup); diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c index 9d590166e952..0c99e8fb9af3 100644 --- a/drivers/gpio/gpio-sa1100.c +++ b/drivers/gpio/gpio-sa1100.c @@ -238,7 +238,7 @@ void __init sa1100_init_gpio(void) GRER = 0; GEDR = -1; - gpiochip_add(&sa1100_gpio_chip); + gpiochip_add_data(&sa1100_gpio_chip, NULL); sa1100_gpio_irqdomain = irq_domain_add_simple(NULL, 28, IRQ_GPIO0, diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c index 896bf29776b0..9a1a7e2ef388 100644 --- a/drivers/gpio/gpio-tegra.c +++ b/drivers/gpio/gpio-tegra.c @@ -545,7 +545,7 @@ static int tegra_gpio_probe(struct platform_device *pdev) tegra_gpio_chip.of_node = pdev->dev.of_node; - ret = gpiochip_add(&tegra_gpio_chip); + ret = gpiochip_add_data(&tegra_gpio_chip, NULL); if (ret < 0) { irq_domain_remove(irq_domain); return ret; diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c index 2da7c5f70034..8e9e9853f3bd 100644 --- a/drivers/gpio/gpio-twl6040.c +++ b/drivers/gpio/gpio-twl6040.c @@ -100,7 +100,7 @@ static int gpo_twl6040_probe(struct platform_device *pdev) twl6040gpo_chip.of_node = twl6040_core_dev->of_node; #endif - ret = gpiochip_add(&twl6040gpo_chip); + ret = gpiochip_add_data(&twl6040gpo_chip, NULL); if (ret < 0) { dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret); twl6040gpo_chip.ngpio = 0; diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c index 1947531b7cf5..ac8deb01f6f6 100644 --- a/drivers/gpio/gpio-vr41xx.c +++ b/drivers/gpio/gpio-vr41xx.c @@ -544,7 +544,7 @@ static int giu_probe(struct platform_device *pdev) vr41xx_gpio_chip.parent = &pdev->dev; - ret = gpiochip_add(&vr41xx_gpio_chip); + ret = gpiochip_add_data(&vr41xx_gpio_chip, NULL); if (!ret) { iounmap(giu_base); return -ENODEV; diff --git a/drivers/gpio/gpio-xtensa.c b/drivers/gpio/gpio-xtensa.c index 93ec95df67a3..f16c0427952e 100644 --- a/drivers/gpio/gpio-xtensa.c +++ b/drivers/gpio/gpio-xtensa.c @@ -148,10 +148,10 @@ static int xtensa_gpio_probe(struct platform_device *pdev) { int ret; - ret = gpiochip_add(&impwire_chip); + ret = gpiochip_add_data(&impwire_chip, NULL); if (ret) return ret; - return gpiochip_add(&expstate_chip); + return gpiochip_add_data(&expstate_chip, NULL); } static struct platform_driver xtensa_gpio_driver = { -- cgit From 09dd5f9e240e738b4d5e2e602c3b66659babf068 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 7 Dec 2015 15:31:58 +0100 Subject: gpio: fix misleading comment We are not relying on container_of() now that we have gpiochip_get_data(). Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 905408b8d54b..3db34e74bc34 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -688,7 +688,7 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip) * gpiochip, providing an irq domain to translate the local IRQs to * global irqs in the gpiolib core, and making sure that the gpiochip * is passed as chip data to all related functions. Driver callbacks - * need to use container_of() to get their local state containers back + * need to use gpiochip_get_data() to get their local state containers back * from the gpiochip passed as chip data. An irqdomain will be stored * in the gpiochip that shall be used by the driver to handle IRQ number * translation. The gpiochip will need to be initialized and registered -- cgit From bf9a5c96c87cf113e8e56df183a5f7c9af4a4c89 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 00:03:44 +0100 Subject: pinctrl: baytrail: 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(). Acked-by: Mika Westerberg Acked-by: Heikki Krogerus Signed-off-by: Linus Walleij --- drivers/pinctrl/intel/pinctrl-baytrail.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c index 1fe9c1989353..21b79a446d5a 100644 --- a/drivers/pinctrl/intel/pinctrl-baytrail.c +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -147,12 +147,10 @@ struct byt_gpio { struct byt_gpio_pin_context *saved_context; }; -#define to_byt_gpio(c) container_of(c, struct byt_gpio, chip) - static void __iomem *byt_gpio_reg(struct gpio_chip *chip, unsigned offset, int reg) { - struct byt_gpio *vg = to_byt_gpio(chip); + struct byt_gpio *vg = gpiochip_get_data(chip); u32 reg_offset; if (reg == BYT_INT_STAT_REG) @@ -193,7 +191,7 @@ static u32 byt_get_gpio_mux(struct byt_gpio *vg, unsigned offset) static int byt_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct byt_gpio *vg = to_byt_gpio(chip); + struct byt_gpio *vg = gpiochip_get_data(chip); void __iomem *reg = byt_gpio_reg(chip, offset, BYT_CONF0_REG); u32 value, gpio_mux; unsigned long flags; @@ -229,7 +227,7 @@ static int byt_gpio_request(struct gpio_chip *chip, unsigned offset) static void byt_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct byt_gpio *vg = to_byt_gpio(chip); + struct byt_gpio *vg = gpiochip_get_data(chip); byt_gpio_clear_triggering(vg, offset); pm_runtime_put(&vg->pdev->dev); @@ -237,7 +235,7 @@ static void byt_gpio_free(struct gpio_chip *chip, unsigned offset) static int byt_irq_type(struct irq_data *d, unsigned type) { - struct byt_gpio *vg = to_byt_gpio(irq_data_get_irq_chip_data(d)); + struct byt_gpio *vg = gpiochip_get_data(irq_data_get_irq_chip_data(d)); u32 offset = irqd_to_hwirq(d); u32 value; unsigned long flags; @@ -273,7 +271,7 @@ static int byt_irq_type(struct irq_data *d, unsigned type) static int byt_gpio_get(struct gpio_chip *chip, unsigned offset) { void __iomem *reg = byt_gpio_reg(chip, offset, BYT_VAL_REG); - struct byt_gpio *vg = to_byt_gpio(chip); + struct byt_gpio *vg = gpiochip_get_data(chip); unsigned long flags; u32 val; @@ -286,7 +284,7 @@ static int byt_gpio_get(struct gpio_chip *chip, unsigned offset) static void byt_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct byt_gpio *vg = to_byt_gpio(chip); + struct byt_gpio *vg = gpiochip_get_data(chip); void __iomem *reg = byt_gpio_reg(chip, offset, BYT_VAL_REG); unsigned long flags; u32 old_val; @@ -305,7 +303,7 @@ static void byt_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int byt_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct byt_gpio *vg = to_byt_gpio(chip); + struct byt_gpio *vg = gpiochip_get_data(chip); void __iomem *reg = byt_gpio_reg(chip, offset, BYT_VAL_REG); unsigned long flags; u32 value; @@ -324,7 +322,7 @@ static int byt_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int byt_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value) { - struct byt_gpio *vg = to_byt_gpio(chip); + struct byt_gpio *vg = gpiochip_get_data(chip); void __iomem *conf_reg = byt_gpio_reg(chip, gpio, BYT_CONF0_REG); void __iomem *reg = byt_gpio_reg(chip, gpio, BYT_VAL_REG); unsigned long flags; @@ -356,7 +354,7 @@ static int byt_gpio_direction_output(struct gpio_chip *chip, static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { - struct byt_gpio *vg = to_byt_gpio(chip); + struct byt_gpio *vg = gpiochip_get_data(chip); int i; u32 conf0, val, offs; @@ -428,7 +426,7 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) static void byt_gpio_irq_handler(struct irq_desc *desc) { struct irq_data *data = irq_desc_get_irq_data(desc); - struct byt_gpio *vg = to_byt_gpio(irq_desc_get_handler_data(desc)); + struct byt_gpio *vg = gpiochip_get_data(irq_desc_get_handler_data(desc)); struct irq_chip *chip = irq_data_get_irq_chip(data); u32 base, pin; void __iomem *reg; @@ -450,7 +448,7 @@ static void byt_gpio_irq_handler(struct irq_desc *desc) static void byt_irq_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct byt_gpio *vg = to_byt_gpio(gc); + struct byt_gpio *vg = gpiochip_get_data(gc); unsigned offset = irqd_to_hwirq(d); void __iomem *reg; @@ -463,7 +461,7 @@ static void byt_irq_ack(struct irq_data *d) static void byt_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct byt_gpio *vg = to_byt_gpio(gc); + struct byt_gpio *vg = gpiochip_get_data(gc); unsigned offset = irqd_to_hwirq(d); unsigned long flags; void __iomem *reg; @@ -498,7 +496,7 @@ static void byt_irq_unmask(struct irq_data *d) static void byt_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct byt_gpio *vg = to_byt_gpio(gc); + struct byt_gpio *vg = gpiochip_get_data(gc); byt_gpio_clear_triggering(vg, irqd_to_hwirq(d)); } @@ -605,7 +603,7 @@ static int byt_gpio_probe(struct platform_device *pdev) sizeof(*vg->saved_context), GFP_KERNEL); #endif - ret = gpiochip_add(gc); + ret = gpiochip_add_data(gc, vg); if (ret) { dev_err(&pdev->dev, "failed adding byt-gpio chip\n"); return ret; -- cgit From e19a5f795c1c5be562cfee1c578c97890a755abc Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 22:01:00 +0100 Subject: pinctrl: bcm2835: 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: Stephen Warren Acked-by: Eric Anholt Signed-off-by: Linus Walleij --- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c index 595f87028b19..7c35249058f6 100644 --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -337,14 +337,14 @@ static int bcm2835_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int bcm2835_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct bcm2835_pinctrl *pc = dev_get_drvdata(chip->parent); + struct bcm2835_pinctrl *pc = gpiochip_get_data(chip); return bcm2835_gpio_get_bit(pc, GPLEV0, offset); } static void bcm2835_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct bcm2835_pinctrl *pc = dev_get_drvdata(chip->parent); + struct bcm2835_pinctrl *pc = gpiochip_get_data(chip); bcm2835_gpio_set_bit(pc, value ? GPSET0 : GPCLR0, offset); } @@ -358,7 +358,7 @@ static int bcm2835_gpio_direction_output(struct gpio_chip *chip, static int bcm2835_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct bcm2835_pinctrl *pc = dev_get_drvdata(chip->parent); + struct bcm2835_pinctrl *pc = gpiochip_get_data(chip); return irq_linear_revmap(pc->irq_domain, offset); } @@ -1021,7 +1021,7 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev) } } - err = gpiochip_add(&pc->gpio_chip); + err = gpiochip_add_data(&pc->gpio_chip, pc); if (err) { dev_err(dev, "could not add GPIO chip\n"); return err; -- cgit From 0587d3db005c0bd838bfa0734cc611b4837c0f9d Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 00:16:03 +0100 Subject: pinctrl: cherryview: 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(). Acked-by: Mika Westerberg Acked-by: Heikki Krogerus Signed-off-by: Linus Walleij --- drivers/pinctrl/intel/pinctrl-cherryview.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c index dac8ec46aeb4..4251e0747a3a 100644 --- a/drivers/pinctrl/intel/pinctrl-cherryview.c +++ b/drivers/pinctrl/intel/pinctrl-cherryview.c @@ -181,8 +181,6 @@ struct chv_pinctrl { struct chv_pin_context *saved_pin_context; }; -#define gpiochip_to_pinctrl(c) container_of(c, struct chv_pinctrl, chip) - #define ALTERNATE_FUNCTION(p, m, i) \ { \ .pin = (p), \ @@ -1157,7 +1155,7 @@ static unsigned chv_gpio_offset_to_pin(struct chv_pinctrl *pctrl, static int chv_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct chv_pinctrl *pctrl = gpiochip_to_pinctrl(chip); + struct chv_pinctrl *pctrl = gpiochip_get_data(chip); int pin = chv_gpio_offset_to_pin(pctrl, offset); unsigned long flags; u32 ctrl0, cfg; @@ -1176,7 +1174,7 @@ static int chv_gpio_get(struct gpio_chip *chip, unsigned offset) static void chv_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct chv_pinctrl *pctrl = gpiochip_to_pinctrl(chip); + struct chv_pinctrl *pctrl = gpiochip_get_data(chip); unsigned pin = chv_gpio_offset_to_pin(pctrl, offset); unsigned long flags; void __iomem *reg; @@ -1199,7 +1197,7 @@ static void chv_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int chv_gpio_get_direction(struct gpio_chip *chip, unsigned offset) { - struct chv_pinctrl *pctrl = gpiochip_to_pinctrl(chip); + struct chv_pinctrl *pctrl = gpiochip_get_data(chip); unsigned pin = chv_gpio_offset_to_pin(pctrl, offset); u32 ctrl0, direction; unsigned long flags; @@ -1240,7 +1238,7 @@ static const struct gpio_chip chv_gpio_chip = { static void chv_gpio_irq_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct chv_pinctrl *pctrl = gpiochip_to_pinctrl(gc); + struct chv_pinctrl *pctrl = gpiochip_get_data(gc); int pin = chv_gpio_offset_to_pin(pctrl, irqd_to_hwirq(d)); u32 intr_line; @@ -1257,7 +1255,7 @@ static void chv_gpio_irq_ack(struct irq_data *d) static void chv_gpio_irq_mask_unmask(struct irq_data *d, bool mask) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct chv_pinctrl *pctrl = gpiochip_to_pinctrl(gc); + struct chv_pinctrl *pctrl = gpiochip_get_data(gc); int pin = chv_gpio_offset_to_pin(pctrl, irqd_to_hwirq(d)); u32 value, intr_line; unsigned long flags; @@ -1302,7 +1300,7 @@ static unsigned chv_gpio_irq_startup(struct irq_data *d) */ if (irqd_get_trigger_type(d) == IRQ_TYPE_NONE) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct chv_pinctrl *pctrl = gpiochip_to_pinctrl(gc); + struct chv_pinctrl *pctrl = gpiochip_get_data(gc); unsigned offset = irqd_to_hwirq(d); int pin = chv_gpio_offset_to_pin(pctrl, offset); irq_flow_handler_t handler; @@ -1334,7 +1332,7 @@ static unsigned chv_gpio_irq_startup(struct irq_data *d) static int chv_gpio_irq_type(struct irq_data *d, unsigned type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct chv_pinctrl *pctrl = gpiochip_to_pinctrl(gc); + struct chv_pinctrl *pctrl = gpiochip_get_data(gc); unsigned offset = irqd_to_hwirq(d); int pin = chv_gpio_offset_to_pin(pctrl, offset); unsigned long flags; @@ -1407,7 +1405,7 @@ static struct irq_chip chv_gpio_irqchip = { static void chv_gpio_irq_handler(struct irq_desc *desc) { struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct chv_pinctrl *pctrl = gpiochip_to_pinctrl(gc); + struct chv_pinctrl *pctrl = gpiochip_get_data(gc); struct irq_chip *chip = irq_desc_get_chip(desc); unsigned long pending; u32 intr_line; @@ -1439,7 +1437,7 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq) chip->parent = pctrl->dev; chip->base = -1; - ret = gpiochip_add(chip); + ret = gpiochip_add_data(chip, pctrl); if (ret) { dev_err(pctrl->dev, "Failed to register gpiochip\n"); return ret; -- cgit From acfd4c633aa394ac0323bdb2be95f5b587c0ffbd Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 00:18:59 +0100 Subject: pinctrl: intel: 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(). Acked-by: Mika Westerberg Acked-by: Heikki Krogerus Signed-off-by: Linus Walleij --- drivers/pinctrl/intel/pinctrl-intel.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c index c6dcde7132de..c0f5586218c4 100644 --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c @@ -103,7 +103,6 @@ struct intel_pinctrl { struct intel_pinctrl_context context; }; -#define gpiochip_to_pinctrl(c) container_of(c, struct intel_pinctrl, chip) #define pin_to_padno(c, p) ((p) - (c)->pin_base) static struct intel_community *intel_get_community(struct intel_pinctrl *pctrl, @@ -596,7 +595,7 @@ static const struct pinctrl_desc intel_pinctrl_desc = { static int intel_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct intel_pinctrl *pctrl = gpiochip_to_pinctrl(chip); + struct intel_pinctrl *pctrl = gpiochip_get_data(chip); void __iomem *reg; reg = intel_get_padcfg(pctrl, offset, PADCFG0); @@ -608,7 +607,7 @@ static int intel_gpio_get(struct gpio_chip *chip, unsigned offset) static void intel_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct intel_pinctrl *pctrl = gpiochip_to_pinctrl(chip); + struct intel_pinctrl *pctrl = gpiochip_get_data(chip); void __iomem *reg; reg = intel_get_padcfg(pctrl, offset, PADCFG0); @@ -652,7 +651,7 @@ static const struct gpio_chip intel_gpio_chip = { static void intel_gpio_irq_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct intel_pinctrl *pctrl = gpiochip_to_pinctrl(gc); + struct intel_pinctrl *pctrl = gpiochip_get_data(gc); const struct intel_community *community; unsigned pin = irqd_to_hwirq(d); @@ -673,7 +672,7 @@ static void intel_gpio_irq_ack(struct irq_data *d) static void intel_gpio_irq_mask_unmask(struct irq_data *d, bool mask) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct intel_pinctrl *pctrl = gpiochip_to_pinctrl(gc); + struct intel_pinctrl *pctrl = gpiochip_get_data(gc); const struct intel_community *community; unsigned pin = irqd_to_hwirq(d); unsigned long flags; @@ -713,7 +712,7 @@ static void intel_gpio_irq_unmask(struct irq_data *d) static int intel_gpio_irq_type(struct irq_data *d, unsigned type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct intel_pinctrl *pctrl = gpiochip_to_pinctrl(gc); + struct intel_pinctrl *pctrl = gpiochip_get_data(gc); unsigned pin = irqd_to_hwirq(d); unsigned long flags; void __iomem *reg; @@ -767,7 +766,7 @@ static int intel_gpio_irq_type(struct irq_data *d, unsigned type) static int intel_gpio_irq_wake(struct irq_data *d, unsigned int on) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct intel_pinctrl *pctrl = gpiochip_to_pinctrl(gc); + struct intel_pinctrl *pctrl = gpiochip_get_data(gc); const struct intel_community *community; unsigned pin = irqd_to_hwirq(d); unsigned padno, gpp, gpp_offset; @@ -875,7 +874,7 @@ static int intel_gpio_probe(struct intel_pinctrl *pctrl, int irq) pctrl->chip.parent = pctrl->dev; pctrl->chip.base = -1; - ret = gpiochip_add(&pctrl->chip); + ret = gpiochip_add_data(&pctrl->chip, pctrl); if (ret) { dev_err(pctrl->dev, "failed to register gpiochip\n"); return ret; -- cgit From 827c93dae7275aaf7bfc2f1b41e1e6845751dda9 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 08:26:34 +0100 Subject: pinctrl: meson: 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: Beniamino Galvani Cc: Carlo Caione Cc: Antoine Tenart Signed-off-by: Linus Walleij --- drivers/pinctrl/meson/pinctrl-meson.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c index 4b5f6829144d..50cab27c64d4 100644 --- a/drivers/pinctrl/meson/pinctrl-meson.c +++ b/drivers/pinctrl/meson/pinctrl-meson.c @@ -448,11 +448,6 @@ static const struct pinconf_ops meson_pinconf_ops = { .is_generic = true, }; -static inline struct meson_domain *to_meson_domain(struct gpio_chip *chip) -{ - return container_of(chip, struct meson_domain, chip); -} - static int meson_gpio_request(struct gpio_chip *chip, unsigned gpio) { return pinctrl_request_gpio(chip->base + gpio); @@ -460,14 +455,14 @@ static int meson_gpio_request(struct gpio_chip *chip, unsigned gpio) static void meson_gpio_free(struct gpio_chip *chip, unsigned gpio) { - struct meson_domain *domain = to_meson_domain(chip); + struct meson_domain *domain = gpiochip_get_data(chip); pinctrl_free_gpio(domain->data->pin_base + gpio); } static int meson_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) { - struct meson_domain *domain = to_meson_domain(chip); + struct meson_domain *domain = gpiochip_get_data(chip); unsigned int reg, bit, pin; struct meson_bank *bank; int ret; @@ -485,7 +480,7 @@ static int meson_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) static int meson_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value) { - struct meson_domain *domain = to_meson_domain(chip); + struct meson_domain *domain = gpiochip_get_data(chip); unsigned int reg, bit, pin; struct meson_bank *bank; int ret; @@ -507,7 +502,7 @@ static int meson_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, static void meson_gpio_set(struct gpio_chip *chip, unsigned gpio, int value) { - struct meson_domain *domain = to_meson_domain(chip); + struct meson_domain *domain = gpiochip_get_data(chip); unsigned int reg, bit, pin; struct meson_bank *bank; int ret; @@ -524,7 +519,7 @@ static void meson_gpio_set(struct gpio_chip *chip, unsigned gpio, int value) static int meson_gpio_get(struct gpio_chip *chip, unsigned gpio) { - struct meson_domain *domain = to_meson_domain(chip); + struct meson_domain *domain = gpiochip_get_data(chip); unsigned int reg, bit, val, pin; struct meson_bank *bank; int ret; @@ -575,7 +570,7 @@ static int meson_gpiolib_register(struct meson_pinctrl *pc) domain->chip.of_node = domain->of_node; domain->chip.of_gpio_n_cells = 2; - ret = gpiochip_add(&domain->chip); + ret = gpiochip_add_data(&domain->chip, domain); if (ret) { dev_err(pc->dev, "can't add gpio chip %s\n", domain->data->name); -- cgit From 68ab0126001fb265c080b84e54b3c7c35e9d821d Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 3 Dec 2015 15:44:46 +0100 Subject: pinctrl: nomadik: 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/pinctrl/nomadik/pinctrl-nomadik.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/nomadik/pinctrl-nomadik.c index cb4a327425a0..352406108fa0 100644 --- a/drivers/pinctrl/nomadik/pinctrl-nomadik.c +++ b/drivers/pinctrl/nomadik/pinctrl-nomadik.c @@ -646,7 +646,7 @@ static inline int nmk_gpio_get_bitmask(int gpio) static void nmk_gpio_irq_ack(struct irq_data *d) { struct gpio_chip *chip = irq_data_get_irq_chip_data(d); - struct nmk_gpio_chip *nmk_chip = container_of(chip, struct nmk_gpio_chip, chip); + struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); clk_enable(nmk_chip->clk); writel(nmk_gpio_get_bitmask(d->hwirq), nmk_chip->addr + NMK_GPIO_IC); @@ -863,7 +863,7 @@ static void __nmk_gpio_irq_handler(struct irq_desc *desc, u32 status) static void nmk_gpio_irq_handler(struct irq_desc *desc) { struct gpio_chip *chip = irq_desc_get_handler_data(desc); - struct nmk_gpio_chip *nmk_chip = container_of(chip, struct nmk_gpio_chip, chip); + struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); u32 status; clk_enable(nmk_chip->clk); @@ -876,7 +876,7 @@ static void nmk_gpio_irq_handler(struct irq_desc *desc) static void nmk_gpio_latent_irq_handler(struct irq_desc *desc) { struct gpio_chip *chip = irq_desc_get_handler_data(desc); - struct nmk_gpio_chip *nmk_chip = container_of(chip, struct nmk_gpio_chip, chip); + struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); u32 status = nmk_chip->get_latent_status(nmk_chip->bank); __nmk_gpio_irq_handler(desc, status); @@ -886,8 +886,7 @@ static void nmk_gpio_latent_irq_handler(struct irq_desc *desc) static int nmk_gpio_make_input(struct gpio_chip *chip, unsigned offset) { - struct nmk_gpio_chip *nmk_chip = - container_of(chip, struct nmk_gpio_chip, chip); + struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); clk_enable(nmk_chip->clk); @@ -900,8 +899,7 @@ static int nmk_gpio_make_input(struct gpio_chip *chip, unsigned offset) static int nmk_gpio_get_input(struct gpio_chip *chip, unsigned offset) { - struct nmk_gpio_chip *nmk_chip = - container_of(chip, struct nmk_gpio_chip, chip); + struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); u32 bit = 1 << offset; int value; @@ -917,8 +915,7 @@ static int nmk_gpio_get_input(struct gpio_chip *chip, unsigned offset) static void nmk_gpio_set_output(struct gpio_chip *chip, unsigned offset, int val) { - struct nmk_gpio_chip *nmk_chip = - container_of(chip, struct nmk_gpio_chip, chip); + struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); clk_enable(nmk_chip->clk); @@ -930,8 +927,7 @@ static void nmk_gpio_set_output(struct gpio_chip *chip, unsigned offset, static int nmk_gpio_make_output(struct gpio_chip *chip, unsigned offset, int val) { - struct nmk_gpio_chip *nmk_chip = - container_of(chip, struct nmk_gpio_chip, chip); + struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); clk_enable(nmk_chip->clk); @@ -951,8 +947,7 @@ static void nmk_gpio_dbg_show_one(struct seq_file *s, unsigned offset, unsigned gpio) { const char *label = gpiochip_is_requested(chip, offset); - struct nmk_gpio_chip *nmk_chip = - container_of(chip, struct nmk_gpio_chip, chip); + struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); int mode; bool is_out; bool data_out; @@ -1278,7 +1273,7 @@ static int nmk_gpio_probe(struct platform_device *dev) clk_disable(nmk_chip->clk); chip->of_node = np; - ret = gpiochip_add(chip); + ret = gpiochip_add_data(chip, nmk_chip); if (ret) return ret; @@ -1789,7 +1784,7 @@ static int nmk_gpio_request_enable(struct pinctrl_dev *pctldev, return -EINVAL; } chip = range->gc; - nmk_chip = container_of(chip, struct nmk_gpio_chip, chip); + nmk_chip = gpiochip_get_data(chip); dev_dbg(npct->dev, "enable pin %u as GPIO\n", offset); -- cgit From 2b016d2793d7b23d9fdfc55f5afc8fc6e6fd30eb Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 08:29:43 +0100 Subject: pinctrl: abx500: 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/pinctrl/nomadik/pinctrl-abx500.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/pinctrl/nomadik/pinctrl-abx500.c b/drivers/pinctrl/nomadik/pinctrl-abx500.c index 434d5de0177b..085e60106ec2 100644 --- a/drivers/pinctrl/nomadik/pinctrl-abx500.c +++ b/drivers/pinctrl/nomadik/pinctrl-abx500.c @@ -109,19 +109,10 @@ struct abx500_pinctrl { int irq_cluster_size; }; -/** - * to_abx500_pinctrl() - get the pointer to abx500_pinctrl - * @chip: Member of the structure abx500_pinctrl - */ -static inline struct abx500_pinctrl *to_abx500_pinctrl(struct gpio_chip *chip) -{ - return container_of(chip, struct abx500_pinctrl, chip); -} - static int abx500_gpio_get_bit(struct gpio_chip *chip, u8 reg, unsigned offset, bool *bit) { - struct abx500_pinctrl *pct = to_abx500_pinctrl(chip); + struct abx500_pinctrl *pct = gpiochip_get_data(chip); u8 pos = offset % 8; u8 val; int ret; @@ -143,7 +134,7 @@ static int abx500_gpio_get_bit(struct gpio_chip *chip, u8 reg, static int abx500_gpio_set_bits(struct gpio_chip *chip, u8 reg, unsigned offset, int val) { - struct abx500_pinctrl *pct = to_abx500_pinctrl(chip); + struct abx500_pinctrl *pct = gpiochip_get_data(chip); u8 pos = offset % 8; int ret; @@ -164,7 +155,7 @@ static int abx500_gpio_set_bits(struct gpio_chip *chip, u8 reg, */ static int abx500_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct abx500_pinctrl *pct = to_abx500_pinctrl(chip); + struct abx500_pinctrl *pct = gpiochip_get_data(chip); bool bit; bool is_out; u8 gpio_offset = offset - 1; @@ -192,7 +183,7 @@ out: static void abx500_gpio_set(struct gpio_chip *chip, unsigned offset, int val) { - struct abx500_pinctrl *pct = to_abx500_pinctrl(chip); + struct abx500_pinctrl *pct = gpiochip_get_data(chip); int ret; ret = abx500_gpio_set_bits(chip, AB8500_GPIO_OUT1_REG, offset, val); @@ -272,7 +263,7 @@ out: static bool abx500_pullud_supported(struct gpio_chip *chip, unsigned gpio) { - struct abx500_pinctrl *pct = to_abx500_pinctrl(chip); + struct abx500_pinctrl *pct = gpiochip_get_data(chip); struct pullud *pullud = pct->soc->pullud; return (pullud && @@ -284,7 +275,7 @@ static int abx500_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int val) { - struct abx500_pinctrl *pct = to_abx500_pinctrl(chip); + struct abx500_pinctrl *pct = gpiochip_get_data(chip); unsigned gpio; int ret; @@ -332,7 +323,7 @@ static int abx500_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int abx500_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct abx500_pinctrl *pct = to_abx500_pinctrl(chip); + struct abx500_pinctrl *pct = gpiochip_get_data(chip); /* The AB8500 GPIO numbers are off by one */ int gpio = offset + 1; int hwirq; @@ -634,7 +625,7 @@ static void abx500_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { unsigned i; unsigned gpio = chip->base; - struct abx500_pinctrl *pct = to_abx500_pinctrl(chip); + struct abx500_pinctrl *pct = gpiochip_get_data(chip); struct pinctrl_dev *pctldev = pct->pctldev; for (i = 0; i < chip->ngpio; i++, gpio++) { @@ -1211,7 +1202,7 @@ static int abx500_gpio_probe(struct platform_device *pdev) pct->irq_cluster = pct->soc->gpio_irq_cluster; pct->irq_cluster_size = pct->soc->ngpio_irq_cluster; - ret = gpiochip_add(&pct->chip); + ret = gpiochip_add_data(&pct->chip, pct); if (ret) { dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret); return ret; -- cgit From de3d851beab55f36c7a555e313331c61bbb91f0b Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 08:33:09 +0100 Subject: pinctrl: adi2: 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(). Acked-by: Sonic Zhang Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-adi2.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/pinctrl/pinctrl-adi2.c b/drivers/pinctrl/pinctrl-adi2.c index fd342dffe4dc..9ad1a8d29bbe 100644 --- a/drivers/pinctrl/pinctrl-adi2.c +++ b/drivers/pinctrl/pinctrl-adi2.c @@ -636,7 +636,7 @@ static int adi_pinmux_set(struct pinctrl_dev *pctldev, unsigned func_id, if (range == NULL) /* should not happen */ return -ENODEV; - port = container_of(range->gc, struct gpio_port, chip); + port = gpiochip_get_data(range->gc); spin_lock_irqsave(&port->lock, flags); @@ -684,7 +684,7 @@ static int adi_pinmux_request_gpio(struct pinctrl_dev *pctldev, unsigned long flags; u8 offset; - port = container_of(range->gc, struct gpio_port, chip); + port = gpiochip_get_data(range->gc); offset = pin_to_offset(range, pin); spin_lock_irqsave(&port->lock, flags); @@ -718,7 +718,7 @@ static int adi_gpio_direction_input(struct gpio_chip *chip, unsigned offset) struct gpio_port *port; unsigned long flags; - port = container_of(chip, struct gpio_port, chip); + port = gpiochip_get_data(chip); spin_lock_irqsave(&port->lock, flags); @@ -733,7 +733,7 @@ static int adi_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static void adi_gpio_set_value(struct gpio_chip *chip, unsigned offset, int value) { - struct gpio_port *port = container_of(chip, struct gpio_port, chip); + struct gpio_port *port = gpiochip_get_data(chip); struct gpio_port_t *regs = port->regs; unsigned long flags; @@ -750,7 +750,7 @@ static void adi_gpio_set_value(struct gpio_chip *chip, unsigned offset, static int adi_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct gpio_port *port = container_of(chip, struct gpio_port, chip); + struct gpio_port *port = gpiochip_get_data(chip); struct gpio_port_t *regs = port->regs; unsigned long flags; @@ -770,7 +770,7 @@ static int adi_gpio_direction_output(struct gpio_chip *chip, unsigned offset, static int adi_gpio_get_value(struct gpio_chip *chip, unsigned offset) { - struct gpio_port *port = container_of(chip, struct gpio_port, chip); + struct gpio_port *port = gpiochip_get_data(chip); struct gpio_port_t *regs = port->regs; unsigned long flags; int ret; @@ -786,7 +786,7 @@ static int adi_gpio_get_value(struct gpio_chip *chip, unsigned offset) static int adi_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct gpio_port *port = container_of(chip, struct gpio_port, chip); + struct gpio_port *port = gpiochip_get_data(chip); if (port->irq_base >= 0) return irq_find_mapping(port->domain, offset); @@ -994,7 +994,7 @@ static int adi_gpio_probe(struct platform_device *pdev) port->chip.ngpio = port->width; gpio = port->chip.base + port->width; - ret = gpiochip_add(&port->chip); + ret = gpiochip_add_data(&port->chip, port); if (ret) { dev_err(&pdev->dev, "Fail to add GPIO chip.\n"); goto out_remove_domain; -- cgit From 04d367231162560a51e875836a1f2ebf41780adf Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 09:21:38 +0100 Subject: pinctrl: amd: 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: Ken Xue Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-amd.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c index a74b2b0a75e0..657449431301 100644 --- a/drivers/pinctrl/pinctrl-amd.c +++ b/drivers/pinctrl/pinctrl-amd.c @@ -35,16 +35,11 @@ #include "pinctrl-utils.h" #include "pinctrl-amd.h" -static inline struct amd_gpio *to_amd_gpio(struct gpio_chip *gc) -{ - return container_of(gc, struct amd_gpio, gc); -} - static int amd_gpio_direction_input(struct gpio_chip *gc, unsigned offset) { unsigned long flags; u32 pin_reg; - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + offset * 4); @@ -71,7 +66,7 @@ static int amd_gpio_direction_output(struct gpio_chip *gc, unsigned offset, { u32 pin_reg; unsigned long flags; - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + offset * 4); @@ -90,7 +85,7 @@ static int amd_gpio_get_value(struct gpio_chip *gc, unsigned offset) { u32 pin_reg; unsigned long flags; - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + offset * 4); @@ -103,7 +98,7 @@ static void amd_gpio_set_value(struct gpio_chip *gc, unsigned offset, int value) { u32 pin_reg; unsigned long flags; - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + offset * 4); @@ -122,7 +117,7 @@ static int amd_gpio_set_debounce(struct gpio_chip *gc, unsigned offset, u32 pin_reg; int ret = 0; unsigned long flags; - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + offset * 4); @@ -186,7 +181,7 @@ static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc) u32 pin_reg; unsigned long flags; unsigned int bank, i, pin_num; - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); char *level_trig; char *active_level; @@ -327,7 +322,7 @@ static void amd_gpio_irq_enable(struct irq_data *d) u32 pin_reg; unsigned long flags; struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + (d->hwirq)*4); @@ -351,7 +346,7 @@ static void amd_gpio_irq_disable(struct irq_data *d) u32 pin_reg; unsigned long flags; struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + (d->hwirq)*4); @@ -366,7 +361,7 @@ static void amd_gpio_irq_mask(struct irq_data *d) u32 pin_reg; unsigned long flags; struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + (d->hwirq)*4); @@ -380,7 +375,7 @@ static void amd_gpio_irq_unmask(struct irq_data *d) u32 pin_reg; unsigned long flags; struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + (d->hwirq)*4); @@ -394,7 +389,7 @@ static void amd_gpio_irq_eoi(struct irq_data *d) u32 reg; unsigned long flags; struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); reg = readl(gpio_dev->base + WAKE_INT_MASTER_REG); @@ -409,7 +404,7 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) u32 pin_reg; unsigned long flags; struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); spin_lock_irqsave(&gpio_dev->lock, flags); pin_reg = readl(gpio_dev->base + (d->hwirq)*4); @@ -504,7 +499,7 @@ static void amd_gpio_irq_handler(struct irq_desc *desc) unsigned long flags; struct irq_chip *chip = irq_desc_get_chip(desc); struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct amd_gpio *gpio_dev = to_amd_gpio(gc); + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); chained_irq_enter(chip, desc); /*enable GPIO interrupt again*/ @@ -795,7 +790,7 @@ static int amd_gpio_probe(struct platform_device *pdev) return PTR_ERR(gpio_dev->pctrl); } - ret = gpiochip_add(&gpio_dev->gc); + ret = gpiochip_add_data(&gpio_dev->gc, gpio_dev); if (ret) goto out1; -- cgit From f5bc3568db62c483049ce688baa06ff68dfb0fbd Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 09:24:32 +0100 Subject: pinctrl: as3722: 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: Andrew Bresticker Cc: Mallikarjun Kasoju Acked-by: Laxman Dewangan Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-as3722.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/pinctrl/pinctrl-as3722.c b/drivers/pinctrl/pinctrl-as3722.c index 89479bea6262..e844fdc6d3a8 100644 --- a/drivers/pinctrl/pinctrl-as3722.c +++ b/drivers/pinctrl/pinctrl-as3722.c @@ -436,14 +436,9 @@ static struct pinctrl_desc as3722_pinctrl_desc = { .owner = THIS_MODULE, }; -static inline struct as3722_pctrl_info *to_as_pci(struct gpio_chip *chip) -{ - return container_of(chip, struct as3722_pctrl_info, gpio_chip); -} - static int as3722_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct as3722_pctrl_info *as_pci = to_as_pci(chip); + struct as3722_pctrl_info *as_pci = gpiochip_get_data(chip); struct as3722 *as3722 = as_pci->as3722; int ret; u32 reg; @@ -491,7 +486,7 @@ static int as3722_gpio_get(struct gpio_chip *chip, unsigned offset) static void as3722_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct as3722_pctrl_info *as_pci = to_as_pci(chip); + struct as3722_pctrl_info *as_pci = gpiochip_get_data(chip); struct as3722 *as3722 = as_pci->as3722; int en_invert; u32 val; @@ -531,7 +526,7 @@ static int as3722_gpio_direction_output(struct gpio_chip *chip, static int as3722_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct as3722_pctrl_info *as_pci = to_as_pci(chip); + struct as3722_pctrl_info *as_pci = gpiochip_get_data(chip); return as3722_irq_get_virq(as_pci->as3722, offset); } @@ -584,7 +579,7 @@ static int as3722_pinctrl_probe(struct platform_device *pdev) as_pci->gpio_chip = as3722_gpio_chip; as_pci->gpio_chip.parent = &pdev->dev; as_pci->gpio_chip.of_node = pdev->dev.parent->of_node; - ret = gpiochip_add(&as_pci->gpio_chip); + ret = gpiochip_add_data(&as_pci->gpio_chip, as_pci); if (ret < 0) { dev_err(&pdev->dev, "Couldn't register gpiochip, %d\n", ret); goto fail_chip_add; -- cgit 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(-) 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 From 014c1b3de3bec90df119e718d3f9f131747609bf Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 09:33:30 +0100 Subject: pinctrl: u300: 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/pinctrl/pinctrl-coh901.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/drivers/pinctrl/pinctrl-coh901.c b/drivers/pinctrl/pinctrl-coh901.c index ca0fa79a286c..cf7788df0f95 100644 --- a/drivers/pinctrl/pinctrl-coh901.c +++ b/drivers/pinctrl/pinctrl-coh901.c @@ -208,25 +208,16 @@ bs335_gpio_config[U300_GPIO_NUM_PORTS][U300_GPIO_PINS_PER_PORT] = { } }; -/** - * to_u300_gpio() - get the pointer to u300_gpio - * @chip: the gpio chip member of the structure u300_gpio - */ -static inline struct u300_gpio *to_u300_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct u300_gpio, chip); -} - static int u300_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); return !!(readl(U300_PIN_REG(offset, dir)) & U300_PIN_BIT(offset)); } static void u300_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); unsigned long flags; u32 val; @@ -243,7 +234,7 @@ static void u300_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int u300_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); unsigned long flags; u32 val; @@ -259,7 +250,7 @@ static int u300_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int u300_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); unsigned long flags; u32 oldmode; u32 val; @@ -290,7 +281,7 @@ int u300_gpio_config_get(struct gpio_chip *chip, unsigned offset, unsigned long *config) { - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); enum pin_config_param param = (enum pin_config_param) *config; bool biasmode; u32 drmode; @@ -348,7 +339,7 @@ int u300_gpio_config_get(struct gpio_chip *chip, int u300_gpio_config_set(struct gpio_chip *chip, unsigned offset, enum pin_config_param param) { - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); unsigned long flags; u32 val; @@ -429,7 +420,7 @@ static void u300_toggle_trigger(struct u300_gpio *gpio, unsigned offset) static int u300_gpio_irq_type(struct irq_data *d, unsigned trigger) { struct gpio_chip *chip = irq_data_get_irq_chip_data(d); - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); struct u300_gpio_port *port = &gpio->ports[d->hwirq >> 3]; int offset = d->hwirq; u32 val; @@ -466,7 +457,7 @@ static int u300_gpio_irq_type(struct irq_data *d, unsigned trigger) static void u300_gpio_irq_enable(struct irq_data *d) { struct gpio_chip *chip = irq_data_get_irq_chip_data(d); - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); struct u300_gpio_port *port = &gpio->ports[d->hwirq >> 3]; int offset = d->hwirq; u32 val; @@ -483,7 +474,7 @@ static void u300_gpio_irq_enable(struct irq_data *d) static void u300_gpio_irq_disable(struct irq_data *d) { struct gpio_chip *chip = irq_data_get_irq_chip_data(d); - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); int offset = d->hwirq; u32 val; unsigned long flags; @@ -506,7 +497,7 @@ static void u300_gpio_irq_handler(struct irq_desc *desc) unsigned int irq = irq_desc_get_irq(desc); struct irq_chip *parent_chip = irq_desc_get_chip(desc); struct gpio_chip *chip = irq_desc_get_handler_data(desc); - struct u300_gpio *gpio = to_u300_gpio(chip); + struct u300_gpio *gpio = gpiochip_get_data(chip); struct u300_gpio_port *port = &gpio->ports[irq - chip->base]; int pinoffset = port->number << 3; /* get the right stride */ unsigned long val; @@ -684,7 +675,7 @@ static int __init u300_gpio_probe(struct platform_device *pdev) #ifdef CONFIG_OF_GPIO gpio->chip.of_node = pdev->dev.of_node; #endif - err = gpiochip_add(&gpio->chip); + err = gpiochip_add_data(&gpio->chip, gpio); if (err) { dev_err(gpio->dev, "unable to add gpiochip: %d\n", err); goto err_no_chip; -- cgit From 573718337f0359a935a276ce98996bbe062c926d Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 09:35:14 +0100 Subject: pinctrl: digicolor: 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(). Acked-by: Baruch Siach Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-digicolor.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/pinctrl-digicolor.c b/drivers/pinctrl/pinctrl-digicolor.c index d8efb2ccac6c..f1343d6ca823 100644 --- a/drivers/pinctrl/pinctrl-digicolor.c +++ b/drivers/pinctrl/pinctrl-digicolor.c @@ -171,7 +171,7 @@ static struct pinmux_ops dc_pmxops = { static int dc_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) { - struct dc_pinmap *pmap = container_of(chip, struct dc_pinmap, chip); + struct dc_pinmap *pmap = gpiochip_get_data(chip); int reg_off = GP_DRIVE0(gpio/PINS_PER_COLLECTION); int bit_off = gpio % PINS_PER_COLLECTION; u8 drive; @@ -191,7 +191,7 @@ static void dc_gpio_set(struct gpio_chip *chip, unsigned gpio, int value); static int dc_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value) { - struct dc_pinmap *pmap = container_of(chip, struct dc_pinmap, chip); + struct dc_pinmap *pmap = gpiochip_get_data(chip); int reg_off = GP_DRIVE0(gpio/PINS_PER_COLLECTION); int bit_off = gpio % PINS_PER_COLLECTION; u8 drive; @@ -210,7 +210,7 @@ static int dc_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, static int dc_gpio_get(struct gpio_chip *chip, unsigned gpio) { - struct dc_pinmap *pmap = container_of(chip, struct dc_pinmap, chip); + struct dc_pinmap *pmap = gpiochip_get_data(chip); int reg_off = GP_INPUT(gpio/PINS_PER_COLLECTION); int bit_off = gpio % PINS_PER_COLLECTION; u8 input; @@ -222,7 +222,7 @@ static int dc_gpio_get(struct gpio_chip *chip, unsigned gpio) static void dc_gpio_set(struct gpio_chip *chip, unsigned gpio, int value) { - struct dc_pinmap *pmap = container_of(chip, struct dc_pinmap, chip); + struct dc_pinmap *pmap = gpiochip_get_data(chip); int reg_off = GP_OUTPUT0(gpio/PINS_PER_COLLECTION); int bit_off = gpio % PINS_PER_COLLECTION; u8 output; @@ -258,7 +258,7 @@ static int dc_gpiochip_add(struct dc_pinmap *pmap, struct device_node *np) spin_lock_init(&pmap->lock); - ret = gpiochip_add(chip); + ret = gpiochip_add_data(chip, pmap); if (ret < 0) return ret; -- cgit From 3d18fb5c87576493a00fe51f09b6e82a17168177 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 09:37:00 +0100 Subject: pinctrl: pistachio: 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(). Acked-by: Andrew Bresticker Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-pistachio.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c index fd5148d106a3..856f736cb1a6 100644 --- a/drivers/pinctrl/pinctrl-pistachio.c +++ b/drivers/pinctrl/pinctrl-pistachio.c @@ -842,14 +842,9 @@ static inline void pctl_writel(struct pistachio_pinctrl *pctl, u32 val, u32 reg) writel(val, pctl->base + reg); } -static inline struct pistachio_gpio_bank *gc_to_bank(struct gpio_chip *gc) -{ - return container_of(gc, struct pistachio_gpio_bank, gpio_chip); -} - static inline struct pistachio_gpio_bank *irqd_to_bank(struct irq_data *d) { - return gc_to_bank(irq_data_get_irq_chip_data(d)); + return gpiochip_get_data(irq_data_get_irq_chip_data(d)); } static inline u32 gpio_readl(struct pistachio_gpio_bank *bank, u32 reg) @@ -992,7 +987,7 @@ static int pistachio_pinmux_enable(struct pinctrl_dev *pctldev, range = pinctrl_find_gpio_range_from_pin(pctl->pctldev, pg->pin); if (range) - gpio_disable(gc_to_bank(range->gc), pg->pin - range->pin_base); + gpio_disable(gpiochip_get_data(range->gc), pg->pin - range->pin_base); return 0; } @@ -1173,14 +1168,14 @@ static struct pinctrl_desc pistachio_pinctrl_desc = { static int pistachio_gpio_get_direction(struct gpio_chip *chip, unsigned offset) { - struct pistachio_gpio_bank *bank = gc_to_bank(chip); + struct pistachio_gpio_bank *bank = gpiochip_get_data(chip); return !(gpio_readl(bank, GPIO_OUTPUT_EN) & BIT(offset)); } static int pistachio_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct pistachio_gpio_bank *bank = gc_to_bank(chip); + struct pistachio_gpio_bank *bank = gpiochip_get_data(chip); u32 reg; if (gpio_readl(bank, GPIO_OUTPUT_EN) & BIT(offset)) @@ -1194,7 +1189,7 @@ static int pistachio_gpio_get(struct gpio_chip *chip, unsigned offset) static void pistachio_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct pistachio_gpio_bank *bank = gc_to_bank(chip); + struct pistachio_gpio_bank *bank = gpiochip_get_data(chip); gpio_mask_writel(bank, GPIO_OUTPUT, offset, !!value); } @@ -1202,7 +1197,7 @@ static void pistachio_gpio_set(struct gpio_chip *chip, unsigned offset, static int pistachio_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct pistachio_gpio_bank *bank = gc_to_bank(chip); + struct pistachio_gpio_bank *bank = gpiochip_get_data(chip); gpio_mask_writel(bank, GPIO_OUTPUT_EN, offset, 0); gpio_enable(bank, offset); @@ -1213,7 +1208,7 @@ static int pistachio_gpio_direction_input(struct gpio_chip *chip, static int pistachio_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct pistachio_gpio_bank *bank = gc_to_bank(chip); + struct pistachio_gpio_bank *bank = gpiochip_get_data(chip); pistachio_gpio_set(chip, offset, value); gpio_mask_writel(bank, GPIO_OUTPUT_EN, offset, 1); @@ -1303,7 +1298,7 @@ static int pistachio_gpio_irq_set_type(struct irq_data *data, unsigned int type) static void pistachio_gpio_irq_handler(struct irq_desc *desc) { struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct pistachio_gpio_bank *bank = gc_to_bank(gc); + struct pistachio_gpio_bank *bank = gpiochip_get_data(gc); struct irq_chip *chip = irq_desc_get_chip(desc); unsigned long pending; unsigned int pin; @@ -1390,7 +1385,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl) bank->gpio_chip.parent = pctl->dev; bank->gpio_chip.of_node = child; - ret = gpiochip_add(&bank->gpio_chip); + ret = gpiochip_add_data(&bank->gpio_chip, bank); if (ret < 0) { dev_err(pctl->dev, "Failed to add GPIO chip %u: %d\n", i, ret); -- cgit From 03bf81f1cb49a580d70b7514366760146c3da017 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 09:39:13 +0100 Subject: pinctrl: rockchip: 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(). Acked-by: Heiko Stuebner Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-rockchip.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 2b88a40f61d3..56b8ce2a3df9 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -224,11 +224,6 @@ static struct regmap_config rockchip_regmap_config = { .reg_stride = 4, }; -static inline struct rockchip_pin_bank *gc_to_pin_bank(struct gpio_chip *gc) -{ - return container_of(gc, struct rockchip_pin_bank, gpio_chip); -} - static const inline struct rockchip_pin_group *pinctrl_name_to_group( const struct rockchip_pinctrl *info, const char *name) @@ -939,7 +934,7 @@ static int _rockchip_pmx_gpio_set_direction(struct gpio_chip *chip, unsigned long flags; u32 data; - bank = gc_to_pin_bank(chip); + bank = gpiochip_get_data(chip); ret = rockchip_set_mux(bank, pin, RK_FUNC_GPIO); if (ret < 0) @@ -1376,7 +1371,7 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, static void rockchip_gpio_set(struct gpio_chip *gc, unsigned offset, int value) { - struct rockchip_pin_bank *bank = gc_to_pin_bank(gc); + struct rockchip_pin_bank *bank = gpiochip_get_data(gc); void __iomem *reg = bank->reg_base + GPIO_SWPORT_DR; unsigned long flags; u32 data; @@ -1400,7 +1395,7 @@ static void rockchip_gpio_set(struct gpio_chip *gc, unsigned offset, int value) */ static int rockchip_gpio_get(struct gpio_chip *gc, unsigned offset) { - struct rockchip_pin_bank *bank = gc_to_pin_bank(gc); + struct rockchip_pin_bank *bank = gpiochip_get_data(gc); u32 data; clk_enable(bank->clk); @@ -1439,7 +1434,7 @@ static int rockchip_gpio_direction_output(struct gpio_chip *gc, */ static int rockchip_gpio_to_irq(struct gpio_chip *gc, unsigned offset) { - struct rockchip_pin_bank *bank = gc_to_pin_bank(gc); + struct rockchip_pin_bank *bank = gpiochip_get_data(gc); unsigned int virq; if (!bank->domain) @@ -1758,7 +1753,7 @@ static int rockchip_gpiolib_register(struct platform_device *pdev, gc->of_node = bank->of_node; gc->label = bank->name; - ret = gpiochip_add(gc); + ret = gpiochip_add_data(gc, bank); if (ret) { dev_err(&pdev->dev, "failed to register gpio_chip %s, error code: %d\n", gc->label, ret); -- cgit From 2e862a7bd63f57fcaa4a3a4929f51c56289f1f80 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 09:45:18 +0100 Subject: pinctrl: st: 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: Srinivas Kandagatla Cc: Patrice Chotard Acked-by: Maxime Coquelin Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-st.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index 52639e65ea67..fac844a85cb4 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -203,9 +203,6 @@ #define gpio_range_to_bank(chip) \ container_of(chip, struct st_gpio_bank, range) -#define gpio_chip_to_bank(chip) \ - container_of(chip, struct st_gpio_bank, gpio_chip) - #define pc_to_bank(pc) \ container_of(pc, struct st_gpio_bank, pc) @@ -744,14 +741,14 @@ static void st_gpio_direction(struct st_gpio_bank *bank, static int st_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct st_gpio_bank *bank = gpio_chip_to_bank(chip); + struct st_gpio_bank *bank = gpiochip_get_data(chip); return !!(readl(bank->base + REG_PIO_PIN) & BIT(offset)); } static void st_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct st_gpio_bank *bank = gpio_chip_to_bank(chip); + struct st_gpio_bank *bank = gpiochip_get_data(chip); __st_gpio_set(bank, offset, value); } @@ -765,7 +762,7 @@ static int st_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int st_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct st_gpio_bank *bank = gpio_chip_to_bank(chip); + struct st_gpio_bank *bank = gpiochip_get_data(chip); __st_gpio_set(bank, offset, value); pinctrl_gpio_direction_output(chip->base + offset); @@ -775,7 +772,7 @@ static int st_gpio_direction_output(struct gpio_chip *chip, static int st_gpio_get_direction(struct gpio_chip *chip, unsigned offset) { - struct st_gpio_bank *bank = gpio_chip_to_bank(chip); + struct st_gpio_bank *bank = gpiochip_get_data(chip); struct st_pio_control pc = bank->pc; unsigned long config; unsigned int direction = 0; @@ -1325,7 +1322,7 @@ static int st_pctl_parse_functions(struct device_node *np, static void st_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct st_gpio_bank *bank = gpio_chip_to_bank(gc); + struct st_gpio_bank *bank = gpiochip_get_data(gc); writel(BIT(d->hwirq), bank->base + REG_PIO_CLR_PMASK); } @@ -1333,7 +1330,7 @@ static void st_gpio_irq_mask(struct irq_data *d) static void st_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct st_gpio_bank *bank = gpio_chip_to_bank(gc); + struct st_gpio_bank *bank = gpiochip_get_data(gc); writel(BIT(d->hwirq), bank->base + REG_PIO_SET_PMASK); } @@ -1341,7 +1338,7 @@ static void st_gpio_irq_unmask(struct irq_data *d) static int st_gpio_irq_set_type(struct irq_data *d, unsigned type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct st_gpio_bank *bank = gpio_chip_to_bank(gc); + struct st_gpio_bank *bank = gpiochip_get_data(gc); unsigned long flags; int comp, pin = d->hwirq; u32 val; @@ -1455,7 +1452,7 @@ static void st_gpio_irq_handler(struct irq_desc *desc) /* interrupt dedicated per bank */ struct irq_chip *chip = irq_desc_get_chip(desc); struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct st_gpio_bank *bank = gpio_chip_to_bank(gc); + struct st_gpio_bank *bank = gpiochip_get_data(gc); chained_irq_enter(chip, desc); __gpio_irq_handler(bank); @@ -1532,7 +1529,7 @@ static int st_gpiolib_register_bank(struct st_pinctrl *info, range->pin_base = range->base = range->id * ST_GPIO_PINS_PER_BANK; range->npins = bank->gpio_chip.ngpio; range->gc = &bank->gpio_chip; - err = gpiochip_add(&bank->gpio_chip); + err = gpiochip_add_data(&bank->gpio_chip, bank); if (err) { dev_err(dev, "Failed to add gpiochip(%d)!\n", bank_num); return err; -- cgit From fded3f40bf96d14a8c5bc3e4593e7cdc5709ab88 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 09:49:18 +0100 Subject: pinctrl: msm: use gpiochip data pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Stephen Boyd Cc: Björn Andersson Signed-off-by: Linus Walleij --- drivers/pinctrl/qcom/pinctrl-msm.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index af2a13040898..8777cf083eef 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c @@ -69,11 +69,6 @@ struct msm_pinctrl { void __iomem *regs; }; -static inline struct msm_pinctrl *to_msm_pinctrl(struct gpio_chip *gc) -{ - return container_of(gc, struct msm_pinctrl, chip); -} - static int msm_get_groups_count(struct pinctrl_dev *pctldev) { struct msm_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); @@ -381,7 +376,7 @@ static struct pinctrl_desc msm_pinctrl_desc = { static int msm_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { const struct msm_pingroup *g; - struct msm_pinctrl *pctrl = container_of(chip, struct msm_pinctrl, chip); + struct msm_pinctrl *pctrl = gpiochip_get_data(chip); unsigned long flags; u32 val; @@ -401,7 +396,7 @@ static int msm_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int msm_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { const struct msm_pingroup *g; - struct msm_pinctrl *pctrl = container_of(chip, struct msm_pinctrl, chip); + struct msm_pinctrl *pctrl = gpiochip_get_data(chip); unsigned long flags; u32 val; @@ -428,7 +423,7 @@ static int msm_gpio_direction_output(struct gpio_chip *chip, unsigned offset, in static int msm_gpio_get(struct gpio_chip *chip, unsigned offset) { const struct msm_pingroup *g; - struct msm_pinctrl *pctrl = container_of(chip, struct msm_pinctrl, chip); + struct msm_pinctrl *pctrl = gpiochip_get_data(chip); u32 val; g = &pctrl->soc->groups[offset]; @@ -440,7 +435,7 @@ static int msm_gpio_get(struct gpio_chip *chip, unsigned offset) static void msm_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { const struct msm_pingroup *g; - struct msm_pinctrl *pctrl = container_of(chip, struct msm_pinctrl, chip); + struct msm_pinctrl *pctrl = gpiochip_get_data(chip); unsigned long flags; u32 val; @@ -468,7 +463,7 @@ static void msm_gpio_dbg_show_one(struct seq_file *s, unsigned gpio) { const struct msm_pingroup *g; - struct msm_pinctrl *pctrl = container_of(chip, struct msm_pinctrl, chip); + struct msm_pinctrl *pctrl = gpiochip_get_data(chip); unsigned func; int is_out; int drive; @@ -567,7 +562,7 @@ static void msm_gpio_update_dual_edge_pos(struct msm_pinctrl *pctrl, static void msm_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct msm_pinctrl *pctrl = to_msm_pinctrl(gc); + struct msm_pinctrl *pctrl = gpiochip_get_data(gc); const struct msm_pingroup *g; unsigned long flags; u32 val; @@ -588,7 +583,7 @@ static void msm_gpio_irq_mask(struct irq_data *d) static void msm_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct msm_pinctrl *pctrl = to_msm_pinctrl(gc); + struct msm_pinctrl *pctrl = gpiochip_get_data(gc); const struct msm_pingroup *g; unsigned long flags; u32 val; @@ -613,7 +608,7 @@ static void msm_gpio_irq_unmask(struct irq_data *d) static void msm_gpio_irq_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct msm_pinctrl *pctrl = to_msm_pinctrl(gc); + struct msm_pinctrl *pctrl = gpiochip_get_data(gc); const struct msm_pingroup *g; unsigned long flags; u32 val; @@ -638,7 +633,7 @@ static void msm_gpio_irq_ack(struct irq_data *d) static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct msm_pinctrl *pctrl = to_msm_pinctrl(gc); + struct msm_pinctrl *pctrl = gpiochip_get_data(gc); const struct msm_pingroup *g; unsigned long flags; u32 val; @@ -732,7 +727,7 @@ static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int type) static int msm_gpio_irq_set_wake(struct irq_data *d, unsigned int on) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct msm_pinctrl *pctrl = to_msm_pinctrl(gc); + struct msm_pinctrl *pctrl = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&pctrl->lock, flags); @@ -757,7 +752,7 @@ static void msm_gpio_irq_handler(struct irq_desc *desc) { struct gpio_chip *gc = irq_desc_get_handler_data(desc); const struct msm_pingroup *g; - struct msm_pinctrl *pctrl = to_msm_pinctrl(gc); + struct msm_pinctrl *pctrl = gpiochip_get_data(gc); struct irq_chip *chip = irq_desc_get_chip(desc); int irq_pin; int handled = 0; @@ -804,7 +799,7 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl) chip->owner = THIS_MODULE; chip->of_node = pctrl->dev->of_node; - ret = gpiochip_add(&pctrl->chip); + ret = gpiochip_add_data(&pctrl->chip, pctrl); if (ret) { dev_err(pctrl->dev, "Failed register gpiochip\n"); return ret; -- cgit From c52d9df14ba75af351a2be7cc49f9e055192af93 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 09:51:47 +0100 Subject: pinctrl: spmi: use gpiochip data pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Ivan T. Ivanov Cc: Björn Andersson Signed-off-by: Linus Walleij --- drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c index 4460b2c9c8bd..23553ecd8115 100644 --- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c @@ -158,11 +158,6 @@ static const char *const pmic_gpio_functions[] = { PMIC_GPIO_FUNC_DTEST3, PMIC_GPIO_FUNC_DTEST4, }; -static inline struct pmic_gpio_state *to_gpio_state(struct gpio_chip *chip) -{ - return container_of(chip, struct pmic_gpio_state, chip); -}; - static int pmic_gpio_read(struct pmic_gpio_state *state, struct pmic_gpio_pad *pad, unsigned int addr) { @@ -495,7 +490,7 @@ static const struct pinconf_ops pmic_gpio_pinconf_ops = { static int pmic_gpio_direction_input(struct gpio_chip *chip, unsigned pin) { - struct pmic_gpio_state *state = to_gpio_state(chip); + struct pmic_gpio_state *state = gpiochip_get_data(chip); unsigned long config; config = pinconf_to_config_packed(PIN_CONFIG_INPUT_ENABLE, 1); @@ -506,7 +501,7 @@ static int pmic_gpio_direction_input(struct gpio_chip *chip, unsigned pin) static int pmic_gpio_direction_output(struct gpio_chip *chip, unsigned pin, int val) { - struct pmic_gpio_state *state = to_gpio_state(chip); + struct pmic_gpio_state *state = gpiochip_get_data(chip); unsigned long config; config = pinconf_to_config_packed(PIN_CONFIG_OUTPUT, val); @@ -516,7 +511,7 @@ static int pmic_gpio_direction_output(struct gpio_chip *chip, static int pmic_gpio_get(struct gpio_chip *chip, unsigned pin) { - struct pmic_gpio_state *state = to_gpio_state(chip); + struct pmic_gpio_state *state = gpiochip_get_data(chip); struct pmic_gpio_pad *pad; int ret; @@ -538,7 +533,7 @@ static int pmic_gpio_get(struct gpio_chip *chip, unsigned pin) static void pmic_gpio_set(struct gpio_chip *chip, unsigned pin, int value) { - struct pmic_gpio_state *state = to_gpio_state(chip); + struct pmic_gpio_state *state = gpiochip_get_data(chip); unsigned long config; config = pinconf_to_config_packed(PIN_CONFIG_OUTPUT, value); @@ -561,7 +556,7 @@ static int pmic_gpio_of_xlate(struct gpio_chip *chip, static int pmic_gpio_to_irq(struct gpio_chip *chip, unsigned pin) { - struct pmic_gpio_state *state = to_gpio_state(chip); + struct pmic_gpio_state *state = gpiochip_get_data(chip); struct pmic_gpio_pad *pad; pad = state->ctrl->desc->pins[pin].drv_data; @@ -571,7 +566,7 @@ static int pmic_gpio_to_irq(struct gpio_chip *chip, unsigned pin) static void pmic_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { - struct pmic_gpio_state *state = to_gpio_state(chip); + struct pmic_gpio_state *state = gpiochip_get_data(chip); unsigned i; for (i = 0; i < chip->ngpio; i++) { @@ -771,7 +766,7 @@ static int pmic_gpio_probe(struct platform_device *pdev) if (IS_ERR(state->ctrl)) return PTR_ERR(state->ctrl); - ret = gpiochip_add(&state->chip); + ret = gpiochip_add_data(&state->chip, state); if (ret) { dev_err(state->dev, "can't add gpio chip\n"); goto err_chip; -- cgit From 064761d1566617018567ed4d18bbb82519c01506 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 09:53:39 +0100 Subject: pinctrl: spmi-mpp: use gpiochip data pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Björn Andersson Cc: Ivan T. Ivanov Signed-off-by: Linus Walleij --- drivers/pinctrl/qcom/pinctrl-spmi-mpp.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c index ea1d2b2f6fd1..f49713d199ca 100644 --- a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c +++ b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c @@ -178,11 +178,6 @@ static const char *const pmic_mpp_functions[] = { "digital", "analog", "sink" }; -static inline struct pmic_mpp_state *to_mpp_state(struct gpio_chip *chip) -{ - return container_of(chip, struct pmic_mpp_state, chip); -}; - static int pmic_mpp_read(struct pmic_mpp_state *state, struct pmic_mpp_pad *pad, unsigned int addr) { @@ -556,7 +551,7 @@ static const struct pinconf_ops pmic_mpp_pinconf_ops = { static int pmic_mpp_direction_input(struct gpio_chip *chip, unsigned pin) { - struct pmic_mpp_state *state = to_mpp_state(chip); + struct pmic_mpp_state *state = gpiochip_get_data(chip); unsigned long config; config = pinconf_to_config_packed(PIN_CONFIG_INPUT_ENABLE, 1); @@ -567,7 +562,7 @@ static int pmic_mpp_direction_input(struct gpio_chip *chip, unsigned pin) static int pmic_mpp_direction_output(struct gpio_chip *chip, unsigned pin, int val) { - struct pmic_mpp_state *state = to_mpp_state(chip); + struct pmic_mpp_state *state = gpiochip_get_data(chip); unsigned long config; config = pinconf_to_config_packed(PIN_CONFIG_OUTPUT, val); @@ -577,7 +572,7 @@ static int pmic_mpp_direction_output(struct gpio_chip *chip, static int pmic_mpp_get(struct gpio_chip *chip, unsigned pin) { - struct pmic_mpp_state *state = to_mpp_state(chip); + struct pmic_mpp_state *state = gpiochip_get_data(chip); struct pmic_mpp_pad *pad; int ret; @@ -596,7 +591,7 @@ static int pmic_mpp_get(struct gpio_chip *chip, unsigned pin) static void pmic_mpp_set(struct gpio_chip *chip, unsigned pin, int value) { - struct pmic_mpp_state *state = to_mpp_state(chip); + struct pmic_mpp_state *state = gpiochip_get_data(chip); unsigned long config; config = pinconf_to_config_packed(PIN_CONFIG_OUTPUT, value); @@ -619,7 +614,7 @@ static int pmic_mpp_of_xlate(struct gpio_chip *chip, static int pmic_mpp_to_irq(struct gpio_chip *chip, unsigned pin) { - struct pmic_mpp_state *state = to_mpp_state(chip); + struct pmic_mpp_state *state = gpiochip_get_data(chip); struct pmic_mpp_pad *pad; pad = state->ctrl->desc->pins[pin].drv_data; @@ -629,7 +624,7 @@ static int pmic_mpp_to_irq(struct gpio_chip *chip, unsigned pin) static void pmic_mpp_dbg_show(struct seq_file *s, struct gpio_chip *chip) { - struct pmic_mpp_state *state = to_mpp_state(chip); + struct pmic_mpp_state *state = gpiochip_get_data(chip); unsigned i; for (i = 0; i < chip->ngpio; i++) { @@ -873,7 +868,7 @@ static int pmic_mpp_probe(struct platform_device *pdev) if (IS_ERR(state->ctrl)) return PTR_ERR(state->ctrl); - ret = gpiochip_add(&state->chip); + ret = gpiochip_add_data(&state->chip, state); if (ret) { dev_err(state->dev, "can't add gpio chip\n"); goto err_chip; -- cgit From ed47941a17993cc455b1009a9810b85faa02c23f Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 10:13:53 +0100 Subject: pinctrl: ssbi-mpp: use gpiochip data pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Björn Andersson Signed-off-by: Linus Walleij --- drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c b/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c index 629642b73489..6c8ad0ee8554 100644 --- a/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c +++ b/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c @@ -448,7 +448,7 @@ static struct pinctrl_desc pm8xxx_pinctrl_desc = { static int pm8xxx_mpp_direction_input(struct gpio_chip *chip, unsigned offset) { - struct pm8xxx_mpp *pctrl = container_of(chip, struct pm8xxx_mpp, chip); + struct pm8xxx_mpp *pctrl = gpiochip_get_data(chip); struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; switch (pin->mode) { @@ -472,7 +472,7 @@ static int pm8xxx_mpp_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct pm8xxx_mpp *pctrl = container_of(chip, struct pm8xxx_mpp, chip); + struct pm8xxx_mpp *pctrl = gpiochip_get_data(chip); struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; switch (pin->mode) { @@ -496,7 +496,7 @@ static int pm8xxx_mpp_direction_output(struct gpio_chip *chip, static int pm8xxx_mpp_get(struct gpio_chip *chip, unsigned offset) { - struct pm8xxx_mpp *pctrl = container_of(chip, struct pm8xxx_mpp, chip); + struct pm8xxx_mpp *pctrl = gpiochip_get_data(chip); struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; bool state; int ret; @@ -513,7 +513,7 @@ static int pm8xxx_mpp_get(struct gpio_chip *chip, unsigned offset) static void pm8xxx_mpp_set(struct gpio_chip *chip, unsigned offset, int value) { - struct pm8xxx_mpp *pctrl = container_of(chip, struct pm8xxx_mpp, chip); + struct pm8xxx_mpp *pctrl = gpiochip_get_data(chip); struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; pin->output_value = !!value; @@ -537,7 +537,7 @@ static int pm8xxx_mpp_of_xlate(struct gpio_chip *chip, static int pm8xxx_mpp_to_irq(struct gpio_chip *chip, unsigned offset) { - struct pm8xxx_mpp *pctrl = container_of(chip, struct pm8xxx_mpp, chip); + struct pm8xxx_mpp *pctrl = gpiochip_get_data(chip); struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; return pin->irq; @@ -552,7 +552,7 @@ static void pm8xxx_mpp_dbg_show_one(struct seq_file *s, unsigned offset, unsigned gpio) { - struct pm8xxx_mpp *pctrl = container_of(chip, struct pm8xxx_mpp, chip); + struct pm8xxx_mpp *pctrl = gpiochip_get_data(chip); struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; static const char * const aout_lvls[] = { @@ -826,7 +826,7 @@ static int pm8xxx_mpp_probe(struct platform_device *pdev) pctrl->chip.of_gpio_n_cells = 2; pctrl->chip.label = dev_name(pctrl->dev); pctrl->chip.ngpio = pctrl->npins; - ret = gpiochip_add(&pctrl->chip); + ret = gpiochip_add_data(&pctrl->chip, pctrl); if (ret) { dev_err(&pdev->dev, "failed register gpiochip\n"); goto unregister_pinctrl; -- cgit From 378596f99460ebd255dc3f5c1bc67a9ff09273f3 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 10:16:00 +0100 Subject: pinctrl: ssbi-gpio: use gpiochip data pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Björn Andersson Signed-off-by: Linus Walleij --- drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c index 7bea0df06fb1..c01f51d094f7 100644 --- a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c +++ b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c @@ -443,7 +443,7 @@ static struct pinctrl_desc pm8xxx_pinctrl_desc = { static int pm8xxx_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct pm8xxx_gpio *pctrl = container_of(chip, struct pm8xxx_gpio, chip); + struct pm8xxx_gpio *pctrl = gpiochip_get_data(chip); struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; u8 val; @@ -459,7 +459,7 @@ static int pm8xxx_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct pm8xxx_gpio *pctrl = container_of(chip, struct pm8xxx_gpio, chip); + struct pm8xxx_gpio *pctrl = gpiochip_get_data(chip); struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; u8 val; @@ -477,7 +477,7 @@ static int pm8xxx_gpio_direction_output(struct gpio_chip *chip, static int pm8xxx_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct pm8xxx_gpio *pctrl = container_of(chip, struct pm8xxx_gpio, chip); + struct pm8xxx_gpio *pctrl = gpiochip_get_data(chip); struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; bool state; int ret; @@ -495,7 +495,7 @@ static int pm8xxx_gpio_get(struct gpio_chip *chip, unsigned offset) static void pm8xxx_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct pm8xxx_gpio *pctrl = container_of(chip, struct pm8xxx_gpio, chip); + struct pm8xxx_gpio *pctrl = gpiochip_get_data(chip); struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; u8 val; @@ -524,7 +524,7 @@ static int pm8xxx_gpio_of_xlate(struct gpio_chip *chip, static int pm8xxx_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct pm8xxx_gpio *pctrl = container_of(chip, struct pm8xxx_gpio, chip); + struct pm8xxx_gpio *pctrl = gpiochip_get_data(chip); struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; return pin->irq; @@ -539,7 +539,7 @@ static void pm8xxx_gpio_dbg_show_one(struct seq_file *s, unsigned offset, unsigned gpio) { - struct pm8xxx_gpio *pctrl = container_of(chip, struct pm8xxx_gpio, chip); + struct pm8xxx_gpio *pctrl = gpiochip_get_data(chip); struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; static const char * const modes[] = { @@ -735,7 +735,7 @@ static int pm8xxx_gpio_probe(struct platform_device *pdev) pctrl->chip.of_gpio_n_cells = 2; pctrl->chip.label = dev_name(pctrl->dev); pctrl->chip.ngpio = pctrl->npins; - ret = gpiochip_add(&pctrl->chip); + ret = gpiochip_add_data(&pctrl->chip, pctrl); if (ret) { dev_err(&pdev->dev, "failed register gpiochip\n"); goto unregister_pinctrl; -- cgit From 9f57f81c129f0f9456f78f00235f70ac5e21e0f5 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 10:18:50 +0100 Subject: pinctrl: samsung: 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: Tomasz Figa Signed-off-by: Linus Walleij --- drivers/pinctrl/samsung/pinctrl-samsung.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c index bb4db2050f19..a4fb8379f521 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.c +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c @@ -50,11 +50,6 @@ static LIST_HEAD(drvdata_list); static unsigned int pin_base; -static inline struct samsung_pin_bank *gc_to_pin_bank(struct gpio_chip *gc) -{ - return container_of(gc, struct samsung_pin_bank, gpio_chip); -} - static int samsung_get_group_count(struct pinctrl_dev *pctldev) { struct samsung_pinctrl_drv_data *pmx = pinctrl_dev_get_drvdata(pctldev); @@ -522,7 +517,7 @@ static const struct pinconf_ops samsung_pinconf_ops = { /* gpiolib gpio_set callback function */ static void samsung_gpio_set(struct gpio_chip *gc, unsigned offset, int value) { - struct samsung_pin_bank *bank = gc_to_pin_bank(gc); + struct samsung_pin_bank *bank = gpiochip_get_data(gc); const struct samsung_pin_bank_type *type = bank->type; unsigned long flags; void __iomem *reg; @@ -546,7 +541,7 @@ static int samsung_gpio_get(struct gpio_chip *gc, unsigned offset) { void __iomem *reg; u32 data; - struct samsung_pin_bank *bank = gc_to_pin_bank(gc); + struct samsung_pin_bank *bank = gpiochip_get_data(gc); const struct samsung_pin_bank_type *type = bank->type; reg = bank->drvdata->virt_base + bank->pctl_offset; @@ -571,7 +566,7 @@ static int samsung_gpio_set_direction(struct gpio_chip *gc, u32 data, mask, shift; unsigned long flags; - bank = gc_to_pin_bank(gc); + bank = gpiochip_get_data(gc); type = bank->type; drvdata = bank->drvdata; @@ -619,7 +614,7 @@ static int samsung_gpio_direction_output(struct gpio_chip *gc, unsigned offset, */ static int samsung_gpio_to_irq(struct gpio_chip *gc, unsigned offset) { - struct samsung_pin_bank *bank = gc_to_pin_bank(gc); + struct samsung_pin_bank *bank = gpiochip_get_data(gc); unsigned int virq; if (!bank->irq_domain) @@ -918,7 +913,7 @@ static int samsung_gpiolib_register(struct platform_device *pdev, gc->of_node = bank->of_node; gc->label = bank->name; - ret = gpiochip_add(gc); + ret = gpiochip_add_data(gc, bank); if (ret) { dev_err(&pdev->dev, "failed to register gpio_chip %s, error code: %d\n", gc->label, ret); -- cgit From 88057d6e4a2a9c221bf81cfd18f25d0ff956af9e Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 22:40:43 +0100 Subject: pinctrl: sunxi: 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: Chen-Yu Tsai Acked-by: Maxime Ripard Signed-off-by: Linus Walleij --- drivers/pinctrl/sunxi/pinctrl-sunxi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index c53a2dbdb5cf..7a2465f5e71e 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include #include @@ -454,7 +454,7 @@ static int sunxi_pinctrl_gpio_direction_input(struct gpio_chip *chip, static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->parent); + struct sunxi_pinctrl *pctl = gpiochip_get_data(chip); u32 reg = sunxi_data_reg(offset); u8 index = sunxi_data_offset(offset); u32 set_mux = pctl->desc->irq_read_needs_mux && @@ -475,7 +475,7 @@ static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset) static void sunxi_pinctrl_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->parent); + struct sunxi_pinctrl *pctl = gpiochip_get_data(chip); u32 reg = sunxi_data_reg(offset); u8 index = sunxi_data_offset(offset); unsigned long flags; @@ -522,7 +522,7 @@ static int sunxi_pinctrl_gpio_of_xlate(struct gpio_chip *gc, static int sunxi_pinctrl_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->parent); + struct sunxi_pinctrl *pctl = gpiochip_get_data(chip); struct sunxi_desc_function *desc; unsigned pinnum = pctl->desc->pin_base + offset; unsigned irqnum; @@ -962,7 +962,7 @@ int sunxi_pinctrl_init(struct platform_device *pdev, pctl->chip->parent = &pdev->dev; pctl->chip->base = pctl->desc->pin_base; - ret = gpiochip_add(pctl->chip); + ret = gpiochip_add_data(pctl->chip, pctl); if (ret) goto pinctrl_error; -- cgit From 7cb093c4bce3a145cc1586d4464cd362376c2cc6 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 10:24:54 +0100 Subject: pinctrl: sh-pfc: 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: Geert Uytterhoeven Cc: Laurent Pinchart Signed-off-by: Linus Walleij --- drivers/pinctrl/sh-pfc/gpio.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/sh-pfc/gpio.c b/drivers/pinctrl/sh-pfc/gpio.c index cdb2460a7b00..a6681b8b17c3 100644 --- a/drivers/pinctrl/sh-pfc/gpio.c +++ b/drivers/pinctrl/sh-pfc/gpio.c @@ -38,14 +38,10 @@ struct sh_pfc_chip { struct sh_pfc_gpio_pin *pins; }; -static struct sh_pfc_chip *gpio_to_pfc_chip(struct gpio_chip *gc) -{ - return container_of(gc, struct sh_pfc_chip, gpio_chip); -} - static struct sh_pfc *gpio_to_pfc(struct gpio_chip *gc) { - return gpio_to_pfc_chip(gc)->pfc; + struct sh_pfc_chip *chip = gpiochip_get_data(gc); + return chip->pfc; } static void gpio_get_data_reg(struct sh_pfc_chip *chip, unsigned int offset, @@ -178,14 +174,14 @@ static int gpio_pin_direction_input(struct gpio_chip *gc, unsigned offset) static int gpio_pin_direction_output(struct gpio_chip *gc, unsigned offset, int value) { - gpio_pin_set_value(gpio_to_pfc_chip(gc), offset, value); + gpio_pin_set_value(gpiochip_get_data(gc), offset, value); return pinctrl_gpio_direction_output(offset); } static int gpio_pin_get(struct gpio_chip *gc, unsigned offset) { - struct sh_pfc_chip *chip = gpio_to_pfc_chip(gc); + struct sh_pfc_chip *chip = gpiochip_get_data(gc); struct sh_pfc_gpio_data_reg *reg; unsigned int bit; unsigned int pos; @@ -199,7 +195,7 @@ static int gpio_pin_get(struct gpio_chip *gc, unsigned offset) static void gpio_pin_set(struct gpio_chip *gc, unsigned offset, int value) { - gpio_pin_set_value(gpio_to_pfc_chip(gc), offset, value); + gpio_pin_set_value(gpiochip_get_data(gc), offset, value); } static int gpio_pin_to_irq(struct gpio_chip *gc, unsigned offset) @@ -322,7 +318,7 @@ sh_pfc_add_gpiochip(struct sh_pfc *pfc, int(*setup)(struct sh_pfc_chip *), if (ret < 0) return ERR_PTR(ret); - ret = gpiochip_add(&chip->gpio_chip); + ret = gpiochip_add_data(&chip->gpio_chip, chip); if (unlikely(ret < 0)) return ERR_PTR(ret); -- cgit 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(-) 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 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(-) 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 From cff4c7efbc2a1771af431edad6cf1df2a9d9dd46 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 10:31:35 +0100 Subject: pinctrl: spear-plgpio: 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: spear-devel@list.st.com Acked-by: Viresh Kumar Signed-off-by: Linus Walleij --- drivers/pinctrl/spear/pinctrl-plgpio.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/pinctrl/spear/pinctrl-plgpio.c b/drivers/pinctrl/spear/pinctrl-plgpio.c index 925f597de266..4c9b863f8267 100644 --- a/drivers/pinctrl/spear/pinctrl-plgpio.c +++ b/drivers/pinctrl/spear/pinctrl-plgpio.c @@ -107,7 +107,7 @@ static inline void plgpio_reg_reset(void __iomem *base, u32 pin, u32 reg) /* gpio framework specific routines */ static int plgpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct plgpio *plgpio = container_of(chip, struct plgpio, chip); + struct plgpio *plgpio = gpiochip_get_data(chip); unsigned long flags; /* get correct offset for "offset" pin */ @@ -127,7 +127,7 @@ static int plgpio_direction_input(struct gpio_chip *chip, unsigned offset) static int plgpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct plgpio *plgpio = container_of(chip, struct plgpio, chip); + struct plgpio *plgpio = gpiochip_get_data(chip); unsigned long flags; unsigned dir_offset = offset, wdata_offset = offset, tmp; @@ -159,7 +159,7 @@ static int plgpio_direction_output(struct gpio_chip *chip, unsigned offset, static int plgpio_get_value(struct gpio_chip *chip, unsigned offset) { - struct plgpio *plgpio = container_of(chip, struct plgpio, chip); + struct plgpio *plgpio = gpiochip_get_data(chip); if (offset >= chip->ngpio) return -EINVAL; @@ -176,7 +176,7 @@ static int plgpio_get_value(struct gpio_chip *chip, unsigned offset) static void plgpio_set_value(struct gpio_chip *chip, unsigned offset, int value) { - struct plgpio *plgpio = container_of(chip, struct plgpio, chip); + struct plgpio *plgpio = gpiochip_get_data(chip); if (offset >= chip->ngpio) return; @@ -196,7 +196,7 @@ static void plgpio_set_value(struct gpio_chip *chip, unsigned offset, int value) static int plgpio_request(struct gpio_chip *chip, unsigned offset) { - struct plgpio *plgpio = container_of(chip, struct plgpio, chip); + struct plgpio *plgpio = gpiochip_get_data(chip); int gpio = chip->base + offset; unsigned long flags; int ret = 0; @@ -248,7 +248,7 @@ err0: static void plgpio_free(struct gpio_chip *chip, unsigned offset) { - struct plgpio *plgpio = container_of(chip, struct plgpio, chip); + struct plgpio *plgpio = gpiochip_get_data(chip); int gpio = chip->base + offset; unsigned long flags; @@ -280,7 +280,7 @@ disable_clk: static void plgpio_irq_disable(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct plgpio *plgpio = container_of(gc, struct plgpio, chip); + struct plgpio *plgpio = gpiochip_get_data(gc); int offset = d->hwirq; unsigned long flags; @@ -299,7 +299,7 @@ static void plgpio_irq_disable(struct irq_data *d) static void plgpio_irq_enable(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct plgpio *plgpio = container_of(gc, struct plgpio, chip); + struct plgpio *plgpio = gpiochip_get_data(gc); int offset = d->hwirq; unsigned long flags; @@ -318,7 +318,7 @@ static void plgpio_irq_enable(struct irq_data *d) static int plgpio_irq_set_type(struct irq_data *d, unsigned trigger) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct plgpio *plgpio = container_of(gc, struct plgpio, chip); + struct plgpio *plgpio = gpiochip_get_data(gc); int offset = d->hwirq; void __iomem *reg_off; unsigned int supported_type = 0, val; @@ -359,7 +359,7 @@ static struct irq_chip plgpio_irqchip = { static void plgpio_irq_handler(struct irq_desc *desc) { struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct plgpio *plgpio = container_of(gc, struct plgpio, chip); + struct plgpio *plgpio = gpiochip_get_data(gc); struct irq_chip *irqchip = irq_desc_get_chip(desc); int regs_count, count, pin, offset, i = 0; unsigned long pending; @@ -573,7 +573,7 @@ static int plgpio_probe(struct platform_device *pdev) } } - ret = gpiochip_add(&plgpio->chip); + ret = gpiochip_add_data(&plgpio->chip, plgpio); if (ret) { dev_err(&pdev->dev, "unable to add gpio chip\n"); goto unprepare_clk; -- cgit From 11aa679a6a0b20fe105a7a955a82153e255bae74 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 22:06:23 +0100 Subject: pinctrl: mediatek: 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(). Acked-by: Matthias Brugger Signed-off-by: Linus Walleij --- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c index 9ddba444e127..cfba56b43658 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c @@ -14,7 +14,7 @@ */ #include -#include +#include #include #include #include @@ -95,7 +95,7 @@ static void mtk_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { unsigned int reg_addr; unsigned int bit; - struct mtk_pinctrl *pctl = dev_get_drvdata(chip->parent); + struct mtk_pinctrl *pctl = gpiochip_get_data(chip); reg_addr = mtk_get_port(pctl, offset) + pctl->devdata->dout_offset; bit = BIT(offset & 0xf); @@ -742,7 +742,7 @@ static int mtk_gpio_get_direction(struct gpio_chip *chip, unsigned offset) unsigned int bit; unsigned int read_val = 0; - struct mtk_pinctrl *pctl = dev_get_drvdata(chip->parent); + struct mtk_pinctrl *pctl = gpiochip_get_data(chip); reg_addr = mtk_get_port(pctl, offset) + pctl->devdata->dir_offset; bit = BIT(offset & 0xf); @@ -755,7 +755,7 @@ static int mtk_gpio_get(struct gpio_chip *chip, unsigned offset) unsigned int reg_addr; unsigned int bit; unsigned int read_val = 0; - struct mtk_pinctrl *pctl = dev_get_drvdata(chip->parent); + struct mtk_pinctrl *pctl = gpiochip_get_data(chip); reg_addr = mtk_get_port(pctl, offset) + pctl->devdata->din_offset; @@ -768,7 +768,7 @@ static int mtk_gpio_get(struct gpio_chip *chip, unsigned offset) static int mtk_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { const struct mtk_desc_pin *pin; - struct mtk_pinctrl *pctl = dev_get_drvdata(chip->parent); + struct mtk_pinctrl *pctl = gpiochip_get_data(chip); int irq; pin = pctl->devdata->pins + offset; @@ -1348,7 +1348,7 @@ int mtk_pctrl_init(struct platform_device *pdev, pctl->chip->parent = &pdev->dev; pctl->chip->base = -1; - ret = gpiochip_add(pctl->chip); + ret = gpiochip_add_data(pctl->chip, pctl); if (ret) { ret = -EINVAL; goto pctrl_error; -- cgit From 80036f88db18b98bc20f7321dbd5f9947576a2b2 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 22:12:11 +0100 Subject: pinctrl: at91-pio4: 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: Ludovic Desroches Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-at91-pio4.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c index f1daf8580167..27540f5a1067 100644 --- a/drivers/pinctrl/pinctrl-at91-pio4.c +++ b/drivers/pinctrl/pinctrl-at91-pio4.c @@ -15,6 +15,8 @@ */ #include +#include +/* FIXME: needed for gpio_to_irq(), get rid of this */ #include #include #include @@ -290,7 +292,7 @@ static void atmel_gpio_irq_handler(struct irq_desc *desc) static int atmel_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(chip->parent); + struct atmel_pioctrl *atmel_pioctrl = gpiochip_get_data(chip); struct atmel_pin *pin = atmel_pioctrl->pins[offset]; unsigned reg; @@ -305,7 +307,7 @@ static int atmel_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int atmel_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(chip->parent); + struct atmel_pioctrl *atmel_pioctrl = gpiochip_get_data(chip); struct atmel_pin *pin = atmel_pioctrl->pins[offset]; unsigned reg; @@ -317,7 +319,7 @@ static int atmel_gpio_get(struct gpio_chip *chip, unsigned offset) static int atmel_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(chip->parent); + struct atmel_pioctrl *atmel_pioctrl = gpiochip_get_data(chip); struct atmel_pin *pin = atmel_pioctrl->pins[offset]; unsigned reg; @@ -336,7 +338,7 @@ static int atmel_gpio_direction_output(struct gpio_chip *chip, unsigned offset, static void atmel_gpio_set(struct gpio_chip *chip, unsigned offset, int val) { - struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(chip->parent); + struct atmel_pioctrl *atmel_pioctrl = gpiochip_get_data(chip); struct atmel_pin *pin = atmel_pioctrl->pins[offset]; atmel_gpio_write(atmel_pioctrl, pin->bank, @@ -346,7 +348,7 @@ static void atmel_gpio_set(struct gpio_chip *chip, unsigned offset, int val) static int atmel_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(chip->parent); + struct atmel_pioctrl *atmel_pioctrl = gpiochip_get_data(chip); return irq_find_mapping(atmel_pioctrl->irq_domain, offset); } @@ -1037,7 +1039,7 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) goto pinctrl_register_error; } - ret = gpiochip_add(atmel_pioctrl->gpio_chip); + ret = gpiochip_add_data(atmel_pioctrl->gpio_chip, atmel_pioctrl); if (ret) { dev_err(dev, "failed to add gpiochip\n"); goto gpiochip_add_error; -- cgit From dbf09b0aa9e75222dda7aa4f2fcd3eca107cf450 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 22:27:19 +0100 Subject: pinctrl: exynos5440: 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: Kukjin Kim Acked-by: Tomasz Figa Signed-off-by: Linus Walleij --- drivers/pinctrl/samsung/pinctrl-exynos5440.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/samsung/pinctrl-exynos5440.c b/drivers/pinctrl/samsung/pinctrl-exynos5440.c index f61f9a6fa9af..00ab63abf1d9 100644 --- a/drivers/pinctrl/samsung/pinctrl-exynos5440.c +++ b/drivers/pinctrl/samsung/pinctrl-exynos5440.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -539,7 +539,7 @@ static const struct pinconf_ops exynos5440_pinconf_ops = { /* gpiolib gpio_set callback function */ static void exynos5440_gpio_set(struct gpio_chip *gc, unsigned offset, int value) { - struct exynos5440_pinctrl_priv_data *priv = dev_get_drvdata(gc->parent); + struct exynos5440_pinctrl_priv_data *priv = gpiochip_get_data(gc); void __iomem *base = priv->reg_base; u32 data; @@ -553,7 +553,7 @@ static void exynos5440_gpio_set(struct gpio_chip *gc, unsigned offset, int value /* gpiolib gpio_get callback function */ static int exynos5440_gpio_get(struct gpio_chip *gc, unsigned offset) { - struct exynos5440_pinctrl_priv_data *priv = dev_get_drvdata(gc->parent); + struct exynos5440_pinctrl_priv_data *priv = gpiochip_get_data(gc); void __iomem *base = priv->reg_base; u32 data; @@ -566,7 +566,7 @@ static int exynos5440_gpio_get(struct gpio_chip *gc, unsigned offset) /* gpiolib gpio_direction_input callback function */ static int exynos5440_gpio_direction_input(struct gpio_chip *gc, unsigned offset) { - struct exynos5440_pinctrl_priv_data *priv = dev_get_drvdata(gc->parent); + struct exynos5440_pinctrl_priv_data *priv = gpiochip_get_data(gc); void __iomem *base = priv->reg_base; u32 data; @@ -586,7 +586,7 @@ static int exynos5440_gpio_direction_input(struct gpio_chip *gc, unsigned offset static int exynos5440_gpio_direction_output(struct gpio_chip *gc, unsigned offset, int value) { - struct exynos5440_pinctrl_priv_data *priv = dev_get_drvdata(gc->parent); + struct exynos5440_pinctrl_priv_data *priv = gpiochip_get_data(gc); void __iomem *base = priv->reg_base; u32 data; @@ -607,7 +607,7 @@ static int exynos5440_gpio_direction_output(struct gpio_chip *gc, unsigned offse /* gpiolib gpio_to_irq callback function */ static int exynos5440_gpio_to_irq(struct gpio_chip *gc, unsigned offset) { - struct exynos5440_pinctrl_priv_data *priv = dev_get_drvdata(gc->parent); + struct exynos5440_pinctrl_priv_data *priv = gpiochip_get_data(gc); unsigned int virq; if (offset < 16 || offset > 23) @@ -825,7 +825,7 @@ static int exynos5440_gpiolib_register(struct platform_device *pdev, gc->to_irq = exynos5440_gpio_to_irq; gc->label = "gpiolib-exynos5440"; gc->owner = THIS_MODULE; - ret = gpiochip_add(gc); + ret = gpiochip_add_data(gc, priv); if (ret) { dev_err(&pdev->dev, "failed to register gpio_chip %s, error " "code: %d\n", gc->label, ret); -- cgit From 5c809c63ab508423225f5aea00f82308a427b0f9 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 22:50:08 +0100 Subject: pinctrl: vt8500-wmt: 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: Heiko Stuebner Signed-off-by: Linus Walleij --- drivers/pinctrl/vt8500/pinctrl-wmt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/vt8500/pinctrl-wmt.c b/drivers/pinctrl/vt8500/pinctrl-wmt.c index e9c1dfd90570..5c261bf5542f 100644 --- a/drivers/pinctrl/vt8500/pinctrl-wmt.c +++ b/drivers/pinctrl/vt8500/pinctrl-wmt.c @@ -14,7 +14,7 @@ */ #include -#include +#include #include #include #include @@ -488,7 +488,7 @@ static struct pinctrl_desc wmt_desc = { static int wmt_gpio_get_direction(struct gpio_chip *chip, unsigned offset) { - struct wmt_pinctrl_data *data = dev_get_drvdata(chip->parent); + struct wmt_pinctrl_data *data = gpiochip_get_data(chip); u32 bank = WMT_BANK_FROM_PIN(offset); u32 bit = WMT_BIT_FROM_PIN(offset); u32 reg_dir = data->banks[bank].reg_dir; @@ -503,7 +503,7 @@ static int wmt_gpio_get_direction(struct gpio_chip *chip, unsigned offset) static int wmt_gpio_get_value(struct gpio_chip *chip, unsigned offset) { - struct wmt_pinctrl_data *data = dev_get_drvdata(chip->parent); + struct wmt_pinctrl_data *data = gpiochip_get_data(chip); u32 bank = WMT_BANK_FROM_PIN(offset); u32 bit = WMT_BIT_FROM_PIN(offset); u32 reg_data_in = data->banks[bank].reg_data_in; @@ -519,7 +519,7 @@ static int wmt_gpio_get_value(struct gpio_chip *chip, unsigned offset) static void wmt_gpio_set_value(struct gpio_chip *chip, unsigned offset, int val) { - struct wmt_pinctrl_data *data = dev_get_drvdata(chip->parent); + struct wmt_pinctrl_data *data = gpiochip_get_data(chip); u32 bank = WMT_BANK_FROM_PIN(offset); u32 bit = WMT_BIT_FROM_PIN(offset); u32 reg_data_out = data->banks[bank].reg_data_out; @@ -589,7 +589,7 @@ int wmt_pinctrl_probe(struct platform_device *pdev, return PTR_ERR(data->pctl_dev); } - err = gpiochip_add(&data->gpio_chip); + err = gpiochip_add_data(&data->gpio_chip, data); if (err) { dev_err(&pdev->dev, "could not add GPIO chip\n"); goto fail_gpio; -- cgit From 27cc78e3be3abb16ff77324624a6dfb410b3d338 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 10 Dec 2015 19:02:26 +0100 Subject: pinctrl: nsp-gpio: 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: Yendapally Reddy Dhananjaya Reddy Signed-off-by: Linus Walleij --- drivers/pinctrl/bcm/pinctrl-nsp-gpio.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c index 34648f6a4826..a5af9d59969c 100644 --- a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c +++ b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c @@ -18,7 +18,7 @@ * through the interaction with the NSP IOMUX controller. */ -#include +#include #include #include #include @@ -81,11 +81,6 @@ enum base_type { IO_CTRL }; -static inline struct nsp_gpio *to_nsp_gpio(struct gpio_chip *gc) -{ - return container_of(gc, struct nsp_gpio, gc); -} - /* * Mapping from PINCONF pins to GPIO pins is 1-to-1 */ @@ -297,7 +292,7 @@ static void nsp_gpio_free(struct gpio_chip *gc, unsigned offset) static int nsp_gpio_direction_input(struct gpio_chip *gc, unsigned gpio) { - struct nsp_gpio *chip = to_nsp_gpio(gc); + struct nsp_gpio *chip = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -311,7 +306,7 @@ static int nsp_gpio_direction_input(struct gpio_chip *gc, unsigned gpio) static int nsp_gpio_direction_output(struct gpio_chip *gc, unsigned gpio, int val) { - struct nsp_gpio *chip = to_nsp_gpio(gc); + struct nsp_gpio *chip = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -325,7 +320,7 @@ static int nsp_gpio_direction_output(struct gpio_chip *gc, unsigned gpio, static void nsp_gpio_set(struct gpio_chip *gc, unsigned gpio, int val) { - struct nsp_gpio *chip = to_nsp_gpio(gc); + struct nsp_gpio *chip = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -337,14 +332,14 @@ static void nsp_gpio_set(struct gpio_chip *gc, unsigned gpio, int val) static int nsp_gpio_get(struct gpio_chip *gc, unsigned gpio) { - struct nsp_gpio *chip = to_nsp_gpio(gc); + struct nsp_gpio *chip = gpiochip_get_data(gc); return !!(readl(chip->base + NSP_GPIO_DATA_IN) & BIT(gpio)); } static int nsp_gpio_to_irq(struct gpio_chip *gc, unsigned offset) { - struct nsp_gpio *chip = to_nsp_gpio(gc); + struct nsp_gpio *chip = gpiochip_get_data(gc); return irq_linear_revmap(chip->irq_domain, offset); } @@ -713,7 +708,7 @@ static int nsp_gpio_probe(struct platform_device *pdev) writel(val, (chip->base + NSP_CHIP_A_INT_MASK)); } - ret = gpiochip_add(gc); + ret = gpiochip_add_data(gc, chip); if (ret < 0) { dev_err(dev, "unable to add GPIO chip\n"); return ret; -- cgit From 446f59acb70b70a425ea4105277a71eb615327cd Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 5 Jan 2016 14:10:17 +0100 Subject: Revert "pinctrl: lantiq: Implement gpio_chip.to_irq" This reverts commit 3e640743fee6e6a82ead1f163737755b2a965712. This commit needs to go into the pinctrl tree to avoid clashes. --- drivers/pinctrl/pinctrl-xway.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c index ebd867f50700..af69af869f5b 100644 --- a/drivers/pinctrl/pinctrl-xway.c +++ b/drivers/pinctrl/pinctrl-xway.c @@ -682,22 +682,6 @@ static int xway_gpio_dir_out(struct gpio_chip *chip, unsigned int pin, int val) return 0; } -/* - * gpiolib gpiod_to_irq callback function. - * Returns the mapped IRQ (external interrupt) number for a given GPIO pin. - */ -static int xway_gpio_to_irq(struct gpio_chip *chip, unsigned offset) -{ - struct ltq_pinmux_info *info = dev_get_drvdata(chip->parent); - int i; - - for (i = 0; i < info->num_exin; i++) - if (info->exin[i] == offset) - return ltq_eiu_get_irq(i); - - return -1; -} - static struct gpio_chip xway_chip = { .label = "gpio-xway", .direction_input = xway_gpio_dir_in, @@ -706,7 +690,6 @@ static struct gpio_chip xway_chip = { .set = xway_gpio_set, .request = gpiochip_generic_request, .free = gpiochip_generic_free, - .to_irq = xway_gpio_to_irq, .base = -1, }; -- cgit From 166814d8413df49bf21293aacc808b2782cbd9a8 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 5 Jan 2016 14:23:47 +0100 Subject: gpio: pch: Optimize pch_gpio_get() The double negation is costly and can be avoided by shifting the register value before masking the requested bit. Signed-off-by: Jean Delvare Cc: Linus Walleij Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-pch.c b/drivers/gpio/gpio-pch.c index 0475782a7e88..7c7135da5d4a 100644 --- a/drivers/gpio/gpio-pch.c +++ b/drivers/gpio/gpio-pch.c @@ -127,7 +127,7 @@ static int pch_gpio_get(struct gpio_chip *gpio, unsigned nr) { struct pch_gpio *chip = gpiochip_get_data(gpio); - return !!(ioread32(&chip->reg->pi) & (1 << nr)); + return (ioread32(&chip->reg->pi) >> nr) & 1; } static int pch_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, -- cgit From 11680af7c8579fc37ac34bf16cb5ea49435054a4 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 23:20:57 +0100 Subject: video: fbdev: via: 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: Florian Tobias Schandinat Acked-by: Tomi Valkeinen Signed-off-by: Linus Walleij --- drivers/video/fbdev/via/via-gpio.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/video/fbdev/via/via-gpio.c b/drivers/video/fbdev/via/via-gpio.c index 3d3544036bc1..1e89c3434071 100644 --- a/drivers/video/fbdev/via/via-gpio.c +++ b/drivers/video/fbdev/via/via-gpio.c @@ -6,7 +6,7 @@ */ #include -#include +#include #include #include #include @@ -83,9 +83,7 @@ struct viafb_gpio_cfg { static void via_gpio_set(struct gpio_chip *chip, unsigned int nr, int value) { - struct viafb_gpio_cfg *cfg = container_of(chip, - struct viafb_gpio_cfg, - gpio_chip); + struct viafb_gpio_cfg *cfg = gpiochip_get_data(chip); u8 reg; struct viafb_gpio *gpio; unsigned long flags; @@ -115,9 +113,7 @@ static int via_gpio_dir_out(struct gpio_chip *chip, unsigned int nr, */ static int via_gpio_dir_input(struct gpio_chip *chip, unsigned int nr) { - struct viafb_gpio_cfg *cfg = container_of(chip, - struct viafb_gpio_cfg, - gpio_chip); + struct viafb_gpio_cfg *cfg = gpiochip_get_data(chip); struct viafb_gpio *gpio; unsigned long flags; @@ -131,9 +127,7 @@ static int via_gpio_dir_input(struct gpio_chip *chip, unsigned int nr) static int via_gpio_get(struct gpio_chip *chip, unsigned int nr) { - struct viafb_gpio_cfg *cfg = container_of(chip, - struct viafb_gpio_cfg, - gpio_chip); + struct viafb_gpio_cfg *cfg = gpiochip_get_data(chip); u8 reg; struct viafb_gpio *gpio; unsigned long flags; @@ -255,7 +249,8 @@ static int viafb_gpio_probe(struct platform_device *platdev) * Get registered. */ viafb_gpio_config.gpio_chip.base = -1; /* Dynamic */ - ret = gpiochip_add(&viafb_gpio_config.gpio_chip); + ret = gpiochip_add_data(&viafb_gpio_config.gpio_chip, + &viafb_gpio_config); if (ret) { printk(KERN_ERR "viafb: failed to add gpios (%d)\n", ret); viafb_gpio_config.gpio_chip.ngpio = 0; -- cgit From 95bf0951e415cf71654184fd6e8c711782b1f22a Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 13:48:02 +0100 Subject: avr32: gpio: 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: Haavard Skinnemoen Acked-by: Hans-Christian Noren Egtvedt Signed-off-by: Linus Walleij --- arch/avr32/mach-at32ap/pio.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/avr32/mach-at32ap/pio.c b/arch/avr32/mach-at32ap/pio.c index aa74491771fa..5020057ac7a2 100644 --- a/arch/avr32/mach-at32ap/pio.c +++ b/arch/avr32/mach-at32ap/pio.c @@ -203,7 +203,7 @@ fail: static int direction_input(struct gpio_chip *chip, unsigned offset) { - struct pio_device *pio = container_of(chip, struct pio_device, chip); + struct pio_device *pio = gpiochip_get_data(chip); u32 mask = 1 << offset; if (!(pio_readl(pio, PSR) & mask)) @@ -215,7 +215,7 @@ static int direction_input(struct gpio_chip *chip, unsigned offset) static int gpio_get(struct gpio_chip *chip, unsigned offset) { - struct pio_device *pio = container_of(chip, struct pio_device, chip); + struct pio_device *pio = gpiochip_get_data(chip); return (pio_readl(pio, PDSR) >> offset) & 1; } @@ -224,7 +224,7 @@ static void gpio_set(struct gpio_chip *chip, unsigned offset, int value); static int direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct pio_device *pio = container_of(chip, struct pio_device, chip); + struct pio_device *pio = gpiochip_get_data(chip); u32 mask = 1 << offset; if (!(pio_readl(pio, PSR) & mask)) @@ -237,7 +237,7 @@ static int direction_output(struct gpio_chip *chip, unsigned offset, int value) static void gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct pio_device *pio = container_of(chip, struct pio_device, chip); + struct pio_device *pio = gpiochip_get_data(chip); u32 mask = 1 << offset; if (value) @@ -335,7 +335,7 @@ gpio_irq_setup(struct pio_device *pio, int irq, int gpio_irq) */ static void pio_bank_show(struct seq_file *s, struct gpio_chip *chip) { - struct pio_device *pio = container_of(chip, struct pio_device, chip); + struct pio_device *pio = gpiochip_get_data(chip); u32 psr, osr, imr, pdsr, pusr, ifsr, mdsr; unsigned i; u32 mask; @@ -406,7 +406,7 @@ static int __init pio_probe(struct platform_device *pdev) pio->chip.set = gpio_set; pio->chip.dbg_show = pio_bank_show; - gpiochip_add(&pio->chip); + gpiochip_add_data(&pio->chip, pio); gpio_irq_setup(pio, irq, gpio_irq_base); -- cgit From 78d455a2e41fa3de9e1d2d3696cefcb7d6c9c5c4 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 16:17:02 +0100 Subject: bcma: gpio: use gpiochip data pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Kalle Valo Cc: linux-wireless@vger.kernel.org Acked-by: Hauke Mehrtens Acked-by: Rafał Miłecki Signed-off-by: Linus Walleij --- drivers/bcma/driver_gpio.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/bcma/driver_gpio.c b/drivers/bcma/driver_gpio.c index 949754427ce2..98067f757fb0 100644 --- a/drivers/bcma/driver_gpio.c +++ b/drivers/bcma/driver_gpio.c @@ -17,14 +17,9 @@ #define BCMA_GPIO_MAX_PINS 32 -static inline struct bcma_drv_cc *bcma_gpio_get_cc(struct gpio_chip *chip) -{ - return container_of(chip, struct bcma_drv_cc, gpio); -} - static int bcma_gpio_get_value(struct gpio_chip *chip, unsigned gpio) { - struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip); + struct bcma_drv_cc *cc = gpiochip_get_data(chip); return !!bcma_chipco_gpio_in(cc, 1 << gpio); } @@ -32,14 +27,14 @@ static int bcma_gpio_get_value(struct gpio_chip *chip, unsigned gpio) static void bcma_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value) { - struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip); + struct bcma_drv_cc *cc = gpiochip_get_data(chip); bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0); } static int bcma_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) { - struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip); + struct bcma_drv_cc *cc = gpiochip_get_data(chip); bcma_chipco_gpio_outen(cc, 1 << gpio, 0); return 0; @@ -48,7 +43,7 @@ static int bcma_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) static int bcma_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value) { - struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip); + struct bcma_drv_cc *cc = gpiochip_get_data(chip); bcma_chipco_gpio_outen(cc, 1 << gpio, 1 << gpio); bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0); @@ -57,7 +52,7 @@ static int bcma_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, static int bcma_gpio_request(struct gpio_chip *chip, unsigned gpio) { - struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip); + struct bcma_drv_cc *cc = gpiochip_get_data(chip); bcma_chipco_gpio_control(cc, 1 << gpio, 0); /* clear pulldown */ @@ -70,7 +65,7 @@ static int bcma_gpio_request(struct gpio_chip *chip, unsigned gpio) static void bcma_gpio_free(struct gpio_chip *chip, unsigned gpio) { - struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip); + struct bcma_drv_cc *cc = gpiochip_get_data(chip); /* clear pullup */ bcma_chipco_gpio_pullup(cc, 1 << gpio, 0); @@ -81,7 +76,7 @@ static void bcma_gpio_free(struct gpio_chip *chip, unsigned gpio) static void bcma_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct bcma_drv_cc *cc = bcma_gpio_get_cc(gc); + struct bcma_drv_cc *cc = gpiochip_get_data(gc); int gpio = irqd_to_hwirq(d); u32 val = bcma_chipco_gpio_in(cc, BIT(gpio)); @@ -92,7 +87,7 @@ static void bcma_gpio_irq_unmask(struct irq_data *d) static void bcma_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct bcma_drv_cc *cc = bcma_gpio_get_cc(gc); + struct bcma_drv_cc *cc = gpiochip_get_data(gc); int gpio = irqd_to_hwirq(d); bcma_chipco_gpio_intmask(cc, BIT(gpio), 0); @@ -216,7 +211,7 @@ int bcma_gpio_init(struct bcma_drv_cc *cc) else chip->base = -1; - err = gpiochip_add(chip); + err = gpiochip_add_data(chip, cc); if (err) return err; -- cgit From 47513c2ff86e2afd345a9aea3c5626f71cf2f4e9 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 16:26:28 +0100 Subject: hid: cp2112: 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: linux-input@vger.kernel.org Acked-by: Jiri Kosina Signed-off-by: Linus Walleij --- drivers/hid/hid-cp2112.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index f47954e8fd2c..0ccdd37e121a 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -24,7 +24,7 @@ * http://www.silabs.com/Support%20Documents/TechnicalDocs/AN495.pdf */ -#include +#include #include #include #include @@ -169,8 +169,7 @@ MODULE_PARM_DESC(gpio_push_pull, "GPIO push-pull configuration bitmask"); static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct cp2112_device *dev = container_of(chip, struct cp2112_device, - gc); + struct cp2112_device *dev = gpiochip_get_data(chip); struct hid_device *hdev = dev->hdev; u8 buf[5]; int ret; @@ -198,8 +197,7 @@ static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct cp2112_device *dev = container_of(chip, struct cp2112_device, - gc); + struct cp2112_device *dev = gpiochip_get_data(chip); struct hid_device *hdev = dev->hdev; u8 buf[3]; int ret; @@ -216,8 +214,7 @@ static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int cp2112_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct cp2112_device *dev = container_of(chip, struct cp2112_device, - gc); + struct cp2112_device *dev = gpiochip_get_data(chip); struct hid_device *hdev = dev->hdev; u8 buf[2]; int ret; @@ -235,8 +232,7 @@ static int cp2112_gpio_get(struct gpio_chip *chip, unsigned offset) static int cp2112_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct cp2112_device *dev = container_of(chip, struct cp2112_device, - gc); + struct cp2112_device *dev = gpiochip_get_data(chip); struct hid_device *hdev = dev->hdev; u8 buf[5]; int ret; @@ -1106,7 +1102,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) dev->gc.can_sleep = 1; dev->gc.parent = &hdev->dev; - ret = gpiochip_add(&dev->gc); + ret = gpiochip_add_data(&dev->gc, dev); if (ret < 0) { hid_err(hdev, "error registering gpio chip\n"); goto err_free_i2c; -- cgit From 2a6643437083c4dc28169a706099cd22769be1f5 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 16:42:58 +0100 Subject: leds: tca6507: 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: Riku Voipio Cc: Richard Purdie Cc: linux-leds@vger.kernel.org Acked-by: Jacek Anaszewski Signed-off-by: Linus Walleij --- drivers/leds/leds-tca6507.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c index 75529a24a615..c548ea10f0f0 100644 --- a/drivers/leds/leds-tca6507.c +++ b/drivers/leds/leds-tca6507.c @@ -603,7 +603,7 @@ static int tca6507_blink_set(struct led_classdev *led_cdev, static void tca6507_gpio_set_value(struct gpio_chip *gc, unsigned offset, int val) { - struct tca6507_chip *tca = container_of(gc, struct tca6507_chip, gpio); + struct tca6507_chip *tca = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&tca->lock, flags); @@ -655,7 +655,7 @@ static int tca6507_probe_gpios(struct i2c_client *client, #ifdef CONFIG_OF_GPIO tca->gpio.of_node = of_node_get(client->dev.of_node); #endif - err = gpiochip_add(&tca->gpio); + err = gpiochip_add_data(&tca->gpio, tca); if (err) { tca->gpio.ngpio = 0; return err; -- cgit From dced14675818bc9627febcc3159ffc1a0d88199d Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 16:39:20 +0100 Subject: leds: pca9532: 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: Riku Voipio Cc: Richard Purdie Cc: linux-leds@vger.kernel.org Acked-by: Jacek Anaszewski Signed-off-by: Linus Walleij --- drivers/leds/leds-pca9532.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c index a975b32ee8c8..1b228adfd1a7 100644 --- a/drivers/leds/leds-pca9532.c +++ b/drivers/leds/leds-pca9532.c @@ -245,7 +245,7 @@ static void pca9532_led_work(struct work_struct *work) #ifdef CONFIG_LEDS_PCA9532_GPIO static int pca9532_gpio_request_pin(struct gpio_chip *gc, unsigned offset) { - struct pca9532_data *data = container_of(gc, struct pca9532_data, gpio); + struct pca9532_data *data = gpiochip_get_data(gc); struct pca9532_led *led = &data->leds[offset]; if (led->type == PCA9532_TYPE_GPIO) @@ -256,7 +256,7 @@ static int pca9532_gpio_request_pin(struct gpio_chip *gc, unsigned offset) static void pca9532_gpio_set_value(struct gpio_chip *gc, unsigned offset, int val) { - struct pca9532_data *data = container_of(gc, struct pca9532_data, gpio); + struct pca9532_data *data = gpiochip_get_data(gc); struct pca9532_led *led = &data->leds[offset]; if (val) @@ -269,7 +269,7 @@ static void pca9532_gpio_set_value(struct gpio_chip *gc, unsigned offset, int va static int pca9532_gpio_get_value(struct gpio_chip *gc, unsigned offset) { - struct pca9532_data *data = container_of(gc, struct pca9532_data, gpio); + struct pca9532_data *data = gpiochip_get_data(gc); unsigned char reg; reg = i2c_smbus_read_byte_data(data->client, PCA9532_REG_INPUT(offset)); @@ -416,7 +416,7 @@ static int pca9532_configure(struct i2c_client *client, data->gpio.parent = &client->dev; data->gpio.owner = THIS_MODULE; - err = gpiochip_add(&data->gpio); + err = gpiochip_add_data(&data->gpio, data); if (err) { /* Use data->gpio.dev as a flag for freeing gpiochip */ data->gpio.parent = NULL; -- cgit From de06c1db255fb70301651a0255c6147e0036ea01 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Wed, 6 Jan 2016 16:20:10 -0800 Subject: gpio: xilinx: Do not use gpiochip_get_data() in xgpio_save_regs() Commit 097d88e94c44 ("gpio: xilinx: use gpiochip data pointer") replaces the use of container_of() with gpiochip_get_data(). Unfortunately, the data pointer is not yet set by the time xgpio_save_regs() is called, causing a system hang. Fixes: 097d88e94c44 ("gpio: xilinx: use gpiochip data pointer") Signed-off-by: Guenter Roeck Signed-off-by: Linus Walleij --- drivers/gpio/gpio-xilinx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index 3345ab0ba1b3..d0fbb7f99523 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -207,7 +207,8 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) */ static void xgpio_save_regs(struct of_mm_gpio_chip *mm_gc) { - struct xgpio_instance *chip = gpiochip_get_data(&mm_gc->gc); + struct xgpio_instance *chip = + container_of(mm_gc, struct xgpio_instance, mmchip); xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET, chip->gpio_state[0]); xgpio_writereg(mm_gc->regs + XGPIO_TRI_OFFSET, chip->gpio_dir[0]); -- cgit From 780c43dd61a09ce7d9cdb1e7c33d3341ec471ff0 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 7 Jan 2016 14:55:34 +0100 Subject: gpio: moxart: fix build regression A cleanup patch replaced bgpio_chip with gpio_chip but missed two references to the bgpio_chip: drivers/gpio/gpio-moxart.c:60:19: error: use of undeclared identifier 'bgc'; did you mean 'gc'? gc->bgpio_data = bgc->read_reg(bgc->reg_set); drivers/gpio/gpio-moxart.c:35:20: note: 'gc' declared here drivers/gpio/gpio-moxart.c:60:33: error: use of undeclared identifier 'bgc'; did you mean 'gc'? gc->bgpio_data = bgc->read_reg(bgc->reg_set); This adds the missing change. Signed-off-by: Arnd Bergmann Fixes: 0f4630f3720e ("gpio: generic: factor into gpio_chip struct") Signed-off-by: Linus Walleij --- drivers/gpio/gpio-moxart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-moxart.c b/drivers/gpio/gpio-moxart.c index 71c13c4e12b5..ca604538ebf7 100644 --- a/drivers/gpio/gpio-moxart.c +++ b/drivers/gpio/gpio-moxart.c @@ -57,7 +57,7 @@ static int moxart_gpio_probe(struct platform_device *pdev) gc->label = "moxart-gpio"; gc->request = gpiochip_generic_request; gc->free = gpiochip_generic_free; - gc->bgpio_data = bgc->read_reg(bgc->reg_set); + gc->bgpio_data = gc->read_reg(gc->reg_set); gc->base = 0; gc->ngpio = 32; gc->parent = dev; -- cgit From ce5a7e81390b9ae28f8dc82505afa96c1787d312 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Wed, 6 Jan 2016 10:55:22 -0800 Subject: gpio: brcmstb: Set endian flags for big-endian MIPS Broadcom MIPS-based STB chips endianness is configured by boot strap, which also reverses all bus endianness (i.e., big-endian CPU + big endian bus ==> native endian I/O). Other architectures (e.g., ARM) either do not support big endian, or else leave I/O in little endian mode. Signed-off-by: Florian Fainelli Acked-by: Gregory Fong Signed-off-by: Linus Walleij --- drivers/gpio/gpio-brcmstb.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-brcmstb.c b/drivers/gpio/gpio-brcmstb.c index dc3f0395693b..d7644251e869 100644 --- a/drivers/gpio/gpio-brcmstb.c +++ b/drivers/gpio/gpio-brcmstb.c @@ -409,6 +409,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) int num_banks = 0; int err; static int gpio_base; + unsigned long flags = 0; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -438,6 +439,18 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) if (brcmstb_gpio_sanity_check_banks(dev, np, res)) return -EINVAL; + /* + * MIPS endianness is configured by boot strap, which also reverses all + * bus endianness (i.e., big-endian CPU + big endian bus ==> native + * endian I/O). + * + * Other architectures (e.g., ARM) either do not support big endian, or + * else leave I/O in little endian mode. + */ +#if defined(CONFIG_MIPS) && defined(__BIG_ENDIAN) + flags = BGPIOF_BIG_ENDIAN_BYTE_ORDER; +#endif + of_property_for_each_u32(np, "brcm,gpio-bank-widths", prop, p, bank_width) { struct brcmstb_gpio_bank *bank; @@ -466,7 +479,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) err = bgpio_init(gc, dev, 4, reg_base + GIO_DATA(bank->id), NULL, NULL, NULL, - reg_base + GIO_IODIR(bank->id), 0); + reg_base + GIO_IODIR(bank->id), flags); if (err) { dev_err(dev, "bgpio_init() failed\n"); goto fail; -- cgit From a02588a0efd6008f70ab69318ebacd79cbd3dc6b Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Wed, 6 Jan 2016 10:55:23 -0800 Subject: gpio: brcmstb: Allow building driver for BMIPS_GENERIC BMIPS_GENERIC (arch/mips/bmips) is the Kconfig symbol associated with Broadcom MIPS-based STB chips. Since this driver is perfectly usable on these platforms as well, allow using it. Signed-off-by: Florian Fainelli Acked-by: Gregory Fong Signed-off-by: Linus Walleij --- drivers/gpio/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index b60f40a423f3..cb212ebb39ff 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -134,8 +134,8 @@ config GPIO_BCM_KONA config GPIO_BRCMSTB tristate "BRCMSTB GPIO support" - default y if ARCH_BRCMSTB - depends on OF_GPIO && (ARCH_BRCMSTB || COMPILE_TEST) + default y if (ARCH_BRCMSTB || BMIPS_GENERIC) + depends on OF_GPIO && (ARCH_BRCMSTB || BMIPS_GENERIC || COMPILE_TEST) select GPIO_GENERIC select GPIOLIB_IRQCHIP help -- cgit From 95c761705ef5c2f094c56c4b779e74958246f2aa Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 7 Jan 2016 08:24:58 -0800 Subject: gpio: mm-lantiq: Do not use gpiochip_get_data() in ltq_mm_save_regs() Commit 6aa7dbfa2877 ("gpio: mm-lantiq: use gpiochip data pointer") replaces the use of container_of() with gpiochip_get_data(). However, the data pointer is not yet set by the time the save_regs function is called. Fixes: 6aa7dbfa2877 ("gpio: mm-lantiq: use gpiochip data pointer") Cc: Ricardo Ribalda Delgado Cc: John Crispin Signed-off-by: Guenter Roeck Signed-off-by: Linus Walleij --- drivers/gpio/gpio-mm-lantiq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-mm-lantiq.c b/drivers/gpio/gpio-mm-lantiq.c index a2071ed69f79..54e5d8257d34 100644 --- a/drivers/gpio/gpio-mm-lantiq.c +++ b/drivers/gpio/gpio-mm-lantiq.c @@ -91,7 +91,8 @@ static int ltq_mm_dir_out(struct gpio_chip *gc, unsigned offset, int value) */ static void ltq_mm_save_regs(struct of_mm_gpio_chip *mm_gc) { - struct ltq_mm *chip = gpiochip_get_data(&mm_gc->gc); + struct ltq_mm *chip = + container_of(mm_gc, struct ltq_mm, mmchip); /* tell the ebu controller which memory address we will be using */ ltq_ebu_w32(CPHYSADDR(chip->mmchip.regs) | 0x1, LTQ_EBU_ADDRSEL1); -- cgit From 78179989a06636d8362e2eee01b261d02b1500d2 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 7 Jan 2016 08:25:24 -0800 Subject: gpio: mpc8xxx: Do not use gpiochip_get_data() in mpc8xxx_gpio_save_regs() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 709d71a17c33 ("gpio: mpc8xxx: use gpiochip data pointer") replaces the use of container_of() with gpiochip_get_data(). However, the data pointer is not yet set by the time the save_regs function is called. Fixes: 709d71a17c33 ("gpio: mpc8xxx: use gpiochip data pointer") Cc: Uwe Kleine-König Cc: Alexander Stein Signed-off-by: Guenter Roeck Signed-off-by: Linus Walleij --- drivers/gpio/gpio-mpc8xxx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c index 21eff0e1df87..9d40787e66c0 100644 --- a/drivers/gpio/gpio-mpc8xxx.c +++ b/drivers/gpio/gpio-mpc8xxx.c @@ -51,7 +51,8 @@ static inline u32 mpc8xxx_gpio2mask(unsigned int gpio) static void mpc8xxx_gpio_save_regs(struct of_mm_gpio_chip *mm) { - struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(&mm->gc); + struct mpc8xxx_gpio_chip *mpc8xxx_gc = + container_of(mm, struct mpc8xxx_gpio_chip, mm_gc); mpc8xxx_gc->data = in_be32(mm->regs + GPIO_DAT); } -- cgit From 96098df125c0a966631ec114081d8f5630a0e4b8 Mon Sep 17 00:00:00 2001 From: Julien Grossholtz Date: Thu, 7 Jan 2016 16:46:45 -0500 Subject: gpiolib: fix chip order in gpio list In some situations the gpio_list order is not correct. As a consequence gpiochip_find_base returns the same base number twice. This happens when a first ship is added with manual base number, then other ships are added using automatic base number. To prevent this behaviour, this patch add the new chip after the last element of the gpio list. Signed-off-by: Julien Grossholtz Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 3db34e74bc34..a1805734aef8 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -226,8 +226,10 @@ static int gpiochip_add_to_list(struct gpio_chip *chip) */ iterator = list_last_entry(&gpio_chips, struct gpio_chip, list); - if (iterator->base + iterator->ngpio <= chip->base) - goto found; + if (iterator->base + iterator->ngpio <= chip->base) { + list_add(&chip->list, &iterator->list); + return 0; + } dev_err(chip->parent, "GPIO integer space overlap, cannot add chip\n"); -- cgit From c474e348778bdf5b453a2cdff4b2b1f9e000f343 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Sat, 9 Jan 2016 22:16:42 +0100 Subject: gpio: generic: make bgpio_pdata always visible Board files that define their own bgpio_pdata are broken when CONFIG_GPIO_GENERIC is disabled and the bgpio_pdata structure definition is hidden by the #ifdef: arch/arm/mach-clps711x/board-autcpu12.c:148:15: error: variable 'autcpu12_mmgpio_pdata' has initializer but incomplete type static struct bgpio_pdata autcpu12_mmgpio_pdata __initdata = { arch/arm/mach-clps711x/board-autcpu12.c:149:2: error: unknown field 'base' specified in initializer .base = AUTCPU12_MMGPIO_BASE, Since the board files should generally not care what drivers are enabled, this makes the structure definition visible again. Signed-off-by: Arnd Bergmann Fixes: 0f4630f3720e ("gpio: generic: factor into gpio_chip struct") Signed-off-by: Linus Walleij --- include/linux/gpio/driver.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index e2d05fd0e6e3..82fda487453f 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -220,14 +220,14 @@ static inline void *gpiochip_get_data(struct gpio_chip *chip) struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc); -#if IS_ENABLED(CONFIG_GPIO_GENERIC) - struct bgpio_pdata { const char *label; int base; int ngpio; }; +#if IS_ENABLED(CONFIG_GPIO_GENERIC) + int bgpio_init(struct gpio_chip *gc, struct device *dev, unsigned long sz, void __iomem *dat, void __iomem *set, void __iomem *clr, void __iomem *dirout, void __iomem *dirin, -- cgit