patch-2.1.60 linux/drivers/char/rtc.c

Next file: linux/drivers/char/tty_io.c
Previous file: linux/drivers/char/random.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.59/linux/drivers/char/rtc.c linux/drivers/char/rtc.c
@@ -78,8 +78,8 @@
 
 static long long rtc_llseek(struct file *file, loff_t offset, int origin);
 
-static long rtc_read(struct inode *inode, struct file *file,
-			char *buf, unsigned long count);
+static ssize_t rtc_read(struct file *file, char *buf,
+			size_t count, loff_t *ppos);
 
 static int rtc_ioctl(struct inode *inode, struct file *file,
 			unsigned int cmd, unsigned long arg);
@@ -146,11 +146,12 @@
 	return -ESPIPE;
 }
 
-static long rtc_read(struct inode *inode, struct file *file, char *buf,
-		     unsigned long count)
+static ssize_t rtc_read(struct file *file, char *buf,
+			size_t count, loff_t *ppos)
 {
 	struct wait_queue wait = { current, NULL };
-	int retval = 0;
+	unsigned long data;
+	ssize_t retval;
 	
 	if (count < sizeof(unsigned long))
 		return -EINVAL;
@@ -159,30 +160,22 @@
 
 	current->state = TASK_INTERRUPTIBLE;
 		
-	while (rtc_irq_data == 0) {
+	while ((data = xchg(&rtc_irq_data, 0)) == 0) {
 		if (file->f_flags & O_NONBLOCK) {
 			retval = -EAGAIN;
-			break;
+			goto out;
 		}
 		if (signal_pending(current)) {
 			retval = -ERESTARTSYS;
-			break;
+			goto out;
 		}
 		schedule();
 	}
 
-	if (retval == 0) {
-		unsigned long data, flags;
-		save_flags(flags);
-		cli();
-		data = rtc_irq_data;
-		rtc_irq_data = 0;
-		restore_flags(flags);
-		retval = put_user(data, (unsigned long *)buf); 
-		if (!retval)
-			retval = sizeof(unsigned long); 
-	}
-
+	retval = put_user(data, (unsigned long *)buf); 
+	if (!retval)
+		retval = sizeof(unsigned long); 
+out:
 	current->state = TASK_RUNNING;
 	remove_wait_queue(&rtc_wait, &wait);
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov