diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 96bf846..73f5c6e 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -89,6 +89,7 @@ static struct regulator_internal * __regulator_register(struct regulator_dev *rd, const char *name) { struct regulator_internal *ri; + int ret; ri = xzalloc(sizeof(*ri)); ri->rdev = rd; @@ -100,7 +101,19 @@ if (name) ri->name = xstrdup(name); + if (rd->boot_on) { + ret = regulator_enable_internal(ri); + if (ret && ret != -ENOSYS) + goto err; + } + return ri; +err: + list_del(&ri->list); + free(ri->name); + free(ri); + + return ERR_PTR(ret); } @@ -117,6 +130,8 @@ struct regulator_internal *ri; const char *name; + rd->boot_on = of_property_read_bool(node, "regulator-boot-on"); + name = of_get_property(node, "regulator-name", NULL); ri = __regulator_register(rd, name); diff --git a/include/regulator.h b/include/regulator.h index a43d3df..367e13f 100644 --- a/include/regulator.h +++ b/include/regulator.h @@ -6,6 +6,7 @@ struct regulator_dev { struct regulator_ops *ops; + int boot_on; }; struct regulator_ops {