Skip to contentSkip to conversation

gpio: gpio-adp5520: cleanup probe error path + remove platform_set_drvdata()

PATCH Applied Alexandru Ardelean 2 participants 2 messages May 14, 2021 – May 21, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: gpio-adp5520: cleanup probe error path + remove platform_set_drvdata()

The platform_set_drvdata() call is only useful if we need to retrieve back the private information.
Since the driver doesn't do that, it's not useful to have it.

This also means that the 'err' label can be removed and all goto statements replaced with direct returns (with error codes).

---
 drivers/gpio/gpio-adp5520.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/gpio/gpio-adp5520.c +4 -14
index 0386ede53f3a..c55e821c63b6 100644
@@ -113,10 +113,8 @@ static int adp5520_gpio_probe(struct platform_device *pdev)
 		if (pdata->gpio_en_mask & (1 << i))
 			dev->lut[gpios++] = 1 << i;
 
-	if (gpios < 1) {
-		ret = -EINVAL;
-		goto err;
-	}
+	if (gpios < 1)
+		return -EINVAL;
 
 	gc = &dev->gpio_chip;
 	gc->direction_input  = adp5520_gpio_direction_input;
@@ -148,18 +146,10 @@ static int adp5520_gpio_probe(struct platform_device *pdev)
 
 	if (ret) {
 		dev_err(&pdev->dev, "failed to write\n");
-		goto err;
+		return ret;
 	}
 
-	ret = devm_gpiochip_add_data(&pdev->dev, &dev->gpio_chip, dev);
-	if (ret)
-		goto err;
-
-	platform_set_drvdata(pdev, dev);
-	return 0;
-
-err:
-	return ret;
+	return devm_gpiochip_add_data(&pdev->dev, &dev->gpio_chip, dev);
 }
 
 static struct platform_driver adp5520_gpio_driver = {
Signature · 1 line
2.31.1
#1 lore raw
Quoted 52 lines · Alexandru Ardelean

The platform_set_drvdata() call is only useful if we need to retrieve back the private information.
Since the driver doesn't do that, it's not useful to have it.

This also means that the 'err' label can be removed and all goto statements replaced with direct returns (with error codes).

---
 drivers/gpio/gpio-adp5520.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/gpio/gpio-adp5520.c +4 -15
index 0386ede53f3a..c55e821c63b6 100644
@@ -113,10 +113,8 @@ static int adp5520_gpio_probe(struct platform_device *pdev)
                if (pdata->gpio_en_mask & (1 << i))
                        dev->lut[gpios++] = 1 << i;
 
-       if (gpios < 1) {
-               ret = -EINVAL;
-               goto err;
-       }
+       if (gpios < 1)
+               return -EINVAL;
 
        gc = &dev->gpio_chip;
        gc->direction_input  = adp5520_gpio_direction_input;
@@ -148,18 +146,10 @@ static int adp5520_gpio_probe(struct platform_device *pdev)
 
        if (ret) {
                dev_err(&pdev->dev, "failed to write\n");
-               goto err;
+               return ret;
        }
 
-       ret = devm_gpiochip_add_data(&pdev->dev, &dev->gpio_chip, dev);
-       if (ret)
-               goto err;
-
-       platform_set_drvdata(pdev, dev);
-       return 0;
-
-err:
-       return ret;
+       return devm_gpiochip_add_data(&pdev->dev, &dev->gpio_chip, dev);
 }
 
 static struct platform_driver adp5520_gpio_driver = {
--
Quoted 2 lines

2.31.1

Applied, thanks!
Bartosz