Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/lrg/voltage-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/lrg/voltage-2.6:
  regulator: Fix default constraints for fixed voltage regulators
  regulator/bq24022: fix bug in is_enabled function
  regulator/virtual: fix strings compare predicates
  regulator core: fix double-free in regulator_register() error path
  drivers/regulator: fix when type is different from REGULATOR_VOLTAGE or REGULATOR_CURRENT
  unreachable code in drms_uA_update()
  regulator: fix header file missing kernel-doc
  • Loading branch information
Linus Torvalds committed Apr 28, 2009
2 parents c3310e7 + 3e59091 commit 8b86bd7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
3 changes: 1 addition & 2 deletions drivers/regulator/bq24022.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ static int bq24022_disable(struct regulator_dev *rdev)

static int bq24022_is_enabled(struct regulator_dev *rdev)
{
struct platform_device *pdev = rdev_get_drvdata(rdev);
struct bq24022_mach_info *pdata = pdev->dev.platform_data;
struct bq24022_mach_info *pdata = rdev_get_drvdata(rdev);

return !gpio_get_value(pdata->gpio_nce);
}
Expand Down
19 changes: 13 additions & 6 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,8 @@ static void drms_uA_update(struct regulator_dev *rdev)

err = regulator_check_drms(rdev);
if (err < 0 || !rdev->desc->ops->get_optimum_mode ||
!rdev->desc->ops->get_voltage || !rdev->desc->ops->set_mode);
return;
!rdev->desc->ops->get_voltage || !rdev->desc->ops->set_mode)
return;

/* get output voltage */
output_uV = rdev->desc->ops->get_voltage(rdev);
Expand Down Expand Up @@ -703,10 +703,13 @@ static int set_machine_constraints(struct regulator_dev *rdev,
int cmin = constraints->min_uV;
int cmax = constraints->max_uV;

/* it's safe to autoconfigure fixed-voltage supplies */
/* it's safe to autoconfigure fixed-voltage supplies
and the constraints are used by list_voltage. */
if (count == 1 && !cmin) {
cmin = INT_MIN;
cmin = 1;
cmax = INT_MAX;
constraints->min_uV = cmin;
constraints->max_uV = cmax;
}

/* voltage constraints are optional */
Expand Down Expand Up @@ -2001,8 +2004,8 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
if (regulator_desc->name == NULL || regulator_desc->ops == NULL)
return ERR_PTR(-EINVAL);

if (!regulator_desc->type == REGULATOR_VOLTAGE &&
!regulator_desc->type == REGULATOR_CURRENT)
if (regulator_desc->type != REGULATOR_VOLTAGE &&
regulator_desc->type != REGULATOR_CURRENT)
return ERR_PTR(-EINVAL);

if (!init_data)
Expand Down Expand Up @@ -2080,6 +2083,10 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,

scrub:
device_unregister(&rdev->dev);
/* device core frees rdev */
rdev = ERR_PTR(ret);
goto out;

clean:
kfree(rdev);
rdev = ERR_PTR(ret);
Expand Down
8 changes: 4 additions & 4 deletions drivers/regulator/virtual.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,13 @@ static ssize_t set_mode(struct device *dev, struct device_attribute *attr,
* sysfs_streq() doesn't need the \n's, but we add them so the strings
* will be shared with show_mode(), above.
*/
if (sysfs_streq(buf, "fast\n") == 0)
if (sysfs_streq(buf, "fast\n"))
mode = REGULATOR_MODE_FAST;
else if (sysfs_streq(buf, "normal\n") == 0)
else if (sysfs_streq(buf, "normal\n"))
mode = REGULATOR_MODE_NORMAL;
else if (sysfs_streq(buf, "idle\n") == 0)
else if (sysfs_streq(buf, "idle\n"))
mode = REGULATOR_MODE_IDLE;
else if (sysfs_streq(buf, "standby\n") == 0)
else if (sysfs_streq(buf, "standby\n"))
mode = REGULATOR_MODE_STANDBY;
else {
dev_err(dev, "Configuring invalid mode\n");
Expand Down
1 change: 1 addition & 0 deletions include/linux/regulator/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ enum regulator_status {
* @set_current_limit: Configure a limit for a current-limited regulator.
* @get_current_limit: Get the configured limit for a current-limited regulator.
*
* @set_mode: Set the configured operating mode for the regulator.
* @get_mode: Get the configured operating mode for the regulator.
* @get_status: Return actual (not as-configured) status of regulator, as a
* REGULATOR_STATUS value (or negative errno)
Expand Down

0 comments on commit 8b86bd7

Please sign in to comment.