X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=sound%2Fcore%2Fsound.c;h=812f91b3de5b88fca9259dece4ac4c4a5787a551;hb=7f5cc0ae18bdd92ca6c8d5edae3c2e4a84814829;hp=282742022de6f603f905c611b21cebb685edd015;hpb=463e7c7cf9aaf95dd05e97e1a47854fdf5454cdc;p=linux-2.6-omap-h63xx.git diff --git a/sound/core/sound.c b/sound/core/sound.c index 282742022de..812f91b3de5 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -1,6 +1,6 @@ /* * Advanced Linux Sound Architecture - * Copyright (c) by Jaroslav Kysela + * Copyright (c) by Jaroslav Kysela * * * This program is free software; you can redistribute it and/or modify @@ -19,7 +19,6 @@ * */ -#include #include #include #include @@ -42,7 +41,7 @@ EXPORT_SYMBOL(snd_major); static int cards_limit = 1; -MODULE_AUTHOR("Jaroslav Kysela "); +MODULE_AUTHOR("Jaroslav Kysela "); MODULE_DESCRIPTION("Advanced Linux Sound Architecture driver for soundcards."); MODULE_LICENSE("GPL"); module_param(major, int, 0444); @@ -72,8 +71,6 @@ static DEFINE_MUTEX(sound_mutex); */ void snd_request_card(int card) { - if (! current->fs->root) - return; if (snd_card_locked(card)) return; if (card < 0 || card >= cards_limit) @@ -87,8 +84,6 @@ static void snd_request_other(int minor) { char *str; - if (! current->fs->root) - return; switch (minor) { case SNDRV_MINOR_SEQUENCER: str = "snd-seq"; break; case SNDRV_MINOR_TIMER: str = "snd-timer"; break; @@ -168,7 +163,7 @@ static int snd_open(struct inode *inode, struct file *file) return err; } -static struct file_operations snd_fops = +static const struct file_operations snd_fops = { .owner = THIS_MODULE, .open = snd_open @@ -219,26 +214,27 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) #endif /** - * snd_register_device - Register the ALSA device file for the card + * snd_register_device_for_dev - Register the ALSA device file for the card * @type: the device type, SNDRV_DEVICE_TYPE_XXX * @card: the card instance * @dev: the device index * @f_ops: the file operations * @private_data: user pointer for f_ops->open() * @name: the device file name + * @device: the &struct device to link this new device to * * Registers an ALSA device file for the given card. * The operators have to be set in reg parameter. * - * Retrurns zero if successful, or a negative error code on failure. + * Returns zero if successful, or a negative error code on failure. */ -int snd_register_device(int type, struct snd_card *card, int dev, - const struct file_operations *f_ops, void *private_data, - const char *name) +int snd_register_device_for_dev(int type, struct snd_card *card, int dev, + const struct file_operations *f_ops, + void *private_data, + const char *name, struct device *device) { int minor; struct snd_minor *preg; - struct device *device = NULL; snd_assert(name, return -EINVAL); preg = kmalloc(sizeof *preg, GFP_KERNEL); @@ -263,10 +259,16 @@ int snd_register_device(int type, struct snd_card *card, int dev, return minor; } snd_minors[minor] = preg; - if (card) - device = card->dev; preg->dev = device_create(sound_class, device, MKDEV(major, minor), "%s", name); + if (IS_ERR(preg->dev)) { + snd_minors[minor] = NULL; + mutex_unlock(&sound_mutex); + minor = PTR_ERR(preg->dev); + kfree(preg); + return minor; + } + if (preg->dev) dev_set_drvdata(preg->dev, private_data); @@ -274,7 +276,7 @@ int snd_register_device(int type, struct snd_card *card, int dev, return 0; } -EXPORT_SYMBOL(snd_register_device); +EXPORT_SYMBOL(snd_register_device_for_dev); /* find the matching minor record * return the index of snd_minor, or -1 if not found @@ -447,8 +449,7 @@ static void __exit alsa_sound_exit(void) { snd_info_minor_unregister(); snd_info_done(); - if (unregister_chrdev(major, "alsa") != 0) - snd_printk(KERN_ERR "unable to unregister major device number %d\n", major); + unregister_chrdev(major, "alsa"); } module_init(alsa_sound_init)