diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2011-01-31 11:31:49 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-03-23 05:41:45 -0400 |
commit | 6f9f13bf9b9fabf2da2028cb7c1e732ef2efa26d (patch) | |
tree | a5b0626ed1030952a9c7bf4161ffc63bca3175fe /drivers/mfd/tps6586x.c | |
parent | de8c8b0683043e81d2001e446f2bcb143affb0b2 (diff) |
mfd: Invert tps6586x GPIO and subdevices initialization
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>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/tps6586x.c')
-rw-r--r-- | 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 e9018d1394ee..0aa9186aec19 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, | |||
288 | return tps6586x_update(tps6586x->dev, TPS6586X_GPIOSET1, val, mask); | 288 | return tps6586x_update(tps6586x->dev, TPS6586X_GPIOSET1, val, mask); |
289 | } | 289 | } |
290 | 290 | ||
291 | static void tps6586x_gpio_init(struct tps6586x *tps6586x, int gpio_base) | 291 | static int tps6586x_gpio_init(struct tps6586x *tps6586x, int gpio_base) |
292 | { | 292 | { |
293 | int ret; | ||
294 | |||
295 | if (!gpio_base) | 293 | if (!gpio_base) |
296 | return; | 294 | return 0; |
297 | 295 | ||
298 | tps6586x->gpio.owner = THIS_MODULE; | 296 | tps6586x->gpio.owner = THIS_MODULE; |
299 | tps6586x->gpio.label = tps6586x->client->name; | 297 | tps6586x->gpio.label = tps6586x->client->name; |
@@ -307,9 +305,7 @@ static void tps6586x_gpio_init(struct tps6586x *tps6586x, int gpio_base) | |||
307 | tps6586x->gpio.set = tps6586x_gpio_set; | 305 | tps6586x->gpio.set = tps6586x_gpio_set; |
308 | tps6586x->gpio.get = tps6586x_gpio_get; | 306 | tps6586x->gpio.get = tps6586x_gpio_get; |
309 | 307 | ||
310 | ret = gpiochip_add(&tps6586x->gpio); | 308 | return gpiochip_add(&tps6586x->gpio); |
311 | if (ret) | ||
312 | dev_warn(tps6586x->dev, "GPIO registration failed: %d\n", ret); | ||
313 | } | 309 | } |
314 | 310 | ||
315 | static int __remove_subdev(struct device *dev, void *unused) | 311 | static int __remove_subdev(struct device *dev, void *unused) |
@@ -517,17 +513,28 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client, | |||
517 | } | 513 | } |
518 | } | 514 | } |
519 | 515 | ||
516 | ret = tps6586x_gpio_init(tps6586x, pdata->gpio_base); | ||
517 | if (ret) { | ||
518 | dev_err(&client->dev, "GPIO registration failed: %d\n", ret); | ||
519 | goto err_gpio_init; | ||
520 | } | ||
521 | |||
520 | ret = tps6586x_add_subdevs(tps6586x, pdata); | 522 | ret = tps6586x_add_subdevs(tps6586x, pdata); |
521 | if (ret) { | 523 | if (ret) { |
522 | dev_err(&client->dev, "add devices failed: %d\n", ret); | 524 | dev_err(&client->dev, "add devices failed: %d\n", ret); |
523 | goto err_add_devs; | 525 | goto err_add_devs; |
524 | } | 526 | } |
525 | 527 | ||
526 | tps6586x_gpio_init(tps6586x, pdata->gpio_base); | ||
527 | |||
528 | return 0; | 528 | return 0; |
529 | 529 | ||
530 | err_add_devs: | 530 | err_add_devs: |
531 | if (pdata->gpio_base) { | ||
532 | ret = gpiochip_remove(&tps6586x->gpio); | ||
533 | if (ret) | ||
534 | dev_err(&client->dev, "Can't remove gpio chip: %d\n", | ||
535 | ret); | ||
536 | } | ||
537 | err_gpio_init: | ||
531 | if (client->irq) | 538 | if (client->irq) |
532 | free_irq(client->irq, tps6586x); | 539 | free_irq(client->irq, tps6586x); |
533 | err_irq_init: | 540 | err_irq_init: |
@@ -587,4 +594,3 @@ module_exit(tps6586x_exit); | |||
587 | MODULE_DESCRIPTION("TPS6586X core driver"); | 594 | MODULE_DESCRIPTION("TPS6586X core driver"); |
588 | MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>"); | 595 | MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>"); |
589 | MODULE_LICENSE("GPL"); | 596 | MODULE_LICENSE("GPL"); |
590 | |||