Commit ba6764d5 authored by Maxime Ripard's avatar Maxime Ripard Committed by Linus Walleij

pinctrl: sunxi: Fix multiple registration issue

When the support for the PRCM muxer on the A31 has been added, the global
static pinctl_desc definition has been left as is. Unfortunately, this
structure is used to register the pinctrl device, and prior to this
registration, we set the name and pins field.

Since this structure is shared across instances, that means that the latest
registered pinctrl device wins in setting the name, pins and pins numbers,
which is not really a good thing.
Signed-off-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 118c565a
...@@ -436,12 +436,6 @@ static const struct pinmux_ops sunxi_pmx_ops = { ...@@ -436,12 +436,6 @@ static const struct pinmux_ops sunxi_pmx_ops = {
.gpio_set_direction = sunxi_pmx_gpio_set_direction, .gpio_set_direction = sunxi_pmx_gpio_set_direction,
}; };
static struct pinctrl_desc sunxi_pctrl_desc = {
.confops = &sunxi_pconf_ops,
.pctlops = &sunxi_pctrl_ops,
.pmxops = &sunxi_pmx_ops,
};
static int sunxi_pinctrl_gpio_request(struct gpio_chip *chip, unsigned offset) static int sunxi_pinctrl_gpio_request(struct gpio_chip *chip, unsigned offset)
{ {
return pinctrl_request_gpio(chip->base + offset); return pinctrl_request_gpio(chip->base + offset);
...@@ -778,6 +772,7 @@ int sunxi_pinctrl_init(struct platform_device *pdev, ...@@ -778,6 +772,7 @@ int sunxi_pinctrl_init(struct platform_device *pdev,
const struct sunxi_pinctrl_desc *desc) const struct sunxi_pinctrl_desc *desc)
{ {
struct device_node *node = pdev->dev.of_node; struct device_node *node = pdev->dev.of_node;
struct pinctrl_desc *pctrl_desc;
struct pinctrl_pin_desc *pins; struct pinctrl_pin_desc *pins;
struct sunxi_pinctrl *pctl; struct sunxi_pinctrl *pctl;
struct resource *res; struct resource *res;
...@@ -796,6 +791,7 @@ int sunxi_pinctrl_init(struct platform_device *pdev, ...@@ -796,6 +791,7 @@ int sunxi_pinctrl_init(struct platform_device *pdev,
if (IS_ERR(pctl->membase)) if (IS_ERR(pctl->membase))
return PTR_ERR(pctl->membase); return PTR_ERR(pctl->membase);
pctl->dev = &pdev->dev;
pctl->desc = desc; pctl->desc = desc;
ret = sunxi_pinctrl_build_state(pdev); ret = sunxi_pinctrl_build_state(pdev);
...@@ -813,12 +809,21 @@ int sunxi_pinctrl_init(struct platform_device *pdev, ...@@ -813,12 +809,21 @@ int sunxi_pinctrl_init(struct platform_device *pdev,
for (i = 0; i < pctl->desc->npins; i++) for (i = 0; i < pctl->desc->npins; i++)
pins[i] = pctl->desc->pins[i].pin; pins[i] = pctl->desc->pins[i].pin;
sunxi_pctrl_desc.name = dev_name(&pdev->dev); pctrl_desc = devm_kzalloc(&pdev->dev,
sunxi_pctrl_desc.owner = THIS_MODULE; sizeof(*pctrl_desc),
sunxi_pctrl_desc.pins = pins; GFP_KERNEL);
sunxi_pctrl_desc.npins = pctl->desc->npins; if (!pctrl_desc)
pctl->dev = &pdev->dev; return -ENOMEM;
pctl->pctl_dev = pinctrl_register(&sunxi_pctrl_desc,
pctrl_desc->name = dev_name(&pdev->dev);
pctrl_desc->owner = THIS_MODULE;
pctrl_desc->pins = pins;
pctrl_desc->npins = pctl->desc->npins;
pctrl_desc->confops = &sunxi_pconf_ops;
pctrl_desc->pctlops = &sunxi_pctrl_ops;
pctrl_desc->pmxops = &sunxi_pmx_ops;
pctl->pctl_dev = pinctrl_register(pctrl_desc,
&pdev->dev, pctl); &pdev->dev, pctl);
if (!pctl->pctl_dev) { if (!pctl->pctl_dev) {
dev_err(&pdev->dev, "couldn't register pinctrl driver\n"); dev_err(&pdev->dev, "couldn't register pinctrl driver\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment