regulator: Add support for regulator-boot-on device tree property
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
e47bfe803b
commit
4dfa261dcf
|
@ -89,6 +89,7 @@ static int regulator_disable_internal(struct regulator_internal *ri)
|
||||||
static struct regulator_internal * __regulator_register(struct regulator_dev *rd, const char *name)
|
static struct regulator_internal * __regulator_register(struct regulator_dev *rd, const char *name)
|
||||||
{
|
{
|
||||||
struct regulator_internal *ri;
|
struct regulator_internal *ri;
|
||||||
|
int ret;
|
||||||
|
|
||||||
ri = xzalloc(sizeof(*ri));
|
ri = xzalloc(sizeof(*ri));
|
||||||
ri->rdev = rd;
|
ri->rdev = rd;
|
||||||
|
@ -100,7 +101,19 @@ static struct regulator_internal * __regulator_register(struct regulator_dev *rd
|
||||||
if (name)
|
if (name)
|
||||||
ri->name = xstrdup(name);
|
ri->name = xstrdup(name);
|
||||||
|
|
||||||
|
if (rd->boot_on) {
|
||||||
|
ret = regulator_enable_internal(ri);
|
||||||
|
if (ret && ret != -ENOSYS)
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
return ri;
|
return ri;
|
||||||
|
err:
|
||||||
|
list_del(&ri->list);
|
||||||
|
free(ri->name);
|
||||||
|
free(ri);
|
||||||
|
|
||||||
|
return ERR_PTR(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,6 +130,8 @@ int of_regulator_register(struct regulator_dev *rd, struct device_node *node)
|
||||||
struct regulator_internal *ri;
|
struct regulator_internal *ri;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
|
rd->boot_on = of_property_read_bool(node, "regulator-boot-on");
|
||||||
|
|
||||||
name = of_get_property(node, "regulator-name", NULL);
|
name = of_get_property(node, "regulator-name", NULL);
|
||||||
|
|
||||||
ri = __regulator_register(rd, name);
|
ri = __regulator_register(rd, name);
|
||||||
|
|
|
@ -6,6 +6,7 @@ struct regulator;
|
||||||
|
|
||||||
struct regulator_dev {
|
struct regulator_dev {
|
||||||
struct regulator_ops *ops;
|
struct regulator_ops *ops;
|
||||||
|
int boot_on;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct regulator_ops {
|
struct regulator_ops {
|
||||||
|
|
Loading…
Reference in New Issue