Commit 91fc0bcd authored by Andrei Emeltchenko's avatar Andrei Emeltchenko Committed by Anas Nashif
Browse files

netusb: Register each function



Register each function found in the linker USB data cfg section.

Signed-off-by: default avatarAndrei Emeltchenko <andrei.emeltchenko@intel.com>
parent 6b3c096a
Loading
Loading
Loading
Loading
+22 −12
Original line number Diff line number Diff line
@@ -196,22 +196,32 @@ static void netusb_init(struct net_if *iface)
	}

#ifndef CONFIG_USB_COMPOSITE_DEVICE
	/* Linker-defined symbols bound the USB descriptor structs */
	extern struct usb_cfg_data __usb_data_start[];
	extern struct usb_cfg_data __usb_data_end[];
	size_t size = (__usb_data_end - __usb_data_start);

	for (size_t i = 0; i < size; i++) {
		struct usb_cfg_data *cfg = &(__usb_data_start[i]);
		int ret;

	netusb_config.interface.payload_data = interface_data;
	netusb_config.usb_device_description = usb_get_device_descriptor();
		USB_DBG("Registering function %u", i);

		cfg->interface.payload_data = interface_data;
		cfg->usb_device_description = usb_get_device_descriptor();

	ret = usb_set_config(&netusb_config);
		ret = usb_set_config(cfg);
		if (ret < 0) {
			USB_ERR("Failed to configure USB device");
			return;
		}

	ret = usb_enable(&netusb_config);
		ret = usb_enable(cfg);
		if (ret < 0) {
			USB_ERR("Failed to enable USB");
			return;
		}
	}
#endif /* CONFIG_USB_COMPOSITE_DEVICE */

	USB_INF("netusb initialized");