Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 140264
b: refs/heads/master
c: cd94b50
h: refs/heads/master
v: v3
  • Loading branch information
David Brownell authored and Liam Girdwood committed Mar 31, 2009
1 parent 3ef7376 commit 11907a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1dc60343f874ce4bfbbc2c3d2f7865fc897df479
refs/heads/master: cd94b5053081963614f6ad77b9b66a7968056c84
30 changes: 8 additions & 22 deletions trunk/drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ struct regulator {
int uA_load;
int min_uV;
int max_uV;
int enabled; /* count of client enables */
char *supply_name;
struct device_attribute dev_attr;
struct regulator_dev *rdev;
Expand Down Expand Up @@ -815,6 +814,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
rdev->constraints = NULL;
goto out;
}
rdev->use_count = 1;
}

print_constraints(rdev);
Expand Down Expand Up @@ -1068,10 +1068,6 @@ void regulator_put(struct regulator *regulator)
mutex_lock(&regulator_list_mutex);
rdev = regulator->rdev;

if (WARN(regulator->enabled, "Releasing supply %s while enabled\n",
regulator->supply_name))
_regulator_disable(rdev);

/* remove any sysfs entries */
if (regulator->dev) {
sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name);
Expand Down Expand Up @@ -1146,12 +1142,7 @@ int regulator_enable(struct regulator *regulator)
int ret = 0;

mutex_lock(&rdev->mutex);
if (regulator->enabled == 0)
ret = _regulator_enable(rdev);
else if (regulator->enabled < 0)
ret = -EIO;
if (ret == 0)
regulator->enabled++;
ret = _regulator_enable(rdev);
mutex_unlock(&rdev->mutex);
return ret;
}
Expand All @@ -1162,6 +1153,11 @@ static int _regulator_disable(struct regulator_dev *rdev)
{
int ret = 0;

if (WARN(rdev->use_count <= 0,
"unbalanced disables for %s\n",
rdev->desc->name))
return -EIO;

/* are we the last user and permitted to disable ? */
if (rdev->use_count == 1 && !rdev->constraints->always_on) {

Expand Down Expand Up @@ -1210,16 +1206,7 @@ int regulator_disable(struct regulator *regulator)
int ret = 0;

mutex_lock(&rdev->mutex);
if (regulator->enabled == 1) {
ret = _regulator_disable(rdev);
if (ret == 0)
regulator->uA_load = 0;
} else if (WARN(regulator->enabled <= 0,
"unbalanced disables for supply %s\n",
regulator->supply_name))
ret = -EIO;
if (ret == 0)
regulator->enabled--;
ret = _regulator_disable(rdev);
mutex_unlock(&rdev->mutex);
return ret;
}
Expand Down Expand Up @@ -1266,7 +1253,6 @@ int regulator_force_disable(struct regulator *regulator)
int ret;

mutex_lock(&regulator->rdev->mutex);
regulator->enabled = 0;
regulator->uA_load = 0;
ret = _regulator_force_disable(regulator->rdev);
mutex_unlock(&regulator->rdev->mutex);
Expand Down

0 comments on commit 11907a1

Please sign in to comment.