diff options
author | Mark Brown <broonie@kernel.org> | 2017-04-30 16:17:23 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-04-30 16:17:23 +0300 |
commit | bde1e61b8e18a0654be78576ab2b0bdfeb5ca05d (patch) | |
tree | a69c813942b330baee582c3cf865748ea9bdbb03 /drivers/regulator | |
parent | 6a8007c83a7bc5ccfa02b425f7463dab3dce686a (diff) | |
parent | c93609ab3924cc974fc90001fb6aa250a8900a3c (diff) | |
download | linux-bde1e61b8e18a0654be78576ab2b0bdfeb5ca05d.tar.xz |
Merge remote-tracking branch 'regulator/topic/core' into regulator-next
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/core.c | 33 | ||||
-rw-r--r-- | drivers/regulator/internal.h | 2 |
2 files changed, 16 insertions, 19 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 53d4fc70dbd0..462e6e679ce1 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1326,8 +1326,8 @@ static struct regulator *create_regulator(struct regulator_dev *rdev, regulator->dev = dev; /* Add a link to the device sysfs entry */ - size = scnprintf(buf, REG_STR_SIZE, "%s-%s", - dev->kobj.name, supply_name); + size = snprintf(buf, REG_STR_SIZE, "%s-%s", + dev->kobj.name, supply_name); if (size >= REG_STR_SIZE) goto overflow_err; @@ -1343,7 +1343,7 @@ static struct regulator *create_regulator(struct regulator_dev *rdev, /* non-fatal */ } } else { - regulator->supply_name = kstrdup(supply_name, GFP_KERNEL); + regulator->supply_name = kstrdup_const(supply_name, GFP_KERNEL); if (regulator->supply_name == NULL) goto overflow_err; } @@ -1451,8 +1451,6 @@ static struct regulator_dev *regulator_lookup_by_name(const char *name) * regulator_dev_lookup - lookup a regulator device. * @dev: device for regulator "consumer". * @supply: Supply name or regulator ID. - * @ret: 0 on success, -ENODEV if lookup fails permanently, -EPROBE_DEFER if - * lookup could succeed in the future. * * If successful, returns a struct regulator_dev that corresponds to the name * @supply and with the embedded struct device refcount incremented by one. @@ -1534,14 +1532,6 @@ static int regulator_resolve_supply(struct regulator_dev *rdev) if (IS_ERR(r)) { ret = PTR_ERR(r); - if (ret == -ENODEV) { - /* - * No supply was specified for this regulator and - * there will never be one. - */ - return 0; - } - /* Did the lookup explicitly defer for us? */ if (ret == -EPROBE_DEFER) return ret; @@ -1799,7 +1789,7 @@ static void _regulator_put(struct regulator *regulator) put_device(&rdev->dev); mutex_unlock(&rdev->mutex); - kfree(regulator->supply_name); + kfree_const(regulator->supply_name); kfree(regulator); module_put(rdev->owner); @@ -2486,7 +2476,7 @@ static int _regulator_list_voltage(struct regulator *regulator, ret = ops->list_voltage(rdev, selector); if (lock) mutex_unlock(&rdev->mutex); - } else if (rdev->supply) { + } else if (rdev->is_switch && rdev->supply) { ret = _regulator_list_voltage(rdev->supply, selector, lock); } else { return -EINVAL; @@ -2544,7 +2534,7 @@ int regulator_count_voltages(struct regulator *regulator) if (rdev->desc->n_voltages) return rdev->desc->n_voltages; - if (!rdev->supply) + if (!rdev->is_switch || !rdev->supply) return -EINVAL; return regulator_count_voltages(rdev->supply); @@ -2941,8 +2931,10 @@ static int regulator_set_voltage_unlocked(struct regulator *regulator, if (ret < 0) goto out2; - if (rdev->supply && (rdev->desc->min_dropout_uV || - !rdev->desc->ops->get_voltage)) { + if (rdev->supply && + regulator_ops_is_valid(rdev->supply->rdev, + REGULATOR_CHANGE_VOLTAGE) && + (rdev->desc->min_dropout_uV || !rdev->desc->ops->get_voltage)) { int current_supply_uV; int selector; @@ -4099,6 +4091,11 @@ regulator_register(const struct regulator_desc *regulator_desc, mutex_unlock(®ulator_list_mutex); } + if (!rdev->desc->ops->get_voltage && + !rdev->desc->ops->list_voltage && + !rdev->desc->fixed_uV) + rdev->is_switch = true; + ret = device_register(&rdev->dev); if (ret != 0) { put_device(&rdev->dev); diff --git a/drivers/regulator/internal.h b/drivers/regulator/internal.h index 1dd575b28564..66a8ea0c8386 100644 --- a/drivers/regulator/internal.h +++ b/drivers/regulator/internal.h @@ -29,7 +29,7 @@ struct regulator { int uA_load; int min_uV; int max_uV; - char *supply_name; + const char *supply_name; struct device_attribute dev_attr; struct regulator_dev *rdev; struct dentry *debugfs; |