aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2007-12-05 02:45:05 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-12-05 12:21:18 -0500
commit372a302e9a892229206aafca0352584a745bc5f3 (patch)
tree14cf4e06735d8dd9284e843f36a5abcfcc4cc476 /drivers
parent5cd17569fd0eeca510735e63a6061291e3971bf6 (diff)
RTC: assure proper memory ordering with respect to RTC_DEV_BUSY flag
We must make sure that the RTC_DEV_BUSY flag has proper lock semantics, i.e. that the RTC_DEV_BUSY stores clearing the flag don't get reordered before the preceeding stores and loads and vice versa. Spotted by Nick Piggin. Signed-off-by: Jiri Kosina <jkosina@suse.cz> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: David Brownell <david-b@pacbell.net> Acked-by: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/rtc/interface.c4
-rw-r--r--drivers/rtc/rtc-dev.c6
2 files changed, 5 insertions, 5 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index a4f56e95cf96..f1e00ff54ce8 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -293,7 +293,7 @@ int rtc_irq_register(struct rtc_device *rtc, struct rtc_task *task)
293 return -EINVAL; 293 return -EINVAL;
294 294
295 /* Cannot register while the char dev is in use */ 295 /* Cannot register while the char dev is in use */
296 if (test_and_set_bit(RTC_DEV_BUSY, &rtc->flags)) 296 if (test_and_set_bit_lock(RTC_DEV_BUSY, &rtc->flags))
297 return -EBUSY; 297 return -EBUSY;
298 298
299 spin_lock_irq(&rtc->irq_task_lock); 299 spin_lock_irq(&rtc->irq_task_lock);
@@ -303,7 +303,7 @@ int rtc_irq_register(struct rtc_device *rtc, struct rtc_task *task)
303 } 303 }
304 spin_unlock_irq(&rtc->irq_task_lock); 304 spin_unlock_irq(&rtc->irq_task_lock);
305 305
306 clear_bit(RTC_DEV_BUSY, &rtc->flags); 306 clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags);
307 307
308 return retval; 308 return retval;
309} 309}
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index ae1bf177d625..025c60a17a4a 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -26,7 +26,7 @@ static int rtc_dev_open(struct inode *inode, struct file *file)
26 struct rtc_device, char_dev); 26 struct rtc_device, char_dev);
27 const struct rtc_class_ops *ops = rtc->ops; 27 const struct rtc_class_ops *ops = rtc->ops;
28 28
29 if (test_and_set_bit(RTC_DEV_BUSY, &rtc->flags)) 29 if (test_and_set_bit_lock(RTC_DEV_BUSY, &rtc->flags))
30 return -EBUSY; 30 return -EBUSY;
31 31
32 file->private_data = rtc; 32 file->private_data = rtc;
@@ -41,7 +41,7 @@ static int rtc_dev_open(struct inode *inode, struct file *file)
41 } 41 }
42 42
43 /* something has gone wrong */ 43 /* something has gone wrong */
44 clear_bit(RTC_DEV_BUSY, &rtc->flags); 44 clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags);
45 return err; 45 return err;
46} 46}
47 47
@@ -402,7 +402,7 @@ static int rtc_dev_release(struct inode *inode, struct file *file)
402 if (rtc->ops->release) 402 if (rtc->ops->release)
403 rtc->ops->release(rtc->dev.parent); 403 rtc->ops->release(rtc->dev.parent);
404 404
405 clear_bit(RTC_DEV_BUSY, &rtc->flags); 405 clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags);
406 return 0; 406 return 0;
407} 407}
408 408