diff options
author | Michael R Sweet <msweet@msweet.org> | 2020-12-28 20:18:24 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-01-04 18:49:08 +0300 |
commit | ed054e4e95d6cb0582f1283707ddb40f18d14bfb (patch) | |
tree | 9508f0387b914018fa2ea1cd39b82fb397554f30 /drivers/usb/gadget/function/f_printer.c | |
parent | 7c9a2598463a7803629a90e9e425af7ed241ec65 (diff) | |
download | linux-ed054e4e95d6cb0582f1283707ddb40f18d14bfb.tar.xz |
USB: gadget: f_printer: set a default q_len
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>
Link: https://lore.kernel.org/r/9DFB1605-63A5-46DB-A5A4-B59B315D8115@msweet.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/gadget/function/f_printer.c')
-rw-r--r-- | drivers/usb/gadget/function/f_printer.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c index 64a4112068fc..31eba2a43b1a 100644 --- a/drivers/usb/gadget/function/f_printer.c +++ b/drivers/usb/gadget/function/f_printer.c @@ -51,6 +51,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); @@ -1363,6 +1365,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)) { |