patch-2.4.1 linux/drivers/sbus/char/rtc.c
Next file: linux/drivers/sbus/char/sunkbd.c
Previous file: linux/drivers/sbus/char/pcikbd.c
Back to the patch index
Back to the overall index
- Lines: 111
- Date:
Mon Jan 22 13:30:20 2001
- Orig file:
v2.4.0/linux/drivers/sbus/char/rtc.c
- Orig date:
Tue Aug 29 14:09:15 2000
diff -u --recursive --new-file v2.4.0/linux/drivers/sbus/char/rtc.c linux/drivers/sbus/char/rtc.c
@@ -1,4 +1,4 @@
-/* $Id: rtc.c,v 1.23 2000/08/29 07:01:55 davem Exp $
+/* $Id: rtc.c,v 1.24 2001/01/11 15:07:09 davem Exp $
*
* Linux/SPARC Real Time Clock Driver
* Copyright (C) 1996 Thomas K. Dyas (tdyas@eden.rutgers.edu)
@@ -31,11 +31,9 @@
void get_rtc_time(struct rtc_time *t)
{
unsigned long regs = mstk48t02_regs;
- unsigned long flags;
u8 tmp;
- save_flags(flags);
- cli();
+ spin_lock_irq(&mostek_lock);
tmp = mostek_read(regs + MOSTEK_CREG);
tmp |= MSTK_CREG_READ;
@@ -52,18 +50,18 @@
tmp = mostek_read(regs + MOSTEK_CREG);
tmp &= ~MSTK_CREG_READ;
mostek_write(regs + MOSTEK_CREG, tmp);
- restore_flags(flags);
+
+ spin_unlock_irq(&mostek_lock);
}
/* Set the current date and time inthe real time clock. */
void set_rtc_time(struct rtc_time *t)
{
unsigned long regs = mstk48t02_regs;
- unsigned long flags;
u8 tmp;
- save_flags(flags);
- cli();
+ spin_lock_irq(&mostek_lock);
+
tmp = mostek_read(regs + MOSTEK_CREG);
tmp |= MSTK_CREG_WRITE;
mostek_write(regs + MOSTEK_CREG, tmp);
@@ -79,7 +77,8 @@
tmp = mostek_read(regs + MOSTEK_CREG);
tmp &= ~MSTK_CREG_WRITE;
mostek_write(regs + MOSTEK_CREG, tmp);
- restore_flags(flags);
+
+ spin_unlock_irq(&mostek_lock);
}
static long long rtc_lseek(struct file *file, long long offset, int origin)
@@ -121,20 +120,24 @@
static int rtc_open(struct inode *inode, struct file *file)
{
+ int ret;
- if (rtc_busy)
- return -EBUSY;
-
- rtc_busy = 1;
+ spin_lock_irq(&mostek_lock);
+ if (rtc_busy) {
+ ret = -EBUSY;
+ } else {
+ rtc_busy = 1;
+ ret = 0;
+ }
+ spin_unlock_irq(&mostek_lock);
- return 0;
+ return ret;
}
static int rtc_release(struct inode *inode, struct file *file)
{
- lock_kernel();
rtc_busy = 0;
- unlock_kernel();
+
return 0;
}
@@ -150,11 +153,7 @@
EXPORT_NO_SYMBOLS;
-#ifdef MODULE
-int init_module(void)
-#else
-int __init rtc_sun_init(void)
-#endif
+static int __init rtc_sun_init(void)
{
int error;
@@ -173,9 +172,10 @@
return 0;
}
-#ifdef MODULE
-void cleanup_module(void)
+static void __exit rtc_sun_cleanup(void)
{
misc_deregister(&rtc_dev);
}
-#endif
+
+module_init(rtc_sun_init);
+module_exit(rtc_sun_cleanup);
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)