summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorClifton Barnes <cabarnes@indesign-llc.com>2011-11-02 13:39:55 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2011-11-11 09:43:49 -0800
commit7414af4ea686db48b0985a5d26a6639bbad271ea (patch)
tree18b694bfcdc3e1e0f04593f9deb90ee55c6f4985 /drivers/power
parent1b4e7370d4b6591f64e12f8f35bc219996c509f6 (diff)
drivers/power/ds2780_battery.c: fix deadlock upon insertion and removal
commit 0e053fcbbbc4d945247cb32cad2767b483cb65f8 upstream. Fixes the deadlock when inserting and removing the ds2780. Signed-off-by: Clifton Barnes <cabarnes@indesign-llc.com> Cc: Evgeniy Polyakov <zbr@ioremap.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/ds2780_battery.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/power/ds2780_battery.c b/drivers/power/ds2780_battery.c
index 2571b4143784..91a783d72360 100644
--- a/drivers/power/ds2780_battery.c
+++ b/drivers/power/ds2780_battery.c
@@ -39,6 +39,7 @@ struct ds2780_device_info {
struct device *dev;
struct power_supply bat;
struct device *w1_dev;
+ struct task_struct *mutex_holder;
};
enum current_types {
@@ -63,6 +64,9 @@ static inline struct power_supply *to_power_supply(struct device *dev)
static inline int ds2780_battery_io(struct ds2780_device_info *dev_info,
char *buf, int addr, size_t count, int io)
{
+ if (dev_info->mutex_holder == current)
+ return w1_ds2780_io_nolock(dev_info->w1_dev, buf, addr, count, io);
+ else
return w1_ds2780_io(dev_info->w1_dev, buf, addr, count, io);
}
@@ -775,6 +779,7 @@ static int __devinit ds2780_battery_probe(struct platform_device *pdev)
dev_info->bat.properties = ds2780_battery_props;
dev_info->bat.num_properties = ARRAY_SIZE(ds2780_battery_props);
dev_info->bat.get_property = ds2780_battery_get_property;
+ dev_info->mutex_holder = current;
ret = power_supply_register(&pdev->dev, &dev_info->bat);
if (ret) {
@@ -804,6 +809,8 @@ static int __devinit ds2780_battery_probe(struct platform_device *pdev)
goto fail_remove_bin_file;
}
+ dev_info->mutex_holder = NULL;
+
return 0;
fail_remove_bin_file:
@@ -823,6 +830,8 @@ static int __devexit ds2780_battery_remove(struct platform_device *pdev)
{
struct ds2780_device_info *dev_info = platform_get_drvdata(pdev);
+ dev_info->mutex_holder = current;
+
/* remove attributes */
sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2780_attr_group);