Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1277149rdh; Fri, 24 Nov 2023 08:45:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IG60C229FLYTYlB6PuoViW/8NsjuERb3sxDIcQHcTCrNZOwyMwOK+HsnidCC0rZLVMrf4OX X-Received: by 2002:a05:6a20:4412:b0:18a:d8ba:ca4c with SMTP id ce18-20020a056a20441200b0018ad8baca4cmr4045692pzb.52.1700844321773; Fri, 24 Nov 2023 08:45:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700844321; cv=none; d=google.com; s=arc-20160816; b=VOEKL8aofd/Eqpwp6hVcL4Wd74crS2GHdWgPMWrMjtcLocdakjBXZtu6vnXTdU9IBN YRcV5+eUeMDS3YQUhpR8UY85hr5OVuJKd+o3h0K65HoRI57dE/8n3deX7060v6vCO3+v q0jKXRYJZ3yPwpDEFKaG3fn8ZYIoFchYfcb7L8Np6Dp1pvI1lm1RZDFSJ7Bf71+J0UGl fObXBFFQsUTXWkHzodkR5372mHjTfVt4MXElo+xPZPdisBONlvs14zk2oynvUf1n17s1 ob+Z9kivuohJSwjgHK9I2HwkXB7xxlZjokoXgEUlENMqFy4NiWApVx3i2ufHlRJ5q9wb mDmw== 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=I47y07EvLQUECHcJVKeWbHn0ll9lJU93OUNQpB1hjz4=; fh=ImEDAHDwwefdVYaKIShhm52Wlrykm8gk+Y4GIZ7+YdU=; b=FWg8zv7g6+qqlLp6QrZsTK1q6YWNipIl8SgbPukOxlRkf8b81q3BbiogGS/mvuQh6h Op2aKzrt4HQHOl2A8qH9uMIpAH9Pi7EiHAVpd7QPldAORqxeqHMDc6xg8nbxLZ6bYY+C VXVu8WSgzZ8iV3DLxOT/GbMLLvRzhnCerzupcOn1StByqmtLNKV8miztdSe0YVMc4yKC +ApUeHqA7PkZxBVPu7TAJiX713jHE2jkMvmJuzTapjMZU1sAdLFtRDqq6rxlgJaRAqEu AGu07qxFr7g9bJXZMhlYjUuIv52+IOfXM5VoZ2CiucFso0sq9zsUnZBr4uF9+4cvfCBA 9BPQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id o16-20020a056a0015d000b006cb83204cffsi3964858pfu.256.2023.11.24.08.45.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 08:45:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 E4CA680E6DF2; Fri, 24 Nov 2023 08:45:17 -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 S231462AbjKXQoo (ORCPT + 99 others); Fri, 24 Nov 2023 11:44:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231379AbjKXQol (ORCPT ); Fri, 24 Nov 2023 11:44:41 -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 E45D3173D; Fri, 24 Nov 2023 08:44: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 7E15A5201D5; Fri, 24 Nov 2023 17:44: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.34; Fri, 24 Nov 2023 17:44:44 +0100 From: Hardik Gajjar To: , , CC: , , , , , Subject: [PATCH] usb: gadget: f_fs: Add the missing get_alt callback Date: Fri, 24 Nov 2023 17:44:35 +0100 Message-ID: <20231124164435.74727-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, 24 Nov 2023 08:45:18 -0800 (PST) Some USB OTG hubs have multiple alternate configurations to offer, such as one for Carplay and another for Carlife. This patch implements and sets the get_alt callback to retrieve the currently used alternate setting. The new function allows dynamic retrieval of the current alternate setting for a specific interface. The current alternate setting values are stored in the 'cur_alt' array within the 'ffs_function' structure. Signed-off-by: Hardik Gajjar --- 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