LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] mfd: tps6586x: Invert GPIO and subdevices initialization
@ 2011-01-19 14:52 Vincent Palatin
  2011-01-30 23:37 ` Samuel Ortiz
  0 siblings, 1 reply; 4+ messages in thread
From: Vincent Palatin @ 2011-01-19 14:52 UTC (permalink / raw)
  To: Samuel Ortiz, LKML; +Cc: Olof Johansson, Vincent Palatin

When using a fixed voltage regulator triggered by a TPS6586x GPIO,
this allows to declare and initialize it conveniently from the "subdev" list.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
---
 drivers/mfd/tps6586x.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
index 627cf57..fdb16ed 100644
--- a/drivers/mfd/tps6586x.c
+++ b/drivers/mfd/tps6586x.c
@@ -517,19 +517,25 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
 		}
 	}
 
+	tps6586x_gpio_init(tps6586x, pdata->gpio_base);
+
 	ret = tps6586x_add_subdevs(tps6586x, pdata);
 	if (ret) {
 		dev_err(&client->dev, "add devices failed: %d\n", ret);
 		goto err_add_devs;
 	}
 
-	tps6586x_gpio_init(tps6586x, pdata->gpio_base);
-
 	return 0;
 
 err_add_devs:
 	if (client->irq)
 		free_irq(client->irq, tps6586x);
+	if (pdata->gpio_base) {
+		ret = gpiochip_remove(&tps6586x->gpio);
+		if (ret)
+			dev_err(&client->dev, "Can't remove gpio chip: %d\n",
+				ret);
+	}
 err_irq_init:
 	kfree(tps6586x);
 	return ret;
-- 
1.7.3.1


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

* Re: [PATCH] mfd: tps6586x: Invert GPIO and subdevices initialization
  2011-01-19 14:52 [PATCH] mfd: tps6586x: Invert GPIO and subdevices initialization Vincent Palatin
@ 2011-01-30 23:37 ` Samuel Ortiz
  2011-01-31 15:11   ` Vincent Palatin
  0 siblings, 1 reply; 4+ messages in thread
From: Samuel Ortiz @ 2011-01-30 23:37 UTC (permalink / raw)
  To: Vincent Palatin; +Cc: LKML, Olof Johansson

Hi Vincent,

On Wed, Jan 19, 2011 at 09:52:09AM -0500, Vincent Palatin wrote:
> When using a fixed voltage regulator triggered by a TPS6586x GPIO,
> this allows to declare and initialize it conveniently from the "subdev" list.
> 
> Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
> ---
>  drivers/mfd/tps6586x.c |   10 ++++++++--
>  1 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
> index 627cf57..fdb16ed 100644
> --- a/drivers/mfd/tps6586x.c
> +++ b/drivers/mfd/tps6586x.c
> @@ -517,19 +517,25 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
>  		}
>  	}
>  
> +	tps6586x_gpio_init(tps6586x, pdata->gpio_base);
> +
Wouldn't it make sense to have tps6586x_gpio_init() return an int and check it
before adding the subdevs then ?

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

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

* Re: [PATCH] mfd: tps6586x: Invert GPIO and subdevices initialization
  2011-01-30 23:37 ` Samuel Ortiz
@ 2011-01-31 15:11   ` Vincent Palatin
  2011-01-31 16:31     ` Vincent Palatin
  0 siblings, 1 reply; 4+ messages in thread
From: Vincent Palatin @ 2011-01-31 15:11 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: LKML, Olof Johansson

Hi Samuel,

On Sun, Jan 30, 2011 at 18:37, Samuel Ortiz <sameo@linux.intel.com> wrote:
[...]
>> diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
>> index 627cf57..fdb16ed 100644
>> --- a/drivers/mfd/tps6586x.c
>> +++ b/drivers/mfd/tps6586x.c
>> @@ -517,19 +517,25 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
>>               }
>>       }
>>
>> +     tps6586x_gpio_init(tps6586x, pdata->gpio_base);
>> +
> Wouldn't it make sense to have tps6586x_gpio_init() return an int and check it
> before adding the subdevs then ?

Yes, probably. I will do a v2 which checks the result of the GPIO registration.
By the way, when "gpio_base" is not set, I will consider that the
developer doesn't want the TPS gpio support and gracefully continue
without the GPIO registration in order to keep the current behaviour.

Regards,
-- 
Vincent

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

* [PATCH] mfd: tps6586x: Invert GPIO and subdevices initialization
  2011-01-31 15:11   ` Vincent Palatin
@ 2011-01-31 16:31     ` Vincent Palatin
  0 siblings, 0 replies; 4+ messages in thread
From: Vincent Palatin @ 2011-01-31 16:31 UTC (permalink / raw)
  To: Samuel Ortiz, LKML; +Cc: Olof Johansson, Vincent Palatin

When using a fixed voltage regulator triggered by a TPS6586x GPIO,
this allows to declare and initialize it conveniently from the "subdev" list.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
---
 drivers/mfd/tps6586x.c |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
index 627cf57..c937742 100644
--- a/drivers/mfd/tps6586x.c
+++ b/drivers/mfd/tps6586x.c
@@ -288,12 +288,10 @@ static int tps6586x_gpio_output(struct gpio_chip *gc, unsigned offset,
 	return tps6586x_update(tps6586x->dev, TPS6586X_GPIOSET1, val, mask);
 }
 
-static void tps6586x_gpio_init(struct tps6586x *tps6586x, int gpio_base)
+static int tps6586x_gpio_init(struct tps6586x *tps6586x, int gpio_base)
 {
-	int ret;
-
 	if (!gpio_base)
-		return;
+		return 0;
 
 	tps6586x->gpio.owner		= THIS_MODULE;
 	tps6586x->gpio.label		= tps6586x->client->name;
@@ -307,9 +305,7 @@ static void tps6586x_gpio_init(struct tps6586x *tps6586x, int gpio_base)
 	tps6586x->gpio.set		= tps6586x_gpio_set;
 	tps6586x->gpio.get		= tps6586x_gpio_get;
 
-	ret = gpiochip_add(&tps6586x->gpio);
-	if (ret)
-		dev_warn(tps6586x->dev, "GPIO registration failed: %d\n", ret);
+	return gpiochip_add(&tps6586x->gpio);
 }
 
 static int __remove_subdev(struct device *dev, void *unused)
@@ -517,17 +513,28 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
 		}
 	}
 
+	ret = tps6586x_gpio_init(tps6586x, pdata->gpio_base);
+	if (ret) {
+		dev_err(&client->dev, "GPIO registration failed: %d\n", ret);
+		goto err_gpio_init;
+	}
+
 	ret = tps6586x_add_subdevs(tps6586x, pdata);
 	if (ret) {
 		dev_err(&client->dev, "add devices failed: %d\n", ret);
 		goto err_add_devs;
 	}
 
-	tps6586x_gpio_init(tps6586x, pdata->gpio_base);
-
 	return 0;
 
 err_add_devs:
+	if (pdata->gpio_base) {
+		ret = gpiochip_remove(&tps6586x->gpio);
+		if (ret)
+			dev_err(&client->dev, "Can't remove gpio chip: %d\n",
+				ret);
+	}
+err_gpio_init:
 	if (client->irq)
 		free_irq(client->irq, tps6586x);
 err_irq_init:
@@ -587,4 +594,3 @@ module_exit(tps6586x_exit);
 MODULE_DESCRIPTION("TPS6586X core driver");
 MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>");
 MODULE_LICENSE("GPL");
-
-- 
1.7.3.1


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

end of thread, other threads:[~2011-01-31 16:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-19 14:52 [PATCH] mfd: tps6586x: Invert GPIO and subdevices initialization Vincent Palatin
2011-01-30 23:37 ` Samuel Ortiz
2011-01-31 15:11   ` Vincent Palatin
2011-01-31 16:31     ` Vincent Palatin

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).