diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/w1/masters/ds2482.c | 24 | ||||
-rw-r--r-- | drivers/w1/masters/ds2490.c | 10 | ||||
-rw-r--r-- | drivers/w1/slaves/w1_ds2433.c | 20 | ||||
-rw-r--r-- | drivers/w1/slaves/w1_therm.c | 12 | ||||
-rw-r--r-- | drivers/w1/w1.c | 114 | ||||
-rw-r--r-- | drivers/w1/w1.h | 5 | ||||
-rw-r--r-- | drivers/w1/w1_int.c | 8 | ||||
-rw-r--r-- | drivers/w1/w1_netlink.c | 4 |
8 files changed, 70 insertions, 127 deletions
diff --git a/drivers/w1/masters/ds2482.c b/drivers/w1/masters/ds2482.c index d1cacd23576b..af492cc48db2 100644 --- a/drivers/w1/masters/ds2482.c +++ b/drivers/w1/masters/ds2482.c | |||
@@ -125,7 +125,7 @@ struct ds2482_w1_chan { | |||
125 | 125 | ||
126 | struct ds2482_data { | 126 | struct ds2482_data { |
127 | struct i2c_client client; | 127 | struct i2c_client client; |
128 | struct semaphore access_lock; | 128 | struct mutex access_lock; |
129 | 129 | ||
130 | /* 1-wire interface(s) */ | 130 | /* 1-wire interface(s) */ |
131 | int w1_count; /* 1 or 8 */ | 131 | int w1_count; /* 1 or 8 */ |
@@ -265,7 +265,7 @@ static u8 ds2482_w1_touch_bit(void *data, u8 bit) | |||
265 | struct ds2482_data *pdev = pchan->pdev; | 265 | struct ds2482_data *pdev = pchan->pdev; |
266 | int status = -1; | 266 | int status = -1; |
267 | 267 | ||
268 | down(&pdev->access_lock); | 268 | mutex_lock(&pdev->access_lock); |
269 | 269 | ||
270 | /* Select the channel */ | 270 | /* Select the channel */ |
271 | ds2482_wait_1wire_idle(pdev); | 271 | ds2482_wait_1wire_idle(pdev); |
@@ -277,7 +277,7 @@ static u8 ds2482_w1_touch_bit(void *data, u8 bit) | |||
277 | bit ? 0xFF : 0)) | 277 | bit ? 0xFF : 0)) |
278 | status = ds2482_wait_1wire_idle(pdev); | 278 | status = ds2482_wait_1wire_idle(pdev); |
279 | 279 | ||
280 | up(&pdev->access_lock); | 280 | mutex_unlock(&pdev->access_lock); |
281 | 281 | ||
282 | return (status & DS2482_REG_STS_SBR) ? 1 : 0; | 282 | return (status & DS2482_REG_STS_SBR) ? 1 : 0; |
283 | } | 283 | } |
@@ -297,7 +297,7 @@ static u8 ds2482_w1_triplet(void *data, u8 dbit) | |||
297 | struct ds2482_data *pdev = pchan->pdev; | 297 | struct ds2482_data *pdev = pchan->pdev; |
298 | int status = (3 << 5); | 298 | int status = (3 << 5); |
299 | 299 | ||
300 | down(&pdev->access_lock); | 300 | mutex_lock(&pdev->access_lock); |
301 | 301 | ||
302 | /* Select the channel */ | 302 | /* Select the channel */ |
303 | ds2482_wait_1wire_idle(pdev); | 303 | ds2482_wait_1wire_idle(pdev); |
@@ -309,7 +309,7 @@ static u8 ds2482_w1_triplet(void *data, u8 dbit) | |||
309 | dbit ? 0xFF : 0)) | 309 | dbit ? 0xFF : 0)) |
310 | status = ds2482_wait_1wire_idle(pdev); | 310 | status = ds2482_wait_1wire_idle(pdev); |
311 | 311 | ||
312 | up(&pdev->access_lock); | 312 | mutex_unlock(&pdev->access_lock); |
313 | 313 | ||
314 | /* Decode the status */ | 314 | /* Decode the status */ |
315 | return (status >> 5); | 315 | return (status >> 5); |
@@ -326,7 +326,7 @@ static void ds2482_w1_write_byte(void *data, u8 byte) | |||
326 | struct ds2482_w1_chan *pchan = data; | 326 | struct ds2482_w1_chan *pchan = data; |
327 | struct ds2482_data *pdev = pchan->pdev; | 327 | struct ds2482_data *pdev = pchan->pdev; |
328 | 328 | ||
329 | down(&pdev->access_lock); | 329 | mutex_lock(&pdev->access_lock); |
330 | 330 | ||
331 | /* Select the channel */ | 331 | /* Select the channel */ |
332 | ds2482_wait_1wire_idle(pdev); | 332 | ds2482_wait_1wire_idle(pdev); |
@@ -336,7 +336,7 @@ static void ds2482_w1_write_byte(void *data, u8 byte) | |||
336 | /* Send the write byte command */ | 336 | /* Send the write byte command */ |
337 | ds2482_send_cmd_data(pdev, DS2482_CMD_1WIRE_WRITE_BYTE, byte); | 337 | ds2482_send_cmd_data(pdev, DS2482_CMD_1WIRE_WRITE_BYTE, byte); |
338 | 338 | ||
339 | up(&pdev->access_lock); | 339 | mutex_unlock(&pdev->access_lock); |
340 | } | 340 | } |
341 | 341 | ||
342 | /** | 342 | /** |
@@ -351,7 +351,7 @@ static u8 ds2482_w1_read_byte(void *data) | |||
351 | struct ds2482_data *pdev = pchan->pdev; | 351 | struct ds2482_data *pdev = pchan->pdev; |
352 | int result; | 352 | int result; |
353 | 353 | ||
354 | down(&pdev->access_lock); | 354 | mutex_lock(&pdev->access_lock); |
355 | 355 | ||
356 | /* Select the channel */ | 356 | /* Select the channel */ |
357 | ds2482_wait_1wire_idle(pdev); | 357 | ds2482_wait_1wire_idle(pdev); |
@@ -370,7 +370,7 @@ static u8 ds2482_w1_read_byte(void *data) | |||
370 | /* Read the data byte */ | 370 | /* Read the data byte */ |
371 | result = i2c_smbus_read_byte(&pdev->client); | 371 | result = i2c_smbus_read_byte(&pdev->client); |
372 | 372 | ||
373 | up(&pdev->access_lock); | 373 | mutex_unlock(&pdev->access_lock); |
374 | 374 | ||
375 | return result; | 375 | return result; |
376 | } | 376 | } |
@@ -389,7 +389,7 @@ static u8 ds2482_w1_reset_bus(void *data) | |||
389 | int err; | 389 | int err; |
390 | u8 retval = 1; | 390 | u8 retval = 1; |
391 | 391 | ||
392 | down(&pdev->access_lock); | 392 | mutex_lock(&pdev->access_lock); |
393 | 393 | ||
394 | /* Select the channel */ | 394 | /* Select the channel */ |
395 | ds2482_wait_1wire_idle(pdev); | 395 | ds2482_wait_1wire_idle(pdev); |
@@ -409,7 +409,7 @@ static u8 ds2482_w1_reset_bus(void *data) | |||
409 | 0xF0); | 409 | 0xF0); |
410 | } | 410 | } |
411 | 411 | ||
412 | up(&pdev->access_lock); | 412 | mutex_unlock(&pdev->access_lock); |
413 | 413 | ||
414 | return retval; | 414 | return retval; |
415 | } | 415 | } |
@@ -482,7 +482,7 @@ static int ds2482_detect(struct i2c_adapter *adapter, int address, int kind) | |||
482 | snprintf(new_client->name, sizeof(new_client->name), "ds2482-%d00", | 482 | snprintf(new_client->name, sizeof(new_client->name), "ds2482-%d00", |
483 | data->w1_count); | 483 | data->w1_count); |
484 | 484 | ||
485 | init_MUTEX(&data->access_lock); | 485 | mutex_init(&data->access_lock); |
486 | 486 | ||
487 | /* Tell the I2C layer a new client has arrived */ | 487 | /* Tell the I2C layer a new client has arrived */ |
488 | if ((err = i2c_attach_client(new_client))) | 488 | if ((err = i2c_attach_client(new_client))) |
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c index 637677833da5..299e274d241a 100644 --- a/drivers/w1/masters/ds2490.c +++ b/drivers/w1/masters/ds2490.c | |||
@@ -169,7 +169,7 @@ static int ds_send_control(struct ds_device *, u16, u16); | |||
169 | static int ds_send_control_cmd(struct ds_device *, u16, u16); | 169 | static int ds_send_control_cmd(struct ds_device *, u16, u16); |
170 | 170 | ||
171 | static LIST_HEAD(ds_devices); | 171 | static LIST_HEAD(ds_devices); |
172 | static DECLARE_MUTEX(ds_mutex); | 172 | static DEFINE_MUTEX(ds_mutex); |
173 | 173 | ||
174 | static struct usb_driver ds_driver = { | 174 | static struct usb_driver ds_driver = { |
175 | .name = "DS9490R", | 175 | .name = "DS9490R", |
@@ -887,9 +887,9 @@ static int ds_probe(struct usb_interface *intf, | |||
887 | if (err) | 887 | if (err) |
888 | goto err_out_clear; | 888 | goto err_out_clear; |
889 | 889 | ||
890 | down(&ds_mutex); | 890 | mutex_lock(&ds_mutex); |
891 | list_add_tail(&dev->ds_entry, &ds_devices); | 891 | list_add_tail(&dev->ds_entry, &ds_devices); |
892 | up(&ds_mutex); | 892 | mutex_unlock(&ds_mutex); |
893 | 893 | ||
894 | return 0; | 894 | return 0; |
895 | 895 | ||
@@ -909,9 +909,9 @@ static void ds_disconnect(struct usb_interface *intf) | |||
909 | if (!dev) | 909 | if (!dev) |
910 | return; | 910 | return; |
911 | 911 | ||
912 | down(&ds_mutex); | 912 | mutex_lock(&ds_mutex); |
913 | list_del(&dev->ds_entry); | 913 | list_del(&dev->ds_entry); |
914 | up(&ds_mutex); | 914 | mutex_unlock(&ds_mutex); |
915 | 915 | ||
916 | ds_w1_fini(dev); | 916 | ds_w1_fini(dev); |
917 | 917 | ||
diff --git a/drivers/w1/slaves/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c index ddd01e6fc2c9..2ac238f1480e 100644 --- a/drivers/w1/slaves/w1_ds2433.c +++ b/drivers/w1/slaves/w1_ds2433.c | |||
@@ -105,11 +105,7 @@ static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off, | |||
105 | if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0) | 105 | if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0) |
106 | return 0; | 106 | return 0; |
107 | 107 | ||
108 | atomic_inc(&sl->refcnt); | 108 | mutex_lock(&sl->master->mutex); |
109 | if (down_interruptible(&sl->master->mutex)) { | ||
110 | count = 0; | ||
111 | goto out_dec; | ||
112 | } | ||
113 | 109 | ||
114 | #ifdef CONFIG_W1_F23_CRC | 110 | #ifdef CONFIG_W1_F23_CRC |
115 | 111 | ||
@@ -140,9 +136,7 @@ static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off, | |||
140 | #endif /* CONFIG_W1_F23_CRC */ | 136 | #endif /* CONFIG_W1_F23_CRC */ |
141 | 137 | ||
142 | out_up: | 138 | out_up: |
143 | up(&sl->master->mutex); | 139 | mutex_unlock(&sl->master->mutex); |
144 | out_dec: | ||
145 | atomic_dec(&sl->refcnt); | ||
146 | 140 | ||
147 | return count; | 141 | return count; |
148 | } | 142 | } |
@@ -231,11 +225,7 @@ static ssize_t w1_f23_write_bin(struct kobject *kobj, char *buf, loff_t off, | |||
231 | } | 225 | } |
232 | #endif /* CONFIG_W1_F23_CRC */ | 226 | #endif /* CONFIG_W1_F23_CRC */ |
233 | 227 | ||
234 | atomic_inc(&sl->refcnt); | 228 | mutex_lock(&sl->master->mutex); |
235 | if (down_interruptible(&sl->master->mutex)) { | ||
236 | count = 0; | ||
237 | goto out_dec; | ||
238 | } | ||
239 | 229 | ||
240 | /* Can only write data to one page at a time */ | 230 | /* Can only write data to one page at a time */ |
241 | idx = 0; | 231 | idx = 0; |
@@ -253,9 +243,7 @@ static ssize_t w1_f23_write_bin(struct kobject *kobj, char *buf, loff_t off, | |||
253 | } | 243 | } |
254 | 244 | ||
255 | out_up: | 245 | out_up: |
256 | up(&sl->master->mutex); | 246 | mutex_unlock(&sl->master->mutex); |
257 | out_dec: | ||
258 | atomic_dec(&sl->refcnt); | ||
259 | 247 | ||
260 | return count; | 248 | return count; |
261 | } | 249 | } |
diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c index 44afdffe3c8b..5372cfcbd054 100644 --- a/drivers/w1/slaves/w1_therm.c +++ b/drivers/w1/slaves/w1_therm.c | |||
@@ -165,12 +165,7 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si | |||
165 | u8 rom[9], crc, verdict; | 165 | u8 rom[9], crc, verdict; |
166 | int i, max_trying = 10; | 166 | int i, max_trying = 10; |
167 | 167 | ||
168 | atomic_inc(&sl->refcnt); | 168 | mutex_lock(&sl->master->mutex); |
169 | smp_mb__after_atomic_inc(); | ||
170 | if (down_interruptible(&sl->master->mutex)) { | ||
171 | count = 0; | ||
172 | goto out_dec; | ||
173 | } | ||
174 | 169 | ||
175 | if (off > W1_SLAVE_DATA_SIZE) { | 170 | if (off > W1_SLAVE_DATA_SIZE) { |
176 | count = 0; | 171 | count = 0; |
@@ -233,10 +228,7 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si | |||
233 | 228 | ||
234 | count += sprintf(buf + count, "t=%d\n", w1_convert_temp(rom, sl->family->fid)); | 229 | count += sprintf(buf + count, "t=%d\n", w1_convert_temp(rom, sl->family->fid)); |
235 | out: | 230 | out: |
236 | up(&dev->mutex); | 231 | mutex_unlock(&dev->mutex); |
237 | out_dec: | ||
238 | smp_mb__before_atomic_inc(); | ||
239 | atomic_dec(&sl->refcnt); | ||
240 | 232 | ||
241 | return count; | 233 | return count; |
242 | } | 234 | } |
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index 32d8de881f11..420be14c2f8e 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c | |||
@@ -54,7 +54,7 @@ module_param_named(control_timeout, w1_control_timeout, int, 0); | |||
54 | module_param_named(max_slave_count, w1_max_slave_count, int, 0); | 54 | module_param_named(max_slave_count, w1_max_slave_count, int, 0); |
55 | module_param_named(slave_ttl, w1_max_slave_ttl, int, 0); | 55 | module_param_named(slave_ttl, w1_max_slave_ttl, int, 0); |
56 | 56 | ||
57 | DECLARE_MUTEX(w1_mlock); | 57 | DEFINE_MUTEX(w1_mlock); |
58 | LIST_HEAD(w1_masters); | 58 | LIST_HEAD(w1_masters); |
59 | 59 | ||
60 | static struct task_struct *w1_control_thread; | 60 | static struct task_struct *w1_control_thread; |
@@ -139,11 +139,7 @@ static ssize_t w1_default_write(struct kobject *kobj, char *buf, loff_t off, siz | |||
139 | { | 139 | { |
140 | struct w1_slave *sl = kobj_to_w1_slave(kobj); | 140 | struct w1_slave *sl = kobj_to_w1_slave(kobj); |
141 | 141 | ||
142 | if (down_interruptible(&sl->master->mutex)) { | 142 | mutex_lock(&sl->master->mutex); |
143 | count = 0; | ||
144 | goto out; | ||
145 | } | ||
146 | |||
147 | if (w1_reset_select_slave(sl)) { | 143 | if (w1_reset_select_slave(sl)) { |
148 | count = 0; | 144 | count = 0; |
149 | goto out_up; | 145 | goto out_up; |
@@ -152,8 +148,7 @@ static ssize_t w1_default_write(struct kobject *kobj, char *buf, loff_t off, siz | |||
152 | w1_write_block(sl->master, buf, count); | 148 | w1_write_block(sl->master, buf, count); |
153 | 149 | ||
154 | out_up: | 150 | out_up: |
155 | up(&sl->master->mutex); | 151 | mutex_unlock(&sl->master->mutex); |
156 | out: | ||
157 | return count; | 152 | return count; |
158 | } | 153 | } |
159 | 154 | ||
@@ -161,15 +156,9 @@ static ssize_t w1_default_read(struct kobject *kobj, char *buf, loff_t off, size | |||
161 | { | 156 | { |
162 | struct w1_slave *sl = kobj_to_w1_slave(kobj); | 157 | struct w1_slave *sl = kobj_to_w1_slave(kobj); |
163 | 158 | ||
164 | if (down_interruptible(&sl->master->mutex)) { | 159 | mutex_lock(&sl->master->mutex); |
165 | count = 0; | ||
166 | goto out; | ||
167 | } | ||
168 | |||
169 | w1_read_block(sl->master, buf, count); | 160 | w1_read_block(sl->master, buf, count); |
170 | 161 | mutex_unlock(&sl->master->mutex); | |
171 | up(&sl->master->mutex); | ||
172 | out: | ||
173 | return count; | 162 | return count; |
174 | } | 163 | } |
175 | 164 | ||
@@ -243,12 +232,9 @@ static ssize_t w1_master_attribute_show_name(struct device *dev, struct device_a | |||
243 | struct w1_master *md = dev_to_w1_master(dev); | 232 | struct w1_master *md = dev_to_w1_master(dev); |
244 | ssize_t count; | 233 | ssize_t count; |
245 | 234 | ||
246 | if (down_interruptible (&md->mutex)) | 235 | mutex_lock(&md->mutex); |
247 | return -EBUSY; | ||
248 | |||
249 | count = sprintf(buf, "%s\n", md->name); | 236 | count = sprintf(buf, "%s\n", md->name); |
250 | 237 | mutex_unlock(&md->mutex); | |
251 | up(&md->mutex); | ||
252 | 238 | ||
253 | return count; | 239 | return count; |
254 | } | 240 | } |
@@ -259,12 +245,9 @@ static ssize_t w1_master_attribute_store_search(struct device * dev, | |||
259 | { | 245 | { |
260 | struct w1_master *md = dev_to_w1_master(dev); | 246 | struct w1_master *md = dev_to_w1_master(dev); |
261 | 247 | ||
262 | if (down_interruptible (&md->mutex)) | 248 | mutex_lock(&md->mutex); |
263 | return -EBUSY; | ||
264 | |||
265 | md->search_count = simple_strtol(buf, NULL, 0); | 249 | md->search_count = simple_strtol(buf, NULL, 0); |
266 | 250 | mutex_unlock(&md->mutex); | |
267 | up(&md->mutex); | ||
268 | 251 | ||
269 | return count; | 252 | return count; |
270 | } | 253 | } |
@@ -276,12 +259,9 @@ static ssize_t w1_master_attribute_show_search(struct device *dev, | |||
276 | struct w1_master *md = dev_to_w1_master(dev); | 259 | struct w1_master *md = dev_to_w1_master(dev); |
277 | ssize_t count; | 260 | ssize_t count; |
278 | 261 | ||
279 | if (down_interruptible (&md->mutex)) | 262 | mutex_lock(&md->mutex); |
280 | return -EBUSY; | ||
281 | |||
282 | count = sprintf(buf, "%d\n", md->search_count); | 263 | count = sprintf(buf, "%d\n", md->search_count); |
283 | 264 | mutex_unlock(&md->mutex); | |
284 | up(&md->mutex); | ||
285 | 265 | ||
286 | return count; | 266 | return count; |
287 | } | 267 | } |
@@ -291,12 +271,9 @@ static ssize_t w1_master_attribute_show_pointer(struct device *dev, struct devic | |||
291 | struct w1_master *md = dev_to_w1_master(dev); | 271 | struct w1_master *md = dev_to_w1_master(dev); |
292 | ssize_t count; | 272 | ssize_t count; |
293 | 273 | ||
294 | if (down_interruptible(&md->mutex)) | 274 | mutex_lock(&md->mutex); |
295 | return -EBUSY; | ||
296 | |||
297 | count = sprintf(buf, "0x%p\n", md->bus_master); | 275 | count = sprintf(buf, "0x%p\n", md->bus_master); |
298 | 276 | mutex_unlock(&md->mutex); | |
299 | up(&md->mutex); | ||
300 | return count; | 277 | return count; |
301 | } | 278 | } |
302 | 279 | ||
@@ -312,12 +289,9 @@ static ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, stru | |||
312 | struct w1_master *md = dev_to_w1_master(dev); | 289 | struct w1_master *md = dev_to_w1_master(dev); |
313 | ssize_t count; | 290 | ssize_t count; |
314 | 291 | ||
315 | if (down_interruptible(&md->mutex)) | 292 | mutex_lock(&md->mutex); |
316 | return -EBUSY; | ||
317 | |||
318 | count = sprintf(buf, "%d\n", md->max_slave_count); | 293 | count = sprintf(buf, "%d\n", md->max_slave_count); |
319 | 294 | mutex_unlock(&md->mutex); | |
320 | up(&md->mutex); | ||
321 | return count; | 295 | return count; |
322 | } | 296 | } |
323 | 297 | ||
@@ -326,12 +300,9 @@ static ssize_t w1_master_attribute_show_attempts(struct device *dev, struct devi | |||
326 | struct w1_master *md = dev_to_w1_master(dev); | 300 | struct w1_master *md = dev_to_w1_master(dev); |
327 | ssize_t count; | 301 | ssize_t count; |
328 | 302 | ||
329 | if (down_interruptible(&md->mutex)) | 303 | mutex_lock(&md->mutex); |
330 | return -EBUSY; | ||
331 | |||
332 | count = sprintf(buf, "%lu\n", md->attempts); | 304 | count = sprintf(buf, "%lu\n", md->attempts); |
333 | 305 | mutex_unlock(&md->mutex); | |
334 | up(&md->mutex); | ||
335 | return count; | 306 | return count; |
336 | } | 307 | } |
337 | 308 | ||
@@ -340,12 +311,9 @@ static ssize_t w1_master_attribute_show_slave_count(struct device *dev, struct d | |||
340 | struct w1_master *md = dev_to_w1_master(dev); | 311 | struct w1_master *md = dev_to_w1_master(dev); |
341 | ssize_t count; | 312 | ssize_t count; |
342 | 313 | ||
343 | if (down_interruptible(&md->mutex)) | 314 | mutex_lock(&md->mutex); |
344 | return -EBUSY; | ||
345 | |||
346 | count = sprintf(buf, "%d\n", md->slave_count); | 315 | count = sprintf(buf, "%d\n", md->slave_count); |
347 | 316 | mutex_unlock(&md->mutex); | |
348 | up(&md->mutex); | ||
349 | return count; | 317 | return count; |
350 | } | 318 | } |
351 | 319 | ||
@@ -354,8 +322,7 @@ static ssize_t w1_master_attribute_show_slaves(struct device *dev, struct device | |||
354 | struct w1_master *md = dev_to_w1_master(dev); | 322 | struct w1_master *md = dev_to_w1_master(dev); |
355 | int c = PAGE_SIZE; | 323 | int c = PAGE_SIZE; |
356 | 324 | ||
357 | if (down_interruptible(&md->mutex)) | 325 | mutex_lock(&md->mutex); |
358 | return -EBUSY; | ||
359 | 326 | ||
360 | if (md->slave_count == 0) | 327 | if (md->slave_count == 0) |
361 | c -= snprintf(buf + PAGE_SIZE - c, c, "not found.\n"); | 328 | c -= snprintf(buf + PAGE_SIZE - c, c, "not found.\n"); |
@@ -370,7 +337,7 @@ static ssize_t w1_master_attribute_show_slaves(struct device *dev, struct device | |||
370 | } | 337 | } |
371 | } | 338 | } |
372 | 339 | ||
373 | up(&md->mutex); | 340 | mutex_unlock(&md->mutex); |
374 | 341 | ||
375 | return PAGE_SIZE - c; | 342 | return PAGE_SIZE - c; |
376 | } | 343 | } |
@@ -620,7 +587,7 @@ static struct w1_master *w1_search_master(void *data) | |||
620 | struct w1_master *dev; | 587 | struct w1_master *dev; |
621 | int found = 0; | 588 | int found = 0; |
622 | 589 | ||
623 | down(&w1_mlock); | 590 | mutex_lock(&w1_mlock); |
624 | list_for_each_entry(dev, &w1_masters, w1_master_entry) { | 591 | list_for_each_entry(dev, &w1_masters, w1_master_entry) { |
625 | if (dev->bus_master->data == data) { | 592 | if (dev->bus_master->data == data) { |
626 | found = 1; | 593 | found = 1; |
@@ -628,7 +595,7 @@ static struct w1_master *w1_search_master(void *data) | |||
628 | break; | 595 | break; |
629 | } | 596 | } |
630 | } | 597 | } |
631 | up(&w1_mlock); | 598 | mutex_unlock(&w1_mlock); |
632 | 599 | ||
633 | return (found)?dev:NULL; | 600 | return (found)?dev:NULL; |
634 | } | 601 | } |
@@ -638,7 +605,7 @@ struct w1_master *w1_search_master_id(u32 id) | |||
638 | struct w1_master *dev; | 605 | struct w1_master *dev; |
639 | int found = 0; | 606 | int found = 0; |
640 | 607 | ||
641 | down(&w1_mlock); | 608 | mutex_lock(&w1_mlock); |
642 | list_for_each_entry(dev, &w1_masters, w1_master_entry) { | 609 | list_for_each_entry(dev, &w1_masters, w1_master_entry) { |
643 | if (dev->id == id) { | 610 | if (dev->id == id) { |
644 | found = 1; | 611 | found = 1; |
@@ -646,7 +613,7 @@ struct w1_master *w1_search_master_id(u32 id) | |||
646 | break; | 613 | break; |
647 | } | 614 | } |
648 | } | 615 | } |
649 | up(&w1_mlock); | 616 | mutex_unlock(&w1_mlock); |
650 | 617 | ||
651 | return (found)?dev:NULL; | 618 | return (found)?dev:NULL; |
652 | } | 619 | } |
@@ -657,9 +624,9 @@ struct w1_slave *w1_search_slave(struct w1_reg_num *id) | |||
657 | struct w1_slave *sl = NULL; | 624 | struct w1_slave *sl = NULL; |
658 | int found = 0; | 625 | int found = 0; |
659 | 626 | ||
660 | down(&w1_mlock); | 627 | mutex_lock(&w1_mlock); |
661 | list_for_each_entry(dev, &w1_masters, w1_master_entry) { | 628 | list_for_each_entry(dev, &w1_masters, w1_master_entry) { |
662 | down(&dev->mutex); | 629 | mutex_lock(&dev->mutex); |
663 | list_for_each_entry(sl, &dev->slist, w1_slave_entry) { | 630 | list_for_each_entry(sl, &dev->slist, w1_slave_entry) { |
664 | if (sl->reg_num.family == id->family && | 631 | if (sl->reg_num.family == id->family && |
665 | sl->reg_num.id == id->id && | 632 | sl->reg_num.id == id->id && |
@@ -670,12 +637,12 @@ struct w1_slave *w1_search_slave(struct w1_reg_num *id) | |||
670 | break; | 637 | break; |
671 | } | 638 | } |
672 | } | 639 | } |
673 | up(&dev->mutex); | 640 | mutex_unlock(&dev->mutex); |
674 | 641 | ||
675 | if (found) | 642 | if (found) |
676 | break; | 643 | break; |
677 | } | 644 | } |
678 | up(&w1_mlock); | 645 | mutex_unlock(&w1_mlock); |
679 | 646 | ||
680 | return (found)?sl:NULL; | 647 | return (found)?sl:NULL; |
681 | } | 648 | } |
@@ -684,13 +651,13 @@ void w1_reconnect_slaves(struct w1_family *f) | |||
684 | { | 651 | { |
685 | struct w1_master *dev; | 652 | struct w1_master *dev; |
686 | 653 | ||
687 | down(&w1_mlock); | 654 | mutex_lock(&w1_mlock); |
688 | list_for_each_entry(dev, &w1_masters, w1_master_entry) { | 655 | list_for_each_entry(dev, &w1_masters, w1_master_entry) { |
689 | dev_dbg(&dev->dev, "Reconnecting slaves in %s into new family %02x.\n", | 656 | dev_dbg(&dev->dev, "Reconnecting slaves in %s into new family %02x.\n", |
690 | dev->name, f->fid); | 657 | dev->name, f->fid); |
691 | set_bit(W1_MASTER_NEED_RECONNECT, &dev->flags); | 658 | set_bit(W1_MASTER_NEED_RECONNECT, &dev->flags); |
692 | } | 659 | } |
693 | up(&w1_mlock); | 660 | mutex_unlock(&w1_mlock); |
694 | } | 661 | } |
695 | 662 | ||
696 | static void w1_slave_found(void *data, u64 rn) | 663 | static void w1_slave_found(void *data, u64 rn) |
@@ -845,23 +812,23 @@ static int w1_control(void *data) | |||
845 | if (kthread_should_stop() || test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) { | 812 | if (kthread_should_stop() || test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) { |
846 | set_bit(W1_MASTER_NEED_EXIT, &dev->flags); | 813 | set_bit(W1_MASTER_NEED_EXIT, &dev->flags); |
847 | 814 | ||
848 | down(&w1_mlock); | 815 | mutex_lock(&w1_mlock); |
849 | list_del(&dev->w1_master_entry); | 816 | list_del(&dev->w1_master_entry); |
850 | up(&w1_mlock); | 817 | mutex_unlock(&w1_mlock); |
851 | 818 | ||
852 | down(&dev->mutex); | 819 | mutex_lock(&dev->mutex); |
853 | list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { | 820 | list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { |
854 | w1_slave_detach(sl); | 821 | w1_slave_detach(sl); |
855 | } | 822 | } |
856 | w1_destroy_master_attributes(dev); | 823 | w1_destroy_master_attributes(dev); |
857 | up(&dev->mutex); | 824 | mutex_unlock(&dev->mutex); |
858 | atomic_dec(&dev->refcnt); | 825 | atomic_dec(&dev->refcnt); |
859 | continue; | 826 | continue; |
860 | } | 827 | } |
861 | 828 | ||
862 | if (test_bit(W1_MASTER_NEED_RECONNECT, &dev->flags)) { | 829 | if (test_bit(W1_MASTER_NEED_RECONNECT, &dev->flags)) { |
863 | dev_dbg(&dev->dev, "Reconnecting slaves in device %s.\n", dev->name); | 830 | dev_dbg(&dev->dev, "Reconnecting slaves in device %s.\n", dev->name); |
864 | down(&dev->mutex); | 831 | mutex_lock(&dev->mutex); |
865 | list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { | 832 | list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { |
866 | if (sl->family->fid == W1_FAMILY_DEFAULT) { | 833 | if (sl->family->fid == W1_FAMILY_DEFAULT) { |
867 | struct w1_reg_num rn; | 834 | struct w1_reg_num rn; |
@@ -874,7 +841,7 @@ static int w1_control(void *data) | |||
874 | } | 841 | } |
875 | dev_dbg(&dev->dev, "Reconnecting slaves in device %s has been finished.\n", dev->name); | 842 | dev_dbg(&dev->dev, "Reconnecting slaves in device %s has been finished.\n", dev->name); |
876 | clear_bit(W1_MASTER_NEED_RECONNECT, &dev->flags); | 843 | clear_bit(W1_MASTER_NEED_RECONNECT, &dev->flags); |
877 | up(&dev->mutex); | 844 | mutex_unlock(&dev->mutex); |
878 | } | 845 | } |
879 | } | 846 | } |
880 | } | 847 | } |
@@ -921,12 +888,9 @@ int w1_process(void *data) | |||
921 | if (dev->search_count == 0) | 888 | if (dev->search_count == 0) |
922 | continue; | 889 | continue; |
923 | 890 | ||
924 | if (down_interruptible(&dev->mutex)) | 891 | mutex_lock(&dev->mutex); |
925 | continue; | ||
926 | |||
927 | w1_search_process(dev, W1_SEARCH); | 892 | w1_search_process(dev, W1_SEARCH); |
928 | 893 | mutex_unlock(&dev->mutex); | |
929 | up(&dev->mutex); | ||
930 | } | 894 | } |
931 | 895 | ||
932 | atomic_dec(&dev->refcnt); | 896 | atomic_dec(&dev->refcnt); |
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h index e8c96e6e7418..6caccfc97cdf 100644 --- a/drivers/w1/w1.h +++ b/drivers/w1/w1.h | |||
@@ -41,8 +41,7 @@ struct w1_reg_num | |||
41 | 41 | ||
42 | #include <linux/completion.h> | 42 | #include <linux/completion.h> |
43 | #include <linux/device.h> | 43 | #include <linux/device.h> |
44 | 44 | #include <linux/mutex.h> | |
45 | #include <asm/semaphore.h> | ||
46 | 45 | ||
47 | #include "w1_family.h" | 46 | #include "w1_family.h" |
48 | 47 | ||
@@ -171,7 +170,7 @@ struct w1_master | |||
171 | long flags; | 170 | long flags; |
172 | 171 | ||
173 | struct task_struct *thread; | 172 | struct task_struct *thread; |
174 | struct semaphore mutex; | 173 | struct mutex mutex; |
175 | 174 | ||
176 | struct device_driver *driver; | 175 | struct device_driver *driver; |
177 | struct device dev; | 176 | struct device dev; |
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c index ae78473d11f9..24e7c102fa75 100644 --- a/drivers/w1/w1_int.c +++ b/drivers/w1/w1_int.c | |||
@@ -36,7 +36,7 @@ extern struct device w1_master_device; | |||
36 | extern int w1_max_slave_count; | 36 | extern int w1_max_slave_count; |
37 | extern int w1_max_slave_ttl; | 37 | extern int w1_max_slave_ttl; |
38 | extern struct list_head w1_masters; | 38 | extern struct list_head w1_masters; |
39 | extern struct semaphore w1_mlock; | 39 | extern struct mutex w1_mlock; |
40 | 40 | ||
41 | extern int w1_process(void *); | 41 | extern int w1_process(void *); |
42 | 42 | ||
@@ -74,7 +74,7 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl, | |||
74 | atomic_set(&dev->refcnt, 2); | 74 | atomic_set(&dev->refcnt, 2); |
75 | 75 | ||
76 | INIT_LIST_HEAD(&dev->slist); | 76 | INIT_LIST_HEAD(&dev->slist); |
77 | init_MUTEX(&dev->mutex); | 77 | mutex_init(&dev->mutex); |
78 | 78 | ||
79 | memcpy(&dev->dev, device, sizeof(struct device)); | 79 | memcpy(&dev->dev, device, sizeof(struct device)); |
80 | snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id), | 80 | snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id), |
@@ -135,9 +135,9 @@ int w1_add_master_device(struct w1_bus_master *master) | |||
135 | 135 | ||
136 | dev->initialized = 1; | 136 | dev->initialized = 1; |
137 | 137 | ||
138 | down(&w1_mlock); | 138 | mutex_lock(&w1_mlock); |
139 | list_add(&dev->w1_master_entry, &w1_masters); | 139 | list_add(&dev->w1_master_entry, &w1_masters); |
140 | up(&w1_mlock); | 140 | mutex_unlock(&w1_mlock); |
141 | 141 | ||
142 | memset(&msg, 0, sizeof(msg)); | 142 | memset(&msg, 0, sizeof(msg)); |
143 | msg.id.mst.id = dev->id; | 143 | msg.id.mst.id = dev->id; |
diff --git a/drivers/w1/w1_netlink.c b/drivers/w1/w1_netlink.c index d539e09aad37..65c5ebd0787e 100644 --- a/drivers/w1/w1_netlink.c +++ b/drivers/w1/w1_netlink.c | |||
@@ -171,7 +171,7 @@ static void w1_cn_callback(void *data) | |||
171 | goto out_cont; | 171 | goto out_cont; |
172 | } | 172 | } |
173 | 173 | ||
174 | down(&dev->mutex); | 174 | mutex_lock(&dev->mutex); |
175 | 175 | ||
176 | if (sl && w1_reset_select_slave(sl)) { | 176 | if (sl && w1_reset_select_slave(sl)) { |
177 | err = -ENODEV; | 177 | err = -ENODEV; |
@@ -198,7 +198,7 @@ out_up: | |||
198 | atomic_dec(&dev->refcnt); | 198 | atomic_dec(&dev->refcnt); |
199 | if (sl) | 199 | if (sl) |
200 | atomic_dec(&sl->refcnt); | 200 | atomic_dec(&sl->refcnt); |
201 | up(&dev->mutex); | 201 | mutex_unlock(&dev->mutex); |
202 | out_cont: | 202 | out_cont: |
203 | msg->len -= sizeof(struct w1_netlink_msg) + m->len; | 203 | msg->len -= sizeof(struct w1_netlink_msg) + m->len; |
204 | m = (struct w1_netlink_msg *)(((u8 *)m) + sizeof(struct w1_netlink_msg) + m->len); | 204 | m = (struct w1_netlink_msg *)(((u8 *)m) + sizeof(struct w1_netlink_msg) + m->len); |