From 58383c78425e4ee1c077253cf297b641c861c02e Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Wed, 4 Nov 2015 09:56:26 +0100 Subject: gpio: change member .dev to .parent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The name .dev in a struct is normally reserved for a struct device that is let us say a superclass to the thing described by the struct. struct gpio_chip stands out by confusingly using a struct device *dev to point to the parent device (such as a platform_device) that represents the hardware. As we want to give gpio_chip:s real devices, this is not working. We need to rename this member to parent. This was done by two coccinelle scripts, I guess it is possible to combine them into one, but I don't know such stuff. They look like this: @@ struct gpio_chip *var; @@ -var->dev +var->parent and: @@ struct gpio_chip var; @@ -var.dev +var.parent and: @@ struct bgpio_chip *var; @@ -var->gc.dev +var->gc.parent Plus a few instances of bgpio that I couldn't figure out how to teach Coccinelle to rewrite. This patch hits all over the place, but I *strongly* prefer this solution to any piecemal approaches that just exercise patch mechanics all over the place. It mainly hits drivers/gpio and drivers/pinctrl which is my own backyard anyway. Cc: Haavard Skinnemoen Cc: Rafał Miłecki Cc: Richard Purdie Cc: Mauro Carvalho Chehab Cc: Alek Du Cc: Jaroslav Kysela Cc: Takashi Iwai Acked-by: Dmitry Torokhov Acked-by: Greg Kroah-Hartman Acked-by: Lee Jones Acked-by: Jiri Kosina Acked-by: Hans-Christian Egtvedt Acked-by: Jacek Anaszewski Signed-off-by: Linus Walleij --- drivers/pinctrl/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 ++++---- 33 files changed, 69 insertions(+), 67 deletions(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c index a1ea565..0bc1abc 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 12a48f4..bd212b2 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 b59ce75..bb92f8a 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 84936ba..dac8ec4 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 392e28d..401c186 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 f307f1d..a71f683 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 84943e4..4b5f682 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 b59fbb4..434d5de 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 eebfae0..cb4a327 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 3318f1d..a74b2b0 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 56af28b..89479be 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 33edd07..f1daf85 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 0d2fc0c..667d906 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 813eb7c..e1cbf56 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 38a7799..d8efb2c 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 85c9046..fd5148d 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 a065112..2b88a40 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 b58d3f2..52639e6 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 ae724bd..b4380fb 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 146264a..af2a130 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 6c42ca1..3e5ccc7 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 9ce0e30..69c14ba 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 d809c9e..7b80fa9 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 8982027..7bc1e0f 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 71ccf6a..7d7374e 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 82dc109..f61f9a6 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 3f622cc..bb4db20 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 db3f09a..cdb2460 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 829018c..1850dc1b386 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 2a8d697..ae97bdc 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 1f0af25..925f597 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 dead97d..a437e4f 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 fb22d3f..e9c1dfd 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; -- cgit v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c index 06b7aaf..bb7891e 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 v1.1 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(+) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c index b4380fb..e56222e 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c index bb7891e..34648f6 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c index bb92f8a..1fe9c198 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/pinctrl-coh901.c b/drivers/pinctrl/pinctrl-coh901.c index e1cbf56..ca0fa79 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c index e56222e..ebd867f 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c index 3e5ccc7..4460b2c 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c index 69c14ba..ea1d2b2 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c index 7bea0df..394ca34 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c b/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c index 8f5c96c..23089d5 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index a437e4f..c53a2db 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c index 394ca34..7bea0df 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 23089d5..629642b 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c index 1fe9c198..21b79a4 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c index 595f870..7c352490 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c index dac8ec4..4251e07 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c index c6dcde7..c0f5586 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c index 4b5f682..50cab27 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/nomadik/pinctrl-nomadik.c index cb4a327..3524061 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/nomadik/pinctrl-abx500.c b/drivers/pinctrl/nomadik/pinctrl-abx500.c index 434d5de..085e601 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/pinctrl-adi2.c b/drivers/pinctrl/pinctrl-adi2.c index fd342df..9ad1a8d 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c index a74b2b0..6574494 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/pinctrl-as3722.c b/drivers/pinctrl/pinctrl-as3722.c index 89479be..e844fdc 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 v1.1 From 370ea61134e9d13cef0dc671ce1fbc5a60756b59 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 09:27:45 +0100 Subject: pinctrl: at91: use gpiochip data pointer This makes the driver use the data pointer added to the gpio_chip to store a pointer to the state container instead of relying on container_of(). Cc: Jean-Christophe Plagniol-Villard Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-at91.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index 667d906..dd30068 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -45,8 +45,6 @@ struct at91_gpio_chip { struct at91_pinctrl_mux_ops *ops; /* ops */ }; -#define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip) - static struct at91_gpio_chip *gpio_chips[MAX_GPIO_BANKS]; static int gpio_banks; @@ -811,7 +809,7 @@ static int at91_gpio_request_enable(struct pinctrl_dev *pctldev, return -EINVAL; } chip = range->gc; - at91_chip = container_of(chip, struct at91_gpio_chip, chip); + at91_chip = gpiochip_get_data(chip); dev_dbg(npct->dev, "enable pin %u as GPIO\n", offset); @@ -1282,7 +1280,7 @@ static int at91_pinctrl_remove(struct platform_device *pdev) static int at91_gpio_get_direction(struct gpio_chip *chip, unsigned offset) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; u32 osr; @@ -1293,7 +1291,7 @@ static int at91_gpio_get_direction(struct gpio_chip *chip, unsigned offset) static int at91_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; @@ -1303,7 +1301,7 @@ static int at91_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int at91_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; u32 pdsr; @@ -1315,7 +1313,7 @@ static int at91_gpio_get(struct gpio_chip *chip, unsigned offset) static void at91_gpio_set(struct gpio_chip *chip, unsigned offset, int val) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; @@ -1325,7 +1323,7 @@ static void at91_gpio_set(struct gpio_chip *chip, unsigned offset, static void at91_gpio_set_multiple(struct gpio_chip *chip, unsigned long *mask, unsigned long *bits) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; #define BITS_MASK(bits) (((bits) == 32) ? ~0U : (BIT(bits) - 1)) @@ -1340,7 +1338,7 @@ static void at91_gpio_set_multiple(struct gpio_chip *chip, static int at91_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int val) { - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; @@ -1355,7 +1353,7 @@ static void at91_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { enum at91_mux mode; int i; - struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); void __iomem *pio = at91_gpio->regbase; for (i = 0; i < chip->ngpio; i++) { @@ -1570,9 +1568,7 @@ static void gpio_irq_handler(struct irq_desc *desc) { struct irq_chip *chip = irq_desc_get_chip(desc); struct gpio_chip *gpio_chip = irq_desc_get_handler_data(desc); - struct at91_gpio_chip *at91_gpio = container_of(gpio_chip, - struct at91_gpio_chip, chip); - + struct at91_gpio_chip *at91_gpio = gpiochip_get_data(gpio_chip); void __iomem *pio = at91_gpio->regbase; unsigned long isr; int n; @@ -1648,7 +1644,7 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev, return 0; } - prev = container_of(gpiochip_prev, struct at91_gpio_chip, chip); + prev = gpiochip_get_data(gpiochip_prev); /* we can only have 2 banks before */ for (i = 0; i < 2; i++) { @@ -1783,7 +1779,7 @@ static int at91_gpio_probe(struct platform_device *pdev) range->npins = chip->ngpio; range->gc = chip; - ret = gpiochip_add(chip); + ret = gpiochip_add_data(chip, at91_chip); if (ret) goto gpiochip_add_err; -- cgit v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/pinctrl-coh901.c b/drivers/pinctrl/pinctrl-coh901.c index ca0fa79..cf7788d 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/pinctrl-digicolor.c b/drivers/pinctrl/pinctrl-digicolor.c index d8efb2c..f1343d6 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c index fd5148d..856f736 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 2b88a40..56b8ce2 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index 52639e6..fac844a 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index af2a130..8777cf0 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c index 4460b2c..23553ec 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c index ea1d2b2..f49713d 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c b/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c index 629642b..6c8ad0e 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c index 7bea0df..c01f51d 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c index bb4db20..a4fb837 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index c53a2db..7a2465f 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/sh-pfc/gpio.c b/drivers/pinctrl/sh-pfc/gpio.c index cdb2460..a6681b8 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 v1.1 From 9420023a5327f29a37cf0a6198bd7d8d80f9634c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 10:27:16 +0100 Subject: pinctrl: sirf-atlas7: use gpiochip data pointer This makes the driver use the data pointer added to the gpio_chip to store a pointer to the state container instead of relying on container_of(). Cc: Barry Song Signed-off-by: Linus Walleij --- drivers/pinctrl/sirf/pinctrl-atlas7.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/sirf/pinctrl-atlas7.c b/drivers/pinctrl/sirf/pinctrl-atlas7.c index 1850dc1b386..3a95ffd 100644 --- a/drivers/pinctrl/sirf/pinctrl-atlas7.c +++ b/drivers/pinctrl/sirf/pinctrl-atlas7.c @@ -355,11 +355,6 @@ struct atlas7_gpio_chip { struct atlas7_gpio_bank banks[0]; }; -static inline struct atlas7_gpio_chip *to_atlas7_gpio(struct gpio_chip *gc) -{ - return container_of(gc, struct atlas7_gpio_chip, chip); -} - /** * @dev: a pointer back to containing device * @virtbase: the offset to the controller in virtual memory @@ -5600,7 +5595,7 @@ static int __atlas7_gpio_to_pin(struct atlas7_gpio_chip *a7gc, u32 gpio) static void atlas7_gpio_irq_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(gc); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(gc); struct atlas7_gpio_bank *bank; void __iomem *ctrl_reg; u32 val, pin_in_bank; @@ -5638,7 +5633,7 @@ static void __atlas7_gpio_irq_mask(struct atlas7_gpio_chip *a7gc, int idx) static void atlas7_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(gc); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&a7gc->lock, flags); @@ -5651,7 +5646,7 @@ static void atlas7_gpio_irq_mask(struct irq_data *d) static void atlas7_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(gc); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(gc); struct atlas7_gpio_bank *bank; void __iomem *ctrl_reg; u32 val, pin_in_bank; @@ -5675,7 +5670,7 @@ static int atlas7_gpio_irq_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(gc); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(gc); struct atlas7_gpio_bank *bank; void __iomem *ctrl_reg; u32 val, pin_in_bank; @@ -5744,7 +5739,7 @@ static struct irq_chip atlas7_gpio_irq_chip = { static void atlas7_gpio_handle_irq(struct irq_desc *desc) { struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(gc); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(gc); struct atlas7_gpio_bank *bank = NULL; u32 status, ctrl; int pin_in_bank = 0, idx; @@ -5812,7 +5807,7 @@ static void __atlas7_gpio_set_input(struct atlas7_gpio_chip *a7gc, static int atlas7_gpio_request(struct gpio_chip *chip, unsigned int gpio) { - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(chip); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(chip); int ret; unsigned long flags; @@ -5840,7 +5835,7 @@ static int atlas7_gpio_request(struct gpio_chip *chip, static void atlas7_gpio_free(struct gpio_chip *chip, unsigned int gpio) { - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(chip); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(chip); unsigned long flags; spin_lock_irqsave(&a7gc->lock, flags); @@ -5856,7 +5851,7 @@ static void atlas7_gpio_free(struct gpio_chip *chip, static int atlas7_gpio_direction_input(struct gpio_chip *chip, unsigned int gpio) { - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(chip); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(chip); unsigned long flags; spin_lock_irqsave(&a7gc->lock, flags); @@ -5893,7 +5888,7 @@ static void __atlas7_gpio_set_output(struct atlas7_gpio_chip *a7gc, static int atlas7_gpio_direction_output(struct gpio_chip *chip, unsigned int gpio, int value) { - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(chip); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(chip); unsigned long flags; spin_lock_irqsave(&a7gc->lock, flags); @@ -5908,7 +5903,7 @@ static int atlas7_gpio_direction_output(struct gpio_chip *chip, static int atlas7_gpio_get_value(struct gpio_chip *chip, unsigned int gpio) { - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(chip); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(chip); struct atlas7_gpio_bank *bank; u32 val, pin_in_bank; unsigned long flags; @@ -5928,7 +5923,7 @@ static int atlas7_gpio_get_value(struct gpio_chip *chip, static void atlas7_gpio_set_value(struct gpio_chip *chip, unsigned int gpio, int value) { - struct atlas7_gpio_chip *a7gc = to_atlas7_gpio(chip); + struct atlas7_gpio_chip *a7gc = gpiochip_get_data(chip); struct atlas7_gpio_bank *bank; void __iomem *ctrl_reg; u32 ctrl, pin_in_bank; @@ -6015,7 +6010,7 @@ static int atlas7_gpio_probe(struct platform_device *pdev) chip->parent = &pdev->dev; /* Add gpio chip to system */ - ret = gpiochip_add(chip); + ret = gpiochip_add_data(chip, a7gc); if (ret) { dev_err(&pdev->dev, "%s: error in probe function with status %d\n", -- cgit v1.1 From 192d3507e2e65790f03ff43aeb1930ae097a8315 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 8 Dec 2015 10:29:35 +0100 Subject: pinctrl: sirf: use gpiochip data pointer This makes the driver use the data pointer added to the gpio_chip to store a pointer to the state container instead of relying on container_of(). Cc: Barry Song Signed-off-by: Linus Walleij --- drivers/pinctrl/sirf/pinctrl-sirf.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/sirf/pinctrl-sirf.c b/drivers/pinctrl/sirf/pinctrl-sirf.c index ae97bdc..aa87fa9 100644 --- a/drivers/pinctrl/sirf/pinctrl-sirf.c +++ b/drivers/pinctrl/sirf/pinctrl-sirf.c @@ -399,11 +399,6 @@ static int __init sirfsoc_pinmux_init(void) } arch_initcall(sirfsoc_pinmux_init); -static inline struct sirfsoc_gpio_chip *to_sirfsoc_gpio(struct gpio_chip *gc) -{ - return container_of(gc, struct sirfsoc_gpio_chip, chip.gc); -} - static inline struct sirfsoc_gpio_bank * sirfsoc_gpio_to_bank(struct sirfsoc_gpio_chip *sgpio, unsigned int offset) { @@ -418,7 +413,7 @@ static inline int sirfsoc_gpio_to_bankoff(unsigned int offset) static void sirfsoc_gpio_irq_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); int idx = sirfsoc_gpio_to_bankoff(d->hwirq); u32 val, offset; @@ -457,7 +452,7 @@ static void __sirfsoc_gpio_irq_mask(struct sirfsoc_gpio_chip *sgpio, static void sirfsoc_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); __sirfsoc_gpio_irq_mask(sgpio, bank, d->hwirq % SIRFSOC_GPIO_BANK_SIZE); @@ -466,7 +461,7 @@ static void sirfsoc_gpio_irq_mask(struct irq_data *d) static void sirfsoc_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); int idx = sirfsoc_gpio_to_bankoff(d->hwirq); u32 val, offset; @@ -487,7 +482,7 @@ static void sirfsoc_gpio_irq_unmask(struct irq_data *d) static int sirfsoc_gpio_irq_type(struct irq_data *d, unsigned type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); int idx = sirfsoc_gpio_to_bankoff(d->hwirq); u32 val, offset; @@ -549,7 +544,7 @@ static void sirfsoc_gpio_handle_irq(struct irq_desc *desc) { unsigned int irq = irq_desc_get_irq(desc); struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); struct sirfsoc_gpio_bank *bank; u32 status, ctrl; int idx = 0; @@ -607,7 +602,7 @@ static inline void sirfsoc_gpio_set_input(struct sirfsoc_gpio_chip *sgpio, static int sirfsoc_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); unsigned long flags; @@ -630,7 +625,7 @@ static int sirfsoc_gpio_request(struct gpio_chip *chip, unsigned offset) static void sirfsoc_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); unsigned long flags; @@ -646,7 +641,7 @@ static void sirfsoc_gpio_free(struct gpio_chip *chip, unsigned offset) static int sirfsoc_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, gpio); int idx = sirfsoc_gpio_to_bankoff(gpio); unsigned long flags; @@ -689,7 +684,7 @@ static inline void sirfsoc_gpio_set_output(struct sirfsoc_gpio_chip *sgpio, static int sirfsoc_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, gpio); int idx = sirfsoc_gpio_to_bankoff(gpio); u32 offset; @@ -708,7 +703,7 @@ static int sirfsoc_gpio_direction_output(struct gpio_chip *chip, static int sirfsoc_gpio_get_value(struct gpio_chip *chip, unsigned offset) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); u32 val; unsigned long flags; @@ -725,7 +720,7 @@ static int sirfsoc_gpio_get_value(struct gpio_chip *chip, unsigned offset) static void sirfsoc_gpio_set_value(struct gpio_chip *chip, unsigned offset, int value) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); u32 ctrl; unsigned long flags; @@ -814,7 +809,7 @@ static int sirfsoc_gpio_probe(struct device_node *np) sgpio->chip.gc.parent = &pdev->dev; sgpio->chip.regs = regs; - err = gpiochip_add(&sgpio->chip.gc); + err = gpiochip_add_data(&sgpio->chip.gc, sgpio); if (err) { dev_err(&pdev->dev, "%s: error in probe function with status %d\n", np->full_name, err); -- cgit v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/spear/pinctrl-plgpio.c b/drivers/pinctrl/spear/pinctrl-plgpio.c index 925f597..4c9b863 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c index 9ddba44..cfba56b 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c index f1daf85..27540f5 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/samsung/pinctrl-exynos5440.c b/drivers/pinctrl/samsung/pinctrl-exynos5440.c index f61f9a6..00ab63a 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/vt8500/pinctrl-wmt.c b/drivers/pinctrl/vt8500/pinctrl-wmt.c index e9c1dfd..5c261bf 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c index 34648f6..a5af9d5 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 v1.1 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(-) (limited to 'drivers/pinctrl') diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c index ebd867f..af69af8 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 v1.1