Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1088691rdb; Fri, 1 Dec 2023 06:52:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IGSeH+6XAFMVg/gEhnDG+0UGk7quoEE9LSdxXQgC5UyPXZ/HDCZa7WLzBYnybxrs+H9TwUG X-Received: by 2002:a05:6a00:244a:b0:6cb:8995:9028 with SMTP id d10-20020a056a00244a00b006cb89959028mr26329332pfj.19.1701442377851; Fri, 01 Dec 2023 06:52:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701442377; cv=none; d=google.com; s=arc-20160816; b=M/c54i3rtu9OU5u5/3mYaPMNoex0EdaLQ+mgOwWtIy4/ukqKK4yzgGd9gzMWGWTNyW 78uXkRvSc6OlRHLSq3rBmCcXODE+RyLlQ3RaEzZs4zV7wnjUxoyNRe1pmUNVwmdszF/D R9hWzf+bnm/3tePhLOgMJnAMPCYq+x91NtR4X6b3uPJI/4rN2DXPiir/v8zLwZIxQMbZ T6nGB5eAvxuZDRXkBL0wqqhR4taUxTigze8sLHwNOr5Rrm92Xh0/c62s1OKBHWXJSCqY AFujWlm5Jj9tAV8b4euyiZ4+48xwnlLXwZG0qretOt1/FLJFjVbEvDT6JFNZ9Ix97PlY G1nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=7ha7RLj/Q1yJq7/nKZ+kgxC7/zcgzfbzcZ0VQHbJ4Zc=; fh=jImt0PtB+CYojpAlQv3WlelyiQp3wfpEkdE9hHO8rtE=; b=vAwyJ71YLRJ542wkOj2Jv9CyxPKMYsGfIyBnwgfTVRsDkpkXbZBpRMdLw4Zzr/Xwk+ 99j/E/cnbaYjWdtHTu/3KiSP3Tp8Tv4UkkdRxGouagOwralkxpZCrBetVv9X0JR1U+VE LCngfUcyW/7HTH5hCPLEFIQA5Gnbg7IodLbMwDIAhWB/7JG5AHBNctgWSKxNfEL95yJv o6BS+o0r87VRoZnPR1XKJG7Is7tY3PoDa2tqWquQGw535c0ftQddlT2EDuoK/Cy1mWD5 lxW8h/dxpOpyzomkZQLRmG+sfAoT0o0Q3EM6yOuwZD4X5wueS0WVrHsGWJTaP54lzvtr TckA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id bm3-20020a656e83000000b005bdc61e1789si3567523pgb.427.2023.12.01.06.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 06:52:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id B5A0581C5092; Fri, 1 Dec 2023 06:52:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379261AbjLAOwk (ORCPT + 99 others); Fri, 1 Dec 2023 09:52:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379210AbjLAOwj (ORCPT ); Fri, 1 Dec 2023 09:52:39 -0500 Received: from hi1smtp01.de.adit-jv.com (smtp1.de.adit-jv.com [93.241.18.167]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BECE7103; Fri, 1 Dec 2023 06:52:45 -0800 (PST) Received: from hi2exch02.adit-jv.com (hi2exch02.adit-jv.com [10.72.92.28]) by hi1smtp01.de.adit-jv.com (Postfix) with ESMTP id 66FE9520123; Fri, 1 Dec 2023 15:52:44 +0100 (CET) Received: from vmlxhi-118.adit-jv.com (10.72.93.77) by hi2exch02.adit-jv.com (10.72.92.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 1 Dec 2023 15:52:44 +0100 From: Hardik Gajjar To: , , CC: , , , , , Subject: [PATCH v2] usb: gadget: f_fs: Add the missing get_alt callback Date: Fri, 1 Dec 2023 15:52:34 +0100 Message-ID: <20231201145234.97452-1-hgajjar@de.adit-jv.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.72.93.77] X-ClientProxiedBy: hi2exch02.adit-jv.com (10.72.92.28) To hi2exch02.adit-jv.com (10.72.92.28) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 01 Dec 2023 06:52:54 -0800 (PST) The Apple CarLife iAP gadget has a descriptor with two alternate settings. The host sends the set_alt request to configure alt_setting 0 or 1, and this is verified by the subsequent get_alt request. This patch implements and sets the get_alt callback. Without the get_alt callback, composite.c abruptly concludes the USB_REQ_GET/SET_INTERFACE request, assuming only one alt setting for the endpoint. Signed-off-by: Hardik Gajjar --- changes since version 1: - improve commit message to indicate why the get_alt callback is necessary - Link to v1 - https://lore.kernel.org/all/20231124164435.74727-1-hgajjar@de.adit-jv.com/ --- drivers/usb/gadget/function/f_fs.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index efe3e3b85769..37c47c11f57a 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -75,6 +75,7 @@ struct ffs_function { short *interfaces_nums; struct usb_function function; + int cur_alt[MAX_CONFIG_INTERFACES]; }; @@ -98,6 +99,7 @@ static int __must_check ffs_func_eps_enable(struct ffs_function *func); static int ffs_func_bind(struct usb_configuration *, struct usb_function *); static int ffs_func_set_alt(struct usb_function *, unsigned, unsigned); +static int ffs_func_get_alt(struct usb_function *f, unsigned int intf); static void ffs_func_disable(struct usb_function *); static int ffs_func_setup(struct usb_function *, const struct usb_ctrlrequest *); @@ -3232,6 +3234,15 @@ static void ffs_reset_work(struct work_struct *work) ffs_data_reset(ffs); } +static int ffs_func_get_alt(struct usb_function *f, + unsigned int interface) +{ + struct ffs_function *func = ffs_func_from_usb(f); + int intf = ffs_func_revmap_intf(func, interface); + + return (intf < 0) ? intf : func->cur_alt[interface]; +} + static int ffs_func_set_alt(struct usb_function *f, unsigned interface, unsigned alt) { @@ -3266,8 +3277,10 @@ static int ffs_func_set_alt(struct usb_function *f, ffs->func = func; ret = ffs_func_eps_enable(func); - if (ret >= 0) + if (ret >= 0) { ffs_event_add(ffs, FUNCTIONFS_ENABLE); + func->cur_alt[interface] = alt; + } return ret; } @@ -3574,6 +3587,7 @@ static struct usb_function *ffs_alloc(struct usb_function_instance *fi) func->function.bind = ffs_func_bind; func->function.unbind = ffs_func_unbind; func->function.set_alt = ffs_func_set_alt; + func->function.get_alt = ffs_func_get_alt; func->function.disable = ffs_func_disable; func->function.setup = ffs_func_setup; func->function.req_match = ffs_func_req_match; -- 2.17.1