Ejemplo n.º 1
0
static int refresh_exported_devices(void)
{
	struct sysfs_device	*suinf;  /* sysfs_device of usb_interface */
	struct dlist		*suinf_list;

	struct sysfs_device	*sudev;  /* sysfs_device of usb_device */
	struct dlist		*sudev_list;


	sudev_list = dlist_new_with_delete(sizeof(struct sysfs_device), delete_nothing);

	suinf_list = sysfs_get_driver_devices(stub_driver->sysfs_driver);
	if (!suinf_list) {
		printf("Bind usbip.ko to a usb device to be exportable!\n");
		goto bye;
	}

	/* collect unique USB devices (not interfaces) */
	dlist_for_each_data(suinf_list, suinf, struct sysfs_device) {

		/* get usb device of this usb interface */
		sudev = sysfs_get_device_parent(suinf);
		if (!sudev) {
			err("get parent dev of %s", suinf->name);
			continue;
		}

		if (check_new(sudev_list, sudev)) {
			dlist_unshift(sudev_list, sudev);
		}
	}
static int refresh_exported_devices(void)
{
	/* sysfs_device of usb_interface */
	struct sysfs_device	*suintf;
	struct dlist		*suintf_list;
	/* sysfs_device of usb_device */
	struct sysfs_device	*sudev;
	struct dlist		*sudev_list;
	struct usbip_exported_device *edev;

	sudev_list = dlist_new_with_delete(sizeof(struct sysfs_device),
					   delete_nothing);

	suintf_list = sysfs_get_driver_devices(host_driver->sysfs_driver);
	if (!suintf_list) {
		/*
		 * Not an error condition. There are simply no devices bound to
		 * the driver yet.
		 */
		dbg("bind " USBIP_HOST_DRV_NAME ".ko to a usb device to be "
		    "exportable!");
		return 0;
	}

	/* collect unique USB devices (not interfaces) */
	dlist_for_each_data(suintf_list, suintf, struct sysfs_device) {
		/* get usb device of this usb interface */
		sudev = sysfs_get_device_parent(suintf);
		if (!sudev) {
			dbg("sysfs_get_device_parent failed: %s", suintf->name);
			continue;
		}

		if (check_new(sudev_list, sudev)) {
			/* insert item at head of list */
			dlist_unshift(sudev_list, sudev);
		}
	}