[ALSA] timers: add module refcounting for global timers
[powerpc.git] / sound / core / rtctimer.c
index 85627db..c3c1856 100644 (file)
@@ -119,17 +119,13 @@ static void rtctimer_interrupt(void *private_data)
  */
 static int __init rtctimer_init(void)
 {
-       int order, err;
+       int err;
        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) {
-               snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", rtctimer_freq);
+       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;
        }
 
@@ -138,6 +134,7 @@ static int __init rtctimer_init(void)
        if (err < 0)
                return err;
 
+       timer->module = THIS_MODULE;
        strcpy(timer->name, "RTC timer");
        timer->hw = rtc_hw;
        timer->hw.resolution = NANO_SEC / rtctimer_freq;