diff --git a/[refs] b/[refs] index d1dc1c919415..524ebbeac44d 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 62df3935a7ef842ad0af6025d2fc59d353de2e1d +refs/heads/master: 2530daa187be3adef2d7cb41bd51f1384e478f2b diff --git a/trunk/drivers/power/power_supply_core.c b/trunk/drivers/power/power_supply_core.c index b10c121244e5..bc82f9589a0d 100644 --- a/trunk/drivers/power/power_supply_core.c +++ b/trunk/drivers/power/power_supply_core.c @@ -98,7 +98,9 @@ static int __power_supply_is_system_supplied(struct device *dev, void *data) { union power_supply_propval ret = {0,}; struct power_supply *psy = dev_get_drvdata(dev); + unsigned int *count = data; + (*count)++; if (psy->type != POWER_SUPPLY_TYPE_BATTERY) { if (psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &ret)) return 0; @@ -111,10 +113,18 @@ static int __power_supply_is_system_supplied(struct device *dev, void *data) int power_supply_is_system_supplied(void) { int error; + unsigned int count = 0; - error = class_for_each_device(power_supply_class, NULL, NULL, + error = class_for_each_device(power_supply_class, NULL, &count, __power_supply_is_system_supplied); + /* + * If no power class device was found at all, most probably we are + * running on a desktop system, so assume we are on mains power. + */ + if (count == 0) + return 1; + return error; } EXPORT_SYMBOL_GPL(power_supply_is_system_supplied);