ARM: includecheck fix: misc.c
[safe/jmp/linux-2.6] / drivers / power / power_supply_core.c
index af1633e..5520040 100644 (file)
@@ -41,7 +41,7 @@ static void power_supply_changed_work(struct work_struct *work)
 
        dev_dbg(psy->dev, "%s\n", __func__);
 
-       class_for_each_device(power_supply_class, psy,
+       class_for_each_device(power_supply_class, NULL, psy,
                              __power_supply_changed_work);
 
        power_supply_update_leds(psy);
@@ -79,7 +79,7 @@ int power_supply_am_i_supplied(struct power_supply *psy)
 {
        int error;
 
-       error = class_for_each_device(power_supply_class, psy,
+       error = class_for_each_device(power_supply_class, NULL, psy,
                                      __power_supply_am_i_supplied);
 
        dev_dbg(psy->dev, "%s %d\n", __func__, error);
@@ -87,12 +87,36 @@ int power_supply_am_i_supplied(struct power_supply *psy)
        return error;
 }
 
+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);
+
+       if (psy->type != POWER_SUPPLY_TYPE_BATTERY) {
+               if (psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &ret))
+                       return 0;
+               if (ret.intval)
+                       return ret.intval;
+       }
+       return 0;
+}
+
+int power_supply_is_system_supplied(void)
+{
+       int error;
+
+       error = class_for_each_device(power_supply_class, NULL, NULL,
+                                     __power_supply_is_system_supplied);
+
+       return error;
+}
+
 int power_supply_register(struct device *parent, struct power_supply *psy)
 {
        int rc = 0;
 
-       psy->dev = device_create_drvdata(power_supply_class, parent, 0,
-                                        psy, "%s", psy->name);
+       psy->dev = device_create(power_supply_class, parent, 0, psy,
+                                "%s", psy->name);
        if (IS_ERR(psy->dev)) {
                rc = PTR_ERR(psy->dev);
                goto dev_create_failed;
@@ -148,6 +172,7 @@ static void __exit power_supply_class_exit(void)
 
 EXPORT_SYMBOL_GPL(power_supply_changed);
 EXPORT_SYMBOL_GPL(power_supply_am_i_supplied);
+EXPORT_SYMBOL_GPL(power_supply_is_system_supplied);
 EXPORT_SYMBOL_GPL(power_supply_register);
 EXPORT_SYMBOL_GPL(power_supply_unregister);