Skip to contentSkip to conversation

us122l: add snd_us122l_free()

PATCH Superseded Karsten Wiese 2 participants 4 messages Apr 17, 2009 – Apr 20, 2009 Sound

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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.

---
 sound/usb/usx2y/us122l.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

Hi Takashi,

this is Version 2 of the patch with a better changelog. Good enough?

Thanks,
Karsten

sound/usb/usx2y/us122l.c +12 -4
index 012ff1f..e0385ce 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008 Karsten Wiese <[email protected]>
+ * Copyright (C) 2007-2009 Karsten Wiese <[email protected]>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -26,7 +26,7 @@
 #include "us122l.h"
 
 MODULE_AUTHOR("Karsten Wiese <[email protected]>");
-MODULE_DESCRIPTION("TASCAM "NAME_ALLCAPS" Version 0.5");
+MODULE_DESCRIPTION("TASCAM "NAME_ALLCAPS" Version 0.6");
 MODULE_LICENSE("GPL");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;	/* Index 0-max */
@@ -474,6 +474,14 @@ static bool us122l_create_card(struct snd_card *card)
 	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)
 {
 	int		dev;
@@ -490,7 +498,7 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
 	if (err < 0)
 		return err;
 	snd_us122l_card_used[US122L(card)->chip.index = dev] = 1;
-
+	card->private_free = snd_us122l_free;
 	US122L(card)->chip.dev = device;
 	US122L(card)->chip.card = card;
 	mutex_init(&US122L(card)->mutex);
@@ -584,7 +592,7 @@ static void snd_us122l_disconnect(struct usb_interface *intf)
 	}
 
 	usb_put_intf(intf);
-	usb_put_dev(US122L(card)->chip.dev);
+	usb_put_dev(us122l->chip.dev);
 
 	while (atomic_read(&us122l->mmap_count))
 		msleep(500);
Signature · 1 line
1.6.0.6
#1 lore raw

At Fri, 17 Apr 2009 14:56:25 +0200,

Quoted 12 lines · Karsten Wiese

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.

Quoted 7 lines
---
 sound/usb/usx2y/us122l.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

Hi Takashi,

this is Version 2 of the patch with a better changelog. Good enough?

Yep. But I'd suggest to remove the change from version number and comment change from this fix patch. Keep the stable change as minimal as possible. The version change can be provided as another patch to 2.6.30.

Could you repost?

thanks,

Takashi

Quoted 60 lines

Thanks,
Karsten

sound/usb/usx2y/us122l.c +12 -4
index 012ff1f..e0385ce 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008 Karsten Wiese <[email protected]>
+ * Copyright (C) 2007-2009 Karsten Wiese <[email protected]>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -26,7 +26,7 @@
 #include "us122l.h"
 
 MODULE_AUTHOR("Karsten Wiese <[email protected]>");
-MODULE_DESCRIPTION("TASCAM "NAME_ALLCAPS" Version 0.5");
+MODULE_DESCRIPTION("TASCAM "NAME_ALLCAPS" Version 0.6");
 MODULE_LICENSE("GPL");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;	/* Index 0-max */
@@ -474,6 +474,14 @@ static bool us122l_create_card(struct snd_card *card)
 	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)
 {
 	int		dev;
@@ -490,7 +498,7 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
 	if (err < 0)
 		return err;
 	snd_us122l_card_used[US122L(card)->chip.index = dev] = 1;
-
+	card->private_free = snd_us122l_free;
 	US122L(card)->chip.dev = device;
 	US122L(card)->chip.card = card;
 	mutex_init(&US122L(card)->mutex);
@@ -584,7 +592,7 @@ static void snd_us122l_disconnect(struct usb_interface *intf)
 	}
 
 	usb_put_intf(intf);
-	usb_put_dev(US122L(card)->chip.dev);
+	usb_put_dev(us122l->chip.dev);
 
 	while (atomic_read(&us122l->mmap_count))
 		msleep(500);
Signature · 1 line
1.6.0.6
#2 lore raw

PATCH v3 1/1 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.

---
 sound/usb/usx2y/us122l.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
sound/usb/usx2y/us122l.c +10 -2
index 012ff1f..a5aae9d 100644
@@ -474,6 +474,14 @@ static bool us122l_create_card(struct snd_card *card)
 	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)
 {
 	int		dev;
@@ -490,7 +498,7 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
 	if (err < 0)
 		return err;
 	snd_us122l_card_used[US122L(card)->chip.index = dev] = 1;
-
+	card->private_free = snd_us122l_free;
 	US122L(card)->chip.dev = device;
 	US122L(card)->chip.card = card;
 	mutex_init(&US122L(card)->mutex);
@@ -584,7 +592,7 @@ static void snd_us122l_disconnect(struct usb_interface *intf)
 	}
 
 	usb_put_intf(intf);
-	usb_put_dev(US122L(card)->chip.dev);
+	usb_put_dev(us122l->chip.dev);
 
 	while (atomic_read(&us122l->mmap_count))
 		msleep(500);
Signature · 1 line
1.6.0.6
#3 lore raw

At Mon, 20 Apr 2009 13:01:21 +0200,

Quoted 10 lines · Karsten Wiese

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.

Quoted 2 lines

Applied now. Thanks.

BTW, unless you need different patches, you don't have to send the patch to [email protected]. They will pick up automatically when the relevant commit appears in the upstream kernel if it has Cc to [email protected] in the changelog.

Takashi