From patchwork Fri Feb 24 05:46:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashanth K X-Patchwork-Id: 61134 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp728534wrd; Thu, 23 Feb 2023 22:06:35 -0800 (PST) X-Google-Smtp-Source: AK7set9rJPoh65vOnX9FmRhcD7E9IGgKY7RC+ddrLv8rXPhgSGC5xVL7FWwn4PcXTg8Yj8/C2TcD X-Received: by 2002:a17:906:3e43:b0:88a:2e57:9813 with SMTP id t3-20020a1709063e4300b0088a2e579813mr23710991eji.33.1677218795700; Thu, 23 Feb 2023 22:06:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677218795; cv=none; d=google.com; s=arc-20160816; b=ESkjo7RlZKAvzgwj1y8Q7YEu1iH/FxYjO9qjkcfgRx/9XfDHjpOui6jlT61h4pOO9k 0Poh3cvXTD4+HQvoQMi6G1J0mugr6hPNsPheEd1J7K0ib4CkeZ1n8/gAYUmN/P5aosvM yAd5UUmI1nzrFAmF+GhNfA1uGJmqTRnXLhli0dbJ2ohKX607ii4wGLTPGFMSzANolAX3 2YDZkDlGWwbuDYVXDV6F6VwxRxF16aBm8mMJQOFRn/5OR2Mq9Odr5NoTWDBLIstdiKGu suy/RLolpxT7OwjKvS7fHZcKkPQaWxz29PtD3UserfdTfDHzWnL0A0YEpf2yoPJKAbOz q9aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=rlTU+1eBS2sxGtfmHpbJ6YlLdWVBPlgiwNQGpi+G7l8=; b=rHaBs3EN6/7why989eQBNAzcm+uO5QVo42Q7VypWK+tvnlO+kVfjBSizoXgzpKqoP+ 0NYI5eZEySVaLU93QN5POVuFWcZ7Jv2/8ka0UckMpPKaAUj9/JDgfgnDJcjwD7/czkXZ afI8vmT1NcfbFSNyVBquJSR3aeN4tskjayRgRyACFoKdkfwfZi5v42v6k/UIxD6jKm1a Or2ZGX8NInXdUfgb5diirxnVG7ReK06KPdEA/EPpNm7l2I8VvSsp+qDFSG0n80gCCB4x BPyq/OUFn0mh/1ufhLbz1MtiQ84Cx4auZPY+LBnK2yy/3FDXiM5on6/BKfaKedeHY+4J A/7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=hQZtrSiA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fi6-20020a1709073ac600b008b1cbfbe1efsi23628089ejc.19.2023.02.23.22.06.08; Thu, 23 Feb 2023 22:06:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=hQZtrSiA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229743AbjBXFra (ORCPT + 99 others); Fri, 24 Feb 2023 00:47:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229715AbjBXFrX (ORCPT ); Fri, 24 Feb 2023 00:47:23 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6BC75D474; Thu, 23 Feb 2023 21:47:22 -0800 (PST) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31O0NQvG015303; Fri, 24 Feb 2023 05:47:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=rlTU+1eBS2sxGtfmHpbJ6YlLdWVBPlgiwNQGpi+G7l8=; b=hQZtrSiACTPKeKa2o2xGRfVkqUUIQLQlJfi0WIgrqTd2awvWgP4tGvnTr6LlIgZbAXFH 25Og5HskLT+Wk/WFSm42ghrUWAa//dcU2CQ2WMmwO2YuwEVl8wDMpRiW5WCQiEw/c7WG gFULw/ygLQV+Qwq93/hbho7Vd+o5Yt2CpMAHbxAFB9lALgad4Xbqao2KCkudkt4V8EpG 3kls+i8XCQfA5tQyIaTz5Wrl2WAMmJmVXSSMPcjbtnqFjDWLRYL8VJEP2Er5l31BsmO9 getPUMBRnz0/NgHU3ByuQMUNGt3kbE3Rf9v0bI0MaLvQ3omGl6TeRMgT/ZNGbMVzfw7C wA== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nwybm3sft-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Feb 2023 05:47:19 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 31O5lIkd002994 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Feb 2023 05:47:18 GMT Received: from hu-prashk-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 23 Feb 2023 21:47:14 -0800 From: Prashanth K To: Greg Kroah-Hartman , Thinh Nguyen , Jakob Koschel , =?utf-8?b?SsOzIMOBZ2lsYSBCaXRzY2g=?= , Alan Stern CC: Pratham Pratap , Jack Pham , , , Prashanth K Subject: [PATCH v4 2/2] usb: gadget: composite: Draw 100mA current if not configured Date: Fri, 24 Feb 2023 11:16:59 +0530 Message-ID: <1677217619-10261-3-git-send-email-quic_prashk@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1677217619-10261-1-git-send-email-quic_prashk@quicinc.com> References: <1677217619-10261-1-git-send-email-quic_prashk@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: P-PazjljN9_9hUXobemwY-iprw2MYhKd X-Proofpoint-GUID: P-PazjljN9_9hUXobemwY-iprw2MYhKd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-24_02,2023-02-23_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=647 suspectscore=0 phishscore=0 spamscore=0 priorityscore=1501 adultscore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302240046 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758691376054439832?= X-GMAIL-MSGID: =?utf-8?q?1758691376054439832?= Currently we don't change the current value if device isn't in configured state. But in battery charging specification (section 1.2 and 1.4.13), it is mentioned that the device can draw up to 100mA of current if it's in unconfigured state. Hence add vbus draw work in composite_resume to draw 100mA if the device isn't configured. Signed-off-by: Prashanth K --- drivers/usb/gadget/composite.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 403563c..386140f 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -2449,6 +2449,10 @@ void composite_resume(struct usb_gadget *gadget) usb_gadget_clear_selfpowered(gadget); usb_gadget_vbus_draw(gadget, maxpower); + } else { + maxpower = CONFIG_USB_GADGET_VBUS_DRAW; + maxpower = min(maxpower, 100U); + usb_gadget_vbus_draw(gadget, maxpower); } cdev->suspended = 0;