ni_usb: bug when setting kernel timer

Stefan Mahr <[email protected]>
Newsgroups gmane.linux.hardware.gpib.general
Message-ID <[email protected]>
Hi,

There's a timer initialisation bug in ni_usb driver, especially
for NI_USB_B. The timer is setup after first use of mod_timer
(ni_usb_b_read_serial_number->usb_send_bulk_msg), so kernel throws a
bug in timer.c: BUG_ON(!timer->function);

Attached patch should fix this issue.

BR,
Stefan

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Linux-gpib-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-gpib-general
timer.patch (text/x-patch, 981 B)
Index: drivers/gpib/ni_usb/ni_usb_gpib.c
===================================================================
--- drivers/gpib/ni_usb/ni_usb_gpib.c	(Revision 1749)
+++ drivers/gpib/ni_usb/ni_usb_gpib.c	(Arbeitskopie)
@@ -2119,6 +2119,13 @@
 	}
 	product_id = USBID_TO_CPU(interface_to_usbdev(ni_priv->bus_interface)->descriptor.idProduct);
 	printk("\tproduct id=0x%x\n", product_id);
+    
+#ifdef HAVE_TIMER_SETUP
+	timer_setup(&ni_priv->bulk_timer, ni_usb_timeout_handler, 0);
+#else
+	setup_timer(&ni_priv->bulk_timer, ni_usb_timeout_handler, (unsigned long)ni_priv);
+#endif
+    
 	if(product_id == USB_DEVICE_ID_NI_USB_B)
 	{
 		ni_priv->bulk_out_endpoint = NIUSB_B_BULK_OUT_ENDPOINT;
@@ -2166,12 +2173,6 @@
 		return retval;
 	}
 
-#ifdef HAVE_TIMER_SETUP
-	timer_setup(&ni_priv->bulk_timer, ni_usb_timeout_handler, 0);
-#else
-	setup_timer(&ni_priv->bulk_timer, ni_usb_timeout_handler, (unsigned long)ni_priv);
-#endif
-
 	retval = ni_usb_init(board);
 	if(retval < 0)
 	{
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.