diff options
| author | Thomas Gleixner <tglx@linutronix.de> | 2009-10-15 04:42:21 -0400 |
|---|---|---|
| committer | Geert Uytterhoeven <geert@linux-m68k.org> | 2010-05-17 15:15:39 -0400 |
| commit | b1f3bb494e8acddeb972331c2ac642b3c7bceeb9 (patch) | |
| tree | 3f04922eb7c5301810db28dd0546293b0bf846ae | |
| parent | e40152ee1e1c7a63f4777791863215e3faa37a86 (diff) | |
m68k: Remove BKL from rtc implementations
m68k does not support SMP. The access to the rtc is already serialized
with local_irq_save/restore which is sufficient on UP.
The open() protection in arch/m68k/mvme16x/rtc.c is not pretty but
sufficient on UP and safe w/o the BKL.
open() in arch/m68k/bvme6000/rtc.c can do with the same atomic logic
as arch/m68k/mvme16x/rtc.c
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
| -rw-r--r-- | arch/m68k/bvme6000/rtc.c | 29 | ||||
| -rw-r--r-- | arch/m68k/mvme16x/rtc.c | 19 |
2 files changed, 14 insertions, 34 deletions
diff --git a/arch/m68k/bvme6000/rtc.c b/arch/m68k/bvme6000/rtc.c index b46ea1714a89..cb8617bb194b 100644 --- a/arch/m68k/bvme6000/rtc.c +++ b/arch/m68k/bvme6000/rtc.c | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | #include <linux/types.h> | 9 | #include <linux/types.h> |
| 10 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
| 11 | #include <linux/miscdevice.h> | 11 | #include <linux/miscdevice.h> |
| 12 | #include <linux/smp_lock.h> | ||
| 13 | #include <linux/ioport.h> | 12 | #include <linux/ioport.h> |
| 14 | #include <linux/capability.h> | 13 | #include <linux/capability.h> |
| 15 | #include <linux/fcntl.h> | 14 | #include <linux/fcntl.h> |
| @@ -35,10 +34,9 @@ | |||
| 35 | static unsigned char days_in_mo[] = | 34 | static unsigned char days_in_mo[] = |
| 36 | {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | 35 | {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; |
| 37 | 36 | ||
| 38 | static char rtc_status; | 37 | static atomic_t rtc_status = ATOMIC_INIT(1); |
| 39 | 38 | ||
| 40 | static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | 39 | static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
| 41 | unsigned long arg) | ||
| 42 | { | 40 | { |
| 43 | volatile RtcPtr_t rtc = (RtcPtr_t)BVME_RTC_BASE; | 41 | volatile RtcPtr_t rtc = (RtcPtr_t)BVME_RTC_BASE; |
| 44 | unsigned char msr; | 42 | unsigned char msr; |
| @@ -132,29 +130,20 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
| 132 | } | 130 | } |
| 133 | 131 | ||
| 134 | /* | 132 | /* |
| 135 | * We enforce only one user at a time here with the open/close. | 133 | * We enforce only one user at a time here with the open/close. |
| 136 | * Also clear the previous interrupt data on an open, and clean | ||
| 137 | * up things on a close. | ||
| 138 | */ | 134 | */ |
| 139 | |||
| 140 | static int rtc_open(struct inode *inode, struct file *file) | 135 | static int rtc_open(struct inode *inode, struct file *file) |
| 141 | { | 136 | { |
| 142 | lock_kernel(); | 137 | if (!atomic_dec_and_test(&rtc_status)) { |
| 143 | if(rtc_status) { | 138 | atomic_inc(&rtc_status); |
| 144 | unlock_kernel(); | ||
| 145 | return -EBUSY; | 139 | return -EBUSY; |
| 146 | } | 140 | } |
| 147 | |||
| 148 | rtc_status = 1; | ||
| 149 | unlock_kernel(); | ||
| 150 | return 0; | 141 | return 0; |
| 151 | } | 142 | } |
| 152 | 143 | ||
| 153 | static int rtc_release(struct inode *inode, struct file *file) | 144 | static int rtc_release(struct inode *inode, struct file *file) |
| 154 | { | 145 | { |
| 155 | lock_kernel(); | 146 | atomic_inc(&rtc_status); |
| 156 | rtc_status = 0; | ||
| 157 | unlock_kernel(); | ||
| 158 | return 0; | 147 | return 0; |
| 159 | } | 148 | } |
| 160 | 149 | ||
| @@ -163,9 +152,9 @@ static int rtc_release(struct inode *inode, struct file *file) | |||
| 163 | */ | 152 | */ |
| 164 | 153 | ||
| 165 | static const struct file_operations rtc_fops = { | 154 | static const struct file_operations rtc_fops = { |
| 166 | .ioctl = rtc_ioctl, | 155 | .unlocked_ioctl = rtc_ioctl, |
| 167 | .open = rtc_open, | 156 | .open = rtc_open, |
| 168 | .release = rtc_release, | 157 | .release = rtc_release, |
| 169 | }; | 158 | }; |
| 170 | 159 | ||
| 171 | static struct miscdevice rtc_dev = { | 160 | static struct miscdevice rtc_dev = { |
diff --git a/arch/m68k/mvme16x/rtc.c b/arch/m68k/mvme16x/rtc.c index 8da9c250d3e1..11ac6f63967a 100644 --- a/arch/m68k/mvme16x/rtc.c +++ b/arch/m68k/mvme16x/rtc.c | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | #include <linux/types.h> | 9 | #include <linux/types.h> |
| 10 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
| 11 | #include <linux/miscdevice.h> | 11 | #include <linux/miscdevice.h> |
| 12 | #include <linux/smp_lock.h> | ||
| 13 | #include <linux/ioport.h> | 12 | #include <linux/ioport.h> |
| 14 | #include <linux/capability.h> | 13 | #include <linux/capability.h> |
| 15 | #include <linux/fcntl.h> | 14 | #include <linux/fcntl.h> |
| @@ -36,8 +35,7 @@ static const unsigned char days_in_mo[] = | |||
| 36 | 35 | ||
| 37 | static atomic_t rtc_ready = ATOMIC_INIT(1); | 36 | static atomic_t rtc_ready = ATOMIC_INIT(1); |
| 38 | 37 | ||
| 39 | static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | 38 | static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
| 40 | unsigned long arg) | ||
| 41 | { | 39 | { |
| 42 | volatile MK48T08ptr_t rtc = (MK48T08ptr_t)MVME_RTC_BASE; | 40 | volatile MK48T08ptr_t rtc = (MK48T08ptr_t)MVME_RTC_BASE; |
| 43 | unsigned long flags; | 41 | unsigned long flags; |
| @@ -120,22 +118,15 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
| 120 | } | 118 | } |
| 121 | 119 | ||
| 122 | /* | 120 | /* |
| 123 | * We enforce only one user at a time here with the open/close. | 121 | * We enforce only one user at a time here with the open/close. |
| 124 | * Also clear the previous interrupt data on an open, and clean | ||
| 125 | * up things on a close. | ||
| 126 | */ | 122 | */ |
| 127 | |||
| 128 | static int rtc_open(struct inode *inode, struct file *file) | 123 | static int rtc_open(struct inode *inode, struct file *file) |
| 129 | { | 124 | { |
| 130 | lock_kernel(); | ||
| 131 | if( !atomic_dec_and_test(&rtc_ready) ) | 125 | if( !atomic_dec_and_test(&rtc_ready) ) |
| 132 | { | 126 | { |
| 133 | atomic_inc( &rtc_ready ); | 127 | atomic_inc( &rtc_ready ); |
| 134 | unlock_kernel(); | ||
| 135 | return -EBUSY; | 128 | return -EBUSY; |
| 136 | } | 129 | } |
| 137 | unlock_kernel(); | ||
| 138 | |||
| 139 | return 0; | 130 | return 0; |
| 140 | } | 131 | } |
| 141 | 132 | ||
| @@ -150,9 +141,9 @@ static int rtc_release(struct inode *inode, struct file *file) | |||
| 150 | */ | 141 | */ |
| 151 | 142 | ||
| 152 | static const struct file_operations rtc_fops = { | 143 | static const struct file_operations rtc_fops = { |
| 153 | .ioctl = rtc_ioctl, | 144 | .unlocked_ioctl = rtc_ioctl, |
| 154 | .open = rtc_open, | 145 | .open = rtc_open, |
| 155 | .release = rtc_release, | 146 | .release = rtc_release, |
| 156 | }; | 147 | }; |
| 157 | 148 | ||
| 158 | static struct miscdevice rtc_dev= | 149 | static struct miscdevice rtc_dev= |
