From c46e97e574fae554112acd931565fc5aa4b511d6 Mon Sep 17 00:00:00 2001 From: Bill Gatliff Date: Wed, 25 Jan 2012 14:59:13 +0100 Subject: [PATCH] regulator: pass voltage to notifiers The regulator API goes to great lengths to stay synchronized with regulator states, but then throws all that hard work away by not pasing the current regulator voltage to notifiers. This forces notifiers to do a schedule_work() or similar to take action based on regulator voltage, since they cannot call regulator_get_voltage() in the notifier function itself. This un-synchronizes them from regulator state changes. The enclosed patch passes the new regulator voltage forward to notifiers, allowing them to stay synchronized with the regulator if that is the only information they need. Change-Id: I9d6dfe82c464a2834ac149275f6d7f0cdf8a8167 Signed-off-by: Bill Gatliff --- drivers/regulator/core.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 5b2328d..9a57ee6 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -643,7 +643,8 @@ static int update_voltage(struct regulator *regulator, int min_uV, int max_uV) if (!ret) goto out; - _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, NULL); + _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, + (void*)_regulator_get_voltage(rdev)); out: return ret; @@ -670,7 +671,8 @@ static int update_voltage_prev(struct regulator_dev *rdev) if (!ret) return ret; - _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, NULL); + _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, + (void*)_regulator_get_voltage(rdev)); return ret; } @@ -1852,7 +1854,7 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev, if (ret == 0) _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, - NULL); + (void*)_regulator_get_voltage(rdev)); trace_regulator_set_voltage_complete(rdev_get_name(rdev), selector); @@ -2342,7 +2344,7 @@ static void _notifier_call_chain(struct regulator_dev *rdev, struct regulator_dev *_rdev; /* call rdev chain first */ - blocking_notifier_call_chain(&rdev->notifier, event, NULL); + blocking_notifier_call_chain(&rdev->notifier, event, data); /* now notify regulator we supply */ list_for_each_entry(_rdev, &rdev->supply_list, slist) { -- 1.7.5.4