ALSA: hwdep - Make open callback optional
authorTakashi Iwai <tiwai@suse.de>
Thu, 5 Feb 2009 08:10:20 +0000 (09:10 +0100)
committerTakashi Iwai <tiwai@suse.de>
Thu, 5 Feb 2009 08:10:20 +0000 (09:10 +0100)
Don't require the open callback as mandatory.
Now all hwdeps ops can be optional.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/hwdep.c

index 195cafc..a70ee7f 100644 (file)
@@ -99,9 +99,6 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
        if (hw == NULL)
                return -ENODEV;
 
-       if (!hw->ops.open)
-               return -ENXIO;
-
        if (!try_module_get(hw->card->module))
                return -EFAULT;
 
@@ -113,6 +110,10 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
                        err = -EBUSY;
                        break;
                }
+               if (!hw->ops.open) {
+                       err = 0;
+                       break;
+               }
                err = hw->ops.open(hw, file);
                if (err >= 0)
                        break;
@@ -151,7 +152,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
 
 static int snd_hwdep_release(struct inode *inode, struct file * file)
 {
-       int err = -ENXIO;
+       int err = 0;
        struct snd_hwdep *hw = file->private_data;
        struct module *mod = hw->card->module;