X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=sound%2Fcore%2Finit.c;h=2cb7099eb1e1b994fa12f7c24da0189f98c5fa5a;hb=25d1b5167780c7f245d9655d302f6a3d8bf61d19;hp=6152a7554dfd2dd32492897befd1bb8ed502cd95;hpb=9cdf083f981b8d37b3212400a359368661385099;p=linux-2.6-omap-h63xx.git diff --git a/sound/core/init.c b/sound/core/init.c index 6152a7554df..2cb7099eb1e 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -1,6 +1,6 @@ /* * Initialization routines - * Copyright (c) by Jaroslav Kysela + * Copyright (c) by Jaroslav Kysela * * * This program is free software; you can redistribute it and/or modify @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -36,7 +35,7 @@ static DEFINE_SPINLOCK(shutdown_lock); static LIST_HEAD(shutdown_files); -static struct file_operations snd_shutdown_f_ops; +static const struct file_operations snd_shutdown_f_ops; static unsigned int snd_cards_lock; /* locked for registering/using */ struct snd_card *snd_cards[SNDRV_CARDS]; @@ -114,22 +113,28 @@ struct snd_card *snd_card_new(int idx, const char *xid, if (idx < 0) { int idx2; for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++) + /* idx == -1 == 0xffff means: take any free slot */ if (~snd_cards_lock & idx & 1<= snd_ecards_limit) snd_ecards_limit = idx + 1; break; } - } else if (idx < snd_ecards_limit) { - if (snd_cards_lock & (1 << idx)) - err = -ENODEV; /* invalid */ - } else if (idx < SNDRV_CARDS) - snd_ecards_limit = idx + 1; /* increase the limit */ - else - err = -ENODEV; + } else { + if (idx < snd_ecards_limit) { + if (snd_cards_lock & (1 << idx)) + err = -EBUSY; /* invalid */ + } else { + if (idx < SNDRV_CARDS) + snd_ecards_limit = idx + 1; /* increase the limit */ + else + err = -ENODEV; + } + } if (idx < 0 || err < 0) { mutex_unlock(&snd_card_mutex); - snd_printk(KERN_ERR "cannot find the slot for index %d (range 0-%i)\n", idx, snd_ecards_limit - 1); + snd_printk(KERN_ERR "cannot find the slot for index %d (range 0-%i), error: %d\n", + idx, snd_ecards_limit - 1, err); goto __error; } snd_cards_lock |= 1 << idx; /* lock it */ @@ -238,7 +243,7 @@ static int snd_disconnect_fasync(int fd, struct file *file, int on) return -ENODEV; } -static struct file_operations snd_shutdown_f_ops = +static const struct file_operations snd_shutdown_f_ops = { .owner = THIS_MODULE, .llseek = snd_disconnect_llseek, @@ -361,8 +366,10 @@ static int snd_card_do_free(struct snd_card *card) snd_printk(KERN_WARNING "unable to free card info\n"); /* Not fatal error */ } - if (card->dev) - device_unregister(card->dev); +#ifndef CONFIG_SYSFS_DEPRECATED + if (card->card_dev) + device_unregister(card->card_dev); +#endif kfree(card); return 0; } @@ -497,12 +504,14 @@ int snd_card_register(struct snd_card *card) int err; snd_assert(card != NULL, return -EINVAL); - if (!card->dev) { - card->dev = device_create(sound_class, card->parent, 0, - "card%i", card->number); - if (IS_ERR(card->dev)) - card->dev = NULL; +#ifndef CONFIG_SYSFS_DEPRECATED + if (!card->card_dev) { + card->card_dev = device_create(sound_class, card->dev, 0, + "card%i", card->number); + if (IS_ERR(card->card_dev)) + card->card_dev = NULL; } +#endif if ((err = snd_device_register_all(card)) < 0) return err; mutex_lock(&snd_card_mutex);