All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix default q_len for usb_f_printer gadget driver
@ 2020-10-30 22:34 Michael R Sweet
  2020-10-30 23:24 ` Peter Chen
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Michael R Sweet @ 2020-10-30 22:34 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: Greg Kroah-Hartman, msweet, linux-usb, linux-kernel

The usb_f_printer gadget driver uses a default q_len value of *0* which prevents
any IO from occurring.  Moreover, once the driver is instantiated it is
impossible to change the q_len value.

The following patch uses a default q_len value of 10 which matches the legacy
g_printer gadget driver.  This minimizes the possibility that you end up with a
non-working printer gadget.  It is still possible to set the q_len to a
different value using the configfs path of the same name.

Signed-off-by: Michael R Sweet <msweet@msweet.org>
---
 drivers/usb/gadget/function/f_printer.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
index 9c7ed2539ff7..4f3161005e4f 100644
--- a/drivers/usb/gadget/function/f_printer.c
+++ b/drivers/usb/gadget/function/f_printer.c
@@ -50,6 +50,8 @@
 #define GET_PORT_STATUS		1
 #define SOFT_RESET		2
 
+#define DEFAULT_Q_LEN		10 /* same as legacy g_printer gadget */
+
 static int major, minors;
 static struct class *usb_gadget_class;
 static DEFINE_IDA(printer_ida);
@@ -1317,6 +1319,9 @@ static struct usb_function_instance *gprinter_alloc_inst(void)
 	opts->func_inst.free_func_inst = gprinter_free_inst;
 	ret = &opts->func_inst;
 
+	/* Make sure q_len is initialized, otherwise the bound device can't support read/write! */
+	opts->q_len = DEFAULT_Q_LEN;
+
 	mutex_lock(&printer_ida_lock);
 
 	if (ida_is_empty(&printer_ida)) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix default q_len for usb_f_printer gadget driver
  2020-10-30 22:34 [PATCH] Fix default q_len for usb_f_printer gadget driver Michael R Sweet
@ 2020-10-30 23:24 ` Peter Chen
  2020-11-30 14:17 ` Michael Sweet
       [not found] ` <3EFD5A31-1794-4172-ADB6-CC2A74646D1D@msweet.org>
  2 siblings, 0 replies; 5+ messages in thread
From: Peter Chen @ 2020-10-30 23:24 UTC (permalink / raw)
  To: Michael R Sweet; +Cc: Felipe Balbi, Greg Kroah-Hartman, linux-usb, linux-kernel

On 20-10-30 18:34:19, Michael R Sweet wrote:
> The usb_f_printer gadget driver uses a default q_len value of *0* which prevents
> any IO from occurring.  Moreover, once the driver is instantiated it is
> impossible to change the q_len value.
> 
> The following patch uses a default q_len value of 10 which matches the legacy
> g_printer gadget driver.  This minimizes the possibility that you end up with a
> non-working printer gadget.  It is still possible to set the q_len to a
> different value using the configfs path of the same name.
> 
> Signed-off-by: Michael R Sweet <msweet@msweet.org>

Reviewed-by: Peter Chen <peter.chen@nxp.com>

Peter
> ---
>  drivers/usb/gadget/function/f_printer.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
> index 9c7ed2539ff7..4f3161005e4f 100644
> --- a/drivers/usb/gadget/function/f_printer.c
> +++ b/drivers/usb/gadget/function/f_printer.c
> @@ -50,6 +50,8 @@
>  #define GET_PORT_STATUS		1
>  #define SOFT_RESET		2
>  
> +#define DEFAULT_Q_LEN		10 /* same as legacy g_printer gadget */
> +
>  static int major, minors;
>  static struct class *usb_gadget_class;
>  static DEFINE_IDA(printer_ida);
> @@ -1317,6 +1319,9 @@ static struct usb_function_instance *gprinter_alloc_inst(void)
>  	opts->func_inst.free_func_inst = gprinter_free_inst;
>  	ret = &opts->func_inst;
>  
> +	/* Make sure q_len is initialized, otherwise the bound device can't support read/write! */
> +	opts->q_len = DEFAULT_Q_LEN;
> +
>  	mutex_lock(&printer_ida_lock);
>  
>  	if (ida_is_empty(&printer_ida)) {
> -- 
> 2.17.1
> 

-- 

Thanks,
Peter Chen

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix default q_len for usb_f_printer gadget driver
  2020-10-30 22:34 [PATCH] Fix default q_len for usb_f_printer gadget driver Michael R Sweet
  2020-10-30 23:24 ` Peter Chen
@ 2020-11-30 14:17 ` Michael Sweet
       [not found] ` <3EFD5A31-1794-4172-ADB6-CC2A74646D1D@msweet.org>
  2 siblings, 0 replies; 5+ messages in thread
From: Michael Sweet @ 2020-11-30 14:17 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1973 bytes --]

Hi,

I submitted this a month ago, and aside from Peter Chen's "reviewed by" response I haven't heard anything nor seen it get merged.  I know you are all really busy and I don't want to be a pest - is there something else I need to do to advance this patch?

Thanks!


> On Oct 30, 2020, at 6:34 PM, Michael R Sweet <msweet@msweet.org> wrote:
> 
> The usb_f_printer gadget driver uses a default q_len value of *0* which prevents
> any IO from occurring.  Moreover, once the driver is instantiated it is
> impossible to change the q_len value.
> 
> The following patch uses a default q_len value of 10 which matches the legacy
> g_printer gadget driver.  This minimizes the possibility that you end up with a
> non-working printer gadget.  It is still possible to set the q_len to a
> different value using the configfs path of the same name.
> 
> Signed-off-by: Michael R Sweet <msweet@msweet.org>
> ---
> drivers/usb/gadget/function/f_printer.c | 5 +++++
> 1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
> index 9c7ed2539ff7..4f3161005e4f 100644
> --- a/drivers/usb/gadget/function/f_printer.c
> +++ b/drivers/usb/gadget/function/f_printer.c
> @@ -50,6 +50,8 @@
> #define GET_PORT_STATUS		1
> #define SOFT_RESET		2
> 
> +#define DEFAULT_Q_LEN		10 /* same as legacy g_printer gadget */
> +
> static int major, minors;
> static struct class *usb_gadget_class;
> static DEFINE_IDA(printer_ida);
> @@ -1317,6 +1319,9 @@ static struct usb_function_instance *gprinter_alloc_inst(void)
> 	opts->func_inst.free_func_inst = gprinter_free_inst;
> 	ret = &opts->func_inst;
> 
> +	/* Make sure q_len is initialized, otherwise the bound device can't support read/write! */
> +	opts->q_len = DEFAULT_Q_LEN;
> +
> 	mutex_lock(&printer_ida_lock);
> 
> 	if (ida_is_empty(&printer_ida)) {
> --
> 2.17.1
> 

________________________
Michael Sweet




[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 874 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fwd: [PATCH] Fix default q_len for usb_f_printer gadget driver
       [not found] ` <3EFD5A31-1794-4172-ADB6-CC2A74646D1D@msweet.org>
@ 2020-12-10  4:47   ` Peter Chen
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Chen @ 2020-12-10  4:47 UTC (permalink / raw)
  To: Michael Sweet, Greg Kroah-Hartman, Felipe Balbi; +Cc: linux-usb

On 20-12-10 02:38:13, Michael Sweet wrote:
> Peter,
> 
> I know you had signed off on this patch at the end of October, but I haven't seen anything happen with it since then.  As this is the first patch I've submitted, I don't know what else I need to do, if anything, to get it merged into the kernel sources?
> 

Add Greg and Felipe.

Hi Michael, 

Yes, I added my Reviewed-by tag at the end of Oct, but I am not the
maintainer for USB Gadget, so I can't add it to my tree.

Felipe is the maintainer of USB Gadget, the accepted patch will go to
his tree, and merge into the kernel.

Peter
      
> Thanks!
> 
> 
> > Begin forwarded message:
> > 
> > From: Michael R Sweet <msweet@msweet.org>
> > Subject: [PATCH] Fix default q_len for usb_f_printer gadget driver
> > Date: October 30, 2020 at 6:34:19 PM EDT
> > To: Felipe Balbi <balbi@kernel.org>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, msweet@msweet.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
> > 
> > The usb_f_printer gadget driver uses a default q_len value of *0* which prevents
> > any IO from occurring.  Moreover, once the driver is instantiated it is
> > impossible to change the q_len value.
> > 
> > The following patch uses a default q_len value of 10 which matches the legacy
> > g_printer gadget driver.  This minimizes the possibility that you end up with a
> > non-working printer gadget.  It is still possible to set the q_len to a
> > different value using the configfs path of the same name.
> > 
> > Signed-off-by: Michael R Sweet <msweet@msweet.org>
> > ---
> > drivers/usb/gadget/function/f_printer.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> > 
> > diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
> > index 9c7ed2539ff7..4f3161005e4f 100644
> > --- a/drivers/usb/gadget/function/f_printer.c
> > +++ b/drivers/usb/gadget/function/f_printer.c
> > @@ -50,6 +50,8 @@
> > #define GET_PORT_STATUS		1
> > #define SOFT_RESET		2
> > 
> > +#define DEFAULT_Q_LEN		10 /* same as legacy g_printer gadget */
> > +
> > static int major, minors;
> > static struct class *usb_gadget_class;
> > static DEFINE_IDA(printer_ida);
> > @@ -1317,6 +1319,9 @@ static struct usb_function_instance *gprinter_alloc_inst(void)
> > 	opts->func_inst.free_func_inst = gprinter_free_inst;
> > 	ret = &opts->func_inst;
> > 
> > +	/* Make sure q_len is initialized, otherwise the bound device can't support read/write! */
> > +	opts->q_len = DEFAULT_Q_LEN;
> > +
> > 	mutex_lock(&printer_ida_lock);
> > 
> > 	if (ida_is_empty(&printer_ida)) {
> > --
> > 2.17.1
> > 
> 
> ________________________
> Michael Sweet
> 
> 
> 



-- 

Thanks,
Peter Chen

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Fix default q_len for usb_f_printer gadget driver
@ 2020-12-28 17:18 Michael R Sweet
  0 siblings, 0 replies; 5+ messages in thread
From: Michael R Sweet @ 2020-12-28 17:18 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Michael Sweet, linux-usb, linux-kernel, Felipe Balbi

The usb_f_printer gadget driver uses a default q_len value of *0* which prevents
any IO from occurring.  Moreover, once the driver is instantiated it is
impossible to change the q_len value.

The following patch uses a default q_len value of 10 which matches the legacy
g_printer gadget driver.  This minimizes the possibility that you end up with a
non-working printer gadget.  It is still possible to set the q_len to a
different value using the configfs path of the same name.

Signed-off-by: Michael R Sweet <msweet@msweet.org>
---
drivers/usb/gadget/function/f_printer.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
index 9c7ed2539ff7..4f3161005e4f 100644
--- a/drivers/usb/gadget/function/f_printer.c
+++ b/drivers/usb/gadget/function/f_printer.c
@@ -50,6 +50,8 @@
#define GET_PORT_STATUS		1
#define SOFT_RESET		2

+#define DEFAULT_Q_LEN		10 /* same as legacy g_printer gadget */
+
static int major, minors;
static struct class *usb_gadget_class;
static DEFINE_IDA(printer_ida);
@@ -1317,6 +1319,9 @@ static struct usb_function_instance *gprinter_alloc_inst(void)
	opts->func_inst.free_func_inst = gprinter_free_inst;
	ret = &opts->func_inst;

+	/* Make sure q_len is initialized, otherwise the bound device can't support read/write! */
+	opts->q_len = DEFAULT_Q_LEN;
+
	mutex_lock(&printer_ida_lock);

	if (ida_is_empty(&printer_ida)) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-28 17:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-30 22:34 [PATCH] Fix default q_len for usb_f_printer gadget driver Michael R Sweet
2020-10-30 23:24 ` Peter Chen
2020-11-30 14:17 ` Michael Sweet
     [not found] ` <3EFD5A31-1794-4172-ADB6-CC2A74646D1D@msweet.org>
2020-12-10  4:47   ` Fwd: " Peter Chen
2020-12-28 17:18 Michael R Sweet

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.