diff mbox

[v2,3/4] regulator: fixed: Use gpio_is_valid

Message ID 1412776028-15655-4-git-send-email-mpa@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Markus Pargmann Oct. 8, 2014, 1:47 p.m. UTC
Use gpio_is_valid instead of an explicit comparison with 0.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 drivers/regulator/fixed.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Brown Oct. 13, 2014, 2:47 p.m. UTC | #1
On Wed, Oct 08, 2014 at 03:47:07PM +0200, Markus Pargmann wrote:
> Use gpio_is_valid instead of an explicit comparison with 0.
> 
> Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
> ---
>  drivers/regulator/fixed.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
> index 441a3e90e266..696f53cc1927 100644
> --- a/drivers/regulator/fixed.c
> +++ b/drivers/regulator/fixed.c
> @@ -157,7 +157,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
>  
>  	drvdata->desc.fixed_uV = config->microvolts;
>  
> -	if (config->gpio >= 0) {
> +	if (gpio_is_valid(config->gpio)) {

Have you audited all users to ensure that they don't rely on zero being
ignored?  Right now we're sharing the core behaviour here so the same
issues apply to this platform data as apply to the core.
Markus Pargmann Nov. 3, 2014, 1:38 p.m. UTC | #2
On Mon, Oct 13, 2014 at 04:47:33PM +0200, Mark Brown wrote:
> On Wed, Oct 08, 2014 at 03:47:07PM +0200, Markus Pargmann wrote:
> > Use gpio_is_valid instead of an explicit comparison with 0.
> > 
> > Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
> > ---
> >  drivers/regulator/fixed.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
> > index 441a3e90e266..696f53cc1927 100644
> > --- a/drivers/regulator/fixed.c
> > +++ b/drivers/regulator/fixed.c
> > @@ -157,7 +157,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
> >  
> >  	drvdata->desc.fixed_uV = config->microvolts;
> >  
> > -	if (config->gpio >= 0) {
> > +	if (gpio_is_valid(config->gpio)) {
> 
> Have you audited all users to ensure that they don't rely on zero being
> ignored?  Right now we're sharing the core behaviour here so the same
> issues apply to this platform data as apply to the core.

For all other drivers this should be fine (just rechecked again). But
the fixed regulator driver patch has this problem.

Thanks,

Markus
diff mbox

Patch

diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 441a3e90e266..696f53cc1927 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -157,7 +157,7 @@  static int reg_fixed_voltage_probe(struct platform_device *pdev)
 
 	drvdata->desc.fixed_uV = config->microvolts;
 
-	if (config->gpio >= 0) {
+	if (gpio_is_valid(config->gpio)) {
 		cfg.ena_gpio = config->gpio;
 		cfg.ena_gpio_initialized = true;
 	}