diff mbox series

USB: gadget: usb function sourcesink and loopback support usb configfs

Message ID 20230801104223.281275-1-zhouscd@gmail.com
State New
Headers show
Series USB: gadget: usb function sourcesink and loopback support usb configfs | expand

Commit Message

zhouscd Aug. 1, 2023, 10:42 a.m. UTC
There are currently two issues that causes sourcesink and loopback to
fail to export to usb configfs:
1. usb_function.name does not match usb_function_driver.name
2. usb configfs does not support function name with '/'

So, we adjusted usb_function.name to "sourcesink" and "loopback",
and remove '/'

Signed-off-by: chengdong zhou <zhouscd@gmail.com>
---
 drivers/usb/gadget/function/f_loopback.c   |  6 +++---
 drivers/usb/gadget/function/f_sourcesink.c | 20 ++++++++++----------
 drivers/usb/gadget/legacy/zero.c           |  6 +++---
 3 files changed, 16 insertions(+), 16 deletions(-)

Comments

Greg Kroah-Hartman Aug. 4, 2023, 12:41 p.m. UTC | #1
On Tue, Aug 01, 2023 at 03:42:23AM -0700, chengdong zhou wrote:
> There are currently two issues that causes sourcesink and loopback to
> fail to export to usb configfs:
> 1. usb_function.name does not match usb_function_driver.name
> 2. usb configfs does not support function name with '/'
> 
> So, we adjusted usb_function.name to "sourcesink" and "loopback",
> and remove '/'
> 
> Signed-off-by: chengdong zhou <zhouscd@gmail.com>
> ---
>  drivers/usb/gadget/function/f_loopback.c   |  6 +++---
>  drivers/usb/gadget/function/f_sourcesink.c | 20 ++++++++++----------
>  drivers/usb/gadget/legacy/zero.c           |  6 +++---
>  3 files changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/f_loopback.c b/drivers/usb/gadget/function/f_loopback.c
> index ae41f556eb75..9900baa31c2d 100644
> --- a/drivers/usb/gadget/function/f_loopback.c
> +++ b/drivers/usb/gadget/function/f_loopback.c
> @@ -583,16 +583,16 @@ static struct usb_function_instance *loopback_alloc_instance(void)
>  
>  	return  &lb_opts->func_inst;
>  }
> -DECLARE_USB_FUNCTION(Loopback, loopback_alloc_instance, loopback_alloc);
> +DECLARE_USB_FUNCTION(loopback, loopback_alloc_instance, loopback_alloc);
>  
>  int __init lb_modinit(void)
>  {
> -	return usb_function_register(&Loopbackusb_func);
> +	return usb_function_register(&loopbackusb_func);
>  }
>  
>  void __exit lb_modexit(void)
>  {
> -	usb_function_unregister(&Loopbackusb_func);
> +	usb_function_unregister(&loopbackusb_func);
>  }
>  
>  MODULE_LICENSE("GPL");
> diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c
> index 6803cd60cc6d..fc879b785ed0 100644
> --- a/drivers/usb/gadget/function/f_sourcesink.c
> +++ b/drivers/usb/gadget/function/f_sourcesink.c
> @@ -1,6 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0+
>  /*
> - * f_sourcesink.c - USB peripheral source/sink configuration driver
> + * f_sourcesink.c - USB peripheral sourcesink configuration driver

Why are documentation changes like this required?

This doesn't make sense :(
Greg Kroah-Hartman Aug. 22, 2023, 12:34 p.m. UTC | #2
On Tue, Aug 01, 2023 at 03:42:23AM -0700, chengdong zhou wrote:
> There are currently two issues that causes sourcesink and loopback to
> fail to export to usb configfs:
> 1. usb_function.name does not match usb_function_driver.name
> 2. usb configfs does not support function name with '/'
> 
> So, we adjusted usb_function.name to "sourcesink" and "loopback",
> and remove '/'

How has this ever worked?  What userspace tools / apis did you just
break or change to get this to work?

this feels odd.

thanks

greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/gadget/function/f_loopback.c b/drivers/usb/gadget/function/f_loopback.c
index ae41f556eb75..9900baa31c2d 100644
--- a/drivers/usb/gadget/function/f_loopback.c
+++ b/drivers/usb/gadget/function/f_loopback.c
@@ -583,16 +583,16 @@  static struct usb_function_instance *loopback_alloc_instance(void)
 
 	return  &lb_opts->func_inst;
 }
-DECLARE_USB_FUNCTION(Loopback, loopback_alloc_instance, loopback_alloc);
+DECLARE_USB_FUNCTION(loopback, loopback_alloc_instance, loopback_alloc);
 
 int __init lb_modinit(void)
 {
-	return usb_function_register(&Loopbackusb_func);
+	return usb_function_register(&loopbackusb_func);
 }
 
 void __exit lb_modexit(void)
 {
-	usb_function_unregister(&Loopbackusb_func);
+	usb_function_unregister(&loopbackusb_func);
 }
 
 MODULE_LICENSE("GPL");
diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c
index 6803cd60cc6d..fc879b785ed0 100644
--- a/drivers/usb/gadget/function/f_sourcesink.c
+++ b/drivers/usb/gadget/function/f_sourcesink.c
@@ -1,6 +1,6 @@ 
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * f_sourcesink.c - USB peripheral source/sink configuration driver
+ * f_sourcesink.c - USB peripheral sourcesink configuration driver
  *
  * Copyright (C) 2003-2008 David Brownell
  * Copyright (C) 2008 by Nokia Corporation
@@ -19,7 +19,7 @@ 
 #include "u_f.h"
 
 /*
- * SOURCE/SINK FUNCTION ... a primary testing vehicle for USB peripheral
+ * SOURCESINK FUNCTION ... a primary testing vehicle for USB peripheral
  * controller drivers.
  *
  * This just sinks bulk packets OUT to the peripheral and sources them IN
@@ -460,7 +460,7 @@  sourcesink_free_func(struct usb_function *f)
 	kfree(func_to_ss(f));
 }
 
-/* optionally require specific source/sink data patterns  */
+/* optionally require specific sourcesink data patterns  */
 static int check_read_data(struct f_sourcesink *ss, struct usb_request *req)
 {
 	unsigned		i;
@@ -818,14 +818,14 @@  static int sourcesink_setup(struct usb_function *f,
 
 	/* respond with data transfer or status phase? */
 	if (value >= 0) {
-		VDBG(c->cdev, "source/sink req%02x.%02x v%04x i%04x l%d\n",
+		VDBG(c->cdev, "sourcesink req%02x.%02x v%04x i%04x l%d\n",
 			ctrl->bRequestType, ctrl->bRequest,
 			w_value, w_index, w_length);
 		req->zero = 0;
 		req->length = value;
 		value = usb_ep_queue(c->cdev->gadget->ep0, req, GFP_ATOMIC);
 		if (value < 0)
-			ERROR(c->cdev, "source/sink response, err %d\n",
+			ERROR(c->cdev, "sourcesink response, err %d\n",
 					value);
 	}
 
@@ -858,7 +858,7 @@  static struct usb_function *source_sink_alloc_func(
 	ss->bulk_qlen = ss_opts->bulk_qlen;
 	ss->iso_qlen = ss_opts->iso_qlen;
 
-	ss->function.name = "source/sink";
+	ss->function.name = "sourcesink";
 	ss->function.bind = sourcesink_bind;
 	ss->function.set_alt = sourcesink_set_alt;
 	ss->function.get_alt = sourcesink_get_alt;
@@ -1263,24 +1263,24 @@  static struct usb_function_instance *source_sink_alloc_inst(void)
 
 	return &ss_opts->func_inst;
 }
-DECLARE_USB_FUNCTION(SourceSink, source_sink_alloc_inst,
+DECLARE_USB_FUNCTION(sourcesink, source_sink_alloc_inst,
 		source_sink_alloc_func);
 
 static int __init sslb_modinit(void)
 {
 	int ret;
 
-	ret = usb_function_register(&SourceSinkusb_func);
+	ret = usb_function_register(&sourcesinkusb_func);
 	if (ret)
 		return ret;
 	ret = lb_modinit();
 	if (ret)
-		usb_function_unregister(&SourceSinkusb_func);
+		usb_function_unregister(&sourcesinkusb_func);
 	return ret;
 }
 static void __exit sslb_modexit(void)
 {
-	usb_function_unregister(&SourceSinkusb_func);
+	usb_function_unregister(&sourcesinkusb_func);
 	lb_modexit();
 }
 module_init(sslb_modinit);
diff --git a/drivers/usb/gadget/legacy/zero.c b/drivers/usb/gadget/legacy/zero.c
index 23312a07efb4..0cddd20e54ff 100644
--- a/drivers/usb/gadget/legacy/zero.c
+++ b/drivers/usb/gadget/legacy/zero.c
@@ -222,7 +222,7 @@  static int ss_config_setup(struct usb_configuration *c,
 }
 
 static struct usb_configuration sourcesink_driver = {
-	.label                  = "source/sink",
+	.label                  = "sourcesink",
 	.setup                  = ss_config_setup,
 	.bConfigurationValue    = 3,
 	.bmAttributes           = USB_CONFIG_ATT_SELFPOWER,
@@ -282,7 +282,7 @@  static int zero_bind(struct usb_composite_dev *cdev)
 	autoresume_cdev = cdev;
 	timer_setup(&autoresume_timer, zero_autoresume, 0);
 
-	func_inst_ss = usb_get_function_instance("SourceSink");
+	func_inst_ss = usb_get_function_instance("sourcesink");
 	if (IS_ERR(func_inst_ss))
 		return PTR_ERR(func_inst_ss);
 
@@ -302,7 +302,7 @@  static int zero_bind(struct usb_composite_dev *cdev)
 		goto err_put_func_inst_ss;
 	}
 
-	func_inst_lb = usb_get_function_instance("Loopback");
+	func_inst_lb = usb_get_function_instance("loopback");
 	if (IS_ERR(func_inst_lb)) {
 		status = PTR_ERR(func_inst_lb);
 		goto err_put_func_ss;