Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 140267
b: refs/heads/master
c: ca72556
h: refs/heads/master
i:
  140265: 5b2f4c1
  140263: 3ef7376
v: v3
  • Loading branch information
Mark Brown authored and Liam Girdwood committed Mar 31, 2009
1 parent 8fea718 commit 8699b5c
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 50f075963f127d713ff0c30359baefc0f89d9ae2
refs/heads/master: ca7255614e0861e36480103f4a402a115803d7b5
92 changes: 92 additions & 0 deletions trunk/drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
static DEFINE_MUTEX(regulator_list_mutex);
static LIST_HEAD(regulator_list);
static LIST_HEAD(regulator_map_list);
static int has_full_constraints;

/*
* struct regulator_map
Expand Down Expand Up @@ -2142,6 +2143,23 @@ int regulator_suspend_prepare(suspend_state_t state)
}
EXPORT_SYMBOL_GPL(regulator_suspend_prepare);

/**
* regulator_has_full_constraints - the system has fully specified constraints
*
* Calling this function will cause the regulator API to disable all
* regulators which have a zero use count and don't have an always_on
* constraint in a late_initcall.
*
* The intention is that this will become the default behaviour in a
* future kernel release so users are encouraged to use this facility
* now.
*/
void regulator_has_full_constraints(void)
{
has_full_constraints = 1;
}
EXPORT_SYMBOL_GPL(regulator_has_full_constraints);

/**
* rdev_get_drvdata - get rdev regulator driver data
* @rdev: regulator
Expand Down Expand Up @@ -2209,3 +2227,77 @@ static int __init regulator_init(void)

/* init early to allow our consumers to complete system booting */
core_initcall(regulator_init);

static int __init regulator_init_complete(void)
{
struct regulator_dev *rdev;
struct regulator_ops *ops;
struct regulation_constraints *c;
int enabled, ret;
const char *name;

mutex_lock(&regulator_list_mutex);

/* If we have a full configuration then disable any regulators
* which are not in use or always_on. This will become the
* default behaviour in the future.
*/
list_for_each_entry(rdev, &regulator_list, list) {
ops = rdev->desc->ops;
c = rdev->constraints;

if (c->name)
name = c->name;
else if (rdev->desc->name)
name = rdev->desc->name;
else
name = "regulator";

if (!ops->disable || c->always_on)
continue;

mutex_lock(&rdev->mutex);

if (rdev->use_count)
goto unlock;

/* If we can't read the status assume it's on. */
if (ops->is_enabled)
enabled = ops->is_enabled(rdev);
else
enabled = 1;

if (!enabled)
goto unlock;

if (has_full_constraints) {
/* We log since this may kill the system if it
* goes wrong. */
printk(KERN_INFO "%s: disabling %s\n",
__func__, name);
ret = ops->disable(rdev);
if (ret != 0) {
printk(KERN_ERR
"%s: couldn't disable %s: %d\n",
__func__, name, ret);
}
} else {
/* The intention is that in future we will
* assume that full constraints are provided
* so warn even if we aren't going to do
* anything here.
*/
printk(KERN_WARNING
"%s: incomplete constraints, leaving %s on\n",
__func__, name);
}

unlock:
mutex_unlock(&rdev->mutex);
}

mutex_unlock(&regulator_list_mutex);

return 0;
}
late_initcall(regulator_init_complete);
2 changes: 2 additions & 0 deletions trunk/include/linux/regulator/machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,6 @@ struct regulator_init_data {

int regulator_suspend_prepare(suspend_state_t state);

void regulator_has_full_constraints(void);

#endif

0 comments on commit 8699b5c

Please sign in to comment.