[ALSA] dynamic minors (1/6): store device type in struct snd_minor
authorClemens Ladisch <clemens@ladisch.de>
Sun, 20 Nov 2005 13:03:48 +0000 (14:03 +0100)
committerJaroslav Kysela <perex@suse.cz>
Tue, 3 Jan 2006 11:29:14 +0000 (12:29 +0100)
Instead of a comment string, store the device type in the snd_minor
structure.  This makes snd_minor more flexible, and has the nice side
effect that we don't need anymore to create a separate snd_minor
template for registering a device but can pass the file_operations
directly to snd_register_device().

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
14 files changed:
include/sound/core.h
include/sound/pcm.h
sound/core/control.c
sound/core/hwdep.c
sound/core/oss/mixer_oss.c
sound/core/oss/pcm_oss.c
sound/core/pcm.c
sound/core/pcm_native.c
sound/core/rawmidi.c
sound/core/seq/oss/seq_oss.c
sound/core/seq/seq_clientmgr.c
sound/core/sound.c
sound/core/sound_oss.c
sound/core/timer.c

index f00b9c9..f557c8a 100644 (file)
@@ -185,8 +185,8 @@ static inline int snd_power_wait(struct snd_card *card, unsigned int state, stru
 struct snd_minor {
        struct list_head list;          /* list of all minors per card */
        int number;                     /* minor number */
+       int type;                       /* SNDRV_DEVICE_TYPE_XXX */
        int device;                     /* device number */
-       const char *comment;            /* for /proc/asound/devices */
        struct file_operations *f_ops;  /* file operations */
        char name[0];                   /* device name (keep at the end of
                                                                structure) */
@@ -199,11 +199,13 @@ extern int snd_ecards_limit;
 
 void snd_request_card(int card);
 
-int snd_register_device(int type, struct snd_card *card, int dev, struct snd_minor *reg, const char *name);
+int snd_register_device(int type, struct snd_card *card, int dev,
+                       struct file_operations *f_ops, const char *name);
 int snd_unregister_device(int type, struct snd_card *card, int dev);
 
 #ifdef CONFIG_SND_OSSEMUL
-int snd_register_oss_device(int type, struct snd_card *card, int dev, struct snd_minor *reg, const char *name);
+int snd_register_oss_device(int type, struct snd_card *card, int dev,
+                           struct file_operations *f_ops, const char *name);
 int snd_unregister_oss_device(int type, struct snd_card *card, int dev);
 #endif
 
index 7e77c0a..5e29b0e 100644 (file)
@@ -402,7 +402,6 @@ struct snd_pcm_str {
        struct snd_pcm_oss_stream oss;
 #endif
        struct snd_pcm_file *files;
-       struct snd_minor *reg;
        struct snd_info_entry *proc_root;
        struct snd_info_entry *proc_info_entry;
 #ifdef CONFIG_SND_DEBUG
@@ -441,7 +440,7 @@ struct snd_pcm_notify {
  */
 
 extern struct snd_pcm *snd_pcm_devices[];
-extern struct snd_minor snd_pcm_reg[2];
+extern struct file_operations snd_pcm_f_ops[2];
 
 int snd_pcm_new(struct snd_card *card, char *id, int device,
                int playback_count, int capture_count,
index f8f98cc..23561e7 100644 (file)
@@ -1264,12 +1264,6 @@ static struct file_operations snd_ctl_f_ops =
        .fasync =       snd_ctl_fasync,
 };
 
-static struct snd_minor snd_ctl_reg =
-{
-       .comment =      "ctl",
-       .f_ops =        &snd_ctl_f_ops,
-};
-
 /*
  * registration of the control device
  */
@@ -1284,7 +1278,7 @@ static int snd_ctl_dev_register(struct snd_device *device)
        snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO);
        sprintf(name, "controlC%i", cardnum);
        if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL,
-                                       card, 0, &snd_ctl_reg, name)) < 0)
+                                      card, -1, &snd_ctl_f_ops, name)) < 0)
                return err;
        return 0;
 }
@@ -1336,7 +1330,8 @@ static int snd_ctl_dev_unregister(struct snd_device *device)
        snd_assert(card != NULL, return -ENXIO);
        cardnum = card->number;
        snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO);
-       if ((err = snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL, card, 0)) < 0)
+       if ((err = snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL,
+                                        card, -1)) < 0)
                return err;
        return snd_ctl_dev_free(device);
 }
index 444e266..27d5bf7 100644 (file)
@@ -330,12 +330,6 @@ static struct file_operations snd_hwdep_f_ops =
        .mmap =         snd_hwdep_mmap,
 };
 
-static struct snd_minor snd_hwdep_reg =
-{
-       .comment =      "hardware dependent",
-       .f_ops =        &snd_hwdep_f_ops,
-};
-
 /**
  * snd_hwdep_new - create a new hwdep instance
  * @card: the card instance
@@ -416,7 +410,7 @@ static int snd_hwdep_dev_register(struct snd_device *device)
        sprintf(name, "hwC%iD%i", hwdep->card->number, hwdep->device);
        if ((err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP,
                                       hwdep->card, hwdep->device,
-                                      &snd_hwdep_reg, name)) < 0) {
+                                      &snd_hwdep_f_ops, name)) < 0) {
                snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n",
                           hwdep->card->number, hwdep->device);
                snd_hwdep_devices[idx] = NULL;
@@ -431,7 +425,8 @@ static int snd_hwdep_dev_register(struct snd_device *device)
                } else {
                        if (snd_register_oss_device(hwdep->oss_type,
                                                    hwdep->card, hwdep->device,
-                                                   &snd_hwdep_reg, hwdep->oss_dev) < 0) {
+                                                   &snd_hwdep_f_ops,
+                                                   hwdep->oss_dev) < 0) {
                                snd_printk(KERN_ERR "unable to register OSS compatibility device %i:%i\n",
                                           hwdep->card->number, hwdep->device);
                        } else
index e448002..2dd6bf9 100644 (file)
@@ -398,12 +398,6 @@ static struct file_operations snd_mixer_oss_f_ops =
        .compat_ioctl = snd_mixer_oss_ioctl_compat,
 };
 
-static struct snd_minor snd_mixer_oss_reg =
-{
-       .comment =      "mixer",
-       .f_ops =        &snd_mixer_oss_f_ops,
-};
-
 /*
  *  utilities
  */
@@ -1292,7 +1286,7 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd)
                sprintf(name, "mixer%i%i", card->number, 0);
                if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER,
                                                   card, 0,
-                                                  &snd_mixer_oss_reg,
+                                                  &snd_mixer_oss_f_ops,
                                                   name)) < 0) {
                        snd_printk(KERN_ERR "unable to register OSS mixer device %i:%i\n",
                                   card->number, 0);
index ffc13b9..947bf08 100644 (file)
@@ -2444,18 +2444,12 @@ static struct file_operations snd_pcm_oss_f_reg =
        .mmap =         snd_pcm_oss_mmap,
 };
 
-static struct snd_minor snd_pcm_oss_reg =
-{
-       .comment =      "digital audio",
-       .f_ops =        &snd_pcm_oss_f_reg,
-};
-
 static void register_oss_dsp(struct snd_pcm *pcm, int index)
 {
        char name[128];
        sprintf(name, "dsp%i%i", pcm->card->number, pcm->device);
        if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_PCM,
-                                   pcm->card, index, &snd_pcm_oss_reg,
+                                   pcm->card, index, &snd_pcm_oss_f_reg,
                                    name) < 0) {
                snd_printk(KERN_ERR "unable to register OSS PCM device %i:%i\n",
                           pcm->card->number, pcm->device);
index 9305ac3..2bc5f69 100644 (file)
@@ -597,7 +597,6 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
        pstr->stream = stream;
        pstr->pcm = pcm;
        pstr->substream_count = substream_count;
-       pstr->reg = &snd_pcm_reg[stream];
        if (substream_count > 0) {
                err = snd_pcm_stream_proc_init(pstr);
                if (err < 0) {
@@ -897,7 +896,10 @@ static int snd_pcm_dev_register(struct snd_device *device)
                        devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE;
                        break;
                }
-               if ((err = snd_register_device(devtype, pcm->card, pcm->device, pcm->streams[cidx].reg, str)) < 0) {
+               if ((err = snd_register_device(devtype, pcm->card,
+                                              pcm->device,
+                                              &snd_pcm_f_ops[cidx], str)) < 0)
+               {
                        snd_pcm_devices[idx] = NULL;
                        up(&register_mutex);
                        return err;
index 7bac1cb..bb40c01 100644 (file)
@@ -3370,40 +3370,29 @@ out:
  *  Register section
  */
 
-static struct file_operations snd_pcm_f_ops_playback = {
-       .owner =        THIS_MODULE,
-       .write =        snd_pcm_write,
-       .writev =       snd_pcm_writev,
-       .open =         snd_pcm_open,
-       .release =      snd_pcm_release,
-       .poll =         snd_pcm_playback_poll,
-       .unlocked_ioctl =       snd_pcm_playback_ioctl,
-       .compat_ioctl = snd_pcm_ioctl_compat,
-       .mmap =         snd_pcm_mmap,
-       .fasync =       snd_pcm_fasync,
-};
-
-static struct file_operations snd_pcm_f_ops_capture = {
-       .owner =        THIS_MODULE,
-       .read =         snd_pcm_read,
-       .readv =        snd_pcm_readv,
-       .open =         snd_pcm_open,
-       .release =      snd_pcm_release,
-       .poll =         snd_pcm_capture_poll,
-       .unlocked_ioctl =       snd_pcm_capture_ioctl,
-       .compat_ioctl = snd_pcm_ioctl_compat,
-       .mmap =         snd_pcm_mmap,
-       .fasync =       snd_pcm_fasync,
-};
-
-struct snd_minor snd_pcm_reg[2] =
-{
+struct file_operations snd_pcm_f_ops[2] = {
        {
-               .comment =      "digital audio playback",
-               .f_ops =        &snd_pcm_f_ops_playback,
+               .owner =                THIS_MODULE,
+               .write =                snd_pcm_write,
+               .writev =               snd_pcm_writev,
+               .open =                 snd_pcm_open,
+               .release =              snd_pcm_release,
+               .poll =                 snd_pcm_playback_poll,
+               .unlocked_ioctl =       snd_pcm_playback_ioctl,
+               .compat_ioctl =         snd_pcm_ioctl_compat,
+               .mmap =                 snd_pcm_mmap,
+               .fasync =               snd_pcm_fasync,
        },
        {
-               .comment =      "digital audio capture",
-               .f_ops =        &snd_pcm_f_ops_capture,
+               .owner =                THIS_MODULE,
+               .read =                 snd_pcm_read,
+               .readv =                snd_pcm_readv,
+               .open =                 snd_pcm_open,
+               .release =              snd_pcm_release,
+               .poll =                 snd_pcm_capture_poll,
+               .unlocked_ioctl =       snd_pcm_capture_ioctl,
+               .compat_ioctl =         snd_pcm_ioctl_compat,
+               .mmap =                 snd_pcm_mmap,
+               .fasync =               snd_pcm_fasync,
        }
 };
index d703545..7ac77e5 100644 (file)
@@ -1367,12 +1367,6 @@ static struct file_operations snd_rawmidi_f_ops =
        .compat_ioctl = snd_rawmidi_ioctl_compat,
 };
 
-static struct snd_minor snd_rawmidi_reg =
-{
-       .comment =      "raw midi",
-       .f_ops =        &snd_rawmidi_f_ops,
-};
-
 static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi,
                                        struct snd_rawmidi_str *stream,
                                        int direction,
@@ -1516,7 +1510,7 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
        sprintf(name, "midiC%iD%i", rmidi->card->number, rmidi->device);
        if ((err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI,
                                       rmidi->card, rmidi->device,
-                                      &snd_rawmidi_reg, name)) < 0) {
+                                      &snd_rawmidi_f_ops, name)) < 0) {
                snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device);
                snd_rawmidi_devices[idx] = NULL;
                up(&register_mutex);
@@ -1533,7 +1527,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
        rmidi->ossreg = 0;
        if ((int)rmidi->device == midi_map[rmidi->card->number]) {
                if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI,
-                                           rmidi->card, 0, &snd_rawmidi_reg, name) < 0) {
+                                           rmidi->card, 0,
+                                           &snd_rawmidi_f_ops, name) < 0) {
                        snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 0);
                } else {
                        rmidi->ossreg++;
@@ -1544,7 +1539,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
        }
        if ((int)rmidi->device == amidi_map[rmidi->card->number]) {
                if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI,
-                                           rmidi->card, 1, &snd_rawmidi_reg, name) < 0) {
+                                           rmidi->card, 1,
+                                           &snd_rawmidi_f_ops, name) < 0) {
                        snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 1);
                } else {
                        rmidi->ossreg++;
index 2371e41..61c0a41 100644 (file)
@@ -217,11 +217,6 @@ static struct file_operations seq_oss_f_ops =
        .compat_ioctl = odev_ioctl_compat,
 };
 
-static struct snd_minor seq_oss_reg = {
-       .comment =      "sequencer",
-       .f_ops =        &seq_oss_f_ops,
-};
-
 static int __init
 register_device(void)
 {
@@ -230,7 +225,7 @@ register_device(void)
        down(&register_mutex);
        if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER,
                                          NULL, 0,
-                                         &seq_oss_reg,
+                                         &seq_oss_f_ops,
                                          SNDRV_SEQ_OSS_DEVNAME)) < 0) {
                snd_printk(KERN_ERR "can't register device seq\n");
                up(&register_mutex);
@@ -238,7 +233,7 @@ register_device(void)
        }
        if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC,
                                          NULL, 0,
-                                         &seq_oss_reg,
+                                         &seq_oss_f_ops,
                                          SNDRV_SEQ_OSS_DEVNAME)) < 0) {
                snd_printk(KERN_ERR "can't register device music\n");
                snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0);
index 5eab420..087fdf3 100644 (file)
@@ -2520,13 +2520,6 @@ static struct file_operations snd_seq_f_ops =
        .compat_ioctl = snd_seq_ioctl_compat,
 };
 
-static struct snd_minor snd_seq_reg =
-{
-       .comment =      "sequencer",
-       .f_ops =        &snd_seq_f_ops,
-};
-
-
 /* 
  * register sequencer device 
  */
@@ -2537,7 +2530,8 @@ int __init snd_sequencer_device_init(void)
        if (down_interruptible(&register_mutex))
                return -ERESTARTSYS;
 
-       if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0, &snd_seq_reg, "seq")) < 0) {
+       if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0,
+                                      &snd_seq_f_ops, "seq")) < 0) {
                up(&register_mutex);
                return err;
        }
index fb236a6..798c24c 100644 (file)
@@ -195,7 +195,7 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev)
  * @type: the device type, SNDRV_DEVICE_TYPE_XXX
  * @card: the card instance
  * @dev: the device index
- * @reg: the struct snd_minor record
+ * @f_ops: the file operations
  * @name: the device file name
  *
  * Registers an ALSA device file for the given card.
@@ -203,7 +203,8 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev)
  *
  * Retrurns zero if successful, or a negative error code on failure.
  */
-int snd_register_device(int type, struct snd_card *card, int dev, struct snd_minor * reg, const char *name)
+int snd_register_device(int type, struct snd_card *card, int dev,
+                       struct file_operations *f_ops, const char *name)
 {
        int minor = snd_kernel_minor(type, card, dev);
        struct snd_minor *preg;
@@ -212,12 +213,13 @@ int snd_register_device(int type, struct snd_card *card, int dev, struct snd_min
        if (minor < 0)
                return minor;
        snd_assert(name, return -EINVAL);
-       preg = kmalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL);
+       preg = kzalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL);
        if (preg == NULL)
                return -ENOMEM;
-       *preg = *reg;
        preg->number = minor;
+       preg->type = type;
        preg->device = dev;
+       preg->f_ops = f_ops;
        strcpy(preg->name, name);
        down(&sound_mutex);
        if (snd_minor_search(minor)) {
@@ -276,6 +278,28 @@ int snd_unregister_device(int type, struct snd_card *card, int dev)
 
 static struct snd_info_entry *snd_minor_info_entry = NULL;
 
+static const char *snd_device_type_name(int type)
+{
+       switch (type) {
+       case SNDRV_DEVICE_TYPE_CONTROL:
+               return "control";
+       case SNDRV_DEVICE_TYPE_HWDEP:
+               return "hardware dependent";
+       case SNDRV_DEVICE_TYPE_RAWMIDI:
+               return "raw midi";
+       case SNDRV_DEVICE_TYPE_PCM_PLAYBACK:
+               return "digital audio playback";
+       case SNDRV_DEVICE_TYPE_PCM_CAPTURE:
+               return "digital audio capture";
+       case SNDRV_DEVICE_TYPE_SEQUENCER:
+               return "sequencer";
+       case SNDRV_DEVICE_TYPE_TIMER:
+               return "timer";
+       default:
+               return "?";
+       }
+}
+
 static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
 {
        int card, device;
@@ -288,11 +312,11 @@ static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_bu
                        mptr = list_entry(list, struct snd_minor, list);
                        if (SNDRV_MINOR_DEVICE(mptr->number) != SNDRV_MINOR_GLOBAL) {
                                if ((device = mptr->device) >= 0)
-                                       snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, device, mptr->comment);
+                                       snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, device, snd_device_type_name(mptr->type));
                                else
-                                       snd_iprintf(buffer, "%3i: [%i]   : %s\n", mptr->number, card, mptr->comment);
+                                       snd_iprintf(buffer, "%3i: [%i]   : %s\n", mptr->number, card, snd_device_type_name(mptr->type));
                        } else {
-                               snd_iprintf(buffer, "%3i:       : %s\n", mptr->number, mptr->comment);
+                               snd_iprintf(buffer, "%3i:       : %s\n", mptr->number, snd_device_type_name(mptr->type));
                        }
                }
        }
index ec37604..4d189ff 100644 (file)
@@ -91,7 +91,7 @@ static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev)
 }
 
 int snd_register_oss_device(int type, struct snd_card *card, int dev,
-                           struct snd_minor * reg, const char *name)
+                           struct file_operations *f_ops, const char *name)
 {
        int minor = snd_oss_kernel_minor(type, card, dev);
        int minor_unit;
@@ -103,12 +103,13 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
 
        if (minor < 0)
                return minor;
-       preg = (struct snd_minor *)kmalloc(sizeof(struct snd_minor), GFP_KERNEL);
+       preg = kzalloc(sizeof(struct snd_minor), GFP_KERNEL);
        if (preg == NULL)
                return -ENOMEM;
-       *preg = *reg;
        preg->number = minor;
+       preg->type = type;
        preg->device = dev;
+       preg->f_ops = f_ops;
        down(&sound_oss_mutex);
        list_add_tail(&preg->list, &snd_oss_minors_hash[cidx]);
        minor_unit = SNDRV_MINOR_OSS_DEVICE(minor);
@@ -125,11 +126,12 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
        }
        if (card)
                carddev = card->dev;
-       register1 = register_sound_special_device(reg->f_ops, minor, carddev);
+       register1 = register_sound_special_device(f_ops, minor, carddev);
        if (register1 != minor)
                goto __end;
        if (track2 >= 0) {
-               register2 = register_sound_special_device(reg->f_ops, track2, carddev);
+               register2 = register_sound_special_device(f_ops, track2,
+                                                         carddev);
                if (register2 != track2)
                        goto __end;
        }
@@ -190,6 +192,25 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev)
 
 static struct snd_info_entry *snd_minor_info_oss_entry = NULL;
 
+static const char *snd_oss_device_type_name(int type)
+{
+       switch (type) {
+       case SNDRV_OSS_DEVICE_TYPE_MIXER:
+               return "mixer";
+       case SNDRV_OSS_DEVICE_TYPE_SEQUENCER:
+       case SNDRV_OSS_DEVICE_TYPE_MUSIC:
+               return "sequencer";
+       case SNDRV_OSS_DEVICE_TYPE_PCM:
+               return "digital audio";
+       case SNDRV_OSS_DEVICE_TYPE_MIDI:
+               return "raw midi";
+       case SNDRV_OSS_DEVICE_TYPE_DMFM:
+               return "hardware dependent";
+       default:
+               return "?";
+       }
+}
+
 static void snd_minor_info_oss_read(struct snd_info_entry *entry,
                                    struct snd_info_buffer *buffer)
 {
@@ -205,9 +226,9 @@ static void snd_minor_info_oss_read(struct snd_info_entry *entry,
                        if (dev != SNDRV_MINOR_OSS_SNDSTAT &&
                            dev != SNDRV_MINOR_OSS_SEQUENCER &&
                            dev != SNDRV_MINOR_OSS_MUSIC)
-                               snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, dev, mptr->comment);
+                               snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, dev, snd_oss_device_type_name(mptr->type));
                        else
-                               snd_iprintf(buffer, "%3i:       : %s\n", mptr->number, mptr->comment);
+                               snd_iprintf(buffer, "%3i:       : %s\n", mptr->number, snd_oss_device_type_name(mptr->type));
                }
        }
        up(&sound_oss_mutex);
index 6aad411..a7bcb04 100644 (file)
@@ -1924,12 +1924,6 @@ static struct file_operations snd_timer_f_ops =
        .fasync =       snd_timer_user_fasync,
 };
 
-static struct snd_minor snd_timer_reg =
-{
-       .comment =      "timer",
-       .f_ops =        &snd_timer_f_ops,
-};
-
 /*
  *  ENTRY functions
  */
@@ -1959,7 +1953,7 @@ static int __init alsa_timer_init(void)
                snd_printk(KERN_ERR "unable to register system timer (%i)\n",
                           err);
        if ((err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER,
-                                       NULL, 0, &snd_timer_reg, "timer"))<0)
+                                      NULL, 0, &snd_timer_f_ops, "timer")) < 0)
                snd_printk(KERN_ERR "unable to register timer device (%i)\n",
                           err);
        return 0;