Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 273272
b: refs/heads/master
c: 0e053fc
h: refs/heads/master
v: v3
  • Loading branch information
Clifton Barnes authored and Linus Torvalds committed Nov 2, 2011
1 parent 916c179 commit 28953ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9fe678fa2feb4aaac0b4220de63e1b7f8ccebae6
refs/heads/master: 0e053fcbbbc4d945247cb32cad2767b483cb65f8
9 changes: 9 additions & 0 deletions trunk/drivers/power/ds2780_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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:
Expand All @@ -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);

Expand Down

0 comments on commit 28953ad

Please sign in to comment.