diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2005-09-27 09:57:24 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2005-11-04 07:16:48 -0500 |
commit | d9ad1bdd6d72606a59cdc07e571fbe695e32f271 (patch) | |
tree | a5a702fc2db1e8079bad25b42d818e2f7636232f /sound/core/rtctimer.c | |
parent | adf25df1be2e3843f786a2562202c7897bbd149d (diff) |
[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: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound/core/rtctimer.c')
-rw-r--r-- | sound/core/rtctimer.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/sound/core/rtctimer.c b/sound/core/rtctimer.c index 85627dbe6a57..8762ff8938c2 100644 --- a/sound/core/rtctimer.c +++ b/sound/core/rtctimer.c | |||
@@ -119,16 +119,11 @@ static void rtctimer_interrupt(void *private_data) | |||
119 | */ | 119 | */ |
120 | static int __init rtctimer_init(void) | 120 | static int __init rtctimer_init(void) |
121 | { | 121 | { |
122 | int order, err; | 122 | int err; |
123 | snd_timer_t *timer; | 123 | snd_timer_t *timer; |
124 | 124 | ||
125 | if (rtctimer_freq < 2 || rtctimer_freq > 8192) { | 125 | if (rtctimer_freq < 2 || rtctimer_freq > 8192 || |
126 | snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", rtctimer_freq); | 126 | (rtctimer_freq & (rtctimer_freq - 1)) != 0) { |
127 | return -EINVAL; | ||
128 | } | ||
129 | for (order = 1; rtctimer_freq > order; order <<= 1) | ||
130 | ; | ||
131 | if (rtctimer_freq != order) { | ||
132 | snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", rtctimer_freq); | 127 | snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", rtctimer_freq); |
133 | return -EINVAL; | 128 | return -EINVAL; |
134 | } | 129 | } |