diff options
Diffstat (limited to 'drivers/power/ds2781_battery.c')
| -rw-r--r-- | drivers/power/ds2781_battery.c | 48 |
1 files changed, 10 insertions, 38 deletions
diff --git a/drivers/power/ds2781_battery.c b/drivers/power/ds2781_battery.c index 975684a40f1..0a5acc6fc6f 100644 --- a/drivers/power/ds2781_battery.c +++ b/drivers/power/ds2781_battery.c @@ -37,7 +37,6 @@ struct ds2781_device_info { struct device *dev; struct power_supply bat; struct device *w1_dev; - struct task_struct *mutex_holder; }; enum current_types { @@ -62,14 +61,10 @@ static inline struct power_supply *to_power_supply(struct device *dev) static inline int ds2781_battery_io(struct ds2781_device_info *dev_info, char *buf, int addr, size_t count, int io) { - if (dev_info->mutex_holder == current) - return w1_ds2781_io_nolock(dev_info->w1_dev, buf, addr, - count, io); - else - return w1_ds2781_io(dev_info->w1_dev, buf, addr, count, io); + return w1_ds2781_io(dev_info->w1_dev, buf, addr, count, io); } -int w1_ds2781_read(struct ds2781_device_info *dev_info, char *buf, +static int w1_ds2781_read(struct ds2781_device_info *dev_info, char *buf, int addr, size_t count) { return ds2781_battery_io(dev_info, buf, addr, count, 0); @@ -755,16 +750,14 @@ static const struct attribute_group ds2781_attr_group = { .attrs = ds2781_attributes, }; -static int __devinit ds2781_battery_probe(struct platform_device *pdev) +static int ds2781_battery_probe(struct platform_device *pdev) { int ret = 0; struct ds2781_device_info *dev_info; - dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL); - if (!dev_info) { - ret = -ENOMEM; - goto fail; - } + dev_info = devm_kzalloc(&pdev->dev, sizeof(*dev_info), GFP_KERNEL); + if (!dev_info) + return -ENOMEM; platform_set_drvdata(pdev, dev_info); @@ -775,12 +768,11 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev) dev_info->bat.properties = ds2781_battery_props; dev_info->bat.num_properties = ARRAY_SIZE(ds2781_battery_props); dev_info->bat.get_property = ds2781_battery_get_property; - dev_info->mutex_holder = current; ret = power_supply_register(&pdev->dev, &dev_info->bat); if (ret) { dev_err(dev_info->dev, "failed to register battery\n"); - goto fail_free_info; + goto fail; } ret = sysfs_create_group(&dev_info->bat.dev->kobj, &ds2781_attr_group); @@ -805,8 +797,6 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev) goto fail_remove_bin_file; } - dev_info->mutex_holder = NULL; - return 0; fail_remove_bin_file: @@ -816,24 +806,19 @@ fail_remove_group: sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2781_attr_group); fail_unregister: power_supply_unregister(&dev_info->bat); -fail_free_info: - kfree(dev_info); fail: return ret; } -static int __devexit ds2781_battery_remove(struct platform_device *pdev) +static int ds2781_battery_remove(struct platform_device *pdev) { struct ds2781_device_info *dev_info = platform_get_drvdata(pdev); - dev_info->mutex_holder = current; - /* remove attributes */ sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2781_attr_group); power_supply_unregister(&dev_info->bat); - kfree(dev_info); return 0; } @@ -842,22 +827,9 @@ static struct platform_driver ds2781_battery_driver = { .name = "ds2781-battery", }, .probe = ds2781_battery_probe, - .remove = __devexit_p(ds2781_battery_remove), + .remove = ds2781_battery_remove, }; - -static int __init ds2781_battery_init(void) -{ - return platform_driver_register(&ds2781_battery_driver); -} - -static void __exit ds2781_battery_exit(void) -{ - platform_driver_unregister(&ds2781_battery_driver); -} - -module_init(ds2781_battery_init); -module_exit(ds2781_battery_exit); - +module_platform_driver(ds2781_battery_driver); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Renata Sayakhova <renata@oktetlabs.ru>"); |
