dm: usb: udc: Use SEQ_ALIAS to index the USB gadget ports
dfu, fastbot and other usb gadget commands take the USB port index as a parameter. Currently this index is assigned in the order of the driver bindings. Changing this behavior using the SEQ_ALIAS feature. This option assign to the device a SEQ number based on its alias (if it exists) To use it we must set the DM_UC_FLAG_SEQ_ALIAS flag and follow the existing naming convention: use "usb" for the name of the gadget UCLASS_DRIVER (same as for the UCLASS_USB). If no alias is provided, then the index falls back to the order in which the bindings took place. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reported-by: Sam Protsenko <semen.protsenko@linaro.org> Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> Tested-by: Sam Protsenko <semen.protsenko@linaro.org>
This commit is contained in:
		
							parent
							
								
									8c6cc71b40
								
							
						
					
					
						commit
						801f1fa442
					
				|  | @ -20,7 +20,7 @@ int usb_gadget_initialize(int index) | ||||||
| 		return -EINVAL; | 		return -EINVAL; | ||||||
| 	if (dev_array[index]) | 	if (dev_array[index]) | ||||||
| 		return 0; | 		return 0; | ||||||
| 	ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, index, &dev); | 	ret = uclass_get_device_by_seq(UCLASS_USB_GADGET_GENERIC, index, &dev); | ||||||
| 	if (!dev || ret) { | 	if (!dev || ret) { | ||||||
| 		pr_err("No USB device found\n"); | 		pr_err("No USB device found\n"); | ||||||
| 		return -ENODEV; | 		return -ENODEV; | ||||||
|  | @ -54,5 +54,6 @@ int usb_gadget_handle_interrupts(int index) | ||||||
| 
 | 
 | ||||||
| UCLASS_DRIVER(usb_gadget_generic) = { | UCLASS_DRIVER(usb_gadget_generic) = { | ||||||
| 	.id		= UCLASS_USB_GADGET_GENERIC, | 	.id		= UCLASS_USB_GADGET_GENERIC, | ||||||
| 	.name		= "usb_gadget_generic", | 	.name		= "usb", | ||||||
|  | 	.flags		= DM_UC_FLAG_SEQ_ALIAS, | ||||||
| }; | }; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue