gpio: Propagate firmware node from a parent device
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 6 Dec 2021 13:18:52 +0000 (15:18 +0200)
committerBartosz Golaszewski <brgl@bgdev.pl>
Fri, 17 Dec 2021 16:50:46 +0000 (17:50 +0100)
When creating MFD platform devices the firmware node is left unset.
This, in particular, prevents GPIO library to use it for different
purposes. Propagate firmware node from the parent device and let
GPIO library do the right thing.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
drivers/gpio/gpio-arizona.c
drivers/gpio/gpio-tps6586x.c
drivers/gpio/gpio-tps65910.c
drivers/gpio/gpio-twl6040.c
drivers/gpio/gpio-wm831x.c

index 2bc173c352ce5aadde7142376c4931a4116bfcf8..02f9ae19cd445ce8e64fb68e1a88250475786f16 100644 (file)
@@ -151,6 +151,8 @@ static int arizona_gpio_probe(struct platform_device *pdev)
        struct arizona_gpio *arizona_gpio;
        int ret;
 
+       device_set_node(&pdev->dev, dev_fwnode(pdev->dev.parent));
+
        arizona_gpio = devm_kzalloc(&pdev->dev, sizeof(*arizona_gpio),
                                    GFP_KERNEL);
        if (!arizona_gpio)
@@ -159,9 +161,6 @@ static int arizona_gpio_probe(struct platform_device *pdev)
        arizona_gpio->arizona = arizona;
        arizona_gpio->gpio_chip = template_chip;
        arizona_gpio->gpio_chip.parent = &pdev->dev;
-#ifdef CONFIG_OF_GPIO
-       arizona_gpio->gpio_chip.of_node = arizona->dev->of_node;
-#endif
 
        switch (arizona->type) {
        case WM5102:
index da0304b764a5187e35aacabfcdd101f93b747b89..c5713524b581df5b35913fd774c747d4cb7cc612 100644 (file)
@@ -77,6 +77,8 @@ static int tps6586x_gpio_probe(struct platform_device *pdev)
        struct tps6586x_platform_data *pdata;
        struct tps6586x_gpio *tps6586x_gpio;
 
+       device_set_node(&pdev->dev, dev_fwnode(pdev->dev.parent));
+
        pdata = dev_get_platdata(pdev->dev.parent);
        tps6586x_gpio = devm_kzalloc(&pdev->dev,
                                sizeof(*tps6586x_gpio), GFP_KERNEL);
@@ -97,9 +99,6 @@ static int tps6586x_gpio_probe(struct platform_device *pdev)
        tps6586x_gpio->gpio_chip.get    = tps6586x_gpio_get;
        tps6586x_gpio->gpio_chip.to_irq = tps6586x_gpio_to_irq;
 
-#ifdef CONFIG_OF_GPIO
-       tps6586x_gpio->gpio_chip.of_node = pdev->dev.parent->of_node;
-#endif
        if (pdata && pdata->gpio_base)
                tps6586x_gpio->gpio_chip.base = pdata->gpio_base;
        else
index 7fa8c841081fc1b860c5b5d8ce30be0f0756f74e..321e6945f0be91a8bad12422c4c41746c5f13f3f 100644 (file)
@@ -111,6 +111,8 @@ static int tps65910_gpio_probe(struct platform_device *pdev)
        int ret;
        int i;
 
+       device_set_node(&pdev->dev, dev_fwnode(pdev->dev.parent));
+
        tps65910_gpio = devm_kzalloc(&pdev->dev,
                                sizeof(*tps65910_gpio), GFP_KERNEL);
        if (!tps65910_gpio)
@@ -137,9 +139,7 @@ static int tps65910_gpio_probe(struct platform_device *pdev)
        tps65910_gpio->gpio_chip.set    = tps65910_gpio_set;
        tps65910_gpio->gpio_chip.get    = tps65910_gpio_get;
        tps65910_gpio->gpio_chip.parent = &pdev->dev;
-#ifdef CONFIG_OF_GPIO
-       tps65910_gpio->gpio_chip.of_node = tps65910->dev->of_node;
-#endif
+
        if (pdata && pdata->gpio_base)
                tps65910_gpio->gpio_chip.base = pdata->gpio_base;
        else
index 648fb418d775bf2a69cbb2a98734629249f6c028..6c3fbf382dba831881fcd9f052e3f6c4e4e20fb5 100644 (file)
@@ -80,6 +80,8 @@ static int gpo_twl6040_probe(struct platform_device *pdev)
        struct twl6040 *twl6040 = dev_get_drvdata(twl6040_core_dev);
        int ret;
 
+       device_set_node(&pdev->dev, dev_fwnode(pdev->dev.parent));
+
        twl6040gpo_chip.base = -1;
 
        if (twl6040_get_revid(twl6040) < TWL6041_REV_ES2_0)
@@ -88,9 +90,6 @@ static int gpo_twl6040_probe(struct platform_device *pdev)
                twl6040gpo_chip.ngpio = 1; /* twl6041 have 1 GPO */
 
        twl6040gpo_chip.parent = &pdev->dev;
-#ifdef CONFIG_OF_GPIO
-       twl6040gpo_chip.of_node = twl6040_core_dev->of_node;
-#endif
 
        ret = devm_gpiochip_add_data(&pdev->dev, &twl6040gpo_chip, NULL);
        if (ret < 0) {
index 9cf1e5ebb352a71600f1fba45e50fd6168e0cd55..7eaf8a28638cf36d494d1f52ed1cabe453738458 100644 (file)
@@ -262,6 +262,8 @@ static int wm831x_gpio_probe(struct platform_device *pdev)
        struct wm831x_pdata *pdata = &wm831x->pdata;
        struct wm831x_gpio *wm831x_gpio;
 
+       device_set_node(&pdev->dev, dev_fwnode(pdev->dev.parent));
+
        wm831x_gpio = devm_kzalloc(&pdev->dev, sizeof(*wm831x_gpio),
                                   GFP_KERNEL);
        if (wm831x_gpio == NULL)
@@ -275,9 +277,6 @@ static int wm831x_gpio_probe(struct platform_device *pdev)
                wm831x_gpio->gpio_chip.base = pdata->gpio_base;
        else
                wm831x_gpio->gpio_chip.base = -1;
-#ifdef CONFIG_OF_GPIO
-       wm831x_gpio->gpio_chip.of_node = wm831x->dev->of_node;
-#endif
 
        return devm_gpiochip_add_data(&pdev->dev, &wm831x_gpio->gpio_chip, wm831x_gpio);
 }