Skip to content

Commit b8e3591

Browse files
Alan-Coxtorvalds
authored andcommitted
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>
1 parent 6d535d3 commit b8e3591

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

‎drivers/char/ds1302.c‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
#include <linux/miscdevice.h>
2121
#include <linux/delay.h>
2222
#include <linux/bcd.h>
23+
#include <linux/smp_lock.h>
24+
#include <linux/uaccess.h>
25+
#include <linux/io.h>
2326

24-
#include <asm/uaccess.h>
2527
#include <asm/system.h>
26-
#include <asm/io.h>
2728
#include <asm/rtc.h>
2829
#if defined(CONFIG_M32R)
2930
#include <asm/m32r.h>
@@ -153,9 +154,7 @@ static unsigned char days_in_mo[] =
153154

154155
/* ioctl that supports RTC_RD_TIME and RTC_SET_TIME (read and set time/date). */
155156

156-
static int
157-
rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
158-
unsigned long arg)
157+
static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
159158
{
160159
unsigned long flags;
161160

@@ -165,7 +164,9 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
165164
struct rtc_time rtc_tm;
166165

167166
memset(&rtc_tm, 0, sizeof (struct rtc_time));
167+
lock_kernel();
168168
get_rtc_time(&rtc_tm);
169+
unlock_kernel();
169170
if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time)))
170171
return -EFAULT;
171172
return 0;
@@ -217,6 +218,7 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
217218
BIN_TO_BCD(mon);
218219
BIN_TO_BCD(yrs);
219220

221+
lock_kernel();
220222
local_irq_save(flags);
221223
CMOS_WRITE(yrs, RTC_YEAR);
222224
CMOS_WRITE(mon, RTC_MONTH);
@@ -225,6 +227,7 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
225227
CMOS_WRITE(min, RTC_MINUTES);
226228
CMOS_WRITE(sec, RTC_SECONDS);
227229
local_irq_restore(flags);
230+
unlock_kernel();
228231

229232
/* Notice that at this point, the RTC is updated but
230233
* the kernel is still running with the old time.
@@ -244,8 +247,10 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
244247
if(copy_from_user(&tcs_val, (int*)arg, sizeof(int)))
245248
return -EFAULT;
246249

250+
lock_kernel();
247251
tcs_val = RTC_TCR_PATTERN | (tcs_val & 0x0F);
248252
ds1302_writereg(RTC_TRICKLECHARGER, tcs_val);
253+
unlock_kernel();
249254
return 0;
250255
}
251256
default:
@@ -282,7 +287,7 @@ get_rtc_status(char *buf)
282287

283288
static const struct file_operations rtc_fops = {
284289
.owner = THIS_MODULE,
285-
.ioctl = rtc_ioctl,
290+
.unlocked_ioctl = rtc_ioctl,
286291
};
287292

288293
/* Probe for the chip by writing something to its RAM and try reading it back. */

0 commit comments

Comments
 (0)