Skip to contentSkip to conversation

More line6 fixes / rewrites

PATCH New Takashi Iwai 1 participant 8 messages Jan 20, 2015 Sound

lore
Share & tools
lore
#0 lore raw

cover More line6 fixes / rewrites

Hi,

this is yet another series of patches for line6 drivers. Most of patches are cleanups and trivial fixes while the last one is to reimplement the LED control via the standard LED class.

As usual, patches are found in test/line6 branch for now.

Takashi

#1 lore raw

PATCH 1/7 ALSA: line6: Yet more cleanup of superfluous NULL checks

... in line6_disconnect() as well.

---
 sound/usb/line6/driver.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)
sound/usb/line6/driver.c +2 -11
index 93cd4daa56bc..e8d51381ffdb 100644
@@ -579,18 +579,9 @@ EXPORT_SYMBOL_GPL(line6_probe);
 */
 void line6_disconnect(struct usb_interface *interface)
 {
-	struct usb_line6 *line6;
-	struct usb_device *usbdev;
-	int interface_number;
-
-	if (interface == NULL)
-		return;
-	usbdev = interface_to_usbdev(interface);
-	if (usbdev == NULL)
-		return;
+	struct usb_line6 *line6 = usb_get_intfdata(interface);
+	struct usb_device *usbdev = interface_to_usbdev(interface);
 
-	interface_number = interface->cur_altsetting->desc.bInterfaceNumber;
-	line6 = usb_get_intfdata(interface);
 	if (!line6)
 		return;
 
Signature · 1 line
2.2.1
#2 lore raw

PATCH 2/7 ALSA: line6: Abort if inconsistent usbdev is found at disconnect

In reply to Takashi Iwai

It's utterly unsafe to proceed further the disconnect procedure if the assigned usbdev is inconsistent with the expected object. Better to put a WARN_ON() for more cautions and abort immediately.

---
 sound/usb/line6/driver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/usb/line6/driver.c +3 -3
index e8d51381ffdb..625272fe227a 100644
@@ -585,12 +585,12 @@ void line6_disconnect(struct usb_interface *interface)
 	if (!line6)
 		return;
 
+	if (WARN_ON(usbdev != line6->usbdev))
+		return;
+
 	if (line6->urb_listen != NULL)
 		line6_stop_listen(line6);
 
-	if (usbdev != line6->usbdev)
-		dev_err(line6->ifcdev, "driver bug: inconsistent usb device\n");
-
 	snd_card_disconnect(line6->card);
 	if (line6->line6pcm)
 		line6_pcm_disconnect(line6->line6pcm);
Signature · 1 line
2.2.1
#3 lore raw

PATCH 3/7 ALSA: line6: Remove superfluous NULL checks in each driver

In reply to Takashi Iwai

The interface and driver objects are always set when callbacks are called. Drop such superfluous NULL checks in init and disconnect calls of each driver.

---
 sound/usb/line6/pod.c      | 28 ++++++++--------------------
 sound/usb/line6/podhd.c    |  4 ----
 sound/usb/line6/toneport.c |  6 ------
 sound/usb/line6/variax.c   |  8 --------
 4 files changed, 8 insertions(+), 38 deletions(-)
sound/usb/line6/pod.c +8 -20
index bf027fc70cba..26ecf26a33ec 100644
@@ -401,25 +401,16 @@ static struct snd_kcontrol_new pod_control_monitor = {
 */
 static void line6_pod_disconnect(struct usb_interface *interface)
 {
-	struct usb_line6_pod *pod;
-
-	if (interface == NULL)
-		return;
-	pod = usb_get_intfdata(interface);
-
-	if (pod != NULL) {
-		struct device *dev = &interface->dev;
+	struct usb_line6_pod *pod = usb_get_intfdata(interface);
+	struct device *dev = &interface->dev;
 
-		if (dev != NULL) {
-			/* remove sysfs entries: */
-			device_remove_file(dev, &dev_attr_device_id);
-			device_remove_file(dev, &dev_attr_firmware_version);
-			device_remove_file(dev, &dev_attr_serial_number);
-		}
+	/* remove sysfs entries: */
+	device_remove_file(dev, &dev_attr_device_id);
+	device_remove_file(dev, &dev_attr_firmware_version);
+	device_remove_file(dev, &dev_attr_serial_number);
 
-		del_timer_sync(&pod->startup_timer);
-		cancel_work_sync(&pod->startup_work);
-	}
+	del_timer_sync(&pod->startup_timer);
+	cancel_work_sync(&pod->startup_work);
 }
 
 /*
@@ -456,9 +447,6 @@ static int pod_init(struct usb_interface *interface,
 	init_timer(&pod->startup_timer);
 	INIT_WORK(&pod->startup_work, pod_startup4);
 
-	if ((interface == NULL) || (pod == NULL))
-		return -ENODEV;
-
 	/* create sysfs entries: */
 	err = pod_create_files2(&interface->dev);
 	if (err < 0)
sound/usb/line6/podhd.c +0 -4
index 7217fa7e5db1..59abbd92624e 100644
@@ -90,12 +90,8 @@ static struct line6_pcm_properties podhd_pcm_properties = {
 static int podhd_init(struct usb_interface *interface,
 		      struct usb_line6 *line6)
 {
-	struct usb_line6_podhd *podhd = (struct usb_line6_podhd *) line6;
 	int err;
 
-	if ((interface == NULL) || (podhd == NULL))
-		return -ENODEV;
-
 	/* initialize MIDI subsystem: */
 	err = line6_init_midi(line6);
 	if (err < 0)
sound/usb/line6/toneport.c +0 -6
index c1f61cde52ab..e5669bd3233a 100644
@@ -370,9 +370,6 @@ static void line6_toneport_disconnect(struct usb_interface *interface)
 	struct usb_line6_toneport *toneport;
 	u16 idProduct;
 
-	if (interface == NULL)
-		return;
-
 	toneport = usb_get_intfdata(interface);
 	del_timer_sync(&toneport->timer);
 	idProduct = le16_to_cpu(toneport->line6.usbdev->descriptor.idProduct);
@@ -393,9 +390,6 @@ static int toneport_init(struct usb_interface *interface,
 	int err;
 	struct usb_line6_toneport *toneport =  (struct usb_line6_toneport *) line6;
 
-	if ((interface == NULL) || (toneport == NULL))
-		return -ENODEV;
-
 	line6->disconnect = line6_toneport_disconnect;
 
 	/* initialize PCM subsystem: */
sound/usb/line6/variax.c +0 -8
index 99a58cbfd2da..cd3adeffde02 100644
@@ -214,12 +214,7 @@ static void line6_variax_disconnect(struct usb_interface *interface)
 {
 	struct usb_line6_variax *variax;
 
-	if (!interface)
-		return;
-
 	variax = usb_get_intfdata(interface);
-	if (!variax)
-		return;
 
 	del_timer(&variax->startup_timer1);
 	del_timer(&variax->startup_timer2);
@@ -244,9 +239,6 @@ static int variax_init(struct usb_interface *interface,
 	init_timer(&variax->startup_timer2);
 	INIT_WORK(&variax->startup_work, variax_startup6);
 
-	if ((interface == NULL) || (variax == NULL))
-		return -ENODEV;
-
 	/* initialize USB buffers: */
 	variax->buffer_activate = kmemdup(variax_activate,
 					  sizeof(variax_activate), GFP_KERNEL);
Signature · 1 line
2.2.1
#4 lore raw

PATCH 4/7 ALSA: line6/toneport: Move setup_timer() at the beginning

In reply to Takashi Iwai

... so that timer_del_sync() in the destructor can be called safely at any time. Also move the mod_timer() call in toneport_setup(), which is a bit clearer place.

---
 sound/usb/line6/toneport.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
sound/usb/line6/toneport.c +5 -4
index e5669bd3233a..fb6d5e1e2ade 100644
@@ -360,6 +360,8 @@ static void toneport_setup(struct usb_line6_toneport *toneport)
 
 	if (toneport_has_led(toneport->type))
 		toneport_update_led(&usbdev->dev);
+
+	mod_timer(&toneport->timer, jiffies + TONEPORT_PCM_DELAY * HZ);
 }
 
 /*
@@ -390,6 +392,9 @@ static int toneport_init(struct usb_interface *interface,
 	int err;
 	struct usb_line6_toneport *toneport =  (struct usb_line6_toneport *) line6;
 
+	setup_timer(&toneport->timer, toneport_start_pcm,
+		    (unsigned long)toneport);
+
 	line6->disconnect = line6_toneport_disconnect;
 
 	/* initialize PCM subsystem: */
@@ -435,10 +440,6 @@ static int toneport_init(struct usb_interface *interface,
 
 	toneport_setup(toneport);
 
-	setup_timer(&toneport->timer, toneport_start_pcm,
-		    (unsigned long)toneport);
-	mod_timer(&toneport->timer, jiffies + TONEPORT_PCM_DELAY * HZ);
-
 	/* register audio system: */
 	return snd_card_register(line6->card);
 }
Signature · 1 line
2.2.1
#5 lore raw

PATCH 5/7 ALSA: line6: Don't forget to call driver's destructor at error path

In reply to Takashi Iwai

Currently disconnect callback is used as a driver's destructor, and this has to be called not only at the disconnection time but also at the error paths during probe.

---
 sound/usb/line6/driver.c | 2 ++
 1 file changed, 2 insertions(+)
sound/usb/line6/driver.c +2 -0
index 625272fe227a..e7f9a99e1949 100644
@@ -568,6 +568,8 @@ int line6_probe(struct usb_interface *interface,
 	return 0;
 
  err_destruct:
+	if (line6->disconnect)
+		line6->disconnect(interface);
 	snd_card_free(card);
  err_put:
 	return ret;
Signature · 1 line
2.2.1
#6 lore raw

PATCH 6/7 ALSA: line6/toneport: Fix wrong argument for toneport_has_led()

In reply to Takashi Iwai
---
 sound/usb/line6/toneport.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
sound/usb/line6/toneport.c +1 -3
index fb6d5e1e2ade..9a4f5403569e 100644
@@ -370,13 +370,11 @@ static void toneport_setup(struct usb_line6_toneport *toneport)
 static void line6_toneport_disconnect(struct usb_interface *interface)
 {
 	struct usb_line6_toneport *toneport;
-	u16 idProduct;
 
 	toneport = usb_get_intfdata(interface);
 	del_timer_sync(&toneport->timer);
-	idProduct = le16_to_cpu(toneport->line6.usbdev->descriptor.idProduct);
 
-	if (toneport_has_led(idProduct)) {
+	if (toneport_has_led(toneport->type)) {
 		device_remove_file(&interface->dev, &dev_attr_led_red);
 		device_remove_file(&interface->dev, &dev_attr_led_green);
 	}
Signature · 1 line
2.2.1
#7 lore raw

PATCH 7/7 ALSA: line6/toneport: Implement LED controls via LED class

In reply to Takashi Iwai

Instead of non-standard sysfs, reimplement the LED controls on TonePort as LED class devices.

---
 sound/usb/line6/Kconfig    |   2 +
 sound/usb/line6/toneport.c | 163 +++++++++++++++++++++++++--------------------
 2 files changed, 91 insertions(+), 74 deletions(-)
sound/usb/line6/Kconfig +2 -0
index af20947e0bda..f4585d378ef3 100644
@@ -29,6 +29,8 @@ config SND_USB_PODHD
 config SND_USB_TONEPORT
 	tristate "TonePort GX, UX1 and UX2 USB support"
 	select SND_USB_LINE6
+	select NEW_LEDS
+	select LEDS_CLASS
 	help
 	  This is a driver for TonePort GX, UX1 and UX2 devices.
 
sound/usb/line6/toneport.c +89 -74

217 lines not on this page · raw message

Signature · 1 line
2.2.1