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;
/* 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;
}
* 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,
----- * or NULL on failure. The refcount must be dropped by calling put_device().
+++++ * @supply and with the embedded struct device refcount incremented by one.
+++++ * The refcount must be dropped by calling put_device().
+++++ * On failure one of the following ERR-PTR-encoded values is returned:
+++++ * -ENODEV if lookup fails permanently, -EPROBE_DEFER if lookup could succeed
+++++ * in the future.
*/
static struct regulator_dev *regulator_dev_lookup(struct device *dev,
----- const char *supply,
----- int *ret)
+++++ const char *supply)
{
struct regulator_dev *r;
struct device_node *node;
r = of_find_regulator_by_node(node);
if (r)
return r;
----- *ret = -EPROBE_DEFER;
----- return NULL;
----- } else {
+++++
/*
----- * If we couldn't even get the node then it's
----- * not just that the device didn't register
----- * yet, there's no node and we'll never
----- * succeed.
+++++ * We have a node, but there is no device.
+++++ * assume it has not registered yet.
*/
----- *ret = -ENODEV;
+++++ return ERR_PTR(-EPROBE_DEFER);
}
}
if (strcmp(map->supply, supply) == 0 &&
get_device(&map->regulator->dev)) {
----- mutex_unlock(®ulator_list_mutex);
----- return map->regulator;
+++++ r = map->regulator;
+++++ break;
}
}
mutex_unlock(®ulator_list_mutex);
----- return NULL;
+++++ if (r)
+++++ return r;
+++++
+++++ return ERR_PTR(-ENODEV);
}
static int regulator_resolve_supply(struct regulator_dev *rdev)
if (rdev->supply)
return 0;
----- r = regulator_dev_lookup(dev, rdev->supply_name, &ret);
----- if (!r) {
----- if (ret == -ENODEV) {
----- /*
----- * No supply was specified for this regulator and
----- * there will never be one.
----- */
----- return 0;
----- }
+++++ r = regulator_dev_lookup(dev, rdev->supply_name);
+++++ if (IS_ERR(r)) {
+++++ ret = PTR_ERR(r);
/* Did the lookup explicitly defer for us? */
if (ret == -EPROBE_DEFER)
}
}
+++++ /*
+++++ * If the supply's parent device is not the same as the
+++++ * regulator's parent device, then ensure the parent device
+++++ * is bound before we resolve the supply, in case the parent
+++++ * device get probe deferred and unregisters the supply.
+++++ */
+++++ if (r->dev.parent && r->dev.parent != rdev->dev.parent) {
+++++ if (!device_is_bound(r->dev.parent)) {
+++++ put_device(&r->dev);
+++++ return -EPROBE_DEFER;
+++++ }
+++++ }
+++++
/* Recursively resolve the supply of the supply */
ret = regulator_resolve_supply(r);
if (ret < 0) {
}
/* Internal regulator request function */
-----static struct regulator *_regulator_get(struct device *dev, const char *id,
----- bool exclusive, bool allow_dummy)
+++++struct regulator *_regulator_get(struct device *dev, const char *id,
+++++ enum regulator_get_type get_type)
{
struct regulator_dev *rdev;
----- struct regulator *regulator = ERR_PTR(-EPROBE_DEFER);
----- const char *devname = NULL;
+++++ struct regulator *regulator;
+++++ const char *devname = dev ? dev_name(dev) : "deviceless";
int ret;
+++++ if (get_type >= MAX_GET_TYPE) {
+++++ dev_err(dev, "invalid type %d in %s\n", get_type, __func__);
+++++ return ERR_PTR(-EINVAL);
+++++ }
+++++
if (id == NULL) {
pr_err("get() with no identifier\n");
return ERR_PTR(-EINVAL);
}
----- if (dev)
----- devname = dev_name(dev);
-----
----- if (have_full_constraints())
----- ret = -ENODEV;
----- else
----- ret = -EPROBE_DEFER;
-----
----- rdev = regulator_dev_lookup(dev, id, &ret);
----- if (rdev)
----- goto found;
+++++ rdev = regulator_dev_lookup(dev, id);
+++++ if (IS_ERR(rdev)) {
+++++ ret = PTR_ERR(rdev);
----- regulator = ERR_PTR(ret);
+++++ /*
+++++ * If regulator_dev_lookup() fails with error other
+++++ * than -ENODEV our job here is done, we simply return it.
+++++ */
+++++ if (ret != -ENODEV)
+++++ return ERR_PTR(ret);
----- /*
----- * If we have return value from dev_lookup fail, we do not expect to
----- * succeed, so, quit with appropriate error value
----- */
----- if (ret && ret != -ENODEV)
----- return regulator;
+++++ if (!have_full_constraints()) {
+++++ dev_warn(dev,
+++++ "incomplete constraints, dummy supplies not allowed\n");
+++++ return ERR_PTR(-ENODEV);
+++++ }
----- if (!devname)
----- devname = "deviceless";
+++++ switch (get_type) {
+++++ case NORMAL_GET:
+++++ /*
+++++ * Assume that a regulator is physically present and
+++++ * enabled, even if it isn't hooked up, and just
+++++ * provide a dummy.
+++++ */
+++++ dev_warn(dev,
+++++ "%s supply %s not found, using dummy regulator\n",
+++++ devname, id);
+++++ rdev = dummy_regulator_rdev;
+++++ get_device(&rdev->dev);
+++++ break;
----- /*
----- * Assume that a regulator is physically present and enabled
----- * even if it isn't hooked up and just provide a dummy.
----- */
----- if (have_full_constraints() && allow_dummy) {
----- pr_warn("%s supply %s not found, using dummy regulator\n",
----- devname, id);
+++++ case EXCLUSIVE_GET:
+++++ dev_warn(dev,
+++++ "dummy supplies not allowed for exclusive requests\n");
+++++ /* fall through */
----- rdev = dummy_regulator_rdev;
----- get_device(&rdev->dev);
----- goto found;
----- /* Don't log an error when called from regulator_get_optional() */
----- } else if (!have_full_constraints() || exclusive) {
----- dev_warn(dev, "dummy supplies not allowed\n");
+++++ default:
+++++ return ERR_PTR(-ENODEV);
+++++ }
}
----- return regulator;
-----
-----found:
if (rdev->exclusive) {
regulator = ERR_PTR(-EPERM);
put_device(&rdev->dev);
return regulator;
}
----- if (exclusive && rdev->open_count) {
+++++ if (get_type == EXCLUSIVE_GET && rdev->open_count) {
regulator = ERR_PTR(-EBUSY);
put_device(&rdev->dev);
return regulator;
}
if (!try_module_get(rdev->owner)) {
+++++ regulator = ERR_PTR(-EPROBE_DEFER);
put_device(&rdev->dev);
return regulator;
}
}
rdev->open_count++;
----- if (exclusive) {
+++++ if (get_type == EXCLUSIVE_GET) {
rdev->exclusive = 1;
ret = _regulator_is_enabled(rdev);
*/
struct regulator *regulator_get(struct device *dev, const char *id)
{
----- return _regulator_get(dev, id, false, true);
+++++ return _regulator_get(dev, id, NORMAL_GET);
}
EXPORT_SYMBOL_GPL(regulator_get);
*/
struct regulator *regulator_get_exclusive(struct device *dev, const char *id)
{
----- return _regulator_get(dev, id, true, false);
+++++ return _regulator_get(dev, id, EXCLUSIVE_GET);
}
EXPORT_SYMBOL_GPL(regulator_get_exclusive);
*/
struct regulator *regulator_get_optional(struct device *dev, const char *id)
{
----- return _regulator_get(dev, id, false, false);
+++++ return _regulator_get(dev, id, OPTIONAL_GET);
}
EXPORT_SYMBOL_GPL(regulator_get_optional);
put_device(&rdev->dev);
mutex_unlock(&rdev->mutex);
----- kfree(regulator->supply_name);
+++++ kfree_const(regulator->supply_name);
kfree(regulator);
module_put(rdev->owner);
if (ret < 0)
return ret;
+ ++++ _notifier_call_chain(rdev, REGULATOR_EVENT_ENABLE,
+ ++++ NULL);
} else if (ret < 0) {
rdev_err(rdev, "is_enabled() failed: %d\n", ret);
return ret;
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;
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);
ramp_delay = rdev->constraints->ramp_delay;
else if (rdev->desc->ramp_delay)
ramp_delay = rdev->desc->ramp_delay;
+++ ++ else if (rdev->constraints->settling_time)
+++ ++ return rdev->constraints->settling_time;
if (ramp_delay == 0) {
rdev_dbg(rdev, "ramp_delay not set\n");
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;
for (++i; i < num_consumers; ++i) {
r = regulator_enable(consumers[i].consumer);
if (r != 0)
----- pr_err("Failed to reename %s: %d\n",
+++++ pr_err("Failed to re-enable %s: %d\n",
consumers[i].supply, r);
}
struct regulator_bulk_data *consumers)
{
int i;
----- int ret;
+++++ int ret = 0;
----- for (i = 0; i < num_consumers; i++)
+++++ for (i = 0; i < num_consumers; i++) {
consumers[i].ret =
regulator_force_disable(consumers[i].consumer);
----- for (i = 0; i < num_consumers; i++) {
----- if (consumers[i].ret != 0) {
+++++ /* Store first error for reporting */
+++++ if (consumers[i].ret && !ret)
ret = consumers[i].ret;
----- goto out;
----- }
}
----- return 0;
-----out:
return ret;
}
EXPORT_SYMBOL_GPL(regulator_bulk_force_disable);
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);
seq_puts(s, "\n");
list_for_each_entry(consumer, &rdev->consumer_list, list) {
----- if (consumer->dev->class == ®ulator_class)
+++++ if (consumer->dev && consumer->dev->class == ®ulator_class)
continue;
seq_printf(s, "%*s%-*s ",
(level + 1) * 3 + 1, "",
----- 30 - (level + 1) * 3, dev_name(consumer->dev));
+++++ 30 - (level + 1) * 3,
+++++ consumer->dev ? dev_name(consumer->dev) : "deviceless");
switch (rdev->desc->type) {
case REGULATOR_VOLTAGE:
if (of_have_populated_dt())
has_full_constraints = true;
+++++ /*
+++++ * Regulators may had failed to resolve their input supplies
+++++ * when were registered, either because the input supply was
+++++ * not registered yet or because its parent device was not
+++++ * bound yet. So attempt to resolve the input supplies for
+++++ * pending regulators before trying to disable unused ones.
+++++ */
+++++ class_for_each_device(®ulator_class, NULL, NULL,
+++++ regulator_register_resolve_supply);
+++++
/* If we have a full configuration then disable any regulators
* we have permission to change the status for and which are
* not in use or always_on. This is effectively the default
#define PFUZE100_REVID 0x3
#define PFUZE100_FABID 0x4
++ +++#define PFUZE100_COINVOL 0x1a
#define PFUZE100_SW1ABVOL 0x20
#define PFUZE100_SW1CVOL 0x2e
#define PFUZE100_SW2VOL 0x35
1000000, 1100000, 1200000, 1300000, 1500000, 1800000, 3000000,
};
++ +++static const int pfuze100_coin[] = {
++ +++ 2500000, 2700000, 2800000, 2900000, 3000000, 3100000, 3200000, 3300000,
++ +++};
++ +++
static const int pfuze3000_sw2lo[] = {
1500000, 1550000, 1600000, 1650000, 1700000, 1750000, 1800000, 1850000,
};
return ret;
}
-----static struct regulator_ops pfuze100_ldo_regulator_ops = {
+++++static const struct regulator_ops pfuze100_ldo_regulator_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
};
-----static struct regulator_ops pfuze100_fixed_regulator_ops = {
+++++static const struct regulator_ops pfuze100_fixed_regulator_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.list_voltage = regulator_list_voltage_linear,
};
-----static struct regulator_ops pfuze100_sw_regulator_ops = {
+++++static const struct regulator_ops pfuze100_sw_regulator_ops = {
.list_voltage = regulator_list_voltage_linear,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_ramp_delay = pfuze100_set_ramp_delay,
};
-----static struct regulator_ops pfuze100_swb_regulator_ops = {
+++++static const struct regulator_ops pfuze100_swb_regulator_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.list_voltage = regulator_list_voltage_table,
.stby_mask = 0x20, \
}
++ +++#define PFUZE100_COIN_REG(_chip, _name, base, mask, voltages) \
++ +++ [_chip ## _ ## _name] = { \
++ +++ .desc = { \
++ +++ .name = #_name, \
++ +++ .n_voltages = ARRAY_SIZE(voltages), \
++ +++ .ops = &pfuze100_swb_regulator_ops, \
++ +++ .type = REGULATOR_VOLTAGE, \
++ +++ .id = _chip ## _ ## _name, \
++ +++ .owner = THIS_MODULE, \
++ +++ .volt_table = voltages, \
++ +++ .vsel_reg = (base), \
++ +++ .vsel_mask = (mask), \
++ +++ .enable_reg = (base), \
++ +++ .enable_mask = 0x8, \
++ +++ }, \
++ +++ }
++ +++
#define PFUZE3000_VCC_REG(_chip, _name, base, min, max, step) { \
.desc = { \
.name = #_name, \
PFUZE100_VGEN_REG(PFUZE200, VGEN4, PFUZE100_VGEN4VOL, 1800000, 3300000, 100000),
PFUZE100_VGEN_REG(PFUZE200, VGEN5, PFUZE100_VGEN5VOL, 1800000, 3300000, 100000),
PFUZE100_VGEN_REG(PFUZE200, VGEN6, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000),
++ +++ PFUZE100_COIN_REG(PFUZE200, COIN, PFUZE100_COINVOL, 0x7, pfuze100_coin),
};
static struct pfuze_regulator pfuze3000_regulators[] = {
{ .name = "vgen4", },
{ .name = "vgen5", },
{ .name = "vgen6", },
++ +++ { .name = "coin", },
};
/* PFUZE3000 */