diff options
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r-- | drivers/regulator/core.c | 76 |
1 files changed, 54 insertions, 22 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 443eaab933fc..c9f72019bd68 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -678,6 +678,8 @@ static int drms_uA_update(struct regulator_dev *rdev) list_for_each_entry(sibling, &rdev->consumer_list, list) current_uA += sibling->uA_load; + current_uA += rdev->constraints->system_load; + if (rdev->desc->ops->set_load) { /* set the optimum mode for our new total regulator load */ err = rdev->desc->ops->set_load(rdev, current_uA); @@ -779,59 +781,64 @@ static int suspend_prepare(struct regulator_dev *rdev, suspend_state_t state) static void print_constraints(struct regulator_dev *rdev) { struct regulation_constraints *constraints = rdev->constraints; - char buf[80] = ""; + char buf[160] = ""; + size_t len = sizeof(buf) - 1; int count = 0; int ret; if (constraints->min_uV && constraints->max_uV) { if (constraints->min_uV == constraints->max_uV) - count += sprintf(buf + count, "%d mV ", - constraints->min_uV / 1000); + count += scnprintf(buf + count, len - count, "%d mV ", + constraints->min_uV / 1000); else - count += sprintf(buf + count, "%d <--> %d mV ", - constraints->min_uV / 1000, - constraints->max_uV / 1000); + count += scnprintf(buf + count, len - count, + "%d <--> %d mV ", + constraints->min_uV / 1000, + constraints->max_uV / 1000); } if (!constraints->min_uV || constraints->min_uV != constraints->max_uV) { ret = _regulator_get_voltage(rdev); if (ret > 0) - count += sprintf(buf + count, "at %d mV ", ret / 1000); + count += scnprintf(buf + count, len - count, + "at %d mV ", ret / 1000); } if (constraints->uV_offset) - count += sprintf(buf, "%dmV offset ", - constraints->uV_offset / 1000); + count += scnprintf(buf + count, len - count, "%dmV offset ", + constraints->uV_offset / 1000); if (constraints->min_uA && constraints->max_uA) { if (constraints->min_uA == constraints->max_uA) - count += sprintf(buf + count, "%d mA ", - constraints->min_uA / 1000); + count += scnprintf(buf + count, len - count, "%d mA ", + constraints->min_uA / 1000); else - count += sprintf(buf + count, "%d <--> %d mA ", - constraints->min_uA / 1000, - constraints->max_uA / 1000); + count += scnprintf(buf + count, len - count, + "%d <--> %d mA ", + constraints->min_uA / 1000, + constraints->max_uA / 1000); } if (!constraints->min_uA || constraints->min_uA != constraints->max_uA) { ret = _regulator_get_current_limit(rdev); if (ret > 0) - count += sprintf(buf + count, "at %d mA ", ret / 1000); + count += scnprintf(buf + count, len - count, + "at %d mA ", ret / 1000); } if (constraints->valid_modes_mask & REGULATOR_MODE_FAST) - count += sprintf(buf + count, "fast "); + count += scnprintf(buf + count, len - count, "fast "); if (constraints->valid_modes_mask & REGULATOR_MODE_NORMAL) - count += sprintf(buf + count, "normal "); + count += scnprintf(buf + count, len - count, "normal "); if (constraints->valid_modes_mask & REGULATOR_MODE_IDLE) - count += sprintf(buf + count, "idle "); + count += scnprintf(buf + count, len - count, "idle "); if (constraints->valid_modes_mask & REGULATOR_MODE_STANDBY) - count += sprintf(buf + count, "standby"); + count += scnprintf(buf + count, len - count, "standby"); if (!count) - sprintf(buf, "no parameters"); + scnprintf(buf, len, "no parameters"); rdev_dbg(rdev, "%s\n", buf); @@ -1006,6 +1013,15 @@ static int set_machine_constraints(struct regulator_dev *rdev, if (ret != 0) goto out; + if (rdev->constraints->ilim_uA && ops->set_input_current_limit) { + ret = ops->set_input_current_limit(rdev, + rdev->constraints->ilim_uA); + if (ret < 0) { + rdev_err(rdev, "failed to set input limit\n"); + goto out; + } + } + /* do we need to setup our suspend state */ if (rdev->constraints->initial_state) { ret = suspend_prepare(rdev, rdev->constraints->initial_state); @@ -1049,6 +1065,22 @@ static int set_machine_constraints(struct regulator_dev *rdev, } } + if (rdev->constraints->pull_down && ops->set_pull_down) { + ret = ops->set_pull_down(rdev); + if (ret < 0) { + rdev_err(rdev, "failed to set pull down\n"); + goto out; + } + } + + if (rdev->constraints->soft_start && ops->set_soft_start) { + ret = ops->set_soft_start(rdev); + if (ret < 0) { + rdev_err(rdev, "failed to set soft start\n"); + goto out; + } + } + print_constraints(rdev); return 0; out: @@ -1192,10 +1224,10 @@ static struct regulator *create_regulator(struct regulator_dev *rdev, if (regulator->supply_name == NULL) goto overflow_err; - err = sysfs_create_link(&rdev->dev.kobj, &dev->kobj, + err = sysfs_create_link_nowarn(&rdev->dev.kobj, &dev->kobj, buf); if (err) { - rdev_warn(rdev, "could not add device link %s err %d\n", + rdev_dbg(rdev, "could not add device link %s err %d\n", dev->kobj.name, err); /* non-fatal */ } |