Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1652643pxx; Fri, 30 Oct 2020 15:42:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzf6SQCAFaBj2ENddArESkh/e4tRgemh6criw4eHt5cEgsixSS93dW7RzZXBsVJvQS5MQqP X-Received: by 2002:aa7:cac2:: with SMTP id l2mr4976616edt.141.1604097751571; Fri, 30 Oct 2020 15:42:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604097751; cv=none; d=google.com; s=arc-20160816; b=xLNhNu0yI+gn4TkPeSItUALw24WfTrnrrvotE42qJRXj9aodMiq5sgJ06ob/xU6mKt NFbsOxCfEfylmhM09BBvZHlDLGxhfqsqALqqbkirSAw8km4mnNbtK7mUfvz2lY8mNFYL cgdyWVEeocO3maa90yqEiif0NL1M+vTRLby827wSh7LHCEFqrOwpMCfyacVpzqdBIku2 0TLhkq3i8sbNWmrTbVZZ6Lj0Q762M1GbVcOByL1W1CL0YCvZYLUZFvkOjiP/E+KRVBI2 u3Dm+s4axYnJFyYAwXAb5PJH/hJwbGj29r3aMPPW0QAxXRX4u4QeezusFb6albAoAGVe 6Ibw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=CueRswaEy4Z2Z5VAmOnBV5i6L+qXf0VNkz3jnz8QXxY=; b=ZtnyKiVHWPE9PFYdMo1zNGdNwWGxVd4fkIfwDrAtOD4849l4O/lyBewTMiTA4ONzq/ 5VmKyPuTk630164Vszx0/Dmo6TUUwkHPyuWJGf+IO6F9w8dUVPzGPV+/ZVanhrpWNW7A TefWE9sFj202wwiqAffdzGZYmzR3TUPQ1yRo1xHMSl2OC/JWRQ2eREXL9iY8xOPWuAop VPNfJ1y2K8kd+yGkXXW8XrGn3gbKrKe9xgDcdjR6zXkqTvuwlkAA9H3RzgWl/jMDqkfE RdY3gT5hdkZw94Nvlu79AuLIKtFYbzC+I3HTWqfjEr+gI6G/VhkMWeczuTZxDYBgRcL6 R55Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u27si1719034edi.588.2020.10.30.15.42.09; Fri, 30 Oct 2020 15:42:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725895AbgJ3Wkh (ORCPT + 99 others); Fri, 30 Oct 2020 18:40:37 -0400 Received: from mail.msweet.org ([173.255.209.91]:57360 "EHLO mail.msweet.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725780AbgJ3Wkh (ORCPT ); Fri, 30 Oct 2020 18:40:37 -0400 X-Greylist: delayed 370 seconds by postgrey-1.27 at vger.kernel.org; Fri, 30 Oct 2020 18:40:37 EDT Received: from mbp16-ubuntu-lts (host-24-231-71-254.public.eastlink.ca [24.231.71.254]) by mail.msweet.org (Postfix) with ESMTPSA id 1B5CF820E3; Fri, 30 Oct 2020 22:34:27 +0000 (UTC) From: Michael R Sweet To: Felipe Balbi Cc: Greg Kroah-Hartman , msweet@msweet.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Fix default q_len for usb_f_printer gadget driver Date: Fri, 30 Oct 2020 18:34:19 -0400 Message-Id: <20201030223419.3780-1-msweet@msweet.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: 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 --- 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