[ALSA] rtctimer: optimize module parameter validation
[linux-2.6.git] / sound / core / rtctimer.c
index 85627dbe6a57c288a52c39cc05eee9952e3183ec..8762ff8938c22b0a5ea142b6dc3a250f99c063d7 100644 (file)
@@ -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) {
-               snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", rtctimer_freq);
-               return -EINVAL;
-       }
-       for (order = 1; rtctimer_freq > order; order <<= 1)
-               ;
-       if (rtctimer_freq != order) {
+       if (rtctimer_freq < 2 || rtctimer_freq > 8192 ||
+           (rtctimer_freq & (rtctimer_freq - 1)) != 0) {
                snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", rtctimer_freq);
                return -EINVAL;
        }
                snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", rtctimer_freq);
                return -EINVAL;
        }