This patch removes the unneeded lock_kernel added during the latest BKL removal
and prepares the open function for the next BKL removal.
--- linux-2.4.0-test4-pre6/drivers/char/rtc.c Thu Jul 13 12:02:14 2000
+++ linux-2.4.0-test4-pre6.patch/drivers/char/rtc.c Thu Jul 13 13:28:35 2000
@@ -65,7 +65,6 @@
#include <linux/poll.h>
#include <linux/proc_fs.h>
#include <linux/spinlock.h>
-#include <linux/smp_lock.h>
#include <asm/io.h>
#include <asm/uaccess.h>
@@ -507,19 +506,24 @@
* up things on a close.
*/
+/* We use rtc_lock to protect against concurrent opens. So the BKL is not
+ * needed here. Or anywhere else in this driver. */
static int rtc_open(struct inode *inode, struct file *file)
{
- /* If someday somebody decides to remove the kernel_lock on open and
- * close and ioctl this is gonna get open to races */
+ spin_lock_irq (&rtc_lock);
+
if(rtc_status & RTC_IS_OPEN)
- return -EBUSY;
+ goto out_busy;
rtc_status |= RTC_IS_OPEN;
- spin_lock_irq (&rtc_lock);
rtc_irq_data = 0;
spin_unlock_irq (&rtc_lock);
return 0;
+
+out_busy:
+ spin_unlock_irq (&rtc_lock);
+ return -EBUSY;
}
static int rtc_fasync (int fd, struct file *filp, int on)
@@ -538,7 +542,6 @@
unsigned char tmp;
- lock_kernel();
spin_lock_irq(&rtc_lock);
tmp = CMOS_READ(RTC_CONTROL);
tmp &= ~RTC_PIE;
@@ -556,16 +559,15 @@
if (file->f_flags & FASYNC) {
rtc_fasync (-1, file, 0);
}
-
-#else
- lock_kernel();
#endif
spin_lock_irq (&rtc_lock);
rtc_irq_data = 0;
spin_unlock_irq (&rtc_lock);
- rtc_status = rtc_status & ~RTC_IS_OPEN;
- unlock_kernel();
+
+ /* No need for locking -- nobody else can do anything until this rmw is
+ * committed, and no timer is running. */
+ rtc_status &= ~RTC_IS_OPEN;
return 0;
}
-- Cesar Eduardo Barros cesarb@nitnet.com.br cesarb@dcc.ufrj.br- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Sat Jul 15 2000 - 21:00:17 EST