aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/power/ds2780_battery.c11
-rw-r--r--drivers/power/ds2781_battery.c12
-rw-r--r--drivers/w1/masters/ds1wm.c4
-rw-r--r--drivers/w1/slaves/w1_bq27000.c4
-rw-r--r--drivers/w1/slaves/w1_ds2408.c24
-rw-r--r--drivers/w1/slaves/w1_ds2423.c4
-rw-r--r--drivers/w1/slaves/w1_ds2431.c8
-rw-r--r--drivers/w1/slaves/w1_ds2433.c8
-rw-r--r--drivers/w1/slaves/w1_ds2760.c8
-rw-r--r--drivers/w1/slaves/w1_ds2780.c22
-rw-r--r--drivers/w1/slaves/w1_ds2780.h2
-rw-r--r--drivers/w1/slaves/w1_ds2781.c22
-rw-r--r--drivers/w1/slaves/w1_ds2781.h2
-rw-r--r--drivers/w1/slaves/w1_therm.c10
-rw-r--r--drivers/w1/w1.c9
-rw-r--r--drivers/w1/w1.h1
-rw-r--r--drivers/w1/w1_int.c1
17 files changed, 57 insertions, 95 deletions
diff --git a/drivers/power/ds2780_battery.c b/drivers/power/ds2780_battery.c
index de31cae1ba53..74fad941c56c 100644
--- a/drivers/power/ds2780_battery.c
+++ b/drivers/power/ds2780_battery.c
@@ -39,7 +39,6 @@ struct ds2780_device_info {
39 struct device *dev; 39 struct device *dev;
40 struct power_supply bat; 40 struct power_supply bat;
41 struct device *w1_dev; 41 struct device *w1_dev;
42 struct task_struct *mutex_holder;
43}; 42};
44 43
45enum current_types { 44enum current_types {
@@ -64,10 +63,7 @@ static inline struct power_supply *to_power_supply(struct device *dev)
64static inline int ds2780_battery_io(struct ds2780_device_info *dev_info, 63static inline int ds2780_battery_io(struct ds2780_device_info *dev_info,
65 char *buf, int addr, size_t count, int io) 64 char *buf, int addr, size_t count, int io)
66{ 65{
67 if (dev_info->mutex_holder == current) 66 return w1_ds2780_io(dev_info->w1_dev, buf, addr, count, io);
68 return w1_ds2780_io_nolock(dev_info->w1_dev, buf, addr, count, io);
69 else
70 return w1_ds2780_io(dev_info->w1_dev, buf, addr, count, io);
71} 67}
72 68
73static inline int ds2780_read8(struct ds2780_device_info *dev_info, u8 *val, 69static inline int ds2780_read8(struct ds2780_device_info *dev_info, u8 *val,
@@ -779,7 +775,6 @@ static int __devinit ds2780_battery_probe(struct platform_device *pdev)
779 dev_info->bat.properties = ds2780_battery_props; 775 dev_info->bat.properties = ds2780_battery_props;
780 dev_info->bat.num_properties = ARRAY_SIZE(ds2780_battery_props); 776 dev_info->bat.num_properties = ARRAY_SIZE(ds2780_battery_props);
781 dev_info->bat.get_property = ds2780_battery_get_property; 777 dev_info->bat.get_property = ds2780_battery_get_property;
782 dev_info->mutex_holder = current;
783 778
784 ret = power_supply_register(&pdev->dev, &dev_info->bat); 779 ret = power_supply_register(&pdev->dev, &dev_info->bat);
785 if (ret) { 780 if (ret) {
@@ -809,8 +804,6 @@ static int __devinit ds2780_battery_probe(struct platform_device *pdev)
809 goto fail_remove_bin_file; 804 goto fail_remove_bin_file;
810 } 805 }
811 806
812 dev_info->mutex_holder = NULL;
813
814 return 0; 807 return 0;
815 808
816fail_remove_bin_file: 809fail_remove_bin_file:
@@ -830,8 +823,6 @@ static int __devexit ds2780_battery_remove(struct platform_device *pdev)
830{ 823{
831 struct ds2780_device_info *dev_info = platform_get_drvdata(pdev); 824 struct ds2780_device_info *dev_info = platform_get_drvdata(pdev);
832 825
833 dev_info->mutex_holder = current;
834
835 /* remove attributes */ 826 /* remove attributes */
836 sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2780_attr_group); 827 sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2780_attr_group);
837 828
diff --git a/drivers/power/ds2781_battery.c b/drivers/power/ds2781_battery.c
index 975684a40f15..5f92a4bb33f9 100644
--- a/drivers/power/ds2781_battery.c
+++ b/drivers/power/ds2781_battery.c
@@ -37,7 +37,6 @@ struct ds2781_device_info {
37 struct device *dev; 37 struct device *dev;
38 struct power_supply bat; 38 struct power_supply bat;
39 struct device *w1_dev; 39 struct device *w1_dev;
40 struct task_struct *mutex_holder;
41}; 40};
42 41
43enum current_types { 42enum current_types {
@@ -62,11 +61,7 @@ static inline struct power_supply *to_power_supply(struct device *dev)
62static inline int ds2781_battery_io(struct ds2781_device_info *dev_info, 61static inline int ds2781_battery_io(struct ds2781_device_info *dev_info,
63 char *buf, int addr, size_t count, int io) 62 char *buf, int addr, size_t count, int io)
64{ 63{
65 if (dev_info->mutex_holder == current) 64 return w1_ds2781_io(dev_info->w1_dev, buf, addr, count, io);
66 return w1_ds2781_io_nolock(dev_info->w1_dev, buf, addr,
67 count, io);
68 else
69 return w1_ds2781_io(dev_info->w1_dev, buf, addr, count, io);
70} 65}
71 66
72int w1_ds2781_read(struct ds2781_device_info *dev_info, char *buf, 67int w1_ds2781_read(struct ds2781_device_info *dev_info, char *buf,
@@ -775,7 +770,6 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev)
775 dev_info->bat.properties = ds2781_battery_props; 770 dev_info->bat.properties = ds2781_battery_props;
776 dev_info->bat.num_properties = ARRAY_SIZE(ds2781_battery_props); 771 dev_info->bat.num_properties = ARRAY_SIZE(ds2781_battery_props);
777 dev_info->bat.get_property = ds2781_battery_get_property; 772 dev_info->bat.get_property = ds2781_battery_get_property;
778 dev_info->mutex_holder = current;
779 773
780 ret = power_supply_register(&pdev->dev, &dev_info->bat); 774 ret = power_supply_register(&pdev->dev, &dev_info->bat);
781 if (ret) { 775 if (ret) {
@@ -805,8 +799,6 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev)
805 goto fail_remove_bin_file; 799 goto fail_remove_bin_file;
806 } 800 }
807 801
808 dev_info->mutex_holder = NULL;
809
810 return 0; 802 return 0;
811 803
812fail_remove_bin_file: 804fail_remove_bin_file:
@@ -826,8 +818,6 @@ static int __devexit ds2781_battery_remove(struct platform_device *pdev)
826{ 818{
827 struct ds2781_device_info *dev_info = platform_get_drvdata(pdev); 819 struct ds2781_device_info *dev_info = platform_get_drvdata(pdev);
828 820
829 dev_info->mutex_holder = current;
830
831 /* remove attributes */ 821 /* remove attributes */
832 sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2781_attr_group); 822 sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2781_attr_group);
833 823
diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c
index a0c8965c1a79..530a2d309063 100644
--- a/drivers/w1/masters/ds1wm.c
+++ b/drivers/w1/masters/ds1wm.c
@@ -334,7 +334,9 @@ static void ds1wm_search(void *data, struct w1_master *master_dev,
334 return; 334 return;
335 } 335 }
336 336
337 mutex_lock(&master_dev->bus_mutex);
337 if (ds1wm_reset(ds1wm_data)) { 338 if (ds1wm_reset(ds1wm_data)) {
339 mutex_unlock(&master_dev->bus_mutex);
338 dev_dbg(&ds1wm_data->pdev->dev, 340 dev_dbg(&ds1wm_data->pdev->dev,
339 "pass: %d reset error (or no slaves)\n", pass); 341 "pass: %d reset error (or no slaves)\n", pass);
340 break; 342 break;
@@ -387,6 +389,7 @@ static void ds1wm_search(void *data, struct w1_master *master_dev,
387 389
388 } 390 }
389 if (ds1wm_data->read_error) { 391 if (ds1wm_data->read_error) {
392 mutex_unlock(&master_dev->bus_mutex);
390 dev_err(&ds1wm_data->pdev->dev, 393 dev_err(&ds1wm_data->pdev->dev,
391 "pass: %d read error, retrying\n", pass); 394 "pass: %d read error, retrying\n", pass);
392 break; 395 break;
@@ -400,6 +403,7 @@ static void ds1wm_search(void *data, struct w1_master *master_dev,
400 dev_dbg(&ds1wm_data->pdev->dev, 403 dev_dbg(&ds1wm_data->pdev->dev,
401 "pass: %d resetting bus\n", pass); 404 "pass: %d resetting bus\n", pass);
402 ds1wm_reset(ds1wm_data); 405 ds1wm_reset(ds1wm_data);
406 mutex_unlock(&master_dev->bus_mutex);
403 if ((r_prime & ((u64)1 << 63)) && (d & ((u64)1 << 63))) { 407 if ((r_prime & ((u64)1 << 63)) && (d & ((u64)1 << 63))) {
404 dev_err(&ds1wm_data->pdev->dev, 408 dev_err(&ds1wm_data->pdev->dev,
405 "pass: %d bus error, retrying\n", pass); 409 "pass: %d bus error, retrying\n", pass);
diff --git a/drivers/w1/slaves/w1_bq27000.c b/drivers/w1/slaves/w1_bq27000.c
index 52ad812fa1e7..773dca5beafe 100644
--- a/drivers/w1/slaves/w1_bq27000.c
+++ b/drivers/w1/slaves/w1_bq27000.c
@@ -31,10 +31,10 @@ static int w1_bq27000_read(struct device *dev, unsigned int reg)
31 u8 val; 31 u8 val;
32 struct w1_slave *sl = container_of(dev->parent, struct w1_slave, dev); 32 struct w1_slave *sl = container_of(dev->parent, struct w1_slave, dev);
33 33
34 mutex_lock(&sl->master->mutex); 34 mutex_lock(&sl->master->bus_mutex);
35 w1_write_8(sl->master, HDQ_CMD_READ | reg); 35 w1_write_8(sl->master, HDQ_CMD_READ | reg);
36 val = w1_read_8(sl->master); 36 val = w1_read_8(sl->master);
37 mutex_unlock(&sl->master->mutex); 37 mutex_unlock(&sl->master->bus_mutex);
38 38
39 return val; 39 return val;
40} 40}
diff --git a/drivers/w1/slaves/w1_ds2408.c b/drivers/w1/slaves/w1_ds2408.c
index 8e813eed0f0a..441ad3a3b586 100644
--- a/drivers/w1/slaves/w1_ds2408.c
+++ b/drivers/w1/slaves/w1_ds2408.c
@@ -52,11 +52,11 @@ static int _read_reg(struct w1_slave *sl, u8 address, unsigned char* buf)
52 if (!buf) 52 if (!buf)
53 return -EINVAL; 53 return -EINVAL;
54 54
55 mutex_lock(&sl->master->mutex); 55 mutex_lock(&sl->master->bus_mutex);
56 dev_dbg(&sl->dev, "mutex locked"); 56 dev_dbg(&sl->dev, "mutex locked");
57 57
58 if (w1_reset_select_slave(sl)) { 58 if (w1_reset_select_slave(sl)) {
59 mutex_unlock(&sl->master->mutex); 59 mutex_unlock(&sl->master->bus_mutex);
60 return -EIO; 60 return -EIO;
61 } 61 }
62 62
@@ -66,7 +66,7 @@ static int _read_reg(struct w1_slave *sl, u8 address, unsigned char* buf)
66 w1_write_block(sl->master, wrbuf, 3); 66 w1_write_block(sl->master, wrbuf, 3);
67 *buf = w1_read_8(sl->master); 67 *buf = w1_read_8(sl->master);
68 68
69 mutex_unlock(&sl->master->mutex); 69 mutex_unlock(&sl->master->bus_mutex);
70 dev_dbg(&sl->dev, "mutex unlocked"); 70 dev_dbg(&sl->dev, "mutex unlocked");
71 return 1; 71 return 1;
72} 72}
@@ -165,7 +165,7 @@ static ssize_t w1_f29_write_output(
165 return -EFAULT; 165 return -EFAULT;
166 166
167 dev_dbg(&sl->dev, "locking mutex for write_output"); 167 dev_dbg(&sl->dev, "locking mutex for write_output");
168 mutex_lock(&sl->master->mutex); 168 mutex_lock(&sl->master->bus_mutex);
169 dev_dbg(&sl->dev, "mutex locked"); 169 dev_dbg(&sl->dev, "mutex locked");
170 170
171 if (w1_reset_select_slave(sl)) 171 if (w1_reset_select_slave(sl))
@@ -200,14 +200,14 @@ static ssize_t w1_f29_write_output(
200 /* read the result of the READ_PIO_REGS command */ 200 /* read the result of the READ_PIO_REGS command */
201 if (w1_read_8(sl->master) == *buf) { 201 if (w1_read_8(sl->master) == *buf) {
202 /* success! */ 202 /* success! */
203 mutex_unlock(&sl->master->mutex); 203 mutex_unlock(&sl->master->bus_mutex);
204 dev_dbg(&sl->dev, 204 dev_dbg(&sl->dev,
205 "mutex unlocked, retries:%d", retries); 205 "mutex unlocked, retries:%d", retries);
206 return 1; 206 return 1;
207 } 207 }
208 } 208 }
209error: 209error:
210 mutex_unlock(&sl->master->mutex); 210 mutex_unlock(&sl->master->bus_mutex);
211 dev_dbg(&sl->dev, "mutex unlocked in error, retries:%d", retries); 211 dev_dbg(&sl->dev, "mutex unlocked in error, retries:%d", retries);
212 212
213 return -EIO; 213 return -EIO;
@@ -228,7 +228,7 @@ static ssize_t w1_f29_write_activity(
228 if (count != 1 || off != 0) 228 if (count != 1 || off != 0)
229 return -EFAULT; 229 return -EFAULT;
230 230
231 mutex_lock(&sl->master->mutex); 231 mutex_lock(&sl->master->bus_mutex);
232 232
233 if (w1_reset_select_slave(sl)) 233 if (w1_reset_select_slave(sl))
234 goto error; 234 goto error;
@@ -236,7 +236,7 @@ static ssize_t w1_f29_write_activity(
236 while (retries--) { 236 while (retries--) {
237 w1_write_8(sl->master, W1_F29_FUNC_RESET_ACTIVITY_LATCHES); 237 w1_write_8(sl->master, W1_F29_FUNC_RESET_ACTIVITY_LATCHES);
238 if (w1_read_8(sl->master) == W1_F29_SUCCESS_CONFIRM_BYTE) { 238 if (w1_read_8(sl->master) == W1_F29_SUCCESS_CONFIRM_BYTE) {
239 mutex_unlock(&sl->master->mutex); 239 mutex_unlock(&sl->master->bus_mutex);
240 return 1; 240 return 1;
241 } 241 }
242 if (w1_reset_resume_command(sl->master)) 242 if (w1_reset_resume_command(sl->master))
@@ -244,7 +244,7 @@ static ssize_t w1_f29_write_activity(
244 } 244 }
245 245
246error: 246error:
247 mutex_unlock(&sl->master->mutex); 247 mutex_unlock(&sl->master->bus_mutex);
248 return -EIO; 248 return -EIO;
249} 249}
250 250
@@ -263,7 +263,7 @@ static ssize_t w1_f29_write_status_control(
263 if (count != 1 || off != 0) 263 if (count != 1 || off != 0)
264 return -EFAULT; 264 return -EFAULT;
265 265
266 mutex_lock(&sl->master->mutex); 266 mutex_lock(&sl->master->bus_mutex);
267 267
268 if (w1_reset_select_slave(sl)) 268 if (w1_reset_select_slave(sl))
269 goto error; 269 goto error;
@@ -285,12 +285,12 @@ static ssize_t w1_f29_write_status_control(
285 w1_write_block(sl->master, w1_buf, 3); 285 w1_write_block(sl->master, w1_buf, 3);
286 if (w1_read_8(sl->master) == *buf) { 286 if (w1_read_8(sl->master) == *buf) {
287 /* success! */ 287 /* success! */
288 mutex_unlock(&sl->master->mutex); 288 mutex_unlock(&sl->master->bus_mutex);
289 return 1; 289 return 1;
290 } 290 }
291 } 291 }
292error: 292error:
293 mutex_unlock(&sl->master->mutex); 293 mutex_unlock(&sl->master->bus_mutex);
294 294
295 return -EIO; 295 return -EIO;
296} 296}
diff --git a/drivers/w1/slaves/w1_ds2423.c b/drivers/w1/slaves/w1_ds2423.c
index 7a7dbe5026f1..40a10b5ed120 100644
--- a/drivers/w1/slaves/w1_ds2423.c
+++ b/drivers/w1/slaves/w1_ds2423.c
@@ -66,7 +66,7 @@ static ssize_t w1_counter_read(struct device *device,
66 wrbuf[0] = 0xA5; 66 wrbuf[0] = 0xA5;
67 wrbuf[1] = rom_addr & 0xFF; 67 wrbuf[1] = rom_addr & 0xFF;
68 wrbuf[2] = rom_addr >> 8; 68 wrbuf[2] = rom_addr >> 8;
69 mutex_lock(&dev->mutex); 69 mutex_lock(&dev->bus_mutex);
70 if (!w1_reset_select_slave(sl)) { 70 if (!w1_reset_select_slave(sl)) {
71 w1_write_block(dev, wrbuf, 3); 71 w1_write_block(dev, wrbuf, 3);
72 read_byte_count = 0; 72 read_byte_count = 0;
@@ -124,7 +124,7 @@ static ssize_t w1_counter_read(struct device *device,
124 } else { 124 } else {
125 c -= snprintf(out_buf + PAGE_SIZE - c, c, "Connection error"); 125 c -= snprintf(out_buf + PAGE_SIZE - c, c, "Connection error");
126 } 126 }
127 mutex_unlock(&dev->mutex); 127 mutex_unlock(&dev->bus_mutex);
128 return PAGE_SIZE - c; 128 return PAGE_SIZE - c;
129} 129}
130 130
diff --git a/drivers/w1/slaves/w1_ds2431.c b/drivers/w1/slaves/w1_ds2431.c
index 84e2410aec1d..984b30331a45 100644
--- a/drivers/w1/slaves/w1_ds2431.c
+++ b/drivers/w1/slaves/w1_ds2431.c
@@ -107,7 +107,7 @@ static ssize_t w1_f2d_read_bin(struct file *filp, struct kobject *kobj,
107 if (count == 0) 107 if (count == 0)
108 return 0; 108 return 0;
109 109
110 mutex_lock(&sl->master->mutex); 110 mutex_lock(&sl->master->bus_mutex);
111 111
112 /* read directly from the EEPROM in chunks of W1_F2D_READ_MAXLEN */ 112 /* read directly from the EEPROM in chunks of W1_F2D_READ_MAXLEN */
113 while (todo > 0) { 113 while (todo > 0) {
@@ -126,7 +126,7 @@ static ssize_t w1_f2d_read_bin(struct file *filp, struct kobject *kobj,
126 off += W1_F2D_READ_MAXLEN; 126 off += W1_F2D_READ_MAXLEN;
127 } 127 }
128 128
129 mutex_unlock(&sl->master->mutex); 129 mutex_unlock(&sl->master->bus_mutex);
130 130
131 return count; 131 return count;
132} 132}
@@ -214,7 +214,7 @@ static ssize_t w1_f2d_write_bin(struct file *filp, struct kobject *kobj,
214 if (count == 0) 214 if (count == 0)
215 return 0; 215 return 0;
216 216
217 mutex_lock(&sl->master->mutex); 217 mutex_lock(&sl->master->bus_mutex);
218 218
219 /* Can only write data in blocks of the size of the scratchpad */ 219 /* Can only write data in blocks of the size of the scratchpad */
220 addr = off; 220 addr = off;
@@ -259,7 +259,7 @@ static ssize_t w1_f2d_write_bin(struct file *filp, struct kobject *kobj,
259 } 259 }
260 260
261out_up: 261out_up:
262 mutex_unlock(&sl->master->mutex); 262 mutex_unlock(&sl->master->bus_mutex);
263 263
264 return count; 264 return count;
265} 265}
diff --git a/drivers/w1/slaves/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c
index 0f7b8f9c509a..85f2cdb27fa2 100644
--- a/drivers/w1/slaves/w1_ds2433.c
+++ b/drivers/w1/slaves/w1_ds2433.c
@@ -107,7 +107,7 @@ static ssize_t w1_f23_read_bin(struct file *filp, struct kobject *kobj,
107 if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0) 107 if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0)
108 return 0; 108 return 0;
109 109
110 mutex_lock(&sl->master->mutex); 110 mutex_lock(&sl->master->bus_mutex);
111 111
112#ifdef CONFIG_W1_SLAVE_DS2433_CRC 112#ifdef CONFIG_W1_SLAVE_DS2433_CRC
113 113
@@ -138,7 +138,7 @@ static ssize_t w1_f23_read_bin(struct file *filp, struct kobject *kobj,
138#endif /* CONFIG_W1_SLAVE_DS2433_CRC */ 138#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
139 139
140out_up: 140out_up:
141 mutex_unlock(&sl->master->mutex); 141 mutex_unlock(&sl->master->bus_mutex);
142 142
143 return count; 143 return count;
144} 144}
@@ -233,7 +233,7 @@ static ssize_t w1_f23_write_bin(struct file *filp, struct kobject *kobj,
233 } 233 }
234#endif /* CONFIG_W1_SLAVE_DS2433_CRC */ 234#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
235 235
236 mutex_lock(&sl->master->mutex); 236 mutex_lock(&sl->master->bus_mutex);
237 237
238 /* Can only write data to one page at a time */ 238 /* Can only write data to one page at a time */
239 idx = 0; 239 idx = 0;
@@ -251,7 +251,7 @@ static ssize_t w1_f23_write_bin(struct file *filp, struct kobject *kobj,
251 } 251 }
252 252
253out_up: 253out_up:
254 mutex_unlock(&sl->master->mutex); 254 mutex_unlock(&sl->master->bus_mutex);
255 255
256 return count; 256 return count;
257} 257}
diff --git a/drivers/w1/slaves/w1_ds2760.c b/drivers/w1/slaves/w1_ds2760.c
index 5754c9a4f58b..aa7bd5fa2fa8 100644
--- a/drivers/w1/slaves/w1_ds2760.c
+++ b/drivers/w1/slaves/w1_ds2760.c
@@ -31,7 +31,7 @@ static int w1_ds2760_io(struct device *dev, char *buf, int addr, size_t count,
31 if (!dev) 31 if (!dev)
32 return 0; 32 return 0;
33 33
34 mutex_lock(&sl->master->mutex); 34 mutex_lock(&sl->master->bus_mutex);
35 35
36 if (addr > DS2760_DATA_SIZE || addr < 0) { 36 if (addr > DS2760_DATA_SIZE || addr < 0) {
37 count = 0; 37 count = 0;
@@ -54,7 +54,7 @@ static int w1_ds2760_io(struct device *dev, char *buf, int addr, size_t count,
54 } 54 }
55 55
56out: 56out:
57 mutex_unlock(&sl->master->mutex); 57 mutex_unlock(&sl->master->bus_mutex);
58 58
59 return count; 59 return count;
60} 60}
@@ -76,14 +76,14 @@ static int w1_ds2760_eeprom_cmd(struct device *dev, int addr, int cmd)
76 if (!dev) 76 if (!dev)
77 return -EINVAL; 77 return -EINVAL;
78 78
79 mutex_lock(&sl->master->mutex); 79 mutex_lock(&sl->master->bus_mutex);
80 80
81 if (w1_reset_select_slave(sl) == 0) { 81 if (w1_reset_select_slave(sl) == 0) {
82 w1_write_8(sl->master, cmd); 82 w1_write_8(sl->master, cmd);
83 w1_write_8(sl->master, addr); 83 w1_write_8(sl->master, addr);
84 } 84 }
85 85
86 mutex_unlock(&sl->master->mutex); 86 mutex_unlock(&sl->master->bus_mutex);
87 return 0; 87 return 0;
88} 88}
89 89
diff --git a/drivers/w1/slaves/w1_ds2780.c b/drivers/w1/slaves/w1_ds2780.c
index 39f78c0b143c..7b09307de0ef 100644
--- a/drivers/w1/slaves/w1_ds2780.c
+++ b/drivers/w1/slaves/w1_ds2780.c
@@ -60,30 +60,16 @@ int w1_ds2780_io(struct device *dev, char *buf, int addr, size_t count,
60 if (!dev) 60 if (!dev)
61 return -ENODEV; 61 return -ENODEV;
62 62
63 mutex_lock(&sl->master->mutex); 63 mutex_lock(&sl->master->bus_mutex);
64 64
65 ret = w1_ds2780_do_io(dev, buf, addr, count, io); 65 ret = w1_ds2780_do_io(dev, buf, addr, count, io);
66 66
67 mutex_unlock(&sl->master->mutex); 67 mutex_unlock(&sl->master->bus_mutex);
68 68
69 return ret; 69 return ret;
70} 70}
71EXPORT_SYMBOL(w1_ds2780_io); 71EXPORT_SYMBOL(w1_ds2780_io);
72 72
73int w1_ds2780_io_nolock(struct device *dev, char *buf, int addr, size_t count,
74 int io)
75{
76 int ret;
77
78 if (!dev)
79 return -ENODEV;
80
81 ret = w1_ds2780_do_io(dev, buf, addr, count, io);
82
83 return ret;
84}
85EXPORT_SYMBOL(w1_ds2780_io_nolock);
86
87int w1_ds2780_eeprom_cmd(struct device *dev, int addr, int cmd) 73int w1_ds2780_eeprom_cmd(struct device *dev, int addr, int cmd)
88{ 74{
89 struct w1_slave *sl = container_of(dev, struct w1_slave, dev); 75 struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
@@ -91,14 +77,14 @@ int w1_ds2780_eeprom_cmd(struct device *dev, int addr, int cmd)
91 if (!dev) 77 if (!dev)
92 return -EINVAL; 78 return -EINVAL;
93 79
94 mutex_lock(&sl->master->mutex); 80 mutex_lock(&sl->master->bus_mutex);
95 81
96 if (w1_reset_select_slave(sl) == 0) { 82 if (w1_reset_select_slave(sl) == 0) {
97 w1_write_8(sl->master, cmd); 83 w1_write_8(sl->master, cmd);
98 w1_write_8(sl->master, addr); 84 w1_write_8(sl->master, addr);
99 } 85 }
100 86
101 mutex_unlock(&sl->master->mutex); 87 mutex_unlock(&sl->master->bus_mutex);
102 return 0; 88 return 0;
103} 89}
104EXPORT_SYMBOL(w1_ds2780_eeprom_cmd); 90EXPORT_SYMBOL(w1_ds2780_eeprom_cmd);
diff --git a/drivers/w1/slaves/w1_ds2780.h b/drivers/w1/slaves/w1_ds2780.h
index 737379365021..a1fba79eb1b5 100644
--- a/drivers/w1/slaves/w1_ds2780.h
+++ b/drivers/w1/slaves/w1_ds2780.h
@@ -124,8 +124,6 @@
124 124
125extern int w1_ds2780_io(struct device *dev, char *buf, int addr, size_t count, 125extern int w1_ds2780_io(struct device *dev, char *buf, int addr, size_t count,
126 int io); 126 int io);
127extern int w1_ds2780_io_nolock(struct device *dev, char *buf, int addr,
128 size_t count, int io);
129extern int w1_ds2780_eeprom_cmd(struct device *dev, int addr, int cmd); 127extern int w1_ds2780_eeprom_cmd(struct device *dev, int addr, int cmd);
130 128
131#endif /* !_W1_DS2780_H */ 129#endif /* !_W1_DS2780_H */
diff --git a/drivers/w1/slaves/w1_ds2781.c b/drivers/w1/slaves/w1_ds2781.c
index 0d0c7985293f..877daf74159c 100644
--- a/drivers/w1/slaves/w1_ds2781.c
+++ b/drivers/w1/slaves/w1_ds2781.c
@@ -58,30 +58,16 @@ int w1_ds2781_io(struct device *dev, char *buf, int addr, size_t count,
58 if (!dev) 58 if (!dev)
59 return -ENODEV; 59 return -ENODEV;
60 60
61 mutex_lock(&sl->master->mutex); 61 mutex_lock(&sl->master->bus_mutex);
62 62
63 ret = w1_ds2781_do_io(dev, buf, addr, count, io); 63 ret = w1_ds2781_do_io(dev, buf, addr, count, io);
64 64
65 mutex_unlock(&sl->master->mutex); 65 mutex_unlock(&sl->master->bus_mutex);
66 66
67 return ret; 67 return ret;
68} 68}
69EXPORT_SYMBOL(w1_ds2781_io); 69EXPORT_SYMBOL(w1_ds2781_io);
70 70
71int w1_ds2781_io_nolock(struct device *dev, char *buf, int addr, size_t count,
72 int io)
73{
74 int ret;
75
76 if (!dev)
77 return -ENODEV;
78
79 ret = w1_ds2781_do_io(dev, buf, addr, count, io);
80
81 return ret;
82}
83EXPORT_SYMBOL(w1_ds2781_io_nolock);
84
85int w1_ds2781_eeprom_cmd(struct device *dev, int addr, int cmd) 71int w1_ds2781_eeprom_cmd(struct device *dev, int addr, int cmd)
86{ 72{
87 struct w1_slave *sl = container_of(dev, struct w1_slave, dev); 73 struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
@@ -89,14 +75,14 @@ int w1_ds2781_eeprom_cmd(struct device *dev, int addr, int cmd)
89 if (!dev) 75 if (!dev)
90 return -EINVAL; 76 return -EINVAL;
91 77
92 mutex_lock(&sl->master->mutex); 78 mutex_lock(&sl->master->bus_mutex);
93 79
94 if (w1_reset_select_slave(sl) == 0) { 80 if (w1_reset_select_slave(sl) == 0) {
95 w1_write_8(sl->master, cmd); 81 w1_write_8(sl->master, cmd);
96 w1_write_8(sl->master, addr); 82 w1_write_8(sl->master, addr);
97 } 83 }
98 84
99 mutex_unlock(&sl->master->mutex); 85 mutex_unlock(&sl->master->bus_mutex);
100 return 0; 86 return 0;
101} 87}
102EXPORT_SYMBOL(w1_ds2781_eeprom_cmd); 88EXPORT_SYMBOL(w1_ds2781_eeprom_cmd);
diff --git a/drivers/w1/slaves/w1_ds2781.h b/drivers/w1/slaves/w1_ds2781.h
index 82bc66497b43..557dfb0b4f64 100644
--- a/drivers/w1/slaves/w1_ds2781.h
+++ b/drivers/w1/slaves/w1_ds2781.h
@@ -129,8 +129,6 @@
129 129
130extern int w1_ds2781_io(struct device *dev, char *buf, int addr, size_t count, 130extern int w1_ds2781_io(struct device *dev, char *buf, int addr, size_t count,
131 int io); 131 int io);
132extern int w1_ds2781_io_nolock(struct device *dev, char *buf, int addr,
133 size_t count, int io);
134extern int w1_ds2781_eeprom_cmd(struct device *dev, int addr, int cmd); 132extern int w1_ds2781_eeprom_cmd(struct device *dev, int addr, int cmd);
135 133
136#endif /* !_W1_DS2781_H */ 134#endif /* !_W1_DS2781_H */
diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index ff29ae747ee8..d90062b211f8 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -179,7 +179,7 @@ static ssize_t w1_therm_read(struct device *device,
179 int i, max_trying = 10; 179 int i, max_trying = 10;
180 ssize_t c = PAGE_SIZE; 180 ssize_t c = PAGE_SIZE;
181 181
182 i = mutex_lock_interruptible(&dev->mutex); 182 i = mutex_lock_interruptible(&dev->bus_mutex);
183 if (i != 0) 183 if (i != 0)
184 return i; 184 return i;
185 185
@@ -207,19 +207,19 @@ static ssize_t w1_therm_read(struct device *device,
207 w1_write_8(dev, W1_CONVERT_TEMP); 207 w1_write_8(dev, W1_CONVERT_TEMP);
208 208
209 if (external_power) { 209 if (external_power) {
210 mutex_unlock(&dev->mutex); 210 mutex_unlock(&dev->bus_mutex);
211 211
212 sleep_rem = msleep_interruptible(tm); 212 sleep_rem = msleep_interruptible(tm);
213 if (sleep_rem != 0) 213 if (sleep_rem != 0)
214 return -EINTR; 214 return -EINTR;
215 215
216 i = mutex_lock_interruptible(&dev->mutex); 216 i = mutex_lock_interruptible(&dev->bus_mutex);
217 if (i != 0) 217 if (i != 0)
218 return i; 218 return i;
219 } else if (!w1_strong_pullup) { 219 } else if (!w1_strong_pullup) {
220 sleep_rem = msleep_interruptible(tm); 220 sleep_rem = msleep_interruptible(tm);
221 if (sleep_rem != 0) { 221 if (sleep_rem != 0) {
222 mutex_unlock(&dev->mutex); 222 mutex_unlock(&dev->bus_mutex);
223 return -EINTR; 223 return -EINTR;
224 } 224 }
225 } 225 }
@@ -258,7 +258,7 @@ static ssize_t w1_therm_read(struct device *device,
258 258
259 c -= snprintf(buf + PAGE_SIZE - c, c, "t=%d\n", 259 c -= snprintf(buf + PAGE_SIZE - c, c, "t=%d\n",
260 w1_convert_temp(rom, sl->family->fid)); 260 w1_convert_temp(rom, sl->family->fid));
261 mutex_unlock(&dev->mutex); 261 mutex_unlock(&dev->bus_mutex);
262 262
263 return PAGE_SIZE - c; 263 return PAGE_SIZE - c;
264} 264}
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index bfb898641029..1a574370d2cd 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -885,16 +885,21 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb
885 * 885 *
886 * Return 0 - device(s) present, 1 - no devices present. 886 * Return 0 - device(s) present, 1 - no devices present.
887 */ 887 */
888 mutex_lock(&dev->bus_mutex);
888 if (w1_reset_bus(dev)) { 889 if (w1_reset_bus(dev)) {
890 mutex_unlock(&dev->bus_mutex);
889 dev_dbg(&dev->dev, "No devices present on the wire.\n"); 891 dev_dbg(&dev->dev, "No devices present on the wire.\n");
890 break; 892 break;
891 } 893 }
892 894
893 /* Do fast search on single slave bus */ 895 /* Do fast search on single slave bus */
894 if (dev->max_slave_count == 1) { 896 if (dev->max_slave_count == 1) {
897 int rv;
895 w1_write_8(dev, W1_READ_ROM); 898 w1_write_8(dev, W1_READ_ROM);
899 rv = w1_read_block(dev, (u8 *)&rn, 8);
900 mutex_unlock(&dev->bus_mutex);
896 901
897 if (w1_read_block(dev, (u8 *)&rn, 8) == 8 && rn) 902 if (rv == 8 && rn)
898 cb(dev, rn); 903 cb(dev, rn);
899 904
900 break; 905 break;
@@ -927,10 +932,12 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb
927 rn |= (tmp64 << i); 932 rn |= (tmp64 << i);
928 933
929 if (kthread_should_stop()) { 934 if (kthread_should_stop()) {
935 mutex_unlock(&dev->bus_mutex);
930 dev_dbg(&dev->dev, "Abort w1_search\n"); 936 dev_dbg(&dev->dev, "Abort w1_search\n");
931 return; 937 return;
932 } 938 }
933 } 939 }
940 mutex_unlock(&dev->bus_mutex);
934 941
935 if ( (triplet_ret & 0x03) != 0x03 ) { 942 if ( (triplet_ret & 0x03) != 0x03 ) {
936 if ( (desc_bit == last_zero) || (last_zero < 0)) 943 if ( (desc_bit == last_zero) || (last_zero < 0))
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h
index 4d012ca3f32c..45908e56c2f8 100644
--- a/drivers/w1/w1.h
+++ b/drivers/w1/w1.h
@@ -180,6 +180,7 @@ struct w1_master
180 180
181 struct task_struct *thread; 181 struct task_struct *thread;
182 struct mutex mutex; 182 struct mutex mutex;
183 struct mutex bus_mutex;
183 184
184 struct device_driver *driver; 185 struct device_driver *driver;
185 struct device dev; 186 struct device dev;
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 68288355727a..531434180afd 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -76,6 +76,7 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
76 76
77 INIT_LIST_HEAD(&dev->slist); 77 INIT_LIST_HEAD(&dev->slist);
78 mutex_init(&dev->mutex); 78 mutex_init(&dev->mutex);
79 mutex_init(&dev->bus_mutex);
79 80
80 memcpy(&dev->dev, device, sizeof(struct device)); 81 memcpy(&dev->dev, device, sizeof(struct device));
81 dev_set_name(&dev->dev, "w1_bus_master%u", dev->id); 82 dev_set_name(&dev->dev, "w1_bus_master%u", dev->id);