Skip to contentSkip to conversation

staging: usbip: convert usbip-host driver to usb_device_driver

PATCH Superseded Valentina Manea 3 participants 8 messages Jan 23, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: usbip: convert usbip-host driver to usb_device_driver

This driver was previously an interface driver. Since USB/IP exports a whole device, not just an interface, it would make sense to be a device driver.

This patch also modifies the way userspace sees and uses a shared device - dealing with interfaces is no longer required.

---
 drivers/staging/usbip/stub.h                       |   2 +-
 drivers/staging/usbip/stub_dev.c                   | 150 ++++++++-------------
 drivers/staging/usbip/stub_main.c                  |   6 +-
 drivers/staging/usbip/stub_rx.c                    |   2 +-
 .../usbip/userspace/libsrc/usbip_host_driver.c     |  50 ++-----
 drivers/staging/usbip/userspace/src/usbip_bind.c   | 142 ++++++++-----------
 drivers/staging/usbip/userspace/src/usbip_list.c   |  19 +--
 drivers/staging/usbip/userspace/src/usbip_unbind.c |  51 ++-----
 drivers/staging/usbip/userspace/src/usbipd.c       |  15 ---
 drivers/usb/core/generic.c                         |   1 +
 drivers/usb/core/message.c                         |   1 +
 include/linux/usb.h                                |   4 +
 12 files changed, 148 insertions(+), 295 deletions(-)
drivers/staging/usbip/stub.h +1 -1
index a73e437..82e539a 100644
@@ -93,7 +93,7 @@ struct bus_id_priv {
 extern struct kmem_cache *stub_priv_cache;
 
 /* stub_dev.c */
-extern struct usb_driver stub_driver;
+extern struct usb_device_driver stub_driver;
 
 /* stub_main.c */
 struct bus_id_priv *get_busid_priv(const char *busid);
drivers/staging/usbip/stub_dev.c +53 -97

255 lines not on this page · raw message

drivers/staging/usbip/stub_main.c +3 -3
index baf857f..bd7b83a 100644
@@ -254,7 +254,7 @@ static int __init usbip_host_init(void)
 		return -ENOMEM;
 	}
 
-	ret = usb_register(&stub_driver);
+	ret = usb_register_device_driver(&stub_driver, THIS_MODULE);
 	if (ret) {
 		pr_err("usb_register failed %d\n", ret);
 		goto err_usb_register;
@@ -271,7 +271,7 @@ static int __init usbip_host_init(void)
 	return ret;
 
 err_create_file:
-	usb_deregister(&stub_driver);
+	usb_deregister_device_driver(&stub_driver);
 err_usb_register:
 	kmem_cache_destroy(stub_priv_cache);
 	return ret;
@@ -286,7 +286,7 @@ static void __exit usbip_host_exit(void)
 	 * deregister() calls stub_disconnect() for all devices. Device
 	 * specific data is cleared in stub_disconnect().
 	 */
-	usb_deregister(&stub_driver);
+	usb_deregister_device_driver(&stub_driver);
 
 	kmem_cache_destroy(stub_priv_cache);
 }
drivers/staging/usbip/stub_rx.c +1 -1
index 5d1d4a1..76e44d9 100644
@@ -550,7 +550,7 @@ static void stub_rx_pdu(struct usbip_device *ud)
 	int ret;
 	struct usbip_header pdu;
 	struct stub_device *sdev = container_of(ud, struct stub_device, ud);
-	struct device *dev = &sdev->interface->dev;
+	struct device *dev = &sdev->udev->dev;
 
 	usbip_dbg_stub_rx("Enter\n");
 
drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c +14 -36

83 lines not on this page · raw message

drivers/staging/usbip/userspace/src/usbip_bind.c +55 -87

195 lines not on this page · raw message

drivers/staging/usbip/userspace/src/usbip_list.c +1 -18
index 237e099..8864fa2 100644
@@ -52,9 +52,8 @@ static int get_exported_devices(char *host, int sockfd)
 	struct op_devlist_reply reply;
 	uint16_t code = OP_REP_DEVLIST;
 	struct usbip_usb_device udev;
-	struct usbip_usb_interface uintf;
 	unsigned int i;
-	int j, rc;
+	int rc;
 
 	rc = usbip_net_send_op_common(sockfd, OP_REQ_DEVLIST, 0);
 	if (rc < 0) {
@@ -104,22 +103,6 @@ static int get_exported_devices(char *host, int sockfd)
 		printf("%11s: %s\n", "", udev.path);
 		printf("%11s: %s\n", "", class_name);
 
-		for (j = 0; j < udev.bNumInterfaces; j++) {
-			rc = usbip_net_recv(sockfd, &uintf, sizeof(uintf));
-			if (rc < 0) {
-				dbg("usbip_net_recv failed: usbip_usb_intf[%d]",
-				    j);
-
-				return -1;
-			}
-			usbip_net_pack_usb_interface(0, &uintf);
-
-			usbip_names_get_class(class_name, sizeof(class_name),
-					      uintf.bInterfaceClass,
-					      uintf.bInterfaceSubClass,
-					      uintf.bInterfaceProtocol);
-			printf("%11s: %2d - %s\n", "", j, class_name);
-		}
 		printf("\n");
 	}
 
drivers/staging/usbip/userspace/src/usbip_unbind.c +14 -37

81 lines not on this page · raw message

drivers/staging/usbip/userspace/src/usbipd.c +0 -15
index 7980f8b..c2b3ced 100644
@@ -159,9 +159,7 @@ static int send_reply_devlist(int connfd)
 {
 	struct usbip_exported_device *edev;
 	struct usbip_usb_device pdu_udev;
-	struct usbip_usb_interface pdu_uinf;
 	struct op_devlist_reply reply;
-	int i;
 	int rc;
 
 	reply.ndev = 0;
@@ -196,19 +194,6 @@ static int send_reply_devlist(int connfd)
 			dbg("usbip_net_send failed: pdu_udev");
 			return -1;
 		}
-
-		for (i = 0; i < edev->udev.bNumInterfaces; i++) {
-			dump_usb_interface(&edev->uinf[i]);
-			memcpy(&pdu_uinf, &edev->uinf[i], sizeof(pdu_uinf));
-			usbip_net_pack_usb_interface(1, &pdu_uinf);
-
-			rc = usbip_net_send(connfd, &pdu_uinf,
-					    sizeof(pdu_uinf));
-			if (rc < 0) {
-				dbg("usbip_net_send failed: pdu_uinf");
-				return -1;
-			}
-		}
 	}
 
 	return 0;
drivers/usb/core/generic.c +1 -0
index acbfeb0..2770d55 100644
@@ -155,6 +155,7 @@ int usb_choose_configuration(struct usb_device *udev)
 	}
 	return i;
 }
+EXPORT_SYMBOL(usb_choose_configuration);
 
 static int generic_probe(struct usb_device *udev)
 {
drivers/usb/core/message.c +1 -0
index bb31597..fb0a555 100644
@@ -1921,6 +1921,7 @@ free_interfaces:
 	usb_autosuspend_device(dev);
 	return 0;
 }
+EXPORT_SYMBOL(usb_set_configuration);
 
 static LIST_HEAD(set_config_list);
 static DEFINE_SPINLOCK(set_config_lock);
include/linux/usb.h +4 -0
index 512ab16..839d668 100644
@@ -1667,6 +1667,10 @@ extern void usb_reset_endpoint(struct usb_device *dev, unsigned int epaddr);
 /* this request isn't really synchronous, but it belongs with the others */
 extern int usb_driver_set_configuration(struct usb_device *udev, int config);
 
+/* choose and set configuration for device */
+extern int usb_choose_configuration(struct usb_device *udev);
+extern int usb_set_configuration(struct usb_device *dev, int configuration);
+
 /*
  * timeouts, in milliseconds, used for sending/receiving control messages
  * they typically complete within a few frames (msec) after they're issued
Signature · 1 line
1.8.1.2
maintainer
#1 lore raw
Quoted 6 lines · Valentina Manea

This driver was previously an interface driver. Since USB/IP exports a whole device, not just an interface, it would make sense to be a device driver.

This patch also modifies the way userspace sees and uses a shared device - dealing with interfaces is no longer required.

In what way is this modified? What is now different?

Quoted 15 lines
drivers/usb/core/generic.c +1 -0
@@ -155,6 +155,7 @@ int usb_choose_configuration(struct usb_device *udev)
 	}
 	return i;
 }
+EXPORT_SYMBOL(usb_choose_configuration);
 
 static int generic_probe(struct usb_device *udev)
 {
drivers/usb/core/message.c +0 -0
index bb31597..fb0a555 100644

drivers/usb/core/message.c free_interfaces: · line 1927

Quoted 7 lines
drivers/usb/core/message.c +1 -0
@@ -1921,6 +1921,7 @@ free_interfaces:
 	usb_autosuspend_device(dev);
 	return 0;
 }
+EXPORT_SYMBOL(usb_set_configuration);
 
 static LIST_HEAD(set_config_list);
 static DEFINE_SPINLOCK(set_config_lock);

Please make both of these EXPORT_SYMBOL_GPL(), like the rest of the USB symbols are.

thanks,

greg k-h

#2 lore raw
Quoted 10 lines · Greg KH
Quoted 6 lines · Valentina Manea

This driver was previously an interface driver. Since USB/IP exports a whole device, not just an interface, it would make sense to be a device driver.

This patch also modifies the way userspace sees and uses a shared device - dealing with interfaces is no longer required.

In what way is this modified? What is now different?

1. The usbip_status file is no longer created for interface 0, but for the whole device (such as /sys/devices/pci0000:00/0000:00:01.2/usb1/1-1/usbip_status).
2. Per interface information, such as interface class or protocol, is no longer sent/received. Only device specific information is transmitted.
3. Since the driver was moved one level below in the USB architecture, there is no need to bind/unbind each interface, just the device as a whole.

Quoted 3 lines

Please make both of these EXPORT_SYMBOL_GPL(), like the rest of the USB symbols are.

Will fix in V2.

Thanks,
Valentina

maintainer
#3 lore raw
Quoted 12 lines · Valentina Manea
Quoted 10 lines · Greg KH
Quoted 6 lines · Valentina Manea

This driver was previously an interface driver. Since USB/IP exports a whole device, not just an interface, it would make sense to be a device driver.

This patch also modifies the way userspace sees and uses a shared device - dealing with interfaces is no longer required.

In what way is this modified? What is now different?

Quoted 9 lines

1. The usbip_status file is no longer created for interface 0, but for the whole device (such as /sys/devices/pci0000:00/0000:00:01.2/usb1/1-1/usbip_status).
2. Per interface information, such as interface class or protocol, is no longer sent/received. Only device specific information is transmitted.
3. Since the driver was moved one level below in the USB architecture, there is no need to bind/unbind each interface, just the device as a whole.

Please say all of this in your changelog entry :)

thanks,

greg k-h

#4 lore raw
In reply to Valentina Manea
Quoted 9 lines · Valentina Manea

1. The usbip_status file is no longer created for interface 0, but for the whole device (such as /sys/devices/pci0000:00/0000:00:01.2/usb1/1-1/usbip_status).
2. Per interface information, such as interface class or protocol, is no longer sent/received. Only device specific information is transmitted.
3. Since the driver was moved one level below in the USB architecture, there is no need to bind/unbind each interface, just the device as a whole.

If you don't bind the interfaces, they will naturally bind to their normal drivers on the host. You probably don't want that to happen. (Although, at the moment, I don't see how you can prevent it.)

Also, in your patch, stub_probe() calls usb_choose_configuration(). Shouldn't that be done by the client, since the client now has access to the entire device?

Alan Stern

#5 lore raw
Quoted 4 lines

If you don't bind the interfaces, they will naturally bind to their normal drivers on the host. You probably don't want that to happen. (Although, at the moment, I don't see how you can prevent it.)

That's true but, the way I see USB/IP general use case, the drivers from the host the device is physically attached to won't even be actually used, since the host doesn't use the device. However, I can't think of a way to enforce this.

Quoted 3 lines

Also, in your patch, stub_probe() calls usb_choose_configuration(). Shouldn't that be done by the client, since the client now has access to the entire device?

I think the normal user just wants things *to work*. Surely, for advanced user an option for choosing the configuration could be added but I, personally, don't see it as a necessity at this point.

Thanks,
Valentina

#6 lore raw

PATCH v2 1/1 staging: usbip: convert usbip-host driver to usb_device_driver

In reply to Valentina Manea

This driver was previously an interface driver. Since USB/IP exports a whole device, not just an interface, it would make sense to be a device driver.

This patch also modifies the way userspace sees and uses a shared device:

* the usbip_status file is no longer created for interface 0, but for the whole device (such as /sys/devices/pci0000:00/0000:00:01.2/usb1/1-1/usbip_status).
* per interface information, such as interface class or protocol, is no longer sent/received; only device specific information is transmitted.
* since the driver was moved one level below in the USB architecture, there is no need to bind/unbind each interface, just the device as a whole.

---
Changes since v1:
* add extra information to the commit message
* remove a comment that was no longer available
* export USB functions as GPL

 drivers/staging/usbip/stub.h                       |   2 +-
 drivers/staging/usbip/stub_dev.c                   | 150 ++++++++-------------
 drivers/staging/usbip/stub_main.c                  |   6 +-
 drivers/staging/usbip/stub_rx.c                    |   2 +-
 .../usbip/userspace/libsrc/usbip_host_driver.c     |  51 ++-----
 drivers/staging/usbip/userspace/src/usbip_bind.c   | 142 ++++++++-----------
 drivers/staging/usbip/userspace/src/usbip_list.c   |  19 +--
 drivers/staging/usbip/userspace/src/usbip_unbind.c |  51 ++-----
 drivers/staging/usbip/userspace/src/usbipd.c       |  15 ---
 drivers/usb/core/generic.c                         |   1 +
 drivers/usb/core/message.c                         |   1 +
 include/linux/usb.h                                |   4 +
 12 files changed, 148 insertions(+), 296 deletions(-)
drivers/staging/usbip/stub.h +1 -1
index a73e437..82e539a 100644
@@ -93,7 +93,7 @@ struct bus_id_priv {
 extern struct kmem_cache *stub_priv_cache;
 
 /* stub_dev.c */
-extern struct usb_driver stub_driver;
+extern struct usb_device_driver stub_driver;
 
 /* stub_main.c */
 struct bus_id_priv *get_busid_priv(const char *busid);
drivers/staging/usbip/stub_dev.c +53 -97

255 lines not on this page · raw message

drivers/staging/usbip/stub_main.c +3 -3
index baf857f..bd7b83a 100644
@@ -254,7 +254,7 @@ static int __init usbip_host_init(void)
 		return -ENOMEM;
 	}
 
-	ret = usb_register(&stub_driver);
+	ret = usb_register_device_driver(&stub_driver, THIS_MODULE);
 	if (ret) {
 		pr_err("usb_register failed %d\n", ret);
 		goto err_usb_register;
@@ -271,7 +271,7 @@ static int __init usbip_host_init(void)
 	return ret;
 
 err_create_file:
-	usb_deregister(&stub_driver);
+	usb_deregister_device_driver(&stub_driver);
 err_usb_register:
 	kmem_cache_destroy(stub_priv_cache);
 	return ret;
@@ -286,7 +286,7 @@ static void __exit usbip_host_exit(void)
 	 * deregister() calls stub_disconnect() for all devices. Device
 	 * specific data is cleared in stub_disconnect().
 	 */
-	usb_deregister(&stub_driver);
+	usb_deregister_device_driver(&stub_driver);
 
 	kmem_cache_destroy(stub_priv_cache);
 }
drivers/staging/usbip/stub_rx.c +1 -1
index 5d1d4a1..76e44d9 100644
@@ -550,7 +550,7 @@ static void stub_rx_pdu(struct usbip_device *ud)
 	int ret;
 	struct usbip_header pdu;
 	struct stub_device *sdev = container_of(ud, struct stub_device, ud);
-	struct device *dev = &sdev->interface->dev;
+	struct device *dev = &sdev->udev->dev;
 
 	usbip_dbg_stub_rx("Enter\n");
 
drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c +14 -37

90 lines not on this page · raw message

drivers/staging/usbip/userspace/src/usbip_bind.c +55 -87

195 lines not on this page · raw message

drivers/staging/usbip/userspace/src/usbip_list.c +1 -18
index 237e099..8864fa2 100644
@@ -52,9 +52,8 @@ static int get_exported_devices(char *host, int sockfd)
 	struct op_devlist_reply reply;
 	uint16_t code = OP_REP_DEVLIST;
 	struct usbip_usb_device udev;
-	struct usbip_usb_interface uintf;
 	unsigned int i;
-	int j, rc;
+	int rc;
 
 	rc = usbip_net_send_op_common(sockfd, OP_REQ_DEVLIST, 0);
 	if (rc < 0) {
@@ -104,22 +103,6 @@ static int get_exported_devices(char *host, int sockfd)
 		printf("%11s: %s\n", "", udev.path);
 		printf("%11s: %s\n", "", class_name);
 
-		for (j = 0; j < udev.bNumInterfaces; j++) {
-			rc = usbip_net_recv(sockfd, &uintf, sizeof(uintf));
-			if (rc < 0) {
-				dbg("usbip_net_recv failed: usbip_usb_intf[%d]",
-				    j);
-
-				return -1;
-			}
-			usbip_net_pack_usb_interface(0, &uintf);
-
-			usbip_names_get_class(class_name, sizeof(class_name),
-					      uintf.bInterfaceClass,
-					      uintf.bInterfaceSubClass,
-					      uintf.bInterfaceProtocol);
-			printf("%11s: %2d - %s\n", "", j, class_name);
-		}
 		printf("\n");
 	}
 
drivers/staging/usbip/userspace/src/usbip_unbind.c +14 -37

81 lines not on this page · raw message

drivers/staging/usbip/userspace/src/usbipd.c +0 -15
index 7980f8b..c2b3ced 100644
@@ -159,9 +159,7 @@ static int send_reply_devlist(int connfd)
 {
 	struct usbip_exported_device *edev;
 	struct usbip_usb_device pdu_udev;
-	struct usbip_usb_interface pdu_uinf;
 	struct op_devlist_reply reply;
-	int i;
 	int rc;
 
 	reply.ndev = 0;
@@ -196,19 +194,6 @@ static int send_reply_devlist(int connfd)
 			dbg("usbip_net_send failed: pdu_udev");
 			return -1;
 		}
-
-		for (i = 0; i < edev->udev.bNumInterfaces; i++) {
-			dump_usb_interface(&edev->uinf[i]);
-			memcpy(&pdu_uinf, &edev->uinf[i], sizeof(pdu_uinf));
-			usbip_net_pack_usb_interface(1, &pdu_uinf);
-
-			rc = usbip_net_send(connfd, &pdu_uinf,
-					    sizeof(pdu_uinf));
-			if (rc < 0) {
-				dbg("usbip_net_send failed: pdu_uinf");
-				return -1;
-			}
-		}
 	}
 
 	return 0;
drivers/usb/core/generic.c +1 -0
index acbfeb0..358ca8d 100644
@@ -155,6 +155,7 @@ int usb_choose_configuration(struct usb_device *udev)
 	}
 	return i;
 }
+EXPORT_SYMBOL_GPL(usb_choose_configuration);
 
 static int generic_probe(struct usb_device *udev)
 {
drivers/usb/core/message.c +1 -0
index bb31597..a5976d8 100644
@@ -1921,6 +1921,7 @@ free_interfaces:
 	usb_autosuspend_device(dev);
 	return 0;
 }
+EXPORT_SYMBOL_GPL(usb_set_configuration);
 
 static LIST_HEAD(set_config_list);
 static DEFINE_SPINLOCK(set_config_lock);
include/linux/usb.h +4 -0
index 512ab16..839d668 100644
@@ -1667,6 +1667,10 @@ extern void usb_reset_endpoint(struct usb_device *dev, unsigned int epaddr);
 /* this request isn't really synchronous, but it belongs with the others */
 extern int usb_driver_set_configuration(struct usb_device *udev, int config);
 
+/* choose and set configuration for device */
+extern int usb_choose_configuration(struct usb_device *udev);
+extern int usb_set_configuration(struct usb_device *dev, int configuration);
+
 /*
  * timeouts, in milliseconds, used for sending/receiving control messages
  * they typically complete within a few frames (msec) after they're issued
Signature · 1 line
1.8.1.2
#7 lore raw

PATCH v3 1/1 staging: usbip: convert usbip-host driver to usb_device_driver

In reply to Valentina Manea

This driver was previously an interface driver. Since USB/IP exports a whole device, not just an interface, it would make sense to be a device driver.

This patch also modifies the way userspace sees and uses a shared device:

* the usbip_status file is no longer created for interface 0, but for the whole device (such as /sys/devices/pci0000:00/0000:00:01.2/usb1/1-1/usbip_status).
* per interface information, such as interface class or protocol, is no longer sent/received; only device specific information is transmitted.
* since the driver was moved one level below in the USB architecture, there is no need to bind/unbind each interface, just the device as a whole.

---
Changes since v2:
* re-add check for empty device list

 drivers/staging/usbip/stub.h                       |   2 +-
 drivers/staging/usbip/stub_dev.c                   | 150 ++++++++-------------
 drivers/staging/usbip/stub_main.c                  |   6 +-
 drivers/staging/usbip/stub_rx.c                    |   2 +-
 .../usbip/userspace/libsrc/usbip_host_driver.c     |  45 +++----
 drivers/staging/usbip/userspace/src/usbip_bind.c   | 142 ++++++++-----------
 drivers/staging/usbip/userspace/src/usbip_list.c   |  19 +--
 drivers/staging/usbip/userspace/src/usbip_unbind.c |  51 ++-----
 drivers/staging/usbip/userspace/src/usbipd.c       |  15 ---
 drivers/usb/core/generic.c                         |   1 +
 drivers/usb/core/message.c                         |   1 +
 include/linux/usb.h                                |   4 +
 12 files changed, 150 insertions(+), 288 deletions(-)
drivers/staging/usbip/stub.h +1 -1
index a73e437..82e539a 100644
@@ -93,7 +93,7 @@ struct bus_id_priv {
 extern struct kmem_cache *stub_priv_cache;
 
 /* stub_dev.c */
-extern struct usb_driver stub_driver;
+extern struct usb_device_driver stub_driver;
 
 /* stub_main.c */
 struct bus_id_priv *get_busid_priv(const char *busid);
drivers/staging/usbip/stub_dev.c +53 -97

255 lines not on this page · raw message

drivers/staging/usbip/stub_main.c +3 -3
index baf857f..bd7b83a 100644
@@ -254,7 +254,7 @@ static int __init usbip_host_init(void)
 		return -ENOMEM;
 	}
 
-	ret = usb_register(&stub_driver);
+	ret = usb_register_device_driver(&stub_driver, THIS_MODULE);
 	if (ret) {
 		pr_err("usb_register failed %d\n", ret);
 		goto err_usb_register;
@@ -271,7 +271,7 @@ static int __init usbip_host_init(void)
 	return ret;
 
 err_create_file:
-	usb_deregister(&stub_driver);
+	usb_deregister_device_driver(&stub_driver);
 err_usb_register:
 	kmem_cache_destroy(stub_priv_cache);
 	return ret;
@@ -286,7 +286,7 @@ static void __exit usbip_host_exit(void)
 	 * deregister() calls stub_disconnect() for all devices. Device
 	 * specific data is cleared in stub_disconnect().
 	 */
-	usb_deregister(&stub_driver);
+	usb_deregister_device_driver(&stub_driver);
 
 	kmem_cache_destroy(stub_priv_cache);
 }
drivers/staging/usbip/stub_rx.c +1 -1
index 5d1d4a1..76e44d9 100644
@@ -550,7 +550,7 @@ static void stub_rx_pdu(struct usbip_device *ud)
 	int ret;
 	struct usbip_header pdu;
 	struct stub_device *sdev = container_of(ud, struct stub_device, ud);
-	struct device *dev = &sdev->interface->dev;
+	struct device *dev = &sdev->udev->dev;
 
 	usbip_dbg_stub_rx("Enter\n");
 
drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c +16 -29

89 lines not on this page · raw message

drivers/staging/usbip/userspace/src/usbip_bind.c +55 -87

195 lines not on this page · raw message

drivers/staging/usbip/userspace/src/usbip_list.c +1 -18
index 237e099..8864fa2 100644
@@ -52,9 +52,8 @@ static int get_exported_devices(char *host, int sockfd)
 	struct op_devlist_reply reply;
 	uint16_t code = OP_REP_DEVLIST;
 	struct usbip_usb_device udev;
-	struct usbip_usb_interface uintf;
 	unsigned int i;
-	int j, rc;
+	int rc;
 
 	rc = usbip_net_send_op_common(sockfd, OP_REQ_DEVLIST, 0);
 	if (rc < 0) {
@@ -104,22 +103,6 @@ static int get_exported_devices(char *host, int sockfd)
 		printf("%11s: %s\n", "", udev.path);
 		printf("%11s: %s\n", "", class_name);
 
-		for (j = 0; j < udev.bNumInterfaces; j++) {
-			rc = usbip_net_recv(sockfd, &uintf, sizeof(uintf));
-			if (rc < 0) {
-				dbg("usbip_net_recv failed: usbip_usb_intf[%d]",
-				    j);
-
-				return -1;
-			}
-			usbip_net_pack_usb_interface(0, &uintf);
-
-			usbip_names_get_class(class_name, sizeof(class_name),
-					      uintf.bInterfaceClass,
-					      uintf.bInterfaceSubClass,
-					      uintf.bInterfaceProtocol);
-			printf("%11s: %2d - %s\n", "", j, class_name);
-		}
 		printf("\n");
 	}
 
drivers/staging/usbip/userspace/src/usbip_unbind.c +14 -37

81 lines not on this page · raw message

drivers/staging/usbip/userspace/src/usbipd.c +0 -15
index 7980f8b..c2b3ced 100644
@@ -159,9 +159,7 @@ static int send_reply_devlist(int connfd)
 {
 	struct usbip_exported_device *edev;
 	struct usbip_usb_device pdu_udev;
-	struct usbip_usb_interface pdu_uinf;
 	struct op_devlist_reply reply;
-	int i;
 	int rc;
 
 	reply.ndev = 0;
@@ -196,19 +194,6 @@ static int send_reply_devlist(int connfd)
 			dbg("usbip_net_send failed: pdu_udev");
 			return -1;
 		}
-
-		for (i = 0; i < edev->udev.bNumInterfaces; i++) {
-			dump_usb_interface(&edev->uinf[i]);
-			memcpy(&pdu_uinf, &edev->uinf[i], sizeof(pdu_uinf));
-			usbip_net_pack_usb_interface(1, &pdu_uinf);
-
-			rc = usbip_net_send(connfd, &pdu_uinf,
-					    sizeof(pdu_uinf));
-			if (rc < 0) {
-				dbg("usbip_net_send failed: pdu_uinf");
-				return -1;
-			}
-		}
 	}
 
 	return 0;
drivers/usb/core/generic.c +1 -0
index acbfeb0..358ca8d 100644
@@ -155,6 +155,7 @@ int usb_choose_configuration(struct usb_device *udev)
 	}
 	return i;
 }
+EXPORT_SYMBOL_GPL(usb_choose_configuration);
 
 static int generic_probe(struct usb_device *udev)
 {
drivers/usb/core/message.c +1 -0
index bb31597..a5976d8 100644
@@ -1921,6 +1921,7 @@ free_interfaces:
 	usb_autosuspend_device(dev);
 	return 0;
 }
+EXPORT_SYMBOL_GPL(usb_set_configuration);
 
 static LIST_HEAD(set_config_list);
 static DEFINE_SPINLOCK(set_config_lock);
include/linux/usb.h +4 -0
index 512ab16..839d668 100644
@@ -1667,6 +1667,10 @@ extern void usb_reset_endpoint(struct usb_device *dev, unsigned int epaddr);
 /* this request isn't really synchronous, but it belongs with the others */
 extern int usb_driver_set_configuration(struct usb_device *udev, int config);
 
+/* choose and set configuration for device */
+extern int usb_choose_configuration(struct usb_device *udev);
+extern int usb_set_configuration(struct usb_device *dev, int configuration);
+
 /*
  * timeouts, in milliseconds, used for sending/receiving control messages
  * they typically complete within a few frames (msec) after they're issued
Signature · 1 line
1.8.1.2