Commit cd7e36ab authored by Marek Szyprowski's avatar Marek Szyprowski Committed by Mark Brown

regulator: Fix useless O^2 complexity in suspend/resume

regulator_pm_ops with regulator_suspend and regulator_resume functions are
assigned to every regulator device registered in the system, so there is no
need to iterate over all again in them. Replace class_for_each_device()
construction with direct operation on the rdev embedded in the given
regulator device. This saves a lots of useless operations in suspend and
resume paths.

Fixes: f7efad10: regulator: add PM suspend and resume hooks
Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent beb5a17f
...@@ -4464,19 +4464,6 @@ void regulator_unregister(struct regulator_dev *rdev) ...@@ -4464,19 +4464,6 @@ void regulator_unregister(struct regulator_dev *rdev)
EXPORT_SYMBOL_GPL(regulator_unregister); EXPORT_SYMBOL_GPL(regulator_unregister);
#ifdef CONFIG_SUSPEND #ifdef CONFIG_SUSPEND
static int _regulator_suspend(struct device *dev, void *data)
{
struct regulator_dev *rdev = dev_to_rdev(dev);
suspend_state_t *state = data;
int ret;
regulator_lock(rdev);
ret = suspend_set_state(rdev, *state);
regulator_unlock(rdev);
return ret;
}
/** /**
* regulator_suspend - prepare regulators for system wide suspend * regulator_suspend - prepare regulators for system wide suspend
* @state: system suspend state * @state: system suspend state
...@@ -4485,20 +4472,25 @@ static int _regulator_suspend(struct device *dev, void *data) ...@@ -4485,20 +4472,25 @@ static int _regulator_suspend(struct device *dev, void *data)
*/ */
static int regulator_suspend(struct device *dev) static int regulator_suspend(struct device *dev)
{ {
struct regulator_dev *rdev = dev_to_rdev(dev);
suspend_state_t state = pm_suspend_target_state; suspend_state_t state = pm_suspend_target_state;
int ret;
regulator_lock(rdev);
ret = suspend_set_state(rdev, state);
regulator_unlock(rdev);
return class_for_each_device(&regulator_class, NULL, &state, return ret;
_regulator_suspend);
} }
static int _regulator_resume(struct device *dev, void *data) static int regulator_resume(struct device *dev)
{ {
int ret = 0; suspend_state_t state = pm_suspend_target_state;
struct regulator_dev *rdev = dev_to_rdev(dev); struct regulator_dev *rdev = dev_to_rdev(dev);
suspend_state_t *state = data;
struct regulator_state *rstate; struct regulator_state *rstate;
int ret = 0;
rstate = regulator_get_suspend_state(rdev, *state); rstate = regulator_get_suspend_state(rdev, state);
if (rstate == NULL) if (rstate == NULL)
return 0; return 0;
...@@ -4513,15 +4505,6 @@ static int _regulator_resume(struct device *dev, void *data) ...@@ -4513,15 +4505,6 @@ static int _regulator_resume(struct device *dev, void *data)
return ret; return ret;
} }
static int regulator_resume(struct device *dev)
{
suspend_state_t state = pm_suspend_target_state;
return class_for_each_device(&regulator_class, NULL, &state,
_regulator_resume);
}
#else /* !CONFIG_SUSPEND */ #else /* !CONFIG_SUSPEND */
#define regulator_suspend NULL #define regulator_suspend NULL
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment