diff mbox series

[3/5] usb: gadget: CDC ACM: call usb_gadget_initialize

Message ID 20240131-b4-qcom-usb-v1-3-6438b2a2285e@linaro.org
State Superseded
Headers show
Series Qualcomm DWC3 USB support | expand

Commit Message

Caleb Connolly Jan. 31, 2024, 2:57 p.m. UTC
To actually use the gadget the peripheral driver must be probed and we
must call g_dnl_clear_detach(). Otherwise acm_stdio_start() will always
fail to find a UDC on DT platforms.

Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
---
 drivers/usb/gadget/f_acm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Mattijs Korpershoek Feb. 1, 2024, 1:37 p.m. UTC | #1
Hi Caleb,

Thank you for the patch.

On mer., janv. 31, 2024 at 14:57, Caleb Connolly <caleb.connolly@linaro.org> wrote:

> To actually use the gadget the peripheral driver must be probed and we
> must call g_dnl_clear_detach(). Otherwise acm_stdio_start() will always
> fail to find a UDC on DT platforms.
>
> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

> ---
>  drivers/usb/gadget/f_acm.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c
> index de42e0189e8d..ba216128ab27 100644
> --- a/drivers/usb/gadget/f_acm.c
> +++ b/drivers/usb/gadget/f_acm.c
> @@ -623,12 +623,21 @@ static void acm_stdio_puts(struct stdio_dev *dev, const char *str)
>  
>  static int acm_stdio_start(struct stdio_dev *dev)
>  {
> +	struct udevice *udc;
>  	int ret;
>  
>  	if (dev->priv) { /* function already exist */
>  		return 0;
>  	}
>  
> +	ret = udc_device_get_by_index(0, &udc);
> +	if (ret) {
> +		pr_err("USB init failed: %d\n", ret);
> +		return ret;
> +	}
> +
> +	g_dnl_clear_detach();
> +
>  	ret = g_dnl_register("usb_serial_acm");
>  	if (ret)
>  		return ret;
>
> -- 
> 2.43.0
diff mbox series

Patch

diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c
index de42e0189e8d..ba216128ab27 100644
--- a/drivers/usb/gadget/f_acm.c
+++ b/drivers/usb/gadget/f_acm.c
@@ -623,12 +623,21 @@  static void acm_stdio_puts(struct stdio_dev *dev, const char *str)
 
 static int acm_stdio_start(struct stdio_dev *dev)
 {
+	struct udevice *udc;
 	int ret;
 
 	if (dev->priv) { /* function already exist */
 		return 0;
 	}
 
+	ret = udc_device_get_by_index(0, &udc);
+	if (ret) {
+		pr_err("USB init failed: %d\n", ret);
+		return ret;
+	}
+
+	g_dnl_clear_detach();
+
 	ret = g_dnl_register("usb_serial_acm");
 	if (ret)
 		return ret;