ni_usb with multiple devices

Manuel Mommertz <[email protected]>
Newsgroups gmane.linux.hardware.gpib.general
Organization Desy
Message-ID <[email protected]>
Hey,

we want to use multiple GPIB-adapter from NI on one host. But there is 
currently no way to fix the association between a GPIB-board and an NI-GPIB-
adapter. With each reboot we get a random mapping. To fix this quick and dirty 
I prepared the attached patch against linux-gpib-modules-4.2.0-rc1.

To fix it the right way, I think there should be another config entry, like 
'usb_serial'. Would be nice if you can include support for this in future 
versions.

Regards,
Manuel

_______________________________________________
Linux-gpib-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-gpib-general
ni_usb_select.patch (text/x-patch, 1.1 KB)
--- drivers/gpib/ni_usb/ni_usb_gpib.c	(revision 1758)
+++ drivers/gpib/ni_usb/ni_usb_gpib.c	(working copy)
@@ -2073,6 +2073,11 @@
 	return retval;
 }
 
+static inline int ni_usb_device_match(struct usb_interface *interface, const gpib_board_config_t *config)
+{
+    return config->device_tree_path == NULL || strcmp(interface_to_usbdev(interface)->serial, config->device_tree_path) == 0;
+}
+
 int ni_usb_attach(gpib_board_t *board, const gpib_board_config_t *config)
 {
 	int retval;
@@ -2089,11 +2094,9 @@
 		return retval;
 	}
 	ni_priv = board->private_data;
-	/*FIXME: should allow user to specifiy which device he wants to attach.
-	 Use usb_make_path() */
 	for(i = 0; i < MAX_NUM_NI_USB_INTERFACES; i++)
 	{
-		if(ni_usb_driver_interfaces[i] && usb_get_intfdata(ni_usb_driver_interfaces[i]) == NULL)
+		if(ni_usb_driver_interfaces[i] && usb_get_intfdata(ni_usb_driver_interfaces[i]) == NULL && ni_usb_device_match(ni_usb_driver_interfaces[i], config))
 		{
 			ni_priv->bus_interface = ni_usb_driver_interfaces[i];
 			usb_set_intfdata(ni_usb_driver_interfaces[i], board);
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.