Merge branch 'topic/ioctl-use-define' into for-linus
[sfrench/cifs-2.6.git] / drivers / power / ds2760_battery.c
index 308ddb201b660da9d84e21279eef011eb87907af..a52d4a11652d57aa7b045fa225777fdaecb252f2 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;
@@ -354,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);
@@ -371,7 +374,7 @@ static int ds2760_battery_probe(struct platform_device *pdev)
        }
 
        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;