#include "dummy.h"
+#define rdev_err(rdev, fmt, ...) \
+ pr_err("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
+#define rdev_warn(rdev, fmt, ...) \
+ pr_warn("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
+#define rdev_info(rdev, fmt, ...) \
+ pr_info("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
+#define rdev_dbg(rdev, fmt, ...) \
+ pr_debug("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
+
static DEFINE_MUTEX(regulator_list_mutex);
static LIST_HEAD(regulator_list);
static LIST_HEAD(regulator_map_list);
BUG_ON(*min_uV > *max_uV);
if (!rdev->constraints) {
- pr_err("no constraints for %s\n", rdev_get_name(rdev));
+ rdev_err(rdev, "no constraints\n");
return -ENODEV;
}
if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) {
- pr_err("operation not allowed for %s\n", rdev_get_name(rdev));
+ rdev_err(rdev, "operation not allowed\n");
return -EPERM;
}
BUG_ON(*min_uA > *max_uA);
if (!rdev->constraints) {
- pr_err("no constraints for %s\n", rdev_get_name(rdev));
+ rdev_err(rdev, "no constraints\n");
return -ENODEV;
}
if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_CURRENT)) {
- pr_err("operation not allowed for %s\n", rdev_get_name(rdev));
+ rdev_err(rdev, "operation not allowed\n");
return -EPERM;
}
}
if (!rdev->constraints) {
- pr_err("no constraints for %s\n", rdev_get_name(rdev));
+ rdev_err(rdev, "no constraints\n");
return -ENODEV;
}
if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_MODE)) {
- pr_err("operation not allowed for %s\n", rdev_get_name(rdev));
+ rdev_err(rdev, "operation not allowed\n");
return -EPERM;
}
if (!(rdev->constraints->valid_modes_mask & mode)) {
- pr_err("invalid mode %x for %s\n", mode, rdev_get_name(rdev));
+ rdev_err(rdev, "invalid mode %x\n", mode);
return -EINVAL;
}
return 0;
static int regulator_check_drms(struct regulator_dev *rdev)
{
if (!rdev->constraints) {
- pr_err("no constraints for %s\n", rdev_get_name(rdev));
+ rdev_err(rdev, "no constraints\n");
return -ENODEV;
}
if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_DRMS)) {
- pr_err("operation not allowed for %s\n", rdev_get_name(rdev));
+ rdev_err(rdev, "operation not allowed\n");
return -EPERM;
}
return 0;
*/
if (!rstate->enabled && !rstate->disabled) {
if (can_set_state)
- pr_warning("No configuration for %s\n",
- rdev_get_name(rdev));
+ rdev_warn(rdev, "No configuration\n");
return 0;
}
if (rstate->enabled && rstate->disabled) {
- pr_err("invalid configuration for %s\n", rdev_get_name(rdev));
+ rdev_err(rdev, "invalid configuration\n");
return -EINVAL;
}
if (!can_set_state) {
- pr_err("no way to set suspend state\n");
+ rdev_err(rdev, "no way to set suspend state\n");
return -EINVAL;
}
else
ret = rdev->desc->ops->set_suspend_disable(rdev);
if (ret < 0) {
- pr_err("failed to enabled/disable\n");
+ rdev_err(rdev, "failed to enabled/disable\n");
return ret;
}
if (rdev->desc->ops->set_suspend_voltage && rstate->uV > 0) {
ret = rdev->desc->ops->set_suspend_voltage(rdev, rstate->uV);
if (ret < 0) {
- pr_err("failed to set voltage\n");
+ rdev_err(rdev, "failed to set voltage\n");
return ret;
}
}
if (rdev->desc->ops->set_suspend_mode && rstate->mode > 0) {
ret = rdev->desc->ops->set_suspend_mode(rdev, rstate->mode);
if (ret < 0) {
- pr_err("failed to set mode\n");
+ rdev_err(rdev, "failed to set mode\n");
return ret;
}
}
if (constraints->valid_modes_mask & REGULATOR_MODE_STANDBY)
count += sprintf(buf + count, "standby");
- printk(KERN_INFO "regulator: %s: %s\n", rdev_get_name(rdev), buf);
+ rdev_info(rdev, "regulator: %s\n", buf);
}
static int machine_constraints_voltage(struct regulator_dev *rdev,
struct regulation_constraints *constraints)
{
struct regulator_ops *ops = rdev->desc->ops;
- const char *name = rdev_get_name(rdev);
int ret;
unsigned selector;
rdev->constraints->max_uV,
&selector);
if (ret < 0) {
- pr_err("failed to apply %duV constraint to %s\n",
- rdev->constraints->min_uV, name);
+ rdev_err(rdev, "failed to apply %duV constraint\n",
+ rdev->constraints->min_uV);
rdev->constraints = NULL;
return ret;
}
/* else require explicit machine-level constraints */
if (cmin <= 0 || cmax <= 0 || cmax < cmin) {
- pr_err("invalid '%s' voltage constraints\n",
- name);
+ rdev_err(rdev, "invalid voltage constraints\n");
return -EINVAL;
}
/* final: [min_uV..max_uV] valid iff constraints valid */
if (max_uV < min_uV) {
- pr_err("unsupportable '%s' voltage constraints\n",
- name);
+ rdev_err(rdev, "unsupportable voltage constraints\n");
return -EINVAL;
}
/* use regulator's subset of machine constraints */
if (constraints->min_uV < min_uV) {
- pr_debug("override '%s' min_uV, %d -> %d\n",
- name, constraints->min_uV, min_uV);
+ rdev_dbg(rdev, "override min_uV, %d -> %d\n",
+ constraints->min_uV, min_uV);
constraints->min_uV = min_uV;
}
if (constraints->max_uV > max_uV) {
- pr_debug("override '%s' max_uV, %d -> %d\n",
- name, constraints->max_uV, max_uV);
+ rdev_dbg(rdev, "override max_uV, %d -> %d\n",
+ constraints->max_uV, max_uV);
constraints->max_uV = max_uV;
}
}
const struct regulation_constraints *constraints)
{
int ret = 0;
- const char *name;
struct regulator_ops *ops = rdev->desc->ops;
rdev->constraints = kmemdup(constraints, sizeof(*constraints),
if (!rdev->constraints)
return -ENOMEM;
- name = rdev_get_name(rdev);
-
ret = machine_constraints_voltage(rdev, rdev->constraints);
if (ret != 0)
goto out;
if (constraints->initial_state) {
ret = suspend_prepare(rdev, rdev->constraints->initial_state);
if (ret < 0) {
- pr_err("failed to set suspend state for %s\n",
- name);
+ rdev_err(rdev, "failed to set suspend state\n");
rdev->constraints = NULL;
goto out;
}
if (constraints->initial_mode) {
if (!ops->set_mode) {
- pr_err("no set_mode operation for %s\n",
- name);
+ rdev_err(rdev, "no set_mode operation\n");
ret = -EINVAL;
goto out;
}
ret = ops->set_mode(rdev, rdev->constraints->initial_mode);
if (ret < 0) {
- pr_err("failed to set initial mode for %s: %d\n",
- name, ret);
+ rdev_err(rdev, "failed to set initial mode: %d\n", ret);
goto out;
}
}
ops->enable) {
ret = ops->enable(rdev);
if (ret < 0) {
- pr_err("failed to enable %s\n", name);
+ rdev_err(rdev, "failed to enable\n");
rdev->constraints = NULL;
goto out;
}
err = sysfs_create_link(&rdev->dev.kobj, &supply_rdev->dev.kobj,
"supply");
if (err) {
- pr_err("could not add device link %s err %d\n",
- supply_rdev->dev.kobj.name, err);
+ rdev_err(rdev, "could not add device link %s err %d\n",
+ supply_rdev->dev.kobj.name, err);
goto out;
}
rdev->supply = supply_rdev;
continue;
dev_dbg(consumer_dev, "%s/%s is '%s' supply; fail %s/%s\n",
- dev_name(&node->regulator->dev),
- node->regulator->desc->name,
- supply,
- dev_name(&rdev->dev), rdev_get_name(rdev));
+ dev_name(&node->regulator->dev),
+ node->regulator->desc->name,
+ supply,
+ dev_name(&rdev->dev), rdev_get_name(rdev));
return -EBUSY;
}
regulator->dev_attr.show = device_requested_uA_show;
err = device_create_file(dev, ®ulator->dev_attr);
if (err < 0) {
- pr_warning("could not add regulator_dev"
- " requested microamps sysfs entry\n");
+ rdev_warn(rdev, "could not add regulator_dev requested microamps sysfs entry\n");
goto attr_name_err;
}
err = sysfs_create_link(&rdev->dev.kobj, &dev->kobj,
buf);
if (err) {
- pr_warning("could not add device link %s err %d\n",
- dev->kobj.name, err);
+ rdev_warn(rdev, "could not add device link %s err %d\n",
+ dev->kobj.name, err);
goto link_name_err;
}
}
int ret;
if (id == NULL) {
- pr_err("regulator: get() with no identifier\n");
+ pr_err("get() with no identifier\n");
return regulator;
}
* substitute in a dummy regulator so consumers can continue.
*/
if (!has_full_constraints) {
- pr_warning("%s supply %s not found, using dummy regulator\n",
- devname, id);
+ pr_warn("%s supply %s not found, using dummy regulator\n",
+ devname, id);
rdev = dummy_regulator_rdev;
goto found;
}
ret = _regulator_enable(rdev->supply);
mutex_unlock(&rdev->supply->mutex);
if (ret < 0) {
- pr_err("failed to enable %s: %d\n",
- rdev_get_name(rdev), ret);
+ rdev_err(rdev, "failed to enable: %d\n", ret);
return ret;
}
}
if (ret >= 0) {
delay = ret;
} else {
- pr_warning("enable_time() failed for %s: %d\n",
- rdev_get_name(rdev),
+ rdev_warn(rdev, "enable_time() failed: %d\n",
ret);
delay = 0;
}
trace_regulator_enable_complete(rdev_get_name(rdev));
} else if (ret < 0) {
- pr_err("is_enabled() failed for %s: %d\n",
- rdev_get_name(rdev), ret);
+ rdev_err(rdev, "is_enabled() failed: %d\n", ret);
return ret;
}
/* Fallthrough on positive return values - already enabled */
ret = rdev->desc->ops->disable(rdev);
if (ret < 0) {
- pr_err("failed to disable %s\n",
- rdev_get_name(rdev));
+ rdev_err(rdev, "failed to disable\n");
return ret;
}
/* ah well, who wants to live forever... */
ret = rdev->desc->ops->disable(rdev);
if (ret < 0) {
- pr_err("failed to force disable %s\n",
- rdev_get_name(rdev));
+ rdev_err(rdev, "failed to force disable\n");
return ret;
}
/* notify other consumers that power has been forced off */
/* get output voltage */
output_uV = rdev->desc->ops->get_voltage(rdev);
if (output_uV <= 0) {
- pr_err("invalid output voltage found for %s\n",
- rdev_get_name(rdev));
+ rdev_err(rdev, "invalid output voltage found\n");
goto out;
}
else
input_uV = rdev->constraints->input_uV;
if (input_uV <= 0) {
- pr_err("invalid input voltage found for %s\n",
- rdev_get_name(rdev));
+ rdev_err(rdev, "invalid input voltage found\n");
goto out;
}
total_uA_load);
ret = regulator_check_mode(rdev, mode);
if (ret < 0) {
- pr_err("failed to get optimum mode for %s @"
- " %d uA %d -> %d uV\n", rdev_get_name(rdev),
- total_uA_load, input_uV, output_uV);
+ rdev_err(rdev, "failed to get optimum mode @ %d uA %d -> %d uV\n",
+ total_uA_load, input_uV, output_uV);
goto out;
}
ret = rdev->desc->ops->set_mode(rdev, mode);
if (ret < 0) {
- pr_err("failed to set optimum mode %x for %s\n",
- mode, rdev_get_name(rdev));
+ rdev_err(rdev, "failed to set optimum mode %x\n", mode);
goto out;
}
ret = mode;
return 0;
err:
- printk(KERN_ERR "Failed to enable %s: %d\n", consumers[i].supply, ret);
+ pr_err("Failed to enable %s: %d\n", consumers[i].supply, ret);
for (--i; i >= 0; --i)
regulator_disable(consumers[i].consumer);
return 0;
err:
- printk(KERN_ERR "Failed to disable %s: %d\n", consumers[i].supply,
- ret);
+ pr_err("Failed to disable %s: %d\n", consumers[i].supply, ret);
for (--i; i >= 0; --i)
regulator_enable(consumers[i].consumer);
mutex_unlock(&rdev->mutex);
if (ret < 0) {
- pr_err("failed to prepare %s\n", rdev_get_name(rdev));
+ rdev_err(rdev, "failed to prepare\n");
goto out;
}
}
struct regulator_ops *ops;
struct regulation_constraints *c;
int enabled, ret;
- const char *name;
mutex_lock(®ulator_list_mutex);
ops = rdev->desc->ops;
c = rdev->constraints;
- name = rdev_get_name(rdev);
-
if (!ops->disable || (c && c->always_on))
continue;
if (has_full_constraints) {
/* We log since this may kill the system if it
* goes wrong. */
- pr_info("disabling %s\n", name);
+ rdev_info(rdev, "disabling\n");
ret = ops->disable(rdev);
if (ret != 0) {
- pr_err("couldn't disable %s: %d\n", name, ret);
+ rdev_err(rdev, "couldn't disable: %d\n", ret);
}
} else {
/* The intention is that in future we will
* so warn even if we aren't going to do
* anything here.
*/
- pr_warning("incomplete constraints, leaving %s on\n",
- name);
+ rdev_warn(rdev, "incomplete constraints, leaving on\n");
}
unlock: