diff options
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/hpet.c | 98 | ||||
-rw-r--r-- | drivers/char/raw.c | 243 | ||||
-rw-r--r-- | drivers/char/tlclk.c | 6 |
3 files changed, 207 insertions, 140 deletions
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index a0a1829d3198..a4eee324eb1e 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/bcd.h> | 30 | #include <linux/bcd.h> |
31 | #include <linux/seq_file.h> | 31 | #include <linux/seq_file.h> |
32 | #include <linux/bitops.h> | 32 | #include <linux/bitops.h> |
33 | #include <linux/compat.h> | ||
33 | #include <linux/clocksource.h> | 34 | #include <linux/clocksource.h> |
34 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
35 | 36 | ||
@@ -67,6 +68,7 @@ | |||
67 | #define read_counter(MC) readl(MC) | 68 | #define read_counter(MC) readl(MC) |
68 | #endif | 69 | #endif |
69 | 70 | ||
71 | static DEFINE_MUTEX(hpet_mutex); /* replaces BKL */ | ||
70 | static u32 hpet_nhpet, hpet_max_freq = HPET_USER_FREQ; | 72 | static u32 hpet_nhpet, hpet_max_freq = HPET_USER_FREQ; |
71 | 73 | ||
72 | /* This clocksource driver currently only works on ia64 */ | 74 | /* This clocksource driver currently only works on ia64 */ |
@@ -250,7 +252,7 @@ static int hpet_open(struct inode *inode, struct file *file) | |||
250 | if (file->f_mode & FMODE_WRITE) | 252 | if (file->f_mode & FMODE_WRITE) |
251 | return -EINVAL; | 253 | return -EINVAL; |
252 | 254 | ||
253 | lock_kernel(); | 255 | mutex_lock(&hpet_mutex); |
254 | spin_lock_irq(&hpet_lock); | 256 | spin_lock_irq(&hpet_lock); |
255 | 257 | ||
256 | for (devp = NULL, hpetp = hpets; hpetp && !devp; hpetp = hpetp->hp_next) | 258 | for (devp = NULL, hpetp = hpets; hpetp && !devp; hpetp = hpetp->hp_next) |
@@ -264,7 +266,7 @@ static int hpet_open(struct inode *inode, struct file *file) | |||
264 | 266 | ||
265 | if (!devp) { | 267 | if (!devp) { |
266 | spin_unlock_irq(&hpet_lock); | 268 | spin_unlock_irq(&hpet_lock); |
267 | unlock_kernel(); | 269 | mutex_unlock(&hpet_mutex); |
268 | return -EBUSY; | 270 | return -EBUSY; |
269 | } | 271 | } |
270 | 272 | ||
@@ -272,7 +274,7 @@ static int hpet_open(struct inode *inode, struct file *file) | |||
272 | devp->hd_irqdata = 0; | 274 | devp->hd_irqdata = 0; |
273 | devp->hd_flags |= HPET_OPEN; | 275 | devp->hd_flags |= HPET_OPEN; |
274 | spin_unlock_irq(&hpet_lock); | 276 | spin_unlock_irq(&hpet_lock); |
275 | unlock_kernel(); | 277 | mutex_unlock(&hpet_mutex); |
276 | 278 | ||
277 | hpet_timer_set_irq(devp); | 279 | hpet_timer_set_irq(devp); |
278 | 280 | ||
@@ -429,22 +431,6 @@ static int hpet_release(struct inode *inode, struct file *file) | |||
429 | return 0; | 431 | return 0; |
430 | } | 432 | } |
431 | 433 | ||
432 | static int hpet_ioctl_common(struct hpet_dev *, int, unsigned long, int); | ||
433 | |||
434 | static long hpet_ioctl(struct file *file, unsigned int cmd, | ||
435 | unsigned long arg) | ||
436 | { | ||
437 | struct hpet_dev *devp; | ||
438 | int ret; | ||
439 | |||
440 | devp = file->private_data; | ||
441 | lock_kernel(); | ||
442 | ret = hpet_ioctl_common(devp, cmd, arg, 0); | ||
443 | unlock_kernel(); | ||
444 | |||
445 | return ret; | ||
446 | } | ||
447 | |||
448 | static int hpet_ioctl_ieon(struct hpet_dev *devp) | 434 | static int hpet_ioctl_ieon(struct hpet_dev *devp) |
449 | { | 435 | { |
450 | struct hpet_timer __iomem *timer; | 436 | struct hpet_timer __iomem *timer; |
@@ -553,7 +539,8 @@ static inline unsigned long hpet_time_div(struct hpets *hpets, | |||
553 | } | 539 | } |
554 | 540 | ||
555 | static int | 541 | static int |
556 | hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel) | 542 | hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, |
543 | struct hpet_info *info) | ||
557 | { | 544 | { |
558 | struct hpet_timer __iomem *timer; | 545 | struct hpet_timer __iomem *timer; |
559 | struct hpet __iomem *hpet; | 546 | struct hpet __iomem *hpet; |
@@ -594,23 +581,15 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel) | |||
594 | break; | 581 | break; |
595 | case HPET_INFO: | 582 | case HPET_INFO: |
596 | { | 583 | { |
597 | struct hpet_info info; | ||
598 | |||
599 | if (devp->hd_ireqfreq) | 584 | if (devp->hd_ireqfreq) |
600 | info.hi_ireqfreq = | 585 | info->hi_ireqfreq = |
601 | hpet_time_div(hpetp, devp->hd_ireqfreq); | 586 | hpet_time_div(hpetp, devp->hd_ireqfreq); |
602 | else | 587 | else |
603 | info.hi_ireqfreq = 0; | 588 | info->hi_ireqfreq = 0; |
604 | info.hi_flags = | 589 | info->hi_flags = |
605 | readq(&timer->hpet_config) & Tn_PER_INT_CAP_MASK; | 590 | readq(&timer->hpet_config) & Tn_PER_INT_CAP_MASK; |
606 | info.hi_hpet = hpetp->hp_which; | 591 | info->hi_hpet = hpetp->hp_which; |
607 | info.hi_timer = devp - hpetp->hp_dev; | 592 | info->hi_timer = devp - hpetp->hp_dev; |
608 | if (kernel) | ||
609 | memcpy((void *)arg, &info, sizeof(info)); | ||
610 | else | ||
611 | if (copy_to_user((void __user *)arg, &info, | ||
612 | sizeof(info))) | ||
613 | err = -EFAULT; | ||
614 | break; | 593 | break; |
615 | } | 594 | } |
616 | case HPET_EPI: | 595 | case HPET_EPI: |
@@ -636,7 +615,7 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel) | |||
636 | devp->hd_flags &= ~HPET_PERIODIC; | 615 | devp->hd_flags &= ~HPET_PERIODIC; |
637 | break; | 616 | break; |
638 | case HPET_IRQFREQ: | 617 | case HPET_IRQFREQ: |
639 | if (!kernel && (arg > hpet_max_freq) && | 618 | if ((arg > hpet_max_freq) && |
640 | !capable(CAP_SYS_RESOURCE)) { | 619 | !capable(CAP_SYS_RESOURCE)) { |
641 | err = -EACCES; | 620 | err = -EACCES; |
642 | break; | 621 | break; |
@@ -653,12 +632,63 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel) | |||
653 | return err; | 632 | return err; |
654 | } | 633 | } |
655 | 634 | ||
635 | static long | ||
636 | hpet_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
637 | { | ||
638 | struct hpet_info info; | ||
639 | int err; | ||
640 | |||
641 | mutex_lock(&hpet_mutex); | ||
642 | err = hpet_ioctl_common(file->private_data, cmd, arg, &info); | ||
643 | mutex_unlock(&hpet_mutex); | ||
644 | |||
645 | if ((cmd == HPET_INFO) && !err && | ||
646 | (copy_to_user((void __user *)arg, &info, sizeof(info)))) | ||
647 | err = -EFAULT; | ||
648 | |||
649 | return err; | ||
650 | } | ||
651 | |||
652 | #ifdef CONFIG_COMPAT | ||
653 | struct compat_hpet_info { | ||
654 | compat_ulong_t hi_ireqfreq; /* Hz */ | ||
655 | compat_ulong_t hi_flags; /* information */ | ||
656 | unsigned short hi_hpet; | ||
657 | unsigned short hi_timer; | ||
658 | }; | ||
659 | |||
660 | static long | ||
661 | hpet_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
662 | { | ||
663 | struct hpet_info info; | ||
664 | int err; | ||
665 | |||
666 | mutex_lock(&hpet_mutex); | ||
667 | err = hpet_ioctl_common(file->private_data, cmd, arg, &info); | ||
668 | mutex_unlock(&hpet_mutex); | ||
669 | |||
670 | if ((cmd == HPET_INFO) && !err) { | ||
671 | struct compat_hpet_info __user *u = compat_ptr(arg); | ||
672 | if (put_user(info.hi_ireqfreq, &u->hi_ireqfreq) || | ||
673 | put_user(info.hi_flags, &u->hi_flags) || | ||
674 | put_user(info.hi_hpet, &u->hi_hpet) || | ||
675 | put_user(info.hi_timer, &u->hi_timer)) | ||
676 | err = -EFAULT; | ||
677 | } | ||
678 | |||
679 | return err; | ||
680 | } | ||
681 | #endif | ||
682 | |||
656 | static const struct file_operations hpet_fops = { | 683 | static const struct file_operations hpet_fops = { |
657 | .owner = THIS_MODULE, | 684 | .owner = THIS_MODULE, |
658 | .llseek = no_llseek, | 685 | .llseek = no_llseek, |
659 | .read = hpet_read, | 686 | .read = hpet_read, |
660 | .poll = hpet_poll, | 687 | .poll = hpet_poll, |
661 | .unlocked_ioctl = hpet_ioctl, | 688 | .unlocked_ioctl = hpet_ioctl, |
689 | #ifdef CONFIG_COMPAT | ||
690 | .compat_ioctl = hpet_compat_ioctl, | ||
691 | #endif | ||
662 | .open = hpet_open, | 692 | .open = hpet_open, |
663 | .release = hpet_release, | 693 | .release = hpet_release, |
664 | .fasync = hpet_fasync, | 694 | .fasync = hpet_fasync, |
diff --git a/drivers/char/raw.c b/drivers/char/raw.c index b38942f6bf31..24b2b9160aa6 100644 --- a/drivers/char/raw.c +++ b/drivers/char/raw.c | |||
@@ -19,8 +19,8 @@ | |||
19 | #include <linux/cdev.h> | 19 | #include <linux/cdev.h> |
20 | #include <linux/device.h> | 20 | #include <linux/device.h> |
21 | #include <linux/mutex.h> | 21 | #include <linux/mutex.h> |
22 | #include <linux/smp_lock.h> | ||
23 | #include <linux/gfp.h> | 22 | #include <linux/gfp.h> |
23 | #include <linux/compat.h> | ||
24 | 24 | ||
25 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
26 | 26 | ||
@@ -55,7 +55,6 @@ static int raw_open(struct inode *inode, struct file *filp) | |||
55 | return 0; | 55 | return 0; |
56 | } | 56 | } |
57 | 57 | ||
58 | lock_kernel(); | ||
59 | mutex_lock(&raw_mutex); | 58 | mutex_lock(&raw_mutex); |
60 | 59 | ||
61 | /* | 60 | /* |
@@ -82,7 +81,6 @@ static int raw_open(struct inode *inode, struct file *filp) | |||
82 | bdev->bd_inode->i_mapping; | 81 | bdev->bd_inode->i_mapping; |
83 | filp->private_data = bdev; | 82 | filp->private_data = bdev; |
84 | mutex_unlock(&raw_mutex); | 83 | mutex_unlock(&raw_mutex); |
85 | unlock_kernel(); | ||
86 | return 0; | 84 | return 0; |
87 | 85 | ||
88 | out2: | 86 | out2: |
@@ -91,7 +89,6 @@ out1: | |||
91 | blkdev_put(bdev, filp->f_mode); | 89 | blkdev_put(bdev, filp->f_mode); |
92 | out: | 90 | out: |
93 | mutex_unlock(&raw_mutex); | 91 | mutex_unlock(&raw_mutex); |
94 | unlock_kernel(); | ||
95 | return err; | 92 | return err; |
96 | } | 93 | } |
97 | 94 | ||
@@ -125,20 +122,84 @@ static long | |||
125 | raw_ioctl(struct file *filp, unsigned int command, unsigned long arg) | 122 | raw_ioctl(struct file *filp, unsigned int command, unsigned long arg) |
126 | { | 123 | { |
127 | struct block_device *bdev = filp->private_data; | 124 | struct block_device *bdev = filp->private_data; |
128 | int ret; | 125 | return blkdev_ioctl(bdev, 0, command, arg); |
126 | } | ||
127 | |||
128 | static int bind_set(int number, u64 major, u64 minor) | ||
129 | { | ||
130 | dev_t dev = MKDEV(major, minor); | ||
131 | struct raw_device_data *rawdev; | ||
132 | int err = 0; | ||
129 | 133 | ||
130 | lock_kernel(); | 134 | if (number <= 0 || number >= MAX_RAW_MINORS) |
131 | ret = blkdev_ioctl(bdev, 0, command, arg); | 135 | return -EINVAL; |
132 | unlock_kernel(); | ||
133 | 136 | ||
134 | return ret; | 137 | if (MAJOR(dev) != major || MINOR(dev) != minor) |
138 | return -EINVAL; | ||
139 | |||
140 | rawdev = &raw_devices[number]; | ||
141 | |||
142 | /* | ||
143 | * This is like making block devices, so demand the | ||
144 | * same capability | ||
145 | */ | ||
146 | if (!capable(CAP_SYS_ADMIN)) | ||
147 | return -EPERM; | ||
148 | |||
149 | /* | ||
150 | * For now, we don't need to check that the underlying | ||
151 | * block device is present or not: we can do that when | ||
152 | * the raw device is opened. Just check that the | ||
153 | * major/minor numbers make sense. | ||
154 | */ | ||
155 | |||
156 | if (MAJOR(dev) == 0 && dev != 0) | ||
157 | return -EINVAL; | ||
158 | |||
159 | mutex_lock(&raw_mutex); | ||
160 | if (rawdev->inuse) { | ||
161 | mutex_unlock(&raw_mutex); | ||
162 | return -EBUSY; | ||
163 | } | ||
164 | if (rawdev->binding) { | ||
165 | bdput(rawdev->binding); | ||
166 | module_put(THIS_MODULE); | ||
167 | } | ||
168 | if (!dev) { | ||
169 | /* unbind */ | ||
170 | rawdev->binding = NULL; | ||
171 | device_destroy(raw_class, MKDEV(RAW_MAJOR, number)); | ||
172 | } else { | ||
173 | rawdev->binding = bdget(dev); | ||
174 | if (rawdev->binding == NULL) { | ||
175 | err = -ENOMEM; | ||
176 | } else { | ||
177 | dev_t raw = MKDEV(RAW_MAJOR, number); | ||
178 | __module_get(THIS_MODULE); | ||
179 | device_destroy(raw_class, raw); | ||
180 | device_create(raw_class, NULL, raw, NULL, | ||
181 | "raw%d", number); | ||
182 | } | ||
183 | } | ||
184 | mutex_unlock(&raw_mutex); | ||
185 | return err; | ||
135 | } | 186 | } |
136 | 187 | ||
137 | static void bind_device(struct raw_config_request *rq) | 188 | static int bind_get(int number, dev_t *dev) |
138 | { | 189 | { |
139 | device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor)); | 190 | struct raw_device_data *rawdev; |
140 | device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor), NULL, | 191 | struct block_device *bdev; |
141 | "raw%d", rq->raw_minor); | 192 | |
193 | if (number <= 0 || number >= MAX_RAW_MINORS) | ||
194 | return -EINVAL; | ||
195 | |||
196 | rawdev = &raw_devices[number]; | ||
197 | |||
198 | mutex_lock(&raw_mutex); | ||
199 | bdev = rawdev->binding; | ||
200 | *dev = bdev ? bdev->bd_dev : 0; | ||
201 | mutex_unlock(&raw_mutex); | ||
202 | return 0; | ||
142 | } | 203 | } |
143 | 204 | ||
144 | /* | 205 | /* |
@@ -149,105 +210,78 @@ static long raw_ctl_ioctl(struct file *filp, unsigned int command, | |||
149 | unsigned long arg) | 210 | unsigned long arg) |
150 | { | 211 | { |
151 | struct raw_config_request rq; | 212 | struct raw_config_request rq; |
152 | struct raw_device_data *rawdev; | 213 | dev_t dev; |
153 | int err = 0; | 214 | int err; |
154 | 215 | ||
155 | lock_kernel(); | ||
156 | switch (command) { | 216 | switch (command) { |
157 | case RAW_SETBIND: | 217 | case RAW_SETBIND: |
218 | if (copy_from_user(&rq, (void __user *) arg, sizeof(rq))) | ||
219 | return -EFAULT; | ||
220 | |||
221 | return bind_set(rq.raw_minor, rq.block_major, rq.block_minor); | ||
222 | |||
158 | case RAW_GETBIND: | 223 | case RAW_GETBIND: |
224 | if (copy_from_user(&rq, (void __user *) arg, sizeof(rq))) | ||
225 | return -EFAULT; | ||
159 | 226 | ||
160 | /* First, find out which raw minor we want */ | 227 | err = bind_get(rq.raw_minor, &dev); |
228 | if (err) | ||
229 | return err; | ||
161 | 230 | ||
162 | if (copy_from_user(&rq, (void __user *) arg, sizeof(rq))) { | 231 | rq.block_major = MAJOR(dev); |
163 | err = -EFAULT; | 232 | rq.block_minor = MINOR(dev); |
164 | goto out; | ||
165 | } | ||
166 | 233 | ||
167 | if (rq.raw_minor <= 0 || rq.raw_minor >= MAX_RAW_MINORS) { | 234 | if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) |
168 | err = -EINVAL; | 235 | return -EFAULT; |
169 | goto out; | 236 | |
170 | } | 237 | return 0; |
171 | rawdev = &raw_devices[rq.raw_minor]; | ||
172 | |||
173 | if (command == RAW_SETBIND) { | ||
174 | dev_t dev; | ||
175 | |||
176 | /* | ||
177 | * This is like making block devices, so demand the | ||
178 | * same capability | ||
179 | */ | ||
180 | if (!capable(CAP_SYS_ADMIN)) { | ||
181 | err = -EPERM; | ||
182 | goto out; | ||
183 | } | ||
184 | |||
185 | /* | ||
186 | * For now, we don't need to check that the underlying | ||
187 | * block device is present or not: we can do that when | ||
188 | * the raw device is opened. Just check that the | ||
189 | * major/minor numbers make sense. | ||
190 | */ | ||
191 | |||
192 | dev = MKDEV(rq.block_major, rq.block_minor); | ||
193 | if ((rq.block_major == 0 && rq.block_minor != 0) || | ||
194 | MAJOR(dev) != rq.block_major || | ||
195 | MINOR(dev) != rq.block_minor) { | ||
196 | err = -EINVAL; | ||
197 | goto out; | ||
198 | } | ||
199 | |||
200 | mutex_lock(&raw_mutex); | ||
201 | if (rawdev->inuse) { | ||
202 | mutex_unlock(&raw_mutex); | ||
203 | err = -EBUSY; | ||
204 | goto out; | ||
205 | } | ||
206 | if (rawdev->binding) { | ||
207 | bdput(rawdev->binding); | ||
208 | module_put(THIS_MODULE); | ||
209 | } | ||
210 | if (rq.block_major == 0 && rq.block_minor == 0) { | ||
211 | /* unbind */ | ||
212 | rawdev->binding = NULL; | ||
213 | device_destroy(raw_class, | ||
214 | MKDEV(RAW_MAJOR, rq.raw_minor)); | ||
215 | } else { | ||
216 | rawdev->binding = bdget(dev); | ||
217 | if (rawdev->binding == NULL) | ||
218 | err = -ENOMEM; | ||
219 | else { | ||
220 | __module_get(THIS_MODULE); | ||
221 | bind_device(&rq); | ||
222 | } | ||
223 | } | ||
224 | mutex_unlock(&raw_mutex); | ||
225 | } else { | ||
226 | struct block_device *bdev; | ||
227 | |||
228 | mutex_lock(&raw_mutex); | ||
229 | bdev = rawdev->binding; | ||
230 | if (bdev) { | ||
231 | rq.block_major = MAJOR(bdev->bd_dev); | ||
232 | rq.block_minor = MINOR(bdev->bd_dev); | ||
233 | } else { | ||
234 | rq.block_major = rq.block_minor = 0; | ||
235 | } | ||
236 | mutex_unlock(&raw_mutex); | ||
237 | if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) { | ||
238 | err = -EFAULT; | ||
239 | goto out; | ||
240 | } | ||
241 | } | ||
242 | break; | ||
243 | default: | ||
244 | err = -EINVAL; | ||
245 | break; | ||
246 | } | 238 | } |
247 | out: | 239 | |
248 | unlock_kernel(); | 240 | return -EINVAL; |
249 | return err; | 241 | } |
242 | |||
243 | #ifdef CONFIG_COMPAT | ||
244 | struct raw32_config_request { | ||
245 | compat_int_t raw_minor; | ||
246 | compat_u64 block_major; | ||
247 | compat_u64 block_minor; | ||
248 | }; | ||
249 | |||
250 | static long raw_ctl_compat_ioctl(struct file *file, unsigned int cmd, | ||
251 | unsigned long arg) | ||
252 | { | ||
253 | struct raw32_config_request __user *user_req = compat_ptr(arg); | ||
254 | struct raw32_config_request rq; | ||
255 | dev_t dev; | ||
256 | int err = 0; | ||
257 | |||
258 | switch (cmd) { | ||
259 | case RAW_SETBIND: | ||
260 | if (copy_from_user(&rq, user_req, sizeof(rq))) | ||
261 | return -EFAULT; | ||
262 | |||
263 | return bind_set(rq.raw_minor, rq.block_major, rq.block_minor); | ||
264 | |||
265 | case RAW_GETBIND: | ||
266 | if (copy_from_user(&rq, user_req, sizeof(rq))) | ||
267 | return -EFAULT; | ||
268 | |||
269 | err = bind_get(rq.raw_minor, &dev); | ||
270 | if (err) | ||
271 | return err; | ||
272 | |||
273 | rq.block_major = MAJOR(dev); | ||
274 | rq.block_minor = MINOR(dev); | ||
275 | |||
276 | if (copy_to_user(user_req, &rq, sizeof(rq))) | ||
277 | return -EFAULT; | ||
278 | |||
279 | return 0; | ||
280 | } | ||
281 | |||
282 | return -EINVAL; | ||
250 | } | 283 | } |
284 | #endif | ||
251 | 285 | ||
252 | static const struct file_operations raw_fops = { | 286 | static const struct file_operations raw_fops = { |
253 | .read = do_sync_read, | 287 | .read = do_sync_read, |
@@ -263,6 +297,9 @@ static const struct file_operations raw_fops = { | |||
263 | 297 | ||
264 | static const struct file_operations raw_ctl_fops = { | 298 | static const struct file_operations raw_ctl_fops = { |
265 | .unlocked_ioctl = raw_ctl_ioctl, | 299 | .unlocked_ioctl = raw_ctl_ioctl, |
300 | #ifdef CONFIG_COMPAT | ||
301 | .compat_ioctl = raw_ctl_compat_ioctl, | ||
302 | #endif | ||
266 | .open = raw_open, | 303 | .open = raw_open, |
267 | .owner = THIS_MODULE, | 304 | .owner = THIS_MODULE, |
268 | }; | 305 | }; |
diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c index 80ea6bcfffdc..e32cbf0c9a0b 100644 --- a/drivers/char/tlclk.c +++ b/drivers/char/tlclk.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <linux/ioport.h> | 37 | #include <linux/ioport.h> |
38 | #include <linux/interrupt.h> | 38 | #include <linux/interrupt.h> |
39 | #include <linux/spinlock.h> | 39 | #include <linux/spinlock.h> |
40 | #include <linux/smp_lock.h> | 40 | #include <linux/mutex.h> |
41 | #include <linux/timer.h> | 41 | #include <linux/timer.h> |
42 | #include <linux/sysfs.h> | 42 | #include <linux/sysfs.h> |
43 | #include <linux/device.h> | 43 | #include <linux/device.h> |
@@ -206,7 +206,7 @@ static int tlclk_open(struct inode *inode, struct file *filp) | |||
206 | { | 206 | { |
207 | int result; | 207 | int result; |
208 | 208 | ||
209 | lock_kernel(); | 209 | mutex_lock(&tlclk_mutex); |
210 | if (test_and_set_bit(0, &useflags)) { | 210 | if (test_and_set_bit(0, &useflags)) { |
211 | result = -EBUSY; | 211 | result = -EBUSY; |
212 | /* this legacy device is always one per system and it doesn't | 212 | /* this legacy device is always one per system and it doesn't |
@@ -229,7 +229,7 @@ static int tlclk_open(struct inode *inode, struct file *filp) | |||
229 | inb(TLCLK_REG6); /* Clear interrupt events */ | 229 | inb(TLCLK_REG6); /* Clear interrupt events */ |
230 | 230 | ||
231 | out: | 231 | out: |
232 | unlock_kernel(); | 232 | mutex_unlock(&tlclk_mutex); |
233 | return result; | 233 | return result; |
234 | } | 234 | } |
235 | 235 | ||