aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/ds1302.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/char/ds1302.c b/drivers/char/ds1302.c
index fada6ddefbae..c5e67a623951 100644
--- a/drivers/char/ds1302.c
+++ b/drivers/char/ds1302.c
@@ -20,10 +20,11 @@
20#include <linux/miscdevice.h> 20#include <linux/miscdevice.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/bcd.h> 22#include <linux/bcd.h>
23#include <linux/smp_lock.h>
24#include <linux/uaccess.h>
25#include <linux/io.h>
23 26
24#include <asm/uaccess.h>
25#include <asm/system.h> 27#include <asm/system.h>
26#include <asm/io.h>
27#include <asm/rtc.h> 28#include <asm/rtc.h>
28#if defined(CONFIG_M32R) 29#if defined(CONFIG_M32R)
29#include <asm/m32r.h> 30#include <asm/m32r.h>
@@ -153,9 +154,7 @@ static unsigned char days_in_mo[] =
153 154
154/* ioctl that supports RTC_RD_TIME and RTC_SET_TIME (read and set time/date). */ 155/* ioctl that supports RTC_RD_TIME and RTC_SET_TIME (read and set time/date). */
155 156
156static int 157static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
157rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
158 unsigned long arg)
159{ 158{
160 unsigned long flags; 159 unsigned long flags;
161 160
@@ -165,7 +164,9 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
165 struct rtc_time rtc_tm; 164 struct rtc_time rtc_tm;
166 165
167 memset(&rtc_tm, 0, sizeof (struct rtc_time)); 166 memset(&rtc_tm, 0, sizeof (struct rtc_time));
167 lock_kernel();
168 get_rtc_time(&rtc_tm); 168 get_rtc_time(&rtc_tm);
169 unlock_kernel();
169 if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time))) 170 if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time)))
170 return -EFAULT; 171 return -EFAULT;
171 return 0; 172 return 0;
@@ -217,6 +218,7 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
217 BIN_TO_BCD(mon); 218 BIN_TO_BCD(mon);
218 BIN_TO_BCD(yrs); 219 BIN_TO_BCD(yrs);
219 220
221 lock_kernel();
220 local_irq_save(flags); 222 local_irq_save(flags);
221 CMOS_WRITE(yrs, RTC_YEAR); 223 CMOS_WRITE(yrs, RTC_YEAR);
222 CMOS_WRITE(mon, RTC_MONTH); 224 CMOS_WRITE(mon, RTC_MONTH);
@@ -225,6 +227,7 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
225 CMOS_WRITE(min, RTC_MINUTES); 227 CMOS_WRITE(min, RTC_MINUTES);
226 CMOS_WRITE(sec, RTC_SECONDS); 228 CMOS_WRITE(sec, RTC_SECONDS);
227 local_irq_restore(flags); 229 local_irq_restore(flags);
230 unlock_kernel();
228 231
229 /* Notice that at this point, the RTC is updated but 232 /* Notice that at this point, the RTC is updated but
230 * the kernel is still running with the old time. 233 * the kernel is still running with the old time.
@@ -244,8 +247,10 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
244 if(copy_from_user(&tcs_val, (int*)arg, sizeof(int))) 247 if(copy_from_user(&tcs_val, (int*)arg, sizeof(int)))
245 return -EFAULT; 248 return -EFAULT;
246 249
250 lock_kernel();
247 tcs_val = RTC_TCR_PATTERN | (tcs_val & 0x0F); 251 tcs_val = RTC_TCR_PATTERN | (tcs_val & 0x0F);
248 ds1302_writereg(RTC_TRICKLECHARGER, tcs_val); 252 ds1302_writereg(RTC_TRICKLECHARGER, tcs_val);
253 unlock_kernel();
249 return 0; 254 return 0;
250 } 255 }
251 default: 256 default:
@@ -282,7 +287,7 @@ get_rtc_status(char *buf)
282 287
283static const struct file_operations rtc_fops = { 288static const struct file_operations rtc_fops = {
284 .owner = THIS_MODULE, 289 .owner = THIS_MODULE,
285 .ioctl = rtc_ioctl, 290 .unlocked_ioctl = rtc_ioctl,
286}; 291};
287 292
288/* Probe for the chip by writing something to its RAM and try reading it back. */ 293/* Probe for the chip by writing something to its RAM and try reading it back. */