Commit 20158e4d authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: rtc.c __user annotation

Also replacement of #if RTC_IRQ with #ifdef, moved inlined function in
front of all uses.
parent 9464d6ad
...@@ -97,7 +97,7 @@ static unsigned long rtc_port; ...@@ -97,7 +97,7 @@ static unsigned long rtc_port;
static int rtc_irq = PCI_IRQ_NONE; static int rtc_irq = PCI_IRQ_NONE;
#endif #endif
#if RTC_IRQ #ifdef RTC_IRQ
static int rtc_has_irq = 1; static int rtc_has_irq = 1;
#endif #endif
...@@ -125,30 +125,28 @@ static struct fasync_struct *rtc_async_queue; ...@@ -125,30 +125,28 @@ static struct fasync_struct *rtc_async_queue;
static DECLARE_WAIT_QUEUE_HEAD(rtc_wait); static DECLARE_WAIT_QUEUE_HEAD(rtc_wait);
#if RTC_IRQ #ifdef RTC_IRQ
static struct timer_list rtc_irq_timer; static struct timer_list rtc_irq_timer;
#endif #endif
static ssize_t rtc_read(struct file *file, char *buf, static ssize_t rtc_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos); size_t count, loff_t *ppos);
static int rtc_ioctl(struct inode *inode, struct file *file, static int rtc_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
#if RTC_IRQ #ifdef RTC_IRQ
static unsigned int rtc_poll(struct file *file, poll_table *wait); static unsigned int rtc_poll(struct file *file, poll_table *wait);
#endif #endif
static void get_rtc_alm_time (struct rtc_time *alm_tm); static void get_rtc_alm_time (struct rtc_time *alm_tm);
#if RTC_IRQ #ifdef RTC_IRQ
static void rtc_dropped_irq(unsigned long data); static void rtc_dropped_irq(unsigned long data);
static void set_rtc_irq_bit(unsigned char bit); static void set_rtc_irq_bit(unsigned char bit);
static void mask_rtc_irq_bit(unsigned char bit); static void mask_rtc_irq_bit(unsigned char bit);
#endif #endif
static inline unsigned char rtc_is_updating(void);
static int rtc_read_proc(char *page, char **start, off_t off, static int rtc_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data); int count, int *eof, void *data);
...@@ -171,7 +169,7 @@ static unsigned long rtc_freq = 0; /* Current periodic IRQ rate */ ...@@ -171,7 +169,7 @@ static unsigned long rtc_freq = 0; /* Current periodic IRQ rate */
static unsigned long rtc_irq_data = 0; /* our output to the world */ static unsigned long rtc_irq_data = 0; /* our output to the world */
static unsigned long rtc_max_user_freq = 64; /* > this, need CAP_SYS_RESOURCE */ static unsigned long rtc_max_user_freq = 64; /* > this, need CAP_SYS_RESOURCE */
#if RTC_IRQ #ifdef RTC_IRQ
/* /*
* rtc_task_lock nests inside rtc_lock. * rtc_task_lock nests inside rtc_lock.
*/ */
...@@ -189,7 +187,20 @@ static unsigned long epoch = 1900; /* year corresponding to 0x00 */ ...@@ -189,7 +187,20 @@ static unsigned long epoch = 1900; /* year corresponding to 0x00 */
static const unsigned char days_in_mo[] = static const 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};
#if RTC_IRQ /*
* Returns true if a clock update is in progress
*/
static inline unsigned char rtc_is_updating(void)
{
unsigned char uip;
spin_lock_irq(&rtc_lock);
uip = (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP);
spin_unlock_irq(&rtc_lock);
return uip;
}
#ifdef RTC_IRQ
/* /*
* A very tiny interrupt handler. It runs with SA_INTERRUPT set, * A very tiny interrupt handler. It runs with SA_INTERRUPT set,
* but there is possibility of conflicting with the set_rtc_mmss() * but there is possibility of conflicting with the set_rtc_mmss()
...@@ -295,10 +306,10 @@ static void __exit cleanup_sysctl(void) ...@@ -295,10 +306,10 @@ static void __exit cleanup_sysctl(void)
* Now all the various file operations that we export. * Now all the various file operations that we export.
*/ */
static ssize_t rtc_read(struct file *file, char *buf, static ssize_t rtc_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
#if !RTC_IRQ #ifndef RTC_IRQ
return -EIO; return -EIO;
#else #else
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
...@@ -340,9 +351,9 @@ static ssize_t rtc_read(struct file *file, char *buf, ...@@ -340,9 +351,9 @@ static ssize_t rtc_read(struct file *file, char *buf,
} while (1); } while (1);
if (count < sizeof(unsigned long)) if (count < sizeof(unsigned long))
retval = put_user(data, (unsigned int *)buf) ?: sizeof(int); retval = put_user(data, (unsigned int __user *)buf) ?: sizeof(int);
else else
retval = put_user(data, (unsigned long *)buf) ?: sizeof(long); retval = put_user(data, (unsigned long __user *)buf) ?: sizeof(long);
out: out:
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
remove_wait_queue(&rtc_wait, &wait); remove_wait_queue(&rtc_wait, &wait);
...@@ -355,7 +366,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel) ...@@ -355,7 +366,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
{ {
struct rtc_time wtime; struct rtc_time wtime;
#if RTC_IRQ #ifdef RTC_IRQ
if (rtc_has_irq == 0) { if (rtc_has_irq == 0) {
switch (cmd) { switch (cmd) {
case RTC_AIE_OFF: case RTC_AIE_OFF:
...@@ -372,7 +383,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel) ...@@ -372,7 +383,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
#endif #endif
switch (cmd) { switch (cmd) {
#if RTC_IRQ #ifdef RTC_IRQ
case RTC_AIE_OFF: /* Mask alarm int. enab. bit */ case RTC_AIE_OFF: /* Mask alarm int. enab. bit */
{ {
mask_rtc_irq_bit(RTC_AIE); mask_rtc_irq_bit(RTC_AIE);
...@@ -447,7 +458,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel) ...@@ -447,7 +458,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
unsigned char hrs, min, sec; unsigned char hrs, min, sec;
struct rtc_time alm_tm; struct rtc_time alm_tm;
if (copy_from_user(&alm_tm, (struct rtc_time*)arg, if (copy_from_user(&alm_tm, (struct rtc_time __user *)arg,
sizeof(struct rtc_time))) sizeof(struct rtc_time)))
return -EFAULT; return -EFAULT;
...@@ -500,7 +511,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel) ...@@ -500,7 +511,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
if (!capable(CAP_SYS_TIME)) if (!capable(CAP_SYS_TIME))
return -EACCES; return -EACCES;
if (copy_from_user(&rtc_tm, (struct rtc_time*)arg, if (copy_from_user(&rtc_tm, (struct rtc_time __user *)arg,
sizeof(struct rtc_time))) sizeof(struct rtc_time)))
return -EFAULT; return -EFAULT;
...@@ -584,10 +595,10 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel) ...@@ -584,10 +595,10 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
spin_unlock_irq(&rtc_lock); spin_unlock_irq(&rtc_lock);
return 0; return 0;
} }
#if RTC_IRQ #ifdef RTC_IRQ
case RTC_IRQP_READ: /* Read the periodic IRQ rate. */ case RTC_IRQP_READ: /* Read the periodic IRQ rate. */
{ {
return put_user(rtc_freq, (unsigned long *)arg); return put_user(rtc_freq, (unsigned long __user *)arg);
} }
case RTC_IRQP_SET: /* Set periodic IRQ rate. */ case RTC_IRQP_SET: /* Set periodic IRQ rate. */
{ {
...@@ -631,7 +642,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel) ...@@ -631,7 +642,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
#endif #endif
case RTC_EPOCH_READ: /* Read the epoch. */ case RTC_EPOCH_READ: /* Read the epoch. */
{ {
return put_user (epoch, (unsigned long *)arg); return put_user (epoch, (unsigned long __user *)arg);
} }
case RTC_EPOCH_SET: /* Set the epoch. */ case RTC_EPOCH_SET: /* Set the epoch. */
{ {
...@@ -650,7 +661,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel) ...@@ -650,7 +661,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
default: default:
return -ENOTTY; return -ENOTTY;
} }
return copy_to_user((void *)arg, &wtime, sizeof wtime) ? -EFAULT : 0; return copy_to_user((void __user *)arg, &wtime, sizeof wtime) ? -EFAULT : 0;
} }
static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
...@@ -693,7 +704,7 @@ static int rtc_fasync (int fd, struct file *filp, int on) ...@@ -693,7 +704,7 @@ static int rtc_fasync (int fd, struct file *filp, int on)
static int rtc_release(struct inode *inode, struct file *file) static int rtc_release(struct inode *inode, struct file *file)
{ {
#if RTC_IRQ #ifdef RTC_IRQ
unsigned char tmp; unsigned char tmp;
if (rtc_has_irq == 0) if (rtc_has_irq == 0)
...@@ -732,7 +743,7 @@ static int rtc_release(struct inode *inode, struct file *file) ...@@ -732,7 +743,7 @@ static int rtc_release(struct inode *inode, struct file *file)
return 0; return 0;
} }
#if RTC_IRQ #ifdef RTC_IRQ
/* Called without the kernel lock - fine */ /* Called without the kernel lock - fine */
static unsigned int rtc_poll(struct file *file, poll_table *wait) static unsigned int rtc_poll(struct file *file, poll_table *wait)
{ {
...@@ -763,7 +774,7 @@ EXPORT_SYMBOL(rtc_control); ...@@ -763,7 +774,7 @@ EXPORT_SYMBOL(rtc_control);
int rtc_register(rtc_task_t *task) int rtc_register(rtc_task_t *task)
{ {
#if !RTC_IRQ #ifndef RTC_IRQ
return -EIO; return -EIO;
#else #else
if (task == NULL || task->func == NULL) if (task == NULL || task->func == NULL)
...@@ -789,7 +800,7 @@ int rtc_register(rtc_task_t *task) ...@@ -789,7 +800,7 @@ int rtc_register(rtc_task_t *task)
int rtc_unregister(rtc_task_t *task) int rtc_unregister(rtc_task_t *task)
{ {
#if !RTC_IRQ #ifndef RTC_IRQ
return -EIO; return -EIO;
#else #else
unsigned char tmp; unsigned char tmp;
...@@ -825,7 +836,7 @@ int rtc_unregister(rtc_task_t *task) ...@@ -825,7 +836,7 @@ int rtc_unregister(rtc_task_t *task)
int rtc_control(rtc_task_t *task, unsigned int cmd, unsigned long arg) int rtc_control(rtc_task_t *task, unsigned int cmd, unsigned long arg)
{ {
#if !RTC_IRQ #ifndef RTC_IRQ
return -EIO; return -EIO;
#else #else
spin_lock_irq(&rtc_task_lock); spin_lock_irq(&rtc_task_lock);
...@@ -847,7 +858,7 @@ static struct file_operations rtc_fops = { ...@@ -847,7 +858,7 @@ static struct file_operations rtc_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.llseek = no_llseek, .llseek = no_llseek,
.read = rtc_read, .read = rtc_read,
#if RTC_IRQ #ifdef RTC_IRQ
.poll = rtc_poll, .poll = rtc_poll,
#endif #endif
.ioctl = rtc_ioctl, .ioctl = rtc_ioctl,
...@@ -863,7 +874,7 @@ static struct miscdevice rtc_dev= ...@@ -863,7 +874,7 @@ static struct miscdevice rtc_dev=
&rtc_fops &rtc_fops
}; };
#if RTC_IRQ #ifdef RTC_IRQ
static irqreturn_t (*rtc_int_handler_ptr)(int irq, void *dev_id, struct pt_regs *regs); static irqreturn_t (*rtc_int_handler_ptr)(int irq, void *dev_id, struct pt_regs *regs);
#endif #endif
...@@ -933,7 +944,7 @@ static int __init rtc_init(void) ...@@ -933,7 +944,7 @@ static int __init rtc_init(void)
return -EIO; return -EIO;
} }
#if RTC_IRQ #ifdef RTC_IRQ
if (is_hpet_enabled()) { if (is_hpet_enabled()) {
rtc_int_handler_ptr = hpet_rtc_interrupt; rtc_int_handler_ptr = hpet_rtc_interrupt;
} else { } else {
...@@ -953,14 +964,14 @@ static int __init rtc_init(void) ...@@ -953,14 +964,14 @@ static int __init rtc_init(void)
#endif /* __sparc__ vs. others */ #endif /* __sparc__ vs. others */
if (misc_register(&rtc_dev)) { if (misc_register(&rtc_dev)) {
#if RTC_IRQ #ifdef RTC_IRQ
free_irq(RTC_IRQ, NULL); free_irq(RTC_IRQ, NULL);
#endif #endif
release_region(RTC_PORT(0), RTC_IO_EXTENT); release_region(RTC_PORT(0), RTC_IO_EXTENT);
return -ENODEV; return -ENODEV;
} }
if (create_proc_read_entry ("driver/rtc", 0, 0, rtc_read_proc, NULL) == NULL) { if (create_proc_read_entry ("driver/rtc", 0, 0, rtc_read_proc, NULL) == NULL) {
#if RTC_IRQ #ifdef RTC_IRQ
free_irq(RTC_IRQ, NULL); free_irq(RTC_IRQ, NULL);
#endif #endif
release_region(RTC_PORT(0), RTC_IO_EXTENT); release_region(RTC_PORT(0), RTC_IO_EXTENT);
...@@ -1011,7 +1022,7 @@ static int __init rtc_init(void) ...@@ -1011,7 +1022,7 @@ static int __init rtc_init(void)
if (guess) if (guess)
printk(KERN_INFO "rtc: %s epoch (%lu) detected\n", guess, epoch); printk(KERN_INFO "rtc: %s epoch (%lu) detected\n", guess, epoch);
#endif #endif
#if RTC_IRQ #ifdef RTC_IRQ
if (rtc_has_irq == 0) if (rtc_has_irq == 0)
goto no_irq2; goto no_irq2;
...@@ -1045,7 +1056,7 @@ static void __exit rtc_exit (void) ...@@ -1045,7 +1056,7 @@ static void __exit rtc_exit (void)
free_irq (rtc_irq, &rtc_port); free_irq (rtc_irq, &rtc_port);
#else #else
release_region (RTC_PORT (0), RTC_IO_EXTENT); release_region (RTC_PORT (0), RTC_IO_EXTENT);
#if RTC_IRQ #ifdef RTC_IRQ
if (rtc_has_irq) if (rtc_has_irq)
free_irq (RTC_IRQ, NULL); free_irq (RTC_IRQ, NULL);
#endif #endif
...@@ -1055,7 +1066,7 @@ static void __exit rtc_exit (void) ...@@ -1055,7 +1066,7 @@ static void __exit rtc_exit (void)
module_init(rtc_init); module_init(rtc_init);
module_exit(rtc_exit); module_exit(rtc_exit);
#if RTC_IRQ #ifdef RTC_IRQ
/* /*
* At IRQ rates >= 4096Hz, an interrupt may get lost altogether. * At IRQ rates >= 4096Hz, an interrupt may get lost altogether.
* (usually during an IDE disk interrupt, with IRQ unmasking off) * (usually during an IDE disk interrupt, with IRQ unmasking off)
...@@ -1194,20 +1205,6 @@ static int rtc_read_proc(char *page, char **start, off_t off, ...@@ -1194,20 +1205,6 @@ static int rtc_read_proc(char *page, char **start, off_t off,
return len; return len;
} }
/*
* Returns true if a clock update is in progress
*/
/* FIXME shouldn't this be above rtc_init to make it fully inlined? */
static inline unsigned char rtc_is_updating(void)
{
unsigned char uip;
spin_lock_irq(&rtc_lock);
uip = (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP);
spin_unlock_irq(&rtc_lock);
return uip;
}
void rtc_get_rtc_time(struct rtc_time *rtc_tm) void rtc_get_rtc_time(struct rtc_time *rtc_tm)
{ {
unsigned long uip_watchdog = jiffies; unsigned long uip_watchdog = jiffies;
...@@ -1298,7 +1295,7 @@ static void get_rtc_alm_time(struct rtc_time *alm_tm) ...@@ -1298,7 +1295,7 @@ static void get_rtc_alm_time(struct rtc_time *alm_tm)
} }
} }
#if RTC_IRQ #ifdef RTC_IRQ
/* /*
* Used to disable/enable interrupts for any one of UIE, AIE, PIE. * Used to disable/enable interrupts for any one of UIE, AIE, PIE.
* Rumour has it that if you frob the interrupt enable/disable * Rumour has it that if you frob the interrupt enable/disable
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
/* FIXME:RTC Interrupt feature is not implemented yet. */ /* FIXME:RTC Interrupt feature is not implemented yet. */
#undef RTC_IRQ #undef RTC_IRQ
#define RTC_IRQ 0
#if defined(CONFIG_CPU_SH3) #if defined(CONFIG_CPU_SH3)
#define RTC_PORT(n) (R64CNT+(n)*2) #define RTC_PORT(n) (R64CNT+(n)*2)
......
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