Commit 56f10c63 authored by Alessandro Zummo's avatar Alessandro Zummo Committed by Linus Torvalds
Browse files

[PATCH] rtc subsystem, fix capability checks in kernel interface



Remove commented capability checks and add some others.
Signed-off-by: default avatarAlessandro Zummo <a.zummo@towertech.it>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 9c0c5705
...@@ -229,6 +229,9 @@ int rtc_irq_set_state(struct class_device *class_dev, struct rtc_task *task, int ...@@ -229,6 +229,9 @@ int rtc_irq_set_state(struct class_device *class_dev, struct rtc_task *task, int
unsigned long flags; unsigned long flags;
struct rtc_device *rtc = to_rtc_device(class_dev); struct rtc_device *rtc = to_rtc_device(class_dev);
if (rtc->ops->irq_set_state == NULL)
return -ENXIO;
spin_lock_irqsave(&rtc->irq_task_lock, flags); spin_lock_irqsave(&rtc->irq_task_lock, flags);
if (rtc->irq_task != task) if (rtc->irq_task != task)
err = -ENXIO; err = -ENXIO;
...@@ -243,25 +246,12 @@ EXPORT_SYMBOL_GPL(rtc_irq_set_state); ...@@ -243,25 +246,12 @@ EXPORT_SYMBOL_GPL(rtc_irq_set_state);
int rtc_irq_set_freq(struct class_device *class_dev, struct rtc_task *task, int freq) int rtc_irq_set_freq(struct class_device *class_dev, struct rtc_task *task, int freq)
{ {
int err = 0, tmp = 0; int err = 0;
unsigned long flags; unsigned long flags;
struct rtc_device *rtc = to_rtc_device(class_dev); struct rtc_device *rtc = to_rtc_device(class_dev);
/* allowed range is 2-8192 */ if (rtc->ops->irq_set_freq == NULL)
if (freq < 2 || freq > 8192) return -ENXIO;
return -EINVAL;
/*
FIXME: this does not belong here, will move where appropriate
at a later stage. It cannot hurt right now, trust me :)
if ((freq > rtc_max_user_freq) && (!capable(CAP_SYS_RESOURCE)))
return -EACCES;
*/
/* check if freq is a power of 2 */
while (freq > (1 << tmp))
tmp++;
if (freq != (1 << tmp))
return -EINVAL;
spin_lock_irqsave(&rtc->irq_task_lock, flags); spin_lock_irqsave(&rtc->irq_task_lock, flags);
if (rtc->irq_task != task) if (rtc->irq_task != task)
......
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