proc tty: switch sdio_uart to ->proc_fops
[safe/jmp/linux-2.6] / drivers / power / ds2760_battery.c
index 00e1ea6..a52d4a1 100644 (file)
@@ -180,10 +180,13 @@ static int ds2760_battery_read_status(struct ds2760_device_info *di)
        di->empty_uAh = battery_interpolate(scale, di->temp_C / 10);
        di->empty_uAh *= 1000; /* convert to µAh */
 
-       /* From Maxim Application Note 131: remaining capacity =
-        * ((ICA - Empty Value) / (Full Value - Empty Value)) x 100% */
-       di->rem_capacity = ((di->accum_current_uAh - di->empty_uAh) * 100L) /
-                           (di->full_active_uAh - di->empty_uAh);
+       if (di->full_active_uAh == di->empty_uAh)
+               di->rem_capacity = 0;
+       else
+               /* From Maxim Application Note 131: remaining capacity =
+                * ((ICA - Empty Value) / (Full Value - Empty Value)) x 100% */
+               di->rem_capacity = ((di->accum_current_uAh - di->empty_uAh) * 100L) /
+                                   (di->full_active_uAh - di->empty_uAh);
 
        if (di->rem_capacity < 0)
                di->rem_capacity = 0;
@@ -254,8 +257,6 @@ static void ds2760_battery_update_status(struct ds2760_device_info *di)
 
        if (di->charge_status != old_charge_status)
                power_supply_changed(&di->bat);
-
-       return;
 }
 
 static void ds2760_battery_work(struct work_struct *work)
@@ -264,12 +265,10 @@ static void ds2760_battery_work(struct work_struct *work)
                struct ds2760_device_info, monitor_work.work);
        const int interval = HZ * 60;
 
-       dev_dbg(di->dev, "%s\n", __FUNCTION__);
+       dev_dbg(di->dev, "%s\n", __func__);
 
        ds2760_battery_update_status(di);
        queue_delayed_work(di->monitor_wqueue, &di->monitor_work, interval);
-
-       return;
 }
 
 #define to_ds2760_device_info(x) container_of((x), struct ds2760_device_info, \
@@ -279,12 +278,10 @@ static void ds2760_battery_external_power_changed(struct power_supply *psy)
 {
        struct ds2760_device_info *di = to_ds2760_device_info(psy);
 
-       dev_dbg(di->dev, "%s\n", __FUNCTION__);
+       dev_dbg(di->dev, "%s\n", __func__);
 
        cancel_delayed_work(&di->monitor_work);
        queue_delayed_work(di->monitor_wqueue, &di->monitor_work, HZ/10);
-
-       return;
 }
 
 static int ds2760_battery_get_property(struct power_supply *psy,
@@ -360,7 +357,7 @@ static int ds2760_battery_probe(struct platform_device *pdev)
        pdata = pdev->dev.platform_data;
        di->dev         = &pdev->dev;
        di->w1_dev           = pdev->dev.parent;
-       di->bat.name       = pdev->dev.bus_id;
+       di->bat.name       = dev_name(&pdev->dev);
        di->bat.type       = POWER_SUPPLY_TYPE_BATTERY;
        di->bat.properties     = ds2760_battery_props;
        di->bat.num_properties = ARRAY_SIZE(ds2760_battery_props);
@@ -372,12 +369,12 @@ static int ds2760_battery_probe(struct platform_device *pdev)
 
        retval = power_supply_register(&pdev->dev, &di->bat);
        if (retval) {
-               dev_err(di->dev, "failed to register battery");
+               dev_err(di->dev, "failed to register battery\n");
                goto batt_failed;
        }
 
        INIT_DELAYED_WORK(&di->monitor_work, ds2760_battery_work);
-       di->monitor_wqueue = create_singlethread_workqueue(pdev->dev.bus_id);
+       di->monitor_wqueue = create_singlethread_workqueue(dev_name(&pdev->dev));
        if (!di->monitor_wqueue) {
                retval = -ESRCH;
                goto workqueue_failed;
@@ -439,6 +436,8 @@ static int ds2760_battery_resume(struct platform_device *pdev)
 
 #endif /* CONFIG_PM */
 
+MODULE_ALIAS("platform:ds2760-battery");
+
 static struct platform_driver ds2760_battery_driver = {
        .driver = {
                .name = "ds2760-battery",
@@ -457,7 +456,6 @@ static int __init ds2760_battery_init(void)
 static void __exit ds2760_battery_exit(void)
 {
        platform_driver_unregister(&ds2760_battery_driver);
-       return;
 }
 
 module_init(ds2760_battery_init);