gpio: viperboard: remove platform_set_drvdata() call in probe
PATCH 1/1 gpio: viperboard: remove platform_set_drvdata() call in probe
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.
--- drivers/gpio/gpio-viperboard.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpio/gpio-viperboard.c +1 -5
@@ -422,12 +422,8 @@ static int vprbrd_gpio_probe(struct platform_device *pdev) 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 ) { +if (ret <0 )dev_err (vb_gpio->gpiob.parent,"could not add gpio b" ); -return ret; - } - -platform_set_drvdata (pdev, vb_gpio);return ret; }
Signature · 1 line
2.31.1
Quoted 31 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 change removes it.
Signed-off-by Alexandru Ardelean <[email protected]>--- drivers/gpio/gpio-viperboard.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/gpio/gpio-viperboard.c +1
-6@@ -422,12 +422,8 @@ static int vprbrd_gpio_probe(struct platform_device *pdev) 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 ) { +if (ret <0 )dev_err (vb_gpio->gpiob.parent,"could not add gpio b" ); -return ret; - } - -platform_set_drvdata (pdev, vb_gpio);return ret; } --
Quoted 2 lines
2.31.1
The log is not really needed, we'll get an error message from gpiolib core. Can you remove it while you're at it and just return the result of devm_gpiochip_add_data()?
Bart
Quoted 30 lines · Bartosz Golaszewski
Quoted 28 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 change removes it.
Signed-off-by Alexandru Ardelean <[email protected]>--- drivers/gpio/gpio-viperboard.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/gpio/gpio-viperboard.c +1
-5@@ -422,12 +422,8 @@ static int vprbrd_gpio_probe(struct platform_device *pdev) 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 ) { +if (ret <0 )dev_err (vb_gpio->gpiob.parent,"could not add gpio b" ); -return ret; - } - -platform_set_drvdata (pdev, vb_gpio);
Quoted 9 lines
Quoted 5 lines
drivers/gpio/gpio-viperboard.c +0
-1return ret; } --2.31.1
The log is not really needed, we'll get an error message from gpiolib core. Can you remove it while you're at it and just return the result of
devm_gpiochip_add_data()?
I thought about removing it, but in this driver there are 2 devm_gpiochip_add_data() calls.
It registers 2 GPIOchip instances.
Which is not so easy to see in this patch.
First one says "could not add gpio a" and this one says "could not add gpio b". I hesitated to remove either of these.
In this case, it may be a little helpful to know which GPIOchip failed to be registered.
But I don't mind removing them both.
Whatever you prefer. I'm undecided.
Quoted 2 lines
Bart
Quoted 48 lines · Alexandru Ardelean
Quoted 30 lines · Bartosz Golaszewski
Quoted 28 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 change removes it.
Signed-off-by Alexandru Ardelean <[email protected]>--- drivers/gpio/gpio-viperboard.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/gpio/gpio-viperboard.c +1
-5@@ -422,12 +422,8 @@ static int vprbrd_gpio_probe(struct platform_device *pdev) 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 ) { +if (ret <0 )dev_err (vb_gpio->gpiob.parent,"could not add gpio b" ); -return ret; - } - -platform_set_drvdata (pdev, vb_gpio);Quoted 9 lines
Quoted 5 lines
drivers/gpio/gpio-viperboard.c +0
-1return ret; } --2.31.1
The log is not really needed, we'll get an error message from gpiolib core. Can you remove it while you're at it and just return the result of
devm_gpiochip_add_data()?I thought about removing it, but in this driver there are 2
devm_gpiochip_add_data()calls.
It registers 2 GPIOchip instances.
Which is not so easy to see in this patch.
Quoted 9 lines
First one says "could not add gpio a" and this one says "could not add gpio b". I hesitated to remove either of these.
In this case, it may be a little helpful to know which GPIOchip failed to be registered.
But I don't mind removing them both.
Whatever you prefer. I'm undecided.
The core code will still use the label for the error message which says 'a' or 'b' already. I think we can remove it.
PATCH v2 1/1 gpio: viperboard: remove platform_set_drvdata() call in probe
In reply to Alexandru ArdeleanThe 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.
---
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(-)
drivers/gpio/gpio-viperboard.c +3 -11
@@ -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 = {
Signature · 1 line
2.31.1
Bartosz Golaszewski
AppliedQuoted 56 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 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 <[email protected]>---
Changelog v1 -> v2:
* removedev_err()prints
* [styling] added empty line before firstdevm_gpiochip_add_data()drivers/gpio/gpio-viperboard.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)drivers/gpio/gpio-viperboard.c +3
-12@@ -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 = { --
Quoted 2 lines
2.31.1
Applied, thanks!
Bart