Skip to content

Commit

Permalink
ALSA: Consolidate snd_find_free_minor()
Browse files Browse the repository at this point in the history
A really small cleanup to consolidate snd_find_free_minor() and
snd_kernel_minor() so that we can get rid of one more ifdef.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed Feb 17, 2015
1 parent b62b998 commit 38ebb70
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions sound/core/sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static const struct file_operations snd_fops =
};

#ifdef CONFIG_SND_DYNAMIC_MINORS
static int snd_find_free_minor(int type)
static int snd_find_free_minor(int type, struct snd_card *card, int dev)
{
int minor;

Expand All @@ -209,7 +209,7 @@ static int snd_find_free_minor(int type)
return -EBUSY;
}
#else
static int snd_kernel_minor(int type, struct snd_card *card, int dev)
static int snd_find_free_minor(int type, struct snd_card *card, int dev)
{
int minor;

Expand Down Expand Up @@ -237,6 +237,8 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev)
}
if (snd_BUG_ON(minor < 0 || minor >= SNDRV_OS_MINORS))
return -EINVAL;
if (snd_minors[minor])
return -EBUSY;
return minor;
}
#endif
Expand Down Expand Up @@ -276,13 +278,7 @@ int snd_register_device(int type, struct snd_card *card, int dev,
preg->private_data = private_data;
preg->card_ptr = card;
mutex_lock(&sound_mutex);
#ifdef CONFIG_SND_DYNAMIC_MINORS
minor = snd_find_free_minor(type);
#else
minor = snd_kernel_minor(type, card, dev);
if (minor >= 0 && snd_minors[minor])
minor = -EBUSY;
#endif
minor = snd_find_free_minor(type, card, dev);
if (minor < 0) {
err = minor;
goto error;
Expand Down

0 comments on commit 38ebb70

Please sign in to comment.