Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Thomas Gleixner and committed by
Geert Uytterhoeven
b1f3bb49 e40152ee

+14 -34
+9 -20
arch/m68k/bvme6000/rtc.c
··· 9 9 #include <linux/types.h> 10 10 #include <linux/errno.h> 11 11 #include <linux/miscdevice.h> 12 - #include <linux/smp_lock.h> 13 12 #include <linux/ioport.h> 14 13 #include <linux/capability.h> 15 14 #include <linux/fcntl.h> ··· 34 35 static unsigned char days_in_mo[] = 35 36 {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 36 37 37 - static char rtc_status; 38 + static atomic_t rtc_status = ATOMIC_INIT(1); 38 39 39 - static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 40 - unsigned long arg) 40 + static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 41 41 { 42 42 volatile RtcPtr_t rtc = (RtcPtr_t)BVME_RTC_BASE; 43 43 unsigned char msr; ··· 130 132 } 131 133 132 134 /* 133 - * We enforce only one user at a time here with the open/close. 134 - * Also clear the previous interrupt data on an open, and clean 135 - * up things on a close. 135 + * We enforce only one user at a time here with the open/close. 136 136 */ 137 - 138 137 static int rtc_open(struct inode *inode, struct file *file) 139 138 { 140 - lock_kernel(); 141 - if(rtc_status) { 142 - unlock_kernel(); 139 + if (!atomic_dec_and_test(&rtc_status)) { 140 + atomic_inc(&rtc_status); 143 141 return -EBUSY; 144 142 } 145 - 146 - rtc_status = 1; 147 - unlock_kernel(); 148 143 return 0; 149 144 } 150 145 151 146 static int rtc_release(struct inode *inode, struct file *file) 152 147 { 153 - lock_kernel(); 154 - rtc_status = 0; 155 - unlock_kernel(); 148 + atomic_inc(&rtc_status); 156 149 return 0; 157 150 } 158 151 ··· 152 163 */ 153 164 154 165 static const struct file_operations rtc_fops = { 155 - .ioctl = rtc_ioctl, 156 - .open = rtc_open, 157 - .release = rtc_release, 166 + .unlocked_ioctl = rtc_ioctl, 167 + .open = rtc_open, 168 + .release = rtc_release, 158 169 }; 159 170 160 171 static struct miscdevice rtc_dev = {
+5 -14
arch/m68k/mvme16x/rtc.c
··· 9 9 #include <linux/types.h> 10 10 #include <linux/errno.h> 11 11 #include <linux/miscdevice.h> 12 - #include <linux/smp_lock.h> 13 12 #include <linux/ioport.h> 14 13 #include <linux/capability.h> 15 14 #include <linux/fcntl.h> ··· 35 36 36 37 static atomic_t rtc_ready = ATOMIC_INIT(1); 37 38 38 - static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 39 - unsigned long arg) 39 + static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 40 40 { 41 41 volatile MK48T08ptr_t rtc = (MK48T08ptr_t)MVME_RTC_BASE; 42 42 unsigned long flags; ··· 118 120 } 119 121 120 122 /* 121 - * We enforce only one user at a time here with the open/close. 122 - * Also clear the previous interrupt data on an open, and clean 123 - * up things on a close. 123 + * We enforce only one user at a time here with the open/close. 124 124 */ 125 - 126 125 static int rtc_open(struct inode *inode, struct file *file) 127 126 { 128 - lock_kernel(); 129 127 if( !atomic_dec_and_test(&rtc_ready) ) 130 128 { 131 129 atomic_inc( &rtc_ready ); 132 - unlock_kernel(); 133 130 return -EBUSY; 134 131 } 135 - unlock_kernel(); 136 - 137 132 return 0; 138 133 } 139 134 ··· 141 150 */ 142 151 143 152 static const struct file_operations rtc_fops = { 144 - .ioctl = rtc_ioctl, 145 - .open = rtc_open, 146 - .release = rtc_release, 153 + .unlocked_ioctl = rtc_ioctl, 154 + .open = rtc_open, 155 + .release = rtc_release, 147 156 }; 148 157 149 158 static struct miscdevice rtc_dev=