Commit 5f476822 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Linus Torvalds

power: charger_manager: convert to use match_string() helper

The new helper returns index of the mathing string in an array.  We
would use it here.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7a5cf52d
...@@ -2019,27 +2019,6 @@ static void __exit charger_manager_cleanup(void) ...@@ -2019,27 +2019,6 @@ static void __exit charger_manager_cleanup(void)
} }
module_exit(charger_manager_cleanup); module_exit(charger_manager_cleanup);
/**
* find_power_supply - find the associated power_supply of charger
* @cm: the Charger Manager representing the battery
* @psy: pointer to instance of charger's power_supply
*/
static bool find_power_supply(struct charger_manager *cm,
struct power_supply *psy)
{
int i;
bool found = false;
for (i = 0; cm->desc->psy_charger_stat[i]; i++) {
if (!strcmp(psy->desc->name, cm->desc->psy_charger_stat[i])) {
found = true;
break;
}
}
return found;
}
/** /**
* cm_notify_event - charger driver notify Charger Manager of charger event * cm_notify_event - charger driver notify Charger Manager of charger event
* @psy: pointer to instance of charger's power_supply * @psy: pointer to instance of charger's power_supply
...@@ -2057,9 +2036,11 @@ void cm_notify_event(struct power_supply *psy, enum cm_event_types type, ...@@ -2057,9 +2036,11 @@ void cm_notify_event(struct power_supply *psy, enum cm_event_types type,
mutex_lock(&cm_list_mtx); mutex_lock(&cm_list_mtx);
list_for_each_entry(cm, &cm_list, entry) { list_for_each_entry(cm, &cm_list, entry) {
found_power_supply = find_power_supply(cm, psy); if (match_string(cm->desc->psy_charger_stat, -1,
if (found_power_supply) psy->desc->name) >= 0) {
found_power_supply = true;
break; break;
}
} }
mutex_unlock(&cm_list_mtx); mutex_unlock(&cm_list_mtx);
......
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