Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 283479
b: refs/heads/master
c: 2530daa
h: refs/heads/master
i:
  283477: bc5ccfd
  283475: c8e60a9
  283471: 98686a6
v: v3
  • Loading branch information
Jean Delvare authored and Anton Vorontsov committed Jan 6, 2012
1 parent 8b5c5ca commit 7e966c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 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: 62df3935a7ef842ad0af6025d2fc59d353de2e1d
refs/heads/master: 2530daa187be3adef2d7cb41bd51f1384e478f2b
12 changes: 11 additions & 1 deletion trunk/drivers/power/power_supply_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 7e966c1

Please sign in to comment.