Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1742885pxb; Sat, 14 Nov 2020 00:18:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyk0T9TTgkfOHk7cGqzuMAQlqMHRaPnjaTQvO5QRc4nZ9dSTDQFiiAM782lnp0trl3NLaT X-Received: by 2002:a50:9f61:: with SMTP id b88mr6901665edf.282.1605341902287; Sat, 14 Nov 2020 00:18:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605341902; cv=none; d=google.com; s=arc-20160816; b=TDJSFpm29vuslLWwBa8dTZa2wBcY04Fl5xC6RU/NpC2ktINR4+SfwRVLNAdobo695E DxumPUTjdI8uzITiPPDpwLWwbglRYcZOzSo3c+gRwGgDuZFpEolga3bkj/WAneKDLLrI NJMxaxX0e8GIuBkTAYlAstf1GgTmb+ZTikHdefrYxViLahh4QoGJdzbvXi1TlC0rS/gx YMM7C0jjgA6A0ATFEMCL82lbzeL5V5VyK3WWtKcnAFmqdAT6Mb7F4bdsJcK+Vbfmurob Zwtiimjd9aYYsEsK/W0N3rh/caMtzgfMgG1wxuuT2T0zmH+u+JnUctptZYTqnTODYkwT L7aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:sender:dkim-signature; bh=oYttXSsvr3yGBRboyetOc9UMCdoUc2jyN9VMkw7rr9U=; b=y8qmJ8K3Gs0WtAet9fQRGOQqxNhYoZN/GCQbCy8/KSRabJcBX6EN8aqS9TGZbcU4rV Pa9helFM0WqHrmcctLIU+XTrPBUUgL0e60pevzSl96TrhmAVYU6oJTW8NELqX2d38MaV F18LCTu9dUnYaS9XXI4MctLeuO7ytG94SWsuhIMdPXe6IwQyKn4mzhoGomA60fBDfVo8 GGYv6iUA+fKfVgkZh9yJT7cWDaCvutWRIlQUcEy3iok9GOi5Og+1MU7HHFXJrVV4nObN T5+IoBUeru6JjuZuY9SyvXMD3210+Iwcgbg+pGzw9IVUuxogYSLF2x9jKOnt1dB55dlS ndcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b="kqdCI/f6"; 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 p23si3311946ejm.470.2020.11.14.00.18.00; Sat, 14 Nov 2020 00:18:22 -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; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b="kqdCI/f6"; 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 S1726643AbgKNINJ (ORCPT + 99 others); Sat, 14 Nov 2020 03:13:09 -0500 Received: from m42-4.mailgun.net ([69.72.42.4]:34202 "EHLO m42-4.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726642AbgKNINI (ORCPT ); Sat, 14 Nov 2020 03:13:08 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1605341588; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=oYttXSsvr3yGBRboyetOc9UMCdoUc2jyN9VMkw7rr9U=; b=kqdCI/f6QrtVVrk1NpdpCCWYjyJSXbNH/z2xnit6W2aM40dM2KZKnUn7u+F34zxsjMX8/kdL clva5Fhral0VYtrfQHWLuGbFw8MX9FCCpjfWuOPEmmZKT/uScsVk7xgofMA+KYD4f28jcMie SwhtHbWaQ71WXf0jF8MkDSUx7jI= X-Mailgun-Sending-Ip: 69.72.42.4 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n03.prod.us-west-2.postgun.com with SMTP id 5faf9185d3e05bb6db809354 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sat, 14 Nov 2020 08:12:53 GMT Sender: wcheng=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 7A30FC433CB; Sat, 14 Nov 2020 08:12:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from wcheng-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: wcheng) by smtp.codeaurora.org (Postfix) with ESMTPSA id ACA04C433F0; Sat, 14 Nov 2020 08:12:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org ACA04C433F0 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=wcheng@codeaurora.org From: Wesley Cheng To: balbi@kernel.org, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, jackp@codeaurora.org, Wesley Cheng Subject: [PATCH 3/3] usb: gadget: configfs: Add a specific configFS reset callback Date: Sat, 14 Nov 2020 00:12:47 -0800 Message-Id: <20201114081247.25063-4-wcheng@codeaurora.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201114081247.25063-1-wcheng@codeaurora.org> References: <20201114081247.25063-1-wcheng@codeaurora.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order for configFS based USB gadgets to set the proper charge current for bus reset scenarios, expose a separate reset callback to set the current to 100mA based on the USB battery charging specification. Signed-off-by: Wesley Cheng --- drivers/usb/gadget/configfs.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 56051bb97349..80ca7ff2fb97 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -1481,6 +1481,28 @@ static void configfs_composite_disconnect(struct usb_gadget *gadget) spin_unlock_irqrestore(&gi->spinlock, flags); } +static void configfs_composite_reset(struct usb_gadget *gadget) +{ + struct usb_composite_dev *cdev; + struct gadget_info *gi; + unsigned long flags; + + cdev = get_gadget_data(gadget); + if (!cdev) + return; + + gi = container_of(cdev, struct gadget_info, cdev); + spin_lock_irqsave(&gi->spinlock, flags); + cdev = get_gadget_data(gadget); + if (!cdev || gi->unbind) { + spin_unlock_irqrestore(&gi->spinlock, flags); + return; + } + + composite_reset(gadget); + spin_unlock_irqrestore(&gi->spinlock, flags); +} + static void configfs_composite_suspend(struct usb_gadget *gadget) { struct usb_composite_dev *cdev; @@ -1530,7 +1552,7 @@ static const struct usb_gadget_driver configfs_driver_template = { .unbind = configfs_composite_unbind, .setup = configfs_composite_setup, - .reset = configfs_composite_disconnect, + .reset = configfs_composite_reset, .disconnect = configfs_composite_disconnect, .suspend = configfs_composite_suspend, -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project