On Wed, May 02, 2018 at 03:15:05PM +0530, Arvind Yadav wrote:Yes, You are coorect. It'll read gpio form gpio device node. Which means
On Wednesday 02 May 2018 02:13 PM, Johan Hovold wrote:No, I believe you're mistaken here. of_get_named_gpio() does not return
On Sat, Apr 28, 2018 at 10:05:39AM +0530, Arvind Yadav wrote:We need to check gpio validity. If we are using of_get_named_gpio() or
Replace the manual validity checks for the GPIO with theI'm sorry, but I don't this change is desirable. of_get_named_gpio()
gpio_is_valid().
Signed-off-by: Arvind Yadav <arvind.yadav.cs@xxxxxxxxx>
---
chnage in v2 :
Returning invalid gpio as error instead of -ENODEV.
drivers/staging/greybus/arche-platform.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
index 83254a7..c3a7da5 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -448,7 +448,7 @@ static int arche_platform_probe(struct platform_device *pdev)
arche_pdata->svc_reset_gpio = of_get_named_gpio(np,
"svc,reset-gpio",
0);
- if (arche_pdata->svc_reset_gpio < 0) {
+ if (!gpio_is_valid(arche_pdata->svc_reset_gpio)) {
dev_err(dev, "failed to get reset-gpio\n");
return arche_pdata->svc_reset_gpio;
returns a valid gpio number or a negative errno, so there's no need to
use the legacy gpio_is_valid() helper here.
If you grep for of_get_named_gpio() you'll find that some drivers indeed
use that helper this way, but they are in a clear minority.
And ultimately, we want to move to using gpio descriptors anyway.
not. of_get_name_gpio() will read a device node and fetch the value.
But it'll not check that gpio is valid or not valid.
an arbitrary gpio number, unlike what you could possibly find in
legacy board files and for which the gpio_is_valid() helper made sense.
Johan