diff options
author | Evgeniy Polyakov <johnpol@2ka.mipt.ru> | 2006-04-03 04:04:27 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-06-22 14:22:50 -0400 |
commit | abd52a13206e02537ca1dc08fc5438c7d27bdbf1 (patch) | |
tree | efe0ff89898aad10600d392ac727dcea9e7af322 /drivers/w1/slaves | |
parent | 46e07f6e5eb0e465e086b8f485f4238bd453e3e9 (diff) |
[PATCH] w1: Use mutexes instead of semaphores.
Use mutexes instead of semaphores.
Patch tested on x86_64 and i386 with test bus master driver.
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/w1/slaves')
-rw-r--r-- | drivers/w1/slaves/w1_ds2433.c | 20 | ||||
-rw-r--r-- | drivers/w1/slaves/w1_therm.c | 12 |
2 files changed, 6 insertions, 26 deletions
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 | } |