linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regulator: max8973: get rid of extra variable for gpio validity
@ 2015-04-08 13:38 Laxman Dewangan
  2015-04-08 14:42 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Laxman Dewangan @ 2015-04-08 13:38 UTC (permalink / raw)
  To: lgirdwood, broonie; +Cc: linux-kernel, Laxman Dewangan

To find that dvs-gpio is valid or not, gpio API gpio_is_valid()
can be directly used instead of intermediate variable.

Removing the extra variable and using the gpio_is_valid().

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
 drivers/regulator/max8973-regulator.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
index c3d55c2..1890808 100644
--- a/drivers/regulator/max8973-regulator.c
+++ b/drivers/regulator/max8973-regulator.c
@@ -100,7 +100,6 @@ struct max8973_chip {
 	int curr_vout_val[MAX8973_MAX_VOUT_REG];
 	int curr_vout_reg;
 	int curr_gpio_val;
-	bool valid_dvs_gpio;
 	struct regulator_ops ops;
 };
 
@@ -174,7 +173,7 @@ static int max8973_dcdc_set_voltage_sel(struct regulator_dev *rdev,
 	 * If gpios are available to select the VOUT register then least
 	 * recently used register for new configuration.
 	 */
-	if (max->valid_dvs_gpio)
+	if (gpio_is_valid(max->dvs_gpio))
 		found = find_voltage_set_register(max, vsel,
 					&vout_reg, &gpio_val);
 
@@ -191,7 +190,7 @@ static int max8973_dcdc_set_voltage_sel(struct regulator_dev *rdev,
 	}
 
 	/* Select proper VOUT register vio gpios */
-	if (max->valid_dvs_gpio) {
+	if (gpio_is_valid(max->dvs_gpio)) {
 		gpio_set_value_cansleep(max->dvs_gpio, gpio_val & 0x1);
 		max->curr_gpio_val = gpio_val;
 	}
@@ -434,7 +433,6 @@ static int max8973_probe(struct i2c_client *client,
 				max->dvs_gpio, ret);
 			return ret;
 		}
-		max->valid_dvs_gpio = true;
 
 		/*
 		 * Initialize the lru index with vout_reg id
@@ -444,8 +442,6 @@ static int max8973_probe(struct i2c_client *client,
 			max->lru_index[i] = i;
 		max->lru_index[0] = max->curr_vout_reg;
 		max->lru_index[max->curr_vout_reg] = 0;
-	} else {
-		max->valid_dvs_gpio = false;
 	}
 
 	if (pdata) {
-- 
1.8.1.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] regulator: max8973: get rid of extra variable for gpio validity
  2015-04-08 13:38 [PATCH] regulator: max8973: get rid of extra variable for gpio validity Laxman Dewangan
@ 2015-04-08 14:42 ` Mark Brown
  2015-04-09 10:36   ` Laxman Dewangan
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2015-04-08 14:42 UTC (permalink / raw)
  To: Laxman Dewangan; +Cc: lgirdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 357 bytes --]

On Wed, Apr 08, 2015 at 07:08:00PM +0530, Laxman Dewangan wrote:
> To find that dvs-gpio is valid or not, gpio API gpio_is_valid()
> can be directly used instead of intermediate variable.
> 
> Removing the extra variable and using the gpio_is_valid().

Are you sure that platform data using 0 as default/unset is still
handled correctly after this?

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] regulator: max8973: get rid of extra variable for gpio validity
  2015-04-08 14:42 ` Mark Brown
@ 2015-04-09 10:36   ` Laxman Dewangan
  2015-04-10 17:46     ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Laxman Dewangan @ 2015-04-09 10:36 UTC (permalink / raw)
  To: Mark Brown; +Cc: lgirdwood, linux-kernel

On Wednesday 08 April 2015 08:12 PM, Mark Brown wrote:
> * PGP Signed by an unknown key
>
> On Wed, Apr 08, 2015 at 07:08:00PM +0530, Laxman Dewangan wrote:
>> To find that dvs-gpio is valid or not, gpio API gpio_is_valid()
>> can be directly used instead of intermediate variable.
>>
>> Removing the extra variable and using the gpio_is_valid().
> Are you sure that platform data using 0 as default/unset is still
> handled correctly after this?
>

This issue already exist and this patch will not handle this case 
because gpio_is_valid() return true for gpio 0 also.

I search the registration of this driver on linux-next and found that it 
is used from DT only. No one is registering this device from non-DT.

However, I can push another patch to fix the issue as if platform data 
is provided from non-DT and dvs_gpio is 0 then mark this as -EINVAL so 
that it will treat this as invalid gpio.
Still there will be issue if some platform have real GPIO number as 0 
and register from board files.

Does it make sense?



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] regulator: max8973: get rid of extra variable for gpio validity
  2015-04-09 10:36   ` Laxman Dewangan
@ 2015-04-10 17:46     ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2015-04-10 17:46 UTC (permalink / raw)
  To: Laxman Dewangan; +Cc: lgirdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

On Thu, Apr 09, 2015 at 04:06:11PM +0530, Laxman Dewangan wrote:

> However, I can push another patch to fix the issue as if platform data is
> provided from non-DT and dvs_gpio is 0 then mark this as -EINVAL so that it
> will treat this as invalid gpio.
> Still there will be issue if some platform have real GPIO number as 0 and
> register from board files.

> Does it make sense?

Yes, that makes sense.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-04-10 17:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-08 13:38 [PATCH] regulator: max8973: get rid of extra variable for gpio validity Laxman Dewangan
2015-04-08 14:42 ` Mark Brown
2015-04-09 10:36   ` Laxman Dewangan
2015-04-10 17:46     ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).