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>
This commit is contained in:
committed by
Samuel Ortiz
parent
de8c8b0683
commit
6f9f13bf9b
@@ -288,12 +288,10 @@ static int tps6586x_gpio_output(struct gpio_chip *gc, unsigned offset,
|
|||||||
return tps6586x_update(tps6586x->dev, TPS6586X_GPIOSET1, val, mask);
|
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)
|
if (!gpio_base)
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
tps6586x->gpio.owner = THIS_MODULE;
|
tps6586x->gpio.owner = THIS_MODULE;
|
||||||
tps6586x->gpio.label = tps6586x->client->name;
|
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.set = tps6586x_gpio_set;
|
||||||
tps6586x->gpio.get = tps6586x_gpio_get;
|
tps6586x->gpio.get = tps6586x_gpio_get;
|
||||||
|
|
||||||
ret = gpiochip_add(&tps6586x->gpio);
|
return gpiochip_add(&tps6586x->gpio);
|
||||||
if (ret)
|
|
||||||
dev_warn(tps6586x->dev, "GPIO registration failed: %d\n", ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __remove_subdev(struct device *dev, void *unused)
|
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);
|
ret = tps6586x_add_subdevs(tps6586x, pdata);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&client->dev, "add devices failed: %d\n", ret);
|
dev_err(&client->dev, "add devices failed: %d\n", ret);
|
||||||
goto err_add_devs;
|
goto err_add_devs;
|
||||||
}
|
}
|
||||||
|
|
||||||
tps6586x_gpio_init(tps6586x, pdata->gpio_base);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_add_devs:
|
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)
|
if (client->irq)
|
||||||
free_irq(client->irq, tps6586x);
|
free_irq(client->irq, tps6586x);
|
||||||
err_irq_init:
|
err_irq_init:
|
||||||
@@ -587,4 +594,3 @@ module_exit(tps6586x_exit);
|
|||||||
MODULE_DESCRIPTION("TPS6586X core driver");
|
MODULE_DESCRIPTION("TPS6586X core driver");
|
||||||
MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>");
|
MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>");
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user