Skip to content

Commit

Permalink
pinctrl: Get rid of duplicate of_node assignment in the drivers
Browse files Browse the repository at this point in the history
GPIO library does copy the of_node from the parent device of
the GPIO chip, there is no need to repeat this in the individual
drivers. Remove these assignment all at once.

For the details one may look into the of_gpio_dev_init() implementation.

Signed-off-by: Andy Shevchenko <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Linus Walleij <[email protected]>
  • Loading branch information
andy-shev authored and linusw committed Dec 16, 2021
1 parent 8df89a7 commit 8a8d6bb
Show file tree
Hide file tree
Showing 24 changed files with 8 additions and 37 deletions.
1 change: 0 additions & 1 deletion drivers/pinctrl/actions/pinctrl-owl.c
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,6 @@ static int owl_gpio_init(struct owl_pinctrl *pctrl)
chip->label = dev_name(pctrl->dev);
chip->parent = pctrl->dev;
chip->owner = THIS_MODULE;
chip->of_node = pctrl->dev->of_node;

pctrl->irq_chip.name = chip->of_node->name;
pctrl->irq_chip.irq_ack = owl_gpio_irq_ack;
Expand Down
1 change: 0 additions & 1 deletion drivers/pinctrl/bcm/pinctrl-bcm2835.c
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,6 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)

pc->gpio_chip = *pdata->gpio_chip;
pc->gpio_chip.parent = dev;
pc->gpio_chip.of_node = np;

for (i = 0; i < BCM2835_NUM_BANKS; i++) {
unsigned long events;
Expand Down
1 change: 0 additions & 1 deletion drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,6 @@ static int iproc_gpio_probe(struct platform_device *pdev)
chip->num_banks = (ngpios + NGPIOS_PER_BANK - 1) / NGPIOS_PER_BANK;
gc->label = dev_name(dev);
gc->parent = dev;
gc->of_node = dev->of_node;
gc->request = iproc_gpio_request;
gc->free = iproc_gpio_free;
gc->direction_input = iproc_gpio_direction_input;
Expand Down
1 change: 0 additions & 1 deletion drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,6 @@ static int nsp_gpio_probe(struct platform_device *pdev)
gc->ngpio = val;
gc->label = dev_name(dev);
gc->parent = dev;
gc->of_node = dev->of_node;
gc->request = gpiochip_generic_request;
gc->free = gpiochip_generic_free;
gc->direction_input = nsp_gpio_direction_input;
Expand Down
3 changes: 0 additions & 3 deletions drivers/pinctrl/cirrus/pinctrl-lochnagar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1161,9 +1161,6 @@ static int lochnagar_pin_probe(struct platform_device *pdev)
priv->gpio_chip.can_sleep = true;
priv->gpio_chip.parent = dev;
priv->gpio_chip.base = -1;
#ifdef CONFIG_OF_GPIO
priv->gpio_chip.of_node = dev->of_node;
#endif

switch (lochnagar->type) {
case LOCHNAGAR1:
Expand Down
7 changes: 3 additions & 4 deletions drivers/pinctrl/mediatek/pinctrl-moore.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ static int mtk_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
return mtk_eint_set_debounce(hw->eint, desc->eint.eint_n, debounce);
}

static int mtk_build_gpiochip(struct mtk_pinctrl *hw, struct device_node *np)
static int mtk_build_gpiochip(struct mtk_pinctrl *hw)
{
struct gpio_chip *chip = &hw->chip;
int ret;
Expand All @@ -536,7 +536,6 @@ static int mtk_build_gpiochip(struct mtk_pinctrl *hw, struct device_node *np)
chip->set_config = mtk_gpio_set_config;
chip->base = -1;
chip->ngpio = hw->soc->npins;
chip->of_node = np;
chip->of_gpio_n_cells = 2;

ret = gpiochip_add_data(chip, hw);
Expand All @@ -550,7 +549,7 @@ static int mtk_build_gpiochip(struct mtk_pinctrl *hw, struct device_node *np)
* Documentation/devicetree/bindings/gpio/gpio.txt on how to
* bind pinctrl and gpio drivers via the "gpio-ranges" property.
*/
if (!of_find_property(np, "gpio-ranges", NULL)) {
if (!of_find_property(hw->dev->of_node, "gpio-ranges", NULL)) {
ret = gpiochip_add_pin_range(chip, dev_name(hw->dev), 0, 0,
chip->ngpio);
if (ret < 0) {
Expand Down Expand Up @@ -691,7 +690,7 @@ int mtk_moore_pinctrl_probe(struct platform_device *pdev,
"Failed to add EINT, but pinctrl still can work\n");

/* Build gpiochip should be after pinctrl_enable is done */
err = mtk_build_gpiochip(hw, pdev->dev.of_node);
err = mtk_build_gpiochip(hw);
if (err) {
dev_err(&pdev->dev, "Failed to add gpio_chip\n");
return err;
Expand Down
5 changes: 2 additions & 3 deletions drivers/pinctrl/mediatek/pinctrl-paris.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ static int mtk_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
return mtk_eint_set_debounce(hw->eint, desc->eint.eint_n, debounce);
}

static int mtk_build_gpiochip(struct mtk_pinctrl *hw, struct device_node *np)
static int mtk_build_gpiochip(struct mtk_pinctrl *hw)
{
struct gpio_chip *chip = &hw->chip;
int ret;
Expand All @@ -913,7 +913,6 @@ static int mtk_build_gpiochip(struct mtk_pinctrl *hw, struct device_node *np)
chip->set_config = mtk_gpio_set_config;
chip->base = -1;
chip->ngpio = hw->soc->npins;
chip->of_node = np;
chip->of_gpio_n_cells = 2;

ret = gpiochip_add_data(chip, hw);
Expand Down Expand Up @@ -1037,7 +1036,7 @@ int mtk_paris_pinctrl_probe(struct platform_device *pdev,
"Failed to add EINT, but pinctrl still can work\n");

/* Build gpiochip should be after pinctrl_enable is done */
err = mtk_build_gpiochip(hw, pdev->dev.of_node);
err = mtk_build_gpiochip(hw);
if (err) {
dev_err(&pdev->dev, "Failed to add gpio_chip\n");
return err;
Expand Down
3 changes: 0 additions & 3 deletions drivers/pinctrl/pinctrl-amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1009,9 +1009,6 @@ static int amd_gpio_probe(struct platform_device *pdev)
gpio_dev->gc.owner = THIS_MODULE;
gpio_dev->gc.parent = &pdev->dev;
gpio_dev->gc.ngpio = resource_size(res) / 4;
#if defined(CONFIG_OF_GPIO)
gpio_dev->gc.of_node = pdev->dev.of_node;
#endif

gpio_dev->hwbank_num = gpio_dev->gc.ngpio / 64;
gpio_dev->groups = kerncz_groups;
Expand Down
1 change: 0 additions & 1 deletion drivers/pinctrl/pinctrl-at91-pio4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,6 @@ static int atmel_pinctrl_probe(struct platform_device *pdev)
}

atmel_pioctrl->gpio_chip = &atmel_gpio_chip;
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->parent = dev;
Expand Down
1 change: 0 additions & 1 deletion drivers/pinctrl/pinctrl-at91.c
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,6 @@ static int at91_gpio_probe(struct platform_device *pdev)
at91_chip->chip = at91_gpio_template;

chip = &at91_chip->chip;
chip->of_node = np;
chip->label = dev_name(&pdev->dev);
chip->parent = &pdev->dev;
chip->owner = THIS_MODULE;
Expand Down
5 changes: 2 additions & 3 deletions drivers/pinctrl/pinctrl-digicolor.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static void dc_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
spin_unlock_irqrestore(&pmap->lock, flags);
}

static int dc_gpiochip_add(struct dc_pinmap *pmap, struct device_node *np)
static int dc_gpiochip_add(struct dc_pinmap *pmap)
{
struct gpio_chip *chip = &pmap->chip;
int ret;
Expand All @@ -248,7 +248,6 @@ static int dc_gpiochip_add(struct dc_pinmap *pmap, struct device_node *np)
chip->set = dc_gpio_set;
chip->base = -1;
chip->ngpio = PINS_COUNT;
chip->of_node = np;
chip->of_gpio_n_cells = 2;

spin_lock_init(&pmap->lock);
Expand Down Expand Up @@ -326,7 +325,7 @@ static int dc_pinctrl_probe(struct platform_device *pdev)
return PTR_ERR(pmap->pctl);
}

return dc_gpiochip_add(pmap, pdev->dev.of_node);
return dc_gpiochip_add(pmap);
}

static const struct of_device_id dc_pinctrl_ids[] = {
Expand Down
1 change: 0 additions & 1 deletion drivers/pinctrl/pinctrl-mcp23s08.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
mcp->chip.set = mcp23s08_set;
#ifdef CONFIG_OF_GPIO
mcp->chip.of_gpio_n_cells = 2;
mcp->chip.of_node = dev->of_node;
#endif

mcp->chip.base = base;
Expand Down
1 change: 0 additions & 1 deletion drivers/pinctrl/pinctrl-ocelot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1748,7 +1748,6 @@ static int ocelot_gpiochip_register(struct platform_device *pdev,
gc->ngpio = info->desc->npins;
gc->parent = &pdev->dev;
gc->base = -1;
gc->of_node = info->dev->of_node;
gc->label = "ocelot-gpio";

irq = irq_of_parse_and_map(gc->of_node, 0);
Expand Down
1 change: 0 additions & 1 deletion drivers/pinctrl/pinctrl-oxnas.c
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,6 @@ static int oxnas_gpio_probe(struct platform_device *pdev)

bank->id = id;
bank->gpio_chip.parent = &pdev->dev;
bank->gpio_chip.of_node = np;
bank->gpio_chip.ngpio = ngpios;
girq = &bank->gpio_chip.irq;
girq->chip = &bank->irq_chip;
Expand Down
2 changes: 1 addition & 1 deletion drivers/pinctrl/pinctrl-pic32.c
Original file line number Diff line number Diff line change
Expand Up @@ -2241,7 +2241,7 @@ static int pic32_gpio_probe(struct platform_device *pdev)
}

bank->gpio_chip.parent = &pdev->dev;
bank->gpio_chip.of_node = np;

girq = &bank->gpio_chip.irq;
girq->chip = &bank->irq_chip;
girq->parent_handler = pic32_gpio_irq_handler;
Expand Down
1 change: 0 additions & 1 deletion drivers/pinctrl/pinctrl-stmfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,6 @@ static int stmfx_pinctrl_probe(struct platform_device *pdev)
pctl->gpio_chip.base = -1;
pctl->gpio_chip.ngpio = pctl->pctl_desc.npins;
pctl->gpio_chip.can_sleep = true;
pctl->gpio_chip.of_node = np;

pctl->irq_chip.name = dev_name(pctl->dev);
pctl->irq_chip.irq_mask = stmfx_pinctrl_irq_mask;
Expand Down
3 changes: 0 additions & 3 deletions drivers/pinctrl/pinctrl-sx150x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1163,9 +1163,6 @@ static int sx150x_probe(struct i2c_client *client,
pctl->gpio.set = sx150x_gpio_set;
pctl->gpio.set_config = gpiochip_generic_config;
pctl->gpio.parent = dev;
#ifdef CONFIG_OF_GPIO
pctl->gpio.of_node = dev->of_node;
#endif
pctl->gpio.can_sleep = true;
pctl->gpio.label = devm_kstrdup(dev, client->name, GFP_KERNEL);
if (!pctl->gpio.label)
Expand Down
1 change: 0 additions & 1 deletion drivers/pinctrl/pinctrl-xway.c
Original file line number Diff line number Diff line change
Expand Up @@ -1763,7 +1763,6 @@ static int pinmux_xway_probe(struct platform_device *pdev)
/* register the gpio chip */
xway_chip.parent = &pdev->dev;
xway_chip.owner = THIS_MODULE;
xway_chip.of_node = pdev->dev.of_node;
ret = devm_gpiochip_add_data(&pdev->dev, &xway_chip, NULL);
if (ret) {
dev_err(&pdev->dev, "Failed to register gpio chip\n");
Expand Down
1 change: 0 additions & 1 deletion drivers/pinctrl/qcom/pinctrl-msm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,6 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
chip->label = dev_name(pctrl->dev);
chip->parent = pctrl->dev;
chip->owner = THIS_MODULE;
chip->of_node = pctrl->dev->of_node;
if (msm_gpio_needs_valid_mask(pctrl))
chip->init_valid_mask = msm_gpio_init_valid_mask;

Expand Down
1 change: 0 additions & 1 deletion drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,6 @@ static int pm8xxx_gpio_probe(struct platform_device *pdev)
pctrl->chip = pm8xxx_gpio_template;
pctrl->chip.base = -1;
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);
pctrl->chip.ngpio = pctrl->npins;
Expand Down
1 change: 0 additions & 1 deletion drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,6 @@ static int pm8xxx_mpp_probe(struct platform_device *pdev)
pctrl->chip = pm8xxx_mpp_template;
pctrl->chip.base = -1;
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);
pctrl->chip.ngpio = pctrl->npins;
Expand Down
1 change: 0 additions & 1 deletion drivers/pinctrl/renesas/pinctrl-rza2.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ static int rza2_gpio_register(struct rza2_pinctrl_priv *priv)
int ret;

chip.label = devm_kasprintf(priv->dev, GFP_KERNEL, "%pOFn", np);
chip.of_node = np;
chip.parent = priv->dev;
chip.ngpio = priv->npins;

Expand Down
1 change: 0 additions & 1 deletion drivers/pinctrl/spear/pinctrl-plgpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,6 @@ static int plgpio_probe(struct platform_device *pdev)
plgpio->chip.label = dev_name(&pdev->dev);
plgpio->chip.parent = &pdev->dev;
plgpio->chip.owner = THIS_MODULE;
plgpio->chip.of_node = pdev->dev.of_node;

if (!IS_ERR(plgpio->clk)) {
ret = clk_prepare(plgpio->clk);
Expand Down
1 change: 0 additions & 1 deletion drivers/pinctrl/vt8500/pinctrl-wmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,6 @@ int wmt_pinctrl_probe(struct platform_device *pdev,

data->gpio_chip = wmt_gpio_chip;
data->gpio_chip.parent = &pdev->dev;
data->gpio_chip.of_node = pdev->dev.of_node;
data->gpio_chip.ngpio = data->nbanks * 32;

platform_set_drvdata(pdev, data);
Expand Down

0 comments on commit 8a8d6bb

Please sign in to comment.