aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k/bvme6000/rtc.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/m68k/bvme6000/rtc.c')
-rw-r--r--arch/m68k/bvme6000/rtc.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/arch/m68k/bvme6000/rtc.c b/arch/m68k/bvme6000/rtc.c
index c50bec8aabb1..cb8617bb194b 100644
--- a/arch/m68k/bvme6000/rtc.c
+++ b/arch/m68k/bvme6000/rtc.c
@@ -9,8 +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/slab.h>
13#include <linux/smp_lock.h>
14#include <linux/ioport.h> 12#include <linux/ioport.h>
15#include <linux/capability.h> 13#include <linux/capability.h>
16#include <linux/fcntl.h> 14#include <linux/fcntl.h>
@@ -36,10 +34,9 @@
36static unsigned char days_in_mo[] = 34static unsigned char days_in_mo[] =
37{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};
38 36
39static char rtc_status; 37static atomic_t rtc_status = ATOMIC_INIT(1);
40 38
41static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 39static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
42 unsigned long arg)
43{ 40{
44 volatile RtcPtr_t rtc = (RtcPtr_t)BVME_RTC_BASE; 41 volatile RtcPtr_t rtc = (RtcPtr_t)BVME_RTC_BASE;
45 unsigned char msr; 42 unsigned char msr;
@@ -133,29 +130,20 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
133} 130}
134 131
135/* 132/*
136 * 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.
137 * Also clear the previous interrupt data on an open, and clean
138 * up things on a close.
139 */ 134 */
140
141static int rtc_open(struct inode *inode, struct file *file) 135static int rtc_open(struct inode *inode, struct file *file)
142{ 136{
143 lock_kernel(); 137 if (!atomic_dec_and_test(&rtc_status)) {
144 if(rtc_status) { 138 atomic_inc(&rtc_status);
145 unlock_kernel();
146 return -EBUSY; 139 return -EBUSY;
147 } 140 }
148
149 rtc_status = 1;
150 unlock_kernel();
151 return 0; 141 return 0;
152} 142}
153 143
154static int rtc_release(struct inode *inode, struct file *file) 144static int rtc_release(struct inode *inode, struct file *file)
155{ 145{
156 lock_kernel(); 146 atomic_inc(&rtc_status);
157 rtc_status = 0;
158 unlock_kernel();
159 return 0; 147 return 0;
160} 148}
161 149
@@ -164,9 +152,9 @@ static int rtc_release(struct inode *inode, struct file *file)
164 */ 152 */
165 153
166static const struct file_operations rtc_fops = { 154static const struct file_operations rtc_fops = {
167 .ioctl = rtc_ioctl, 155 .unlocked_ioctl = rtc_ioctl,
168 .open = rtc_open, 156 .open = rtc_open,
169 .release = rtc_release, 157 .release = rtc_release,
170}; 158};
171 159
172static struct miscdevice rtc_dev = { 160static struct miscdevice rtc_dev = {