Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d4af1be authored by Karsten Wiese's avatar Karsten Wiese Committed by Takashi Iwai
Browse files

ALSA: us122l: add snd_us122l_free()



Use it to clean up snd_us122l_card_used[].

Without patch unplugging of an US122L soundcard didn't reset the
corresponding element of snd_us122l_card_used[] to 0.
The (SNDRV_CARDS + 1)th plugging in did not result in creating the soundcard
device anymore.
Index values supplied with the modprobe command line were not used correctly
anymore after the first unplugging of an US122L.

Signed-off-by: default avatarKarsten Wiese <fzu@wemgehoertderstaat.de>
Cc: stable@kernel.org
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent f600f6c4
Loading
Loading
Loading
Loading
+10 −2
Original line number Original line Diff line number Diff line
@@ -478,6 +478,14 @@ static bool us122l_create_card(struct snd_card *card)
	return true;
	return true;
}
}


static void snd_us122l_free(struct snd_card *card)
{
	struct us122l	*us122l = US122L(card);
	int		index = us122l->chip.index;
	if (index >= 0  &&  index < SNDRV_CARDS)
		snd_us122l_card_used[index] = 0;
}

static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
{
{
	int		dev;
	int		dev;
@@ -494,7 +502,7 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
	if (err < 0)
	if (err < 0)
		return err;
		return err;
	snd_us122l_card_used[US122L(card)->chip.index = dev] = 1;
	snd_us122l_card_used[US122L(card)->chip.index = dev] = 1;

	card->private_free = snd_us122l_free;
	US122L(card)->chip.dev = device;
	US122L(card)->chip.dev = device;
	US122L(card)->chip.card = card;
	US122L(card)->chip.card = card;
	mutex_init(&US122L(card)->mutex);
	mutex_init(&US122L(card)->mutex);
@@ -588,7 +596,7 @@ static void snd_us122l_disconnect(struct usb_interface *intf)
	}
	}


	usb_put_intf(intf);
	usb_put_intf(intf);
	usb_put_dev(US122L(card)->chip.dev);
	usb_put_dev(us122l->chip.dev);


	while (atomic_read(&us122l->mmap_count))
	while (atomic_read(&us122l->mmap_count))
		msleep(500);
		msleep(500);