Commit 61aab5ad authored by Michał Mirosław's avatar Michał Mirosław Committed by Mark Brown

regulator: print symbolic errors in kernel messages

Change all error-printing messages to include error name via %pe instead
of numeric error or nothing.
Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
Link: https://lore.kernel.org/r/1dcf25f39188882eb56918a9aa281ab17b792aa5.1601155770.git.mirq-linux@rere.qmqm.plSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 99ad5f6e
...@@ -964,7 +964,8 @@ static int drms_uA_update(struct regulator_dev *rdev) ...@@ -964,7 +964,8 @@ static int drms_uA_update(struct regulator_dev *rdev)
/* set the optimum mode for our new total regulator load */ /* set the optimum mode for our new total regulator load */
err = rdev->desc->ops->set_load(rdev, current_uA); err = rdev->desc->ops->set_load(rdev, current_uA);
if (err < 0) if (err < 0)
rdev_err(rdev, "failed to set load %d\n", current_uA); rdev_err(rdev, "failed to set load %d: %pe\n",
current_uA, ERR_PTR(err));
} else { } else {
/* get output voltage */ /* get output voltage */
output_uV = regulator_get_voltage_rdev(rdev); output_uV = regulator_get_voltage_rdev(rdev);
...@@ -991,14 +992,15 @@ static int drms_uA_update(struct regulator_dev *rdev) ...@@ -991,14 +992,15 @@ static int drms_uA_update(struct regulator_dev *rdev)
/* check the new mode is allowed */ /* check the new mode is allowed */
err = regulator_mode_constrain(rdev, &mode); err = regulator_mode_constrain(rdev, &mode);
if (err < 0) { if (err < 0) {
rdev_err(rdev, "failed to get optimum mode @ %d uA %d -> %d uV\n", rdev_err(rdev, "failed to get optimum mode @ %d uA %d -> %d uV: %pe\n",
current_uA, input_uV, output_uV); current_uA, input_uV, output_uV, ERR_PTR(err));
return err; return err;
} }
err = rdev->desc->ops->set_mode(rdev, mode); err = rdev->desc->ops->set_mode(rdev, mode);
if (err < 0) if (err < 0)
rdev_err(rdev, "failed to set optimum mode %x\n", mode); rdev_err(rdev, "failed to set optimum mode %x: %pe\n",
mode, ERR_PTR(err));
} }
return err; return err;
...@@ -1019,14 +1021,14 @@ static int __suspend_set_state(struct regulator_dev *rdev, ...@@ -1019,14 +1021,14 @@ static int __suspend_set_state(struct regulator_dev *rdev,
ret = 0; ret = 0;
if (ret < 0) { if (ret < 0) {
rdev_err(rdev, "failed to enabled/disable\n"); rdev_err(rdev, "failed to enabled/disable: %pe\n", ERR_PTR(ret));
return ret; return ret;
} }
if (rdev->desc->ops->set_suspend_voltage && rstate->uV > 0) { if (rdev->desc->ops->set_suspend_voltage && rstate->uV > 0) {
ret = rdev->desc->ops->set_suspend_voltage(rdev, rstate->uV); ret = rdev->desc->ops->set_suspend_voltage(rdev, rstate->uV);
if (ret < 0) { if (ret < 0) {
rdev_err(rdev, "failed to set voltage\n"); rdev_err(rdev, "failed to set voltage: %pe\n", ERR_PTR(ret));
return ret; return ret;
} }
} }
...@@ -1034,7 +1036,7 @@ static int __suspend_set_state(struct regulator_dev *rdev, ...@@ -1034,7 +1036,7 @@ static int __suspend_set_state(struct regulator_dev *rdev,
if (rdev->desc->ops->set_suspend_mode && rstate->mode > 0) { if (rdev->desc->ops->set_suspend_mode && rstate->mode > 0) {
ret = rdev->desc->ops->set_suspend_mode(rdev, rstate->mode); ret = rdev->desc->ops->set_suspend_mode(rdev, rstate->mode);
if (ret < 0) { if (ret < 0) {
rdev_err(rdev, "failed to set mode\n"); rdev_err(rdev, "failed to set mode: %pe\n", ERR_PTR(ret));
return ret; return ret;
} }
} }
...@@ -1154,8 +1156,8 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, ...@@ -1154,8 +1156,8 @@ static int machine_constraints_voltage(struct regulator_dev *rdev,
if (current_uV < 0) { if (current_uV < 0) {
rdev_err(rdev, rdev_err(rdev,
"failed to get the current voltage(%d)\n", "failed to get the current voltage: %pe\n",
current_uV); ERR_PTR(current_uV));
return current_uV; return current_uV;
} }
...@@ -1184,8 +1186,8 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, ...@@ -1184,8 +1186,8 @@ static int machine_constraints_voltage(struct regulator_dev *rdev,
rdev, target_min, target_max); rdev, target_min, target_max);
if (ret < 0) { if (ret < 0) {
rdev_err(rdev, rdev_err(rdev,
"failed to apply %d-%duV constraint(%d)\n", "failed to apply %d-%duV constraint: %pe\n",
target_min, target_max, ret); target_min, target_max, ERR_PTR(ret));
return ret; return ret;
} }
} }
...@@ -1334,7 +1336,7 @@ static int set_machine_constraints(struct regulator_dev *rdev, ...@@ -1334,7 +1336,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
ret = ops->set_input_current_limit(rdev, ret = ops->set_input_current_limit(rdev,
rdev->constraints->ilim_uA); rdev->constraints->ilim_uA);
if (ret < 0) { if (ret < 0) {
rdev_err(rdev, "failed to set input limit\n"); rdev_err(rdev, "failed to set input limit: %pe\n", ERR_PTR(ret));
return ret; return ret;
} }
} }
...@@ -1343,7 +1345,7 @@ static int set_machine_constraints(struct regulator_dev *rdev, ...@@ -1343,7 +1345,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
if (rdev->constraints->initial_state) { if (rdev->constraints->initial_state) {
ret = suspend_set_initial_state(rdev); ret = suspend_set_initial_state(rdev);
if (ret < 0) { if (ret < 0) {
rdev_err(rdev, "failed to set suspend state\n"); rdev_err(rdev, "failed to set suspend state: %pe\n", ERR_PTR(ret));
return ret; return ret;
} }
} }
...@@ -1356,7 +1358,7 @@ static int set_machine_constraints(struct regulator_dev *rdev, ...@@ -1356,7 +1358,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
ret = ops->set_mode(rdev, rdev->constraints->initial_mode); ret = ops->set_mode(rdev, rdev->constraints->initial_mode);
if (ret < 0) { if (ret < 0) {
rdev_err(rdev, "failed to set initial mode: %d\n", ret); rdev_err(rdev, "failed to set initial mode: %pe\n", ERR_PTR(ret));
return ret; return ret;
} }
} else if (rdev->constraints->system_load) { } else if (rdev->constraints->system_load) {
...@@ -1371,7 +1373,7 @@ static int set_machine_constraints(struct regulator_dev *rdev, ...@@ -1371,7 +1373,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
&& ops->set_ramp_delay) { && ops->set_ramp_delay) {
ret = ops->set_ramp_delay(rdev, rdev->constraints->ramp_delay); ret = ops->set_ramp_delay(rdev, rdev->constraints->ramp_delay);
if (ret < 0) { if (ret < 0) {
rdev_err(rdev, "failed to set ramp_delay\n"); rdev_err(rdev, "failed to set ramp_delay: %pe\n", ERR_PTR(ret));
return ret; return ret;
} }
} }
...@@ -1379,7 +1381,7 @@ static int set_machine_constraints(struct regulator_dev *rdev, ...@@ -1379,7 +1381,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
if (rdev->constraints->pull_down && ops->set_pull_down) { if (rdev->constraints->pull_down && ops->set_pull_down) {
ret = ops->set_pull_down(rdev); ret = ops->set_pull_down(rdev);
if (ret < 0) { if (ret < 0) {
rdev_err(rdev, "failed to set pull down\n"); rdev_err(rdev, "failed to set pull down: %pe\n", ERR_PTR(ret));
return ret; return ret;
} }
} }
...@@ -1387,7 +1389,7 @@ static int set_machine_constraints(struct regulator_dev *rdev, ...@@ -1387,7 +1389,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
if (rdev->constraints->soft_start && ops->set_soft_start) { if (rdev->constraints->soft_start && ops->set_soft_start) {
ret = ops->set_soft_start(rdev); ret = ops->set_soft_start(rdev);
if (ret < 0) { if (ret < 0) {
rdev_err(rdev, "failed to set soft start\n"); rdev_err(rdev, "failed to set soft start: %pe\n", ERR_PTR(ret));
return ret; return ret;
} }
} }
...@@ -1396,7 +1398,8 @@ static int set_machine_constraints(struct regulator_dev *rdev, ...@@ -1396,7 +1398,8 @@ static int set_machine_constraints(struct regulator_dev *rdev,
&& ops->set_over_current_protection) { && ops->set_over_current_protection) {
ret = ops->set_over_current_protection(rdev); ret = ops->set_over_current_protection(rdev);
if (ret < 0) { if (ret < 0) {
rdev_err(rdev, "failed to set over current protection\n"); rdev_err(rdev, "failed to set over current protection: %pe\n",
ERR_PTR(ret));
return ret; return ret;
} }
} }
...@@ -1407,7 +1410,7 @@ static int set_machine_constraints(struct regulator_dev *rdev, ...@@ -1407,7 +1410,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
ret = ops->set_active_discharge(rdev, ad_state); ret = ops->set_active_discharge(rdev, ad_state);
if (ret < 0) { if (ret < 0) {
rdev_err(rdev, "failed to set active discharge\n"); rdev_err(rdev, "failed to set active discharge: %pe\n", ERR_PTR(ret));
return ret; return ret;
} }
} }
...@@ -1427,7 +1430,7 @@ static int set_machine_constraints(struct regulator_dev *rdev, ...@@ -1427,7 +1430,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
ret = _regulator_do_enable(rdev); ret = _regulator_do_enable(rdev);
if (ret < 0 && ret != -EINVAL) { if (ret < 0 && ret != -EINVAL) {
rdev_err(rdev, "failed to enable\n"); rdev_err(rdev, "failed to enable: %pe\n", ERR_PTR(ret));
return ret; return ret;
} }
...@@ -1651,8 +1654,8 @@ static struct regulator *create_regulator(struct regulator_dev *rdev, ...@@ -1651,8 +1654,8 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
err = sysfs_create_link_nowarn(&rdev->dev.kobj, &dev->kobj, err = sysfs_create_link_nowarn(&rdev->dev.kobj, &dev->kobj,
supply_name); supply_name);
if (err) { if (err) {
rdev_dbg(rdev, "could not add device link %s err %d\n", rdev_dbg(rdev, "could not add device link %s: %pe\n",
dev->kobj.name, err); dev->kobj.name, ERR_PTR(err));
/* non-fatal */ /* non-fatal */
} }
} }
...@@ -2440,7 +2443,7 @@ static int _regulator_do_enable(struct regulator_dev *rdev) ...@@ -2440,7 +2443,7 @@ static int _regulator_do_enable(struct regulator_dev *rdev)
if (ret >= 0) { if (ret >= 0) {
delay = ret; delay = ret;
} else { } else {
rdev_warn(rdev, "enable_time() failed: %d\n", ret); rdev_warn(rdev, "enable_time() failed: %pe\n", ERR_PTR(ret));
delay = 0; delay = 0;
} }
...@@ -2629,7 +2632,7 @@ static int _regulator_enable(struct regulator *regulator) ...@@ -2629,7 +2632,7 @@ static int _regulator_enable(struct regulator *regulator)
_notifier_call_chain(rdev, REGULATOR_EVENT_ENABLE, _notifier_call_chain(rdev, REGULATOR_EVENT_ENABLE,
NULL); NULL);
} else if (ret < 0) { } else if (ret < 0) {
rdev_err(rdev, "is_enabled() failed: %d\n", ret); rdev_err(rdev, "is_enabled() failed: %pe\n", ERR_PTR(ret));
goto err_consumer_disable; goto err_consumer_disable;
} }
/* Fallthrough on positive return values - already enabled */ /* Fallthrough on positive return values - already enabled */
...@@ -2731,7 +2734,7 @@ static int _regulator_disable(struct regulator *regulator) ...@@ -2731,7 +2734,7 @@ static int _regulator_disable(struct regulator *regulator)
ret = _regulator_do_disable(rdev); ret = _regulator_do_disable(rdev);
if (ret < 0) { if (ret < 0) {
rdev_err(rdev, "failed to disable\n"); rdev_err(rdev, "failed to disable: %pe\n", ERR_PTR(ret));
_notifier_call_chain(rdev, _notifier_call_chain(rdev,
REGULATOR_EVENT_ABORT_DISABLE, REGULATOR_EVENT_ABORT_DISABLE,
NULL); NULL);
...@@ -2798,7 +2801,7 @@ static int _regulator_force_disable(struct regulator_dev *rdev) ...@@ -2798,7 +2801,7 @@ static int _regulator_force_disable(struct regulator_dev *rdev)
ret = _regulator_do_disable(rdev); ret = _regulator_do_disable(rdev);
if (ret < 0) { if (ret < 0) {
rdev_err(rdev, "failed to force disable\n"); rdev_err(rdev, "failed to force disable: %pe\n", ERR_PTR(ret));
_notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE | _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
REGULATOR_EVENT_ABORT_DISABLE, NULL); REGULATOR_EVENT_ABORT_DISABLE, NULL);
return ret; return ret;
...@@ -2877,7 +2880,8 @@ static void regulator_disable_work(struct work_struct *work) ...@@ -2877,7 +2880,8 @@ static void regulator_disable_work(struct work_struct *work)
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
ret = _regulator_disable(regulator); ret = _regulator_disable(regulator);
if (ret != 0) if (ret != 0)
rdev_err(rdev, "Deferred disable failed: %d\n", ret); rdev_err(rdev, "Deferred disable failed: %pe\n",
ERR_PTR(ret));
} }
} }
WARN_ON(!total_count); WARN_ON(!total_count);
...@@ -3402,7 +3406,7 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev, ...@@ -3402,7 +3406,7 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
} }
if (delay < 0) { if (delay < 0) {
rdev_warn(rdev, "failed to get delay: %d\n", delay); rdev_warn(rdev, "failed to get delay: %pe\n", ERR_PTR(delay));
delay = 0; delay = 0;
} }
...@@ -3554,8 +3558,8 @@ int regulator_set_voltage_rdev(struct regulator_dev *rdev, int min_uV, ...@@ -3554,8 +3558,8 @@ int regulator_set_voltage_rdev(struct regulator_dev *rdev, int min_uV,
ret = regulator_set_voltage_unlocked(rdev->supply, ret = regulator_set_voltage_unlocked(rdev->supply,
best_supply_uV, INT_MAX, state); best_supply_uV, INT_MAX, state);
if (ret) { if (ret) {
dev_err(&rdev->dev, "Failed to increase supply voltage: %d\n", dev_err(&rdev->dev, "Failed to increase supply voltage: %pe\n",
ret); ERR_PTR(ret));
goto out; goto out;
} }
} }
...@@ -3572,8 +3576,8 @@ int regulator_set_voltage_rdev(struct regulator_dev *rdev, int min_uV, ...@@ -3572,8 +3576,8 @@ int regulator_set_voltage_rdev(struct regulator_dev *rdev, int min_uV,
ret = regulator_set_voltage_unlocked(rdev->supply, ret = regulator_set_voltage_unlocked(rdev->supply,
best_supply_uV, INT_MAX, state); best_supply_uV, INT_MAX, state);
if (ret) if (ret)
dev_warn(&rdev->dev, "Failed to decrease supply voltage: %d\n", dev_warn(&rdev->dev, "Failed to decrease supply voltage: %pe\n",
ret); ERR_PTR(ret));
/* No need to fail here */ /* No need to fail here */
ret = 0; ret = 0;
} }
...@@ -4559,8 +4563,8 @@ int regulator_bulk_get(struct device *dev, int num_consumers, ...@@ -4559,8 +4563,8 @@ int regulator_bulk_get(struct device *dev, int num_consumers,
err: err:
if (ret != -EPROBE_DEFER) if (ret != -EPROBE_DEFER)
dev_err(dev, "Failed to get supply '%s': %d\n", dev_err(dev, "Failed to get supply '%s': %pe\n",
consumers[i].supply, ret); consumers[i].supply, ERR_PTR(ret));
else else
dev_dbg(dev, "Failed to get supply '%s', deferring\n", dev_dbg(dev, "Failed to get supply '%s', deferring\n",
consumers[i].supply); consumers[i].supply);
...@@ -4618,8 +4622,8 @@ int regulator_bulk_enable(int num_consumers, ...@@ -4618,8 +4622,8 @@ int regulator_bulk_enable(int num_consumers,
err: err:
for (i = 0; i < num_consumers; i++) { for (i = 0; i < num_consumers; i++) {
if (consumers[i].ret < 0) if (consumers[i].ret < 0)
pr_err("Failed to enable %s: %d\n", consumers[i].supply, pr_err("Failed to enable %s: %pe\n", consumers[i].supply,
consumers[i].ret); ERR_PTR(consumers[i].ret));
else else
regulator_disable(consumers[i].consumer); regulator_disable(consumers[i].consumer);
} }
...@@ -4655,12 +4659,12 @@ int regulator_bulk_disable(int num_consumers, ...@@ -4655,12 +4659,12 @@ int regulator_bulk_disable(int num_consumers,
return 0; return 0;
err: err:
pr_err("Failed to disable %s: %d\n", consumers[i].supply, ret); pr_err("Failed to disable %s: %pe\n", consumers[i].supply, ERR_PTR(ret));
for (++i; i < num_consumers; ++i) { for (++i; i < num_consumers; ++i) {
r = regulator_enable(consumers[i].consumer); r = regulator_enable(consumers[i].consumer);
if (r != 0) if (r != 0)
pr_err("Failed to re-enable %s: %d\n", pr_err("Failed to re-enable %s: %pe\n",
consumers[i].supply, r); consumers[i].supply, ERR_PTR(r));
} }
return ret; return ret;
...@@ -5043,8 +5047,8 @@ static void regulator_remove_coupling(struct regulator_dev *rdev) ...@@ -5043,8 +5047,8 @@ static void regulator_remove_coupling(struct regulator_dev *rdev)
if (coupler && coupler->detach_regulator) { if (coupler && coupler->detach_regulator) {
err = coupler->detach_regulator(coupler, rdev); err = coupler->detach_regulator(coupler, rdev);
if (err) if (err)
rdev_err(rdev, "failed to detach from coupler: %d\n", rdev_err(rdev, "failed to detach from coupler: %pe\n",
err); ERR_PTR(err));
} }
kfree(rdev->coupling_desc.coupled_rdevs); kfree(rdev->coupling_desc.coupled_rdevs);
...@@ -5088,7 +5092,7 @@ static int regulator_init_coupling(struct regulator_dev *rdev) ...@@ -5088,7 +5092,7 @@ static int regulator_init_coupling(struct regulator_dev *rdev)
if (IS_ERR(rdev->coupling_desc.coupler)) { if (IS_ERR(rdev->coupling_desc.coupler)) {
err = PTR_ERR(rdev->coupling_desc.coupler); err = PTR_ERR(rdev->coupling_desc.coupler);
rdev_err(rdev, "failed to get coupler: %d\n", err); rdev_err(rdev, "failed to get coupler: %pe\n", ERR_PTR(err));
return err; return err;
} }
...@@ -5251,8 +5255,8 @@ regulator_register(const struct regulator_desc *regulator_desc, ...@@ -5251,8 +5255,8 @@ regulator_register(const struct regulator_desc *regulator_desc,
if (config->ena_gpiod) { if (config->ena_gpiod) {
ret = regulator_ena_gpio_request(rdev, config); ret = regulator_ena_gpio_request(rdev, config);
if (ret != 0) { if (ret != 0) {
rdev_err(rdev, "Failed to request enable GPIO: %d\n", rdev_err(rdev, "Failed to request enable GPIO: %pe\n",
ret); ERR_PTR(ret));
goto clean; goto clean;
} }
/* The regulator core took over the GPIO descriptor */ /* The regulator core took over the GPIO descriptor */
...@@ -5837,7 +5841,7 @@ static int regulator_late_cleanup(struct device *dev, void *data) ...@@ -5837,7 +5841,7 @@ static int regulator_late_cleanup(struct device *dev, void *data)
rdev_info(rdev, "disabling\n"); rdev_info(rdev, "disabling\n");
ret = _regulator_do_disable(rdev); ret = _regulator_do_disable(rdev);
if (ret != 0) if (ret != 0)
rdev_err(rdev, "couldn't disable: %d\n", ret); rdev_err(rdev, "couldn't disable: %pe\n", ERR_PTR(ret));
} else { } else {
/* The intention is that in future we will /* The intention is that in future we will
* assume that full constraints are provided * assume that full constraints are provided
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment