Commit d9ad1bdd authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Jaroslav Kysela

[ALSA] rtctimer: optimize module parameter validation

Modules: RTC timer driver

The check whether rtctimer_freq is a power of two can be done easier
with a simple bit operation.
Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
parent adf25df1
...@@ -119,16 +119,11 @@ static void rtctimer_interrupt(void *private_data) ...@@ -119,16 +119,11 @@ static void rtctimer_interrupt(void *private_data)
*/ */
static int __init rtctimer_init(void) static int __init rtctimer_init(void)
{ {
int order, err; int err;
snd_timer_t *timer; snd_timer_t *timer;
if (rtctimer_freq < 2 || rtctimer_freq > 8192) { if (rtctimer_freq < 2 || rtctimer_freq > 8192 ||
snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", rtctimer_freq); (rtctimer_freq & (rtctimer_freq - 1)) != 0) {
return -EINVAL;
}
for (order = 1; rtctimer_freq > order; order <<= 1)
;
if (rtctimer_freq != order) {
snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", rtctimer_freq); snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", rtctimer_freq);
return -EINVAL; return -EINVAL;
} }
......
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