diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2008-07-25 04:48:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-25 13:53:43 -0400 |
commit | b8e35919653d76e7dceb8d3b8569c4ec1004d546 (patch) | |
tree | 39d61f03073d2481bf2a9e708554dde57ef37a14 /drivers/char | |
parent | 6d535d3e6ad395345750c361bd2b7f1b9429455d (diff) |
ds1302: push down the BKL into the driver ioctl code
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/ds1302.c | 17 |
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 | ||
156 | static int | 157 | static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
157 | rtc_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 | ||
283 | static const struct file_operations rtc_fops = { | 288 | static 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. */ |