Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=372a302e9a892229206aafca0352584a745bc5f3
Commit:     372a302e9a892229206aafca0352584a745bc5f3
Parent:     5cd17569fd0eeca510735e63a6061291e3971bf6
Author:     Jiri Kosina <[EMAIL PROTECTED]>
AuthorDate: Tue Dec 4 23:45:05 2007 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Wed Dec 5 09:21:18 2007 -0800

    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 <[EMAIL PROTECTED]>
    Cc: Nick Piggin <[EMAIL PROTECTED]>
    Cc: David Brownell <[EMAIL PROTECTED]>
    Acked-by: Alessandro Zummo <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 drivers/rtc/interface.c |    4 ++--
 drivers/rtc/rtc-dev.c   |    6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index a4f56e9..f1e00ff 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)
                return -EINVAL;
 
        /* Cannot register while the char dev is in use */
-       if (test_and_set_bit(RTC_DEV_BUSY, &rtc->flags))
+       if (test_and_set_bit_lock(RTC_DEV_BUSY, &rtc->flags))
                return -EBUSY;
 
        spin_lock_irq(&rtc->irq_task_lock);
@@ -303,7 +303,7 @@ int rtc_irq_register(struct rtc_device *rtc, struct 
rtc_task *task)
        }
        spin_unlock_irq(&rtc->irq_task_lock);
 
-       clear_bit(RTC_DEV_BUSY, &rtc->flags);
+       clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags);
 
        return retval;
 }
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index ae1bf17..025c60a 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)
                                        struct rtc_device, char_dev);
        const struct rtc_class_ops *ops = rtc->ops;
 
-       if (test_and_set_bit(RTC_DEV_BUSY, &rtc->flags))
+       if (test_and_set_bit_lock(RTC_DEV_BUSY, &rtc->flags))
                return -EBUSY;
 
        file->private_data = rtc;
@@ -41,7 +41,7 @@ static int rtc_dev_open(struct inode *inode, struct file 
*file)
        }
 
        /* something has gone wrong */
-       clear_bit(RTC_DEV_BUSY, &rtc->flags);
+       clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags);
        return err;
 }
 
@@ -402,7 +402,7 @@ static int rtc_dev_release(struct inode *inode, struct file 
*file)
        if (rtc->ops->release)
                rtc->ops->release(rtc->dev.parent);
 
-       clear_bit(RTC_DEV_BUSY, &rtc->flags);
+       clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags);
        return 0;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to