Skip to content

Commit 38ebb70

Browse files
committed
ALSA: Consolidate snd_find_free_minor()
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>
1 parent b62b998 commit 38ebb70

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

sound/core/sound.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static const struct file_operations snd_fops =
186186
};
187187

188188
#ifdef CONFIG_SND_DYNAMIC_MINORS
189-
static int snd_find_free_minor(int type)
189+
static int snd_find_free_minor(int type, struct snd_card *card, int dev)
190190
{
191191
int minor;
192192

@@ -209,7 +209,7 @@ static int snd_find_free_minor(int type)
209209
return -EBUSY;
210210
}
211211
#else
212-
static int snd_kernel_minor(int type, struct snd_card *card, int dev)
212+
static int snd_find_free_minor(int type, struct snd_card *card, int dev)
213213
{
214214
int minor;
215215

@@ -237,6 +237,8 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev)
237237
}
238238
if (snd_BUG_ON(minor < 0 || minor >= SNDRV_OS_MINORS))
239239
return -EINVAL;
240+
if (snd_minors[minor])
241+
return -EBUSY;
240242
return minor;
241243
}
242244
#endif
@@ -276,13 +278,7 @@ int snd_register_device(int type, struct snd_card *card, int dev,
276278
preg->private_data = private_data;
277279
preg->card_ptr = card;
278280
mutex_lock(&sound_mutex);
279-
#ifdef CONFIG_SND_DYNAMIC_MINORS
280-
minor = snd_find_free_minor(type);
281-
#else
282-
minor = snd_kernel_minor(type, card, dev);
283-
if (minor >= 0 && snd_minors[minor])
284-
minor = -EBUSY;
285-
#endif
281+
minor = snd_find_free_minor(type, card, dev);
286282
if (minor < 0) {
287283
err = minor;
288284
goto error;

0 commit comments

Comments
 (0)