gpio: Setup parent device and get rid of unnecessary of_node assignment
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 6 Dec 2021 13:18:51 +0000 (15:18 +0200)
committerBartosz Golaszewski <brgl@bgdev.pl>
Fri, 17 Dec 2021 16:44:19 +0000 (17:44 +0100)
Some of the drivers do not set parent device. This may lead to obstacles
during debugging or understanding the device relations from the Linux
point of view. Assign parent device for GPIO chips created by these
drivers.

While at it, let GPIO library to assign of_node from the parent device.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
drivers/gpio/gpio-bcm-kona.c
drivers/gpio/gpio-creg-snps.c
drivers/gpio/gpio-lpc32xx.c
drivers/gpio/gpio-pxa.c

index d329a143f5ec9480cea3809d8cc918ff91051056..e844744944299509ff88d5a061df29f87b7f1a37 100644 (file)
@@ -606,7 +606,7 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev)
 
        kona_gpio->pdev = pdev;
        platform_set_drvdata(pdev, kona_gpio);
-       chip->of_node = dev->of_node;
+       chip->parent = dev;
        chip->ngpio = kona_gpio->num_bank * GPIO_PER_BANK;
 
        kona_gpio->irq_domain = irq_domain_add_linear(dev->of_node,
index 1d0827e7970353099e9eff2a8de6223f9e60df89..789384c6e1782282fd31e082b009b33c92d47732 100644 (file)
@@ -163,12 +163,12 @@ static int creg_gpio_probe(struct platform_device *pdev)
 
        spin_lock_init(&hcg->lock);
 
+       hcg->gc.parent = dev;
        hcg->gc.label = dev_name(dev);
        hcg->gc.base = -1;
        hcg->gc.ngpio = ngpios;
        hcg->gc.set = creg_gpio_set;
        hcg->gc.direction_output = creg_gpio_dir_out;
-       hcg->gc.of_node = dev->of_node;
 
        ret = devm_gpiochip_add_data(dev, &hcg->gc, hcg);
        if (ret)
index 4e626c4235c2e161f704ebe39902d2753bd9c9f5..d2b65cfb336ea92a14e7ef309acdd91bb933eb8b 100644 (file)
@@ -512,10 +512,10 @@ static int lpc32xx_gpio_probe(struct platform_device *pdev)
                return PTR_ERR(reg_base);
 
        for (i = 0; i < ARRAY_SIZE(lpc32xx_gpiochip); i++) {
+               lpc32xx_gpiochip[i].chip.parent = &pdev->dev;
                if (pdev->dev.of_node) {
                        lpc32xx_gpiochip[i].chip.of_xlate = lpc32xx_of_xlate;
                        lpc32xx_gpiochip[i].chip.of_gpio_n_cells = 3;
-                       lpc32xx_gpiochip[i].chip.of_node = pdev->dev.of_node;
                        lpc32xx_gpiochip[i].reg_base = reg_base;
                }
                devm_gpiochip_add_data(&pdev->dev, &lpc32xx_gpiochip[i].chip,
index 382468e294e1af1e99a3aaaae161a719fc0a1b79..c7fbfa3ae43b920eca9e6a9c0d6b3696e64ac851 100644 (file)
@@ -343,8 +343,7 @@ static int pxa_gpio_of_xlate(struct gpio_chip *gc,
 }
 #endif
 
-static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, int ngpio,
-                             struct device_node *np, void __iomem *regbase)
+static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, int ngpio, void __iomem *regbase)
 {
        int i, gpio, nbanks = DIV_ROUND_UP(ngpio, 32);
        struct pxa_gpio_bank *bank;
@@ -354,6 +353,7 @@ static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, int ngpio,
        if (!pchip->banks)
                return -ENOMEM;
 
+       pchip->chip.parent = pchip->dev;
        pchip->chip.label = "gpio-pxa";
        pchip->chip.direction_input  = pxa_gpio_direction_input;
        pchip->chip.direction_output = pxa_gpio_direction_output;
@@ -365,7 +365,6 @@ static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, int ngpio,
        pchip->chip.free = gpiochip_generic_free;
 
 #ifdef CONFIG_OF_GPIO
-       pchip->chip.of_node = np;
        pchip->chip.of_xlate = pxa_gpio_of_xlate;
        pchip->chip.of_gpio_n_cells = 2;
 #endif
@@ -675,8 +674,7 @@ static int pxa_gpio_probe(struct platform_device *pdev)
        }
 
        /* Initialize GPIO chips */
-       ret = pxa_init_gpio_chip(pchip, pxa_last_gpio + 1, pdev->dev.of_node,
-                                gpio_reg_base);
+       ret = pxa_init_gpio_chip(pchip, pxa_last_gpio + 1, gpio_reg_base);
        if (ret) {
                clk_put(clk);
                return ret;