Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9458478pxu; Mon, 28 Dec 2020 17:17:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJwL5QyOgJl1GoARHLd1zcLRrpboMTiVhtYJ1RHGLjFp89ktHGQba+97t6vS4VkDFUqRxbPq X-Received: by 2002:a17:906:718b:: with SMTP id h11mr43377860ejk.241.1609204626922; Mon, 28 Dec 2020 17:17:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609204626; cv=none; d=google.com; s=arc-20160816; b=Rzv8GEbNzVO3JFA+gImrAEcszh+OMtnJbICWrLuVwVwincwrIOnIBJdZ8L3wz7mHbD UeR2ApteHry1AyzxTu333i97FYv/yWfMRnpEmYDv6zcdvkVs44bVcIP9WoFsse4cOCe8 gXUBFoaHL6Q0OTY61en2XEKnG+KtDHSlJOowXpJ888e0qwPEoI3YzEz+Lp0Oy+xKSf+a eAKpaQVBFQeY9bO8p9mikYMXWCk2pB++15MarSDCZHpglbPt6ch6rGady+U4QlbLpL9Y yhXZ02Uq1YJbM/Ym251IESewAeE1U44frJVltMJrux58RE5lqLmOU6cWrYMvQhVLvv4C T9Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from; bh=iYScdBQZdNJpZhS1YOr65mZdiedTtDRRBlSpchbyB54=; b=kCgFI/XXFTvtVYZA/yW+mmYwHNtiS1y7Br2vtkW80LRTfVFer/spJBfveKC1wNDw5Q CRIau8uu6OzljgyYAImZ1ElsZ5sEdA5umit4uL6aiD04a+UbpXQli0LSLsDxgcJP6oXS iBORgJhPTyDwJxf3Hw9xPPLDHYc8bOxJUEQfz4SAZAzZY1myisirvhVHawu9vVrufevr 9JaxsvixkqLB18GU+O7QM2Zw+CVn1RDJSsR+VEDc7hU0lLtUcxW1tkpOgUgLS5kowDgu gd5IkJCAI+V1boogscQO7qzLXgrHvJF6h8S75gYAdCt/axcLBqLu0O+gOhGm8ANhLwI+ CW7w== 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 r13si16956343edc.254.2020.12.28.17.16.44; Mon, 28 Dec 2020 17:17:06 -0800 (PST) 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 S1727876AbgL1RTG convert rfc822-to-8bit (ORCPT + 99 others); Mon, 28 Dec 2020 12:19:06 -0500 Received: from mail.msweet.org ([173.255.209.91]:54870 "EHLO mail.msweet.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727660AbgL1RTG (ORCPT ); Mon, 28 Dec 2020 12:19:06 -0500 Received: from [10.0.1.64] (host-148-170-144-200.public.eastlink.ca [148.170.144.200]) by mail.msweet.org (Postfix) with ESMTPSA id 9EE5E81BF3; Mon, 28 Dec 2020 17:18:25 +0000 (UTC) From: Michael R Sweet Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8BIT Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.40.0.2.32\)) Subject: [PATCH] Fix default q_len for usb_f_printer gadget driver Message-Id: <9DFB1605-63A5-46DB-A5A4-B59B315D8115@msweet.org> Date: Mon, 28 Dec 2020 12:18:24 -0500 Cc: Michael Sweet , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Felipe Balbi To: Greg Kroah-Hartman X-Mailer: Apple Mail (2.3654.40.0.2.32) 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