* [PATCH v2 3/3] w1: ds2780, fix deadlock upon insertion and removal
@ 2011-08-24 14:35 Clifton Barnes
2011-08-24 18:47 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Clifton Barnes @ 2011-08-24 14:35 UTC (permalink / raw)
To: akpm; +Cc: ryan, haojian.zhuang, johnpol, simon.inizan, linux-kernel
Fixes the deadlock when inserting and removing the ds2780.
Signed-off-by: Clifton Barnes <cabarnes@indesign-llc.com>
---
drivers/power/ds2780_battery.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/drivers/power/ds2780_battery.c b/drivers/power/ds2780_battery.c
index 2571b41..91a783d 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);
--
1.7.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 3/3] w1: ds2780, fix deadlock upon insertion and removal
2011-08-24 14:35 [PATCH v2 3/3] w1: ds2780, fix deadlock upon insertion and removal Clifton Barnes
@ 2011-08-24 18:47 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2011-08-24 18:47 UTC (permalink / raw)
To: Clifton Barnes; +Cc: ryan, haojian.zhuang, johnpol, simon.inizan, linux-kernel
On Wed, 24 Aug 2011 10:35:33 -0400
Clifton Barnes <cabarnes@indesign-llc.com> wrote:
> Fixes the deadlock when inserting and removing the ds2780.
When fixing a bug, please always provide a full description of that bug
so that others can review the proposed fix. "the deadlock" is not a
complete description ;)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-08-24 18:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-24 14:35 [PATCH v2 3/3] w1: ds2780, fix deadlock upon insertion and removal Clifton Barnes
2011-08-24 18:47 ` Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.