|
@@ -52,7 +52,6 @@ struct regulator {
|
|
int uA_load;
|
|
int uA_load;
|
|
int min_uV;
|
|
int min_uV;
|
|
int max_uV;
|
|
int max_uV;
|
|
- int enabled; /* count of client enables */
|
|
|
|
char *supply_name;
|
|
char *supply_name;
|
|
struct device_attribute dev_attr;
|
|
struct device_attribute dev_attr;
|
|
struct regulator_dev *rdev;
|
|
struct regulator_dev *rdev;
|
|
@@ -815,6 +814,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
|
|
rdev->constraints = NULL;
|
|
rdev->constraints = NULL;
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
+ rdev->use_count = 1;
|
|
}
|
|
}
|
|
|
|
|
|
print_constraints(rdev);
|
|
print_constraints(rdev);
|
|
@@ -1068,10 +1068,6 @@ void regulator_put(struct regulator *regulator)
|
|
mutex_lock(®ulator_list_mutex);
|
|
mutex_lock(®ulator_list_mutex);
|
|
rdev = regulator->rdev;
|
|
rdev = regulator->rdev;
|
|
|
|
|
|
- if (WARN(regulator->enabled, "Releasing supply %s while enabled\n",
|
|
|
|
- regulator->supply_name))
|
|
|
|
- _regulator_disable(rdev);
|
|
|
|
-
|
|
|
|
/* remove any sysfs entries */
|
|
/* remove any sysfs entries */
|
|
if (regulator->dev) {
|
|
if (regulator->dev) {
|
|
sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name);
|
|
sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name);
|
|
@@ -1146,12 +1142,7 @@ int regulator_enable(struct regulator *regulator)
|
|
int ret = 0;
|
|
int ret = 0;
|
|
|
|
|
|
mutex_lock(&rdev->mutex);
|
|
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);
|
|
mutex_unlock(&rdev->mutex);
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
@@ -1162,6 +1153,11 @@ static int _regulator_disable(struct regulator_dev *rdev)
|
|
{
|
|
{
|
|
int ret = 0;
|
|
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 ? */
|
|
/* are we the last user and permitted to disable ? */
|
|
if (rdev->use_count == 1 && !rdev->constraints->always_on) {
|
|
if (rdev->use_count == 1 && !rdev->constraints->always_on) {
|
|
|
|
|
|
@@ -1210,16 +1206,7 @@ int regulator_disable(struct regulator *regulator)
|
|
int ret = 0;
|
|
int ret = 0;
|
|
|
|
|
|
mutex_lock(&rdev->mutex);
|
|
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);
|
|
mutex_unlock(&rdev->mutex);
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
@@ -1266,7 +1253,6 @@ int regulator_force_disable(struct regulator *regulator)
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
mutex_lock(®ulator->rdev->mutex);
|
|
mutex_lock(®ulator->rdev->mutex);
|
|
- regulator->enabled = 0;
|
|
|
|
regulator->uA_load = 0;
|
|
regulator->uA_load = 0;
|
|
ret = _regulator_force_disable(regulator->rdev);
|
|
ret = _regulator_force_disable(regulator->rdev);
|
|
mutex_unlock(®ulator->rdev->mutex);
|
|
mutex_unlock(®ulator->rdev->mutex);
|