Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 177716
b: refs/heads/master
c: e79055d
h: refs/heads/master
v: v3
  • Loading branch information
Mark Brown authored and Liam Girdwood committed Dec 17, 2009
1 parent 64c8d98 commit 9127e12
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 28 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: 5b307627738f1f6cbc31fad9e28a299b5fe55602
refs/heads/master: e79055d62ea6ca3c36962209f4c819614972c95a
64 changes: 37 additions & 27 deletions trunk/drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,31 +672,11 @@ static void print_constraints(struct regulator_dev *rdev)
printk(KERN_INFO "regulator: %s: %s\n", rdev->desc->name, buf);
}

/**
* set_machine_constraints - sets regulator constraints
* @rdev: regulator source
* @constraints: constraints to apply
*
* Allows platform initialisation code to define and constrain
* regulator circuits e.g. valid voltage/current ranges, etc. NOTE:
* Constraints *must* be set by platform code in order for some
* regulator operations to proceed i.e. set_voltage, set_current_limit,
* set_mode.
*/
static int set_machine_constraints(struct regulator_dev *rdev,
struct regulation_constraints *constraints)
static int machine_constraints_voltage(struct regulator_dev *rdev,
const char *name, struct regulation_constraints *constraints)
{
int ret = 0;
const char *name;
struct regulator_ops *ops = rdev->desc->ops;

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

/* constrain machine-level voltage specs to fit
* the actual range supported by this regulator.
*/
Expand All @@ -719,14 +699,13 @@ static int set_machine_constraints(struct regulator_dev *rdev,

/* voltage constraints are optional */
if ((cmin == 0) && (cmax == 0))
goto out;
return 0;

/* else require explicit machine-level constraints */
if (cmin <= 0 || cmax <= 0 || cmax < cmin) {
pr_err("%s: %s '%s' voltage constraints\n",
__func__, "invalid", name);
ret = -EINVAL;
goto out;
return -EINVAL;
}

/* initial: [cmin..cmax] valid, [min_uV..max_uV] not */
Expand All @@ -748,8 +727,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
if (max_uV < min_uV) {
pr_err("%s: %s '%s' voltage constraints\n",
__func__, "unsupportable", name);
ret = -EINVAL;
goto out;
return -EINVAL;
}

/* use regulator's subset of machine constraints */
Expand All @@ -767,6 +745,38 @@ static int set_machine_constraints(struct regulator_dev *rdev,
}
}

return 0;
}

/**
* set_machine_constraints - sets regulator constraints
* @rdev: regulator source
* @constraints: constraints to apply
*
* Allows platform initialisation code to define and constrain
* regulator circuits e.g. valid voltage/current ranges, etc. NOTE:
* Constraints *must* be set by platform code in order for some
* regulator operations to proceed i.e. set_voltage, set_current_limit,
* set_mode.
*/
static int set_machine_constraints(struct regulator_dev *rdev,
struct regulation_constraints *constraints)
{
int ret = 0;
const char *name;
struct regulator_ops *ops = rdev->desc->ops;

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

ret = machine_constraints_voltage(rdev, name, constraints);
if (ret != 0)
goto out;

rdev->constraints = constraints;

/* do we need to apply the constraint voltage */
Expand Down

0 comments on commit 9127e12

Please sign in to comment.