diff mbox series

[v2] gpio: viperboard: remove platform_set_drvdata() call in probe

Message ID 20210825070125.32918-1-aardelean@deviqon.com
State Accepted
Commit 6b4a2a427245fd357208ccf427891805354ef5b1
Headers show
Series [v2] gpio: viperboard: remove platform_set_drvdata() call in probe | expand

Commit Message

Alexandru Ardelean Aug. 25, 2021, 7:01 a.m. UTC
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 change removes it.
Also removing with this change is some logging about the failure to init
the gpio chip data. There are other logging methods to view that this
failed.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
---

Changelog v1 -> v2:
* remove dev_err() prints
* [styling] added empty line before first devm_gpiochip_add_data()

 drivers/gpio/gpio-viperboard.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

Comments

Bartosz Golaszewski Aug. 31, 2021, 9:29 a.m. UTC | #1
On Wed, Aug 25, 2021 at 9:02 AM Alexandru Ardelean
<aardelean@deviqon.com> wrote:
>

> 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 change removes it.

> Also removing with this change is some logging about the failure to init

> the gpio chip data. There are other logging methods to view that this

> failed.

>

> Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>

> ---

>

> Changelog v1 -> v2:

> * remove dev_err() prints

> * [styling] added empty line before first devm_gpiochip_add_data()

>

>  drivers/gpio/gpio-viperboard.c | 14 +++-----------

>  1 file changed, 3 insertions(+), 11 deletions(-)

>

> diff --git a/drivers/gpio/gpio-viperboard.c b/drivers/gpio/gpio-viperboard.c

> index c301c1d56dd2..e55d28a8a66f 100644

> --- a/drivers/gpio/gpio-viperboard.c

> +++ b/drivers/gpio/gpio-viperboard.c

> @@ -404,11 +404,10 @@ static int vprbrd_gpio_probe(struct platform_device *pdev)

>         vb_gpio->gpioa.get = vprbrd_gpioa_get;

>         vb_gpio->gpioa.direction_input = vprbrd_gpioa_direction_input;

>         vb_gpio->gpioa.direction_output = vprbrd_gpioa_direction_output;

> +

>         ret = devm_gpiochip_add_data(&pdev->dev, &vb_gpio->gpioa, vb_gpio);

> -       if (ret < 0) {

> -               dev_err(vb_gpio->gpioa.parent, "could not add gpio a");

> +       if (ret < 0)

>                 return ret;

> -       }

>

>         /* registering gpio b */

>         vb_gpio->gpiob.label = "viperboard gpio b";

> @@ -421,15 +420,8 @@ static int vprbrd_gpio_probe(struct platform_device *pdev)

>         vb_gpio->gpiob.get = vprbrd_gpiob_get;

>         vb_gpio->gpiob.direction_input = vprbrd_gpiob_direction_input;

>         vb_gpio->gpiob.direction_output = vprbrd_gpiob_direction_output;

> -       ret = devm_gpiochip_add_data(&pdev->dev, &vb_gpio->gpiob, vb_gpio);

> -       if (ret < 0) {

> -               dev_err(vb_gpio->gpiob.parent, "could not add gpio b");

> -               return ret;

> -       }

> -

> -       platform_set_drvdata(pdev, vb_gpio);

>

> -       return ret;

> +       return devm_gpiochip_add_data(&pdev->dev, &vb_gpio->gpiob, vb_gpio);

>  }

>

>  static struct platform_driver vprbrd_gpio_driver = {

> --

> 2.31.1

>


Applied, thanks!

Bart
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-viperboard.c b/drivers/gpio/gpio-viperboard.c
index c301c1d56dd2..e55d28a8a66f 100644
--- a/drivers/gpio/gpio-viperboard.c
+++ b/drivers/gpio/gpio-viperboard.c
@@ -404,11 +404,10 @@  static int vprbrd_gpio_probe(struct platform_device *pdev)
 	vb_gpio->gpioa.get = vprbrd_gpioa_get;
 	vb_gpio->gpioa.direction_input = vprbrd_gpioa_direction_input;
 	vb_gpio->gpioa.direction_output = vprbrd_gpioa_direction_output;
+
 	ret = devm_gpiochip_add_data(&pdev->dev, &vb_gpio->gpioa, vb_gpio);
-	if (ret < 0) {
-		dev_err(vb_gpio->gpioa.parent, "could not add gpio a");
+	if (ret < 0)
 		return ret;
-	}
 
 	/* registering gpio b */
 	vb_gpio->gpiob.label = "viperboard gpio b";
@@ -421,15 +420,8 @@  static int vprbrd_gpio_probe(struct platform_device *pdev)
 	vb_gpio->gpiob.get = vprbrd_gpiob_get;
 	vb_gpio->gpiob.direction_input = vprbrd_gpiob_direction_input;
 	vb_gpio->gpiob.direction_output = vprbrd_gpiob_direction_output;
-	ret = devm_gpiochip_add_data(&pdev->dev, &vb_gpio->gpiob, vb_gpio);
-	if (ret < 0) {
-		dev_err(vb_gpio->gpiob.parent, "could not add gpio b");
-		return ret;
-	}
-
-	platform_set_drvdata(pdev, vb_gpio);
 
-	return ret;
+	return devm_gpiochip_add_data(&pdev->dev, &vb_gpio->gpiob, vb_gpio);
 }
 
 static struct platform_driver vprbrd_gpio_driver = {