Commit b1f3bb49 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Geert Uytterhoeven

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: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
parent e40152ee
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/smp_lock.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/capability.h> #include <linux/capability.h>
#include <linux/fcntl.h> #include <linux/fcntl.h>
...@@ -35,10 +34,9 @@ ...@@ -35,10 +34,9 @@
static unsigned char days_in_mo[] = static unsigned char days_in_mo[] =
{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
static char rtc_status; static atomic_t rtc_status = ATOMIC_INIT(1);
static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
unsigned long arg)
{ {
volatile RtcPtr_t rtc = (RtcPtr_t)BVME_RTC_BASE; volatile RtcPtr_t rtc = (RtcPtr_t)BVME_RTC_BASE;
unsigned char msr; unsigned char msr;
...@@ -133,28 +131,19 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -133,28 +131,19 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
/* /*
* We enforce only one user at a time here with the open/close. * We enforce only one user at a time here with the open/close.
* Also clear the previous interrupt data on an open, and clean
* up things on a close.
*/ */
static int rtc_open(struct inode *inode, struct file *file) static int rtc_open(struct inode *inode, struct file *file)
{ {
lock_kernel(); if (!atomic_dec_and_test(&rtc_status)) {
if(rtc_status) { atomic_inc(&rtc_status);
unlock_kernel();
return -EBUSY; return -EBUSY;
} }
rtc_status = 1;
unlock_kernel();
return 0; return 0;
} }
static int rtc_release(struct inode *inode, struct file *file) static int rtc_release(struct inode *inode, struct file *file)
{ {
lock_kernel(); atomic_inc(&rtc_status);
rtc_status = 0;
unlock_kernel();
return 0; return 0;
} }
...@@ -163,7 +152,7 @@ static int rtc_release(struct inode *inode, struct file *file) ...@@ -163,7 +152,7 @@ static int rtc_release(struct inode *inode, struct file *file)
*/ */
static const struct file_operations rtc_fops = { static const struct file_operations rtc_fops = {
.ioctl = rtc_ioctl, .unlocked_ioctl = rtc_ioctl,
.open = rtc_open, .open = rtc_open,
.release = rtc_release, .release = rtc_release,
}; };
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/smp_lock.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/capability.h> #include <linux/capability.h>
#include <linux/fcntl.h> #include <linux/fcntl.h>
...@@ -36,8 +35,7 @@ static const unsigned char days_in_mo[] = ...@@ -36,8 +35,7 @@ static const unsigned char days_in_mo[] =
static atomic_t rtc_ready = ATOMIC_INIT(1); static atomic_t rtc_ready = ATOMIC_INIT(1);
static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
unsigned long arg)
{ {
volatile MK48T08ptr_t rtc = (MK48T08ptr_t)MVME_RTC_BASE; volatile MK48T08ptr_t rtc = (MK48T08ptr_t)MVME_RTC_BASE;
unsigned long flags; unsigned long flags;
...@@ -121,21 +119,14 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -121,21 +119,14 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
/* /*
* We enforce only one user at a time here with the open/close. * We enforce only one user at a time here with the open/close.
* Also clear the previous interrupt data on an open, and clean
* up things on a close.
*/ */
static int rtc_open(struct inode *inode, struct file *file) static int rtc_open(struct inode *inode, struct file *file)
{ {
lock_kernel();
if( !atomic_dec_and_test(&rtc_ready) ) if( !atomic_dec_and_test(&rtc_ready) )
{ {
atomic_inc( &rtc_ready ); atomic_inc( &rtc_ready );
unlock_kernel();
return -EBUSY; return -EBUSY;
} }
unlock_kernel();
return 0; return 0;
} }
...@@ -150,7 +141,7 @@ static int rtc_release(struct inode *inode, struct file *file) ...@@ -150,7 +141,7 @@ static int rtc_release(struct inode *inode, struct file *file)
*/ */
static const struct file_operations rtc_fops = { static const struct file_operations rtc_fops = {
.ioctl = rtc_ioctl, .unlocked_ioctl = rtc_ioctl,
.open = rtc_open, .open = rtc_open,
.release = rtc_release, .release = rtc_release,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment