From patchwork Sat Mar 27 18:28:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ray Chi X-Patchwork-Id: 12168613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AE72C433C1 for ; Sat, 27 Mar 2021 18:29:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F86B619A9 for ; Sat, 27 Mar 2021 18:29:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230242AbhC0S3I (ORCPT ); Sat, 27 Mar 2021 14:29:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbhC0S2W (ORCPT ); Sat, 27 Mar 2021 14:28:22 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EC68C0613B2 for ; Sat, 27 Mar 2021 11:28:22 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id v186so6110322ybe.5 for ; Sat, 27 Mar 2021 11:28:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=kBTrnovsJTjktUY0EImjz441nnzZDwHzrqZdw8K7lUM=; b=XaG99HhlymUYSpLhoY7iG8qg2FQ0jWc0UK5CKWTx0hIZet6OPWvbgtuUNlDy+i70AJ gq1uVoe7TKh3OBsDaxkVoywnT5E7+DDhVBd7at9QSICSiwcPusEVQ3rcpKNc4XrAPH+d o0VofgDVdy84fWjTlsSOgGv5IEGi/+Xmoun00YI5XL5gzv1Fg36wJzjZWO+RtCr6outo sPAQMF9kbMr89kwrz3S7ELtspDEHEk/Ya0TnlQDMKiYGDm1ne5oULbuhRik5Z7KatDNX KEr7eVzwrqnuJPNy0fgX8PQX5XBUeESZjsnrOEfYVdq098bugJ1e/hL66GlILClVsFO1 5P+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=kBTrnovsJTjktUY0EImjz441nnzZDwHzrqZdw8K7lUM=; b=IKnvx9LBiK03pilSh9oF9fgLLlbplaI9iS73t9RkBYjW84vzRO1KFquYOzed1SelQf 7KX1qau/rBRY2kc/bBpHE2+t53eBis5ZB2oQC0NLtNnGAowKB76Ne8KdcaAd13tlXygu K5DcCn5AL3eqWke9iTl1eK84ckpmUQxS9fZsq0ydYqOdKBOTRNcNr+0jvMHEHNBkH4zB 1U4ApQ7aB2aliB7+2137ZpeBpRVcS/fniWVfYN8TLs839rN6m2LiF/VST4PqD/P/Ysmj cEok4/qGrIpOFTW3wWzxPQ5MMOR3g7MVupCz7EXdr+sH0jYa/Anc7hAFB/KbMRrC4y1i jo4A== X-Gm-Message-State: AOAM533mG0xclcSzqpBDA6EHxZgwrlqZ+lkP1xZ5l7lOaY7NhPGS5/Qn bqsr+nujKOgEVG6A4IhZAcagrCxOsNo= X-Google-Smtp-Source: ABdhPJxkzoGreeV6D3MgL0kgP9jcvFhWrOamEkI1ZLXO0cqd5vQrF7cEJIx92FU+4DZkCxIPCMUJBD+6Hw0= X-Received: from raychi.tao.corp.google.com ([2401:fa00:fc:202:493c:e5b:69c:54cb]) (user=raychi job=sendgmr) by 2002:a25:6fc6:: with SMTP id k189mr26162957ybc.171.1616869701634; Sat, 27 Mar 2021 11:28:21 -0700 (PDT) Date: Sun, 28 Mar 2021 02:28:08 +0800 In-Reply-To: <20210327182809.1814480-1-raychi@google.com> Message-Id: <20210327182809.1814480-2-raychi@google.com> Mime-Version: 1.0 References: <20210327182809.1814480-1-raychi@google.com> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog Subject: [PATCH 1/2] usb: dwc3: gadget: modify the scale in vbus_draw callback From: Ray Chi To: balbi@kernel.org, gregkh@linuxfoundation.org, sre@kernel.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, kyletso@google.com, badhri@google.com, Ray Chi Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Currently, vbus_draw callback used wrong scale for power_supply. The unit of power supply should be uA. Therefore, this patch will fix this problem. Fixes: 99288de36020 ("usb: dwc3: add an alternate path in vbus_draw callback") Reported-by: Sebastian Reichel Signed-off-by: Ray Chi --- drivers/usb/dwc3/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index e1442fc763e1..8a361f07e045 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2536,7 +2536,7 @@ static int dwc3_gadget_vbus_draw(struct usb_gadget *g, unsigned int mA) if (!dwc->usb_psy) return -EOPNOTSUPP; - val.intval = mA; + val.intval = 1000 * mA; ret = power_supply_set_property(dwc->usb_psy, POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, &val); return ret; From patchwork Sat Mar 27 18:28:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ray Chi X-Patchwork-Id: 12168615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF9BAC433E0 for ; Sat, 27 Mar 2021 18:29:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 956D5619C2 for ; Sat, 27 Mar 2021 18:29:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230316AbhC0S3J (ORCPT ); Sat, 27 Mar 2021 14:29:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230105AbhC0S22 (ORCPT ); Sat, 27 Mar 2021 14:28:28 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ABD6C0613B2 for ; Sat, 27 Mar 2021 11:28:28 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id c1so8832507qke.8 for ; Sat, 27 Mar 2021 11:28:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=X45eDZbZ1G5E6KWs205oaawTbgGY1el7OrtpH5YicfE=; b=ugBxdy+F95hbZdPyYjmqGeP8SzM+DpBjPRJZcPWXytAsY1k+nz3/8EKi34dAH9WOBg 23hoCetgwrEkMDIboJ+4+Z4mrYhyyYZxlXvpgKT54j1EKY1sDk9/smndOFswRCIFpTY+ SZ6ct7ocSEBXCaOmqM/wxEgSvOliAgLLwVdQK+qBOlQSdnyD6ibZc/1S4RuhA8cc5bMV vLh+a1vqhaDn+kpaEJ6Zyr/ewdJtTfy4Rq2wvX7CS9kkek4x7jv/NWYNWB0XLm/cQkeW G2jQYOOV4sirkaBvtBstS9mrZXpBteQV9Xlra+qmxPsUOIBbuc8ImsV/YTIYhQ1/ZgC9 czlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=X45eDZbZ1G5E6KWs205oaawTbgGY1el7OrtpH5YicfE=; b=J7GjArNi5vDtjOKDdjBBQDcIVGn72aYZHwmiRLJOANS1oZ+xDEPK0fdkt9CFrcCcTk wc9N0DtUZPdZhE6taqVTqQ0lxiPngf4xOyITb0tjxWEQOFJf7uIUIU37nXWT47bfZR7z 8x01jLIMKKjhZx1y4pKodi9oHOKNnEklhHFDPrtj3cu33Msj83kTn+bJZUuDm8FJ7zCF KpiWb+w+tDVzCfnK3QFhG5/AkSS4rxLHFDHBAK1Y/OUXKxJcpEjv0P4EyJpeVe5WLTuH S27n0vmcxcWFmN5eAVR6MMGj8x/14/paAEt2fhZvU4SQ3PQK1sd8JiMVYCt+Yy/8wnHQ RXwA== X-Gm-Message-State: AOAM533k21EUJJFotV3wRweuKs0mgR8TaijB76+AAt8eU2zygnZ5EWqu MQg8vcuo9/EH9HWy4+nKpAG0AlnF6Ew= X-Google-Smtp-Source: ABdhPJzFbYU/AO5bbpshyBr3fNe2qpIRy0A3unQtF6tfkrKAfdwwJE+s0kUa34JdIl7oU+m1+xqLYG86Ams= X-Received: from raychi.tao.corp.google.com ([2401:fa00:fc:202:493c:e5b:69c:54cb]) (user=raychi job=sendgmr) by 2002:a05:6214:18d2:: with SMTP id cy18mr18945606qvb.50.1616869707507; Sat, 27 Mar 2021 11:28:27 -0700 (PDT) Date: Sun, 28 Mar 2021 02:28:09 +0800 In-Reply-To: <20210327182809.1814480-1-raychi@google.com> Message-Id: <20210327182809.1814480-3-raychi@google.com> Mime-Version: 1.0 References: <20210327182809.1814480-1-raychi@google.com> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog Subject: [PATCH 2/2] power: supply: Fix build error when CONFIG_POWER_SUPPLY is not enabled. From: Ray Chi To: balbi@kernel.org, gregkh@linuxfoundation.org, sre@kernel.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, kyletso@google.com, badhri@google.com, Ray Chi , kernel test robot Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The build error happens when CONFIG_POWER_SUPPLY is not enabled. h8300-linux-ld: drivers/usb/dwc3/gadget.o: in function `.L59': >> gadget.c:(.text+0x655): undefined reference to `power_supply_set_property' Fixes: 99288de36020 ("usb: dwc3: add an alternate path in vbus_draw callback") Reported-by: kernel test robot Signed-off-by: Ray Chi --- include/linux/power_supply.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 81a55e974feb..b495b4374cd0 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -426,9 +426,16 @@ static inline int power_supply_is_system_supplied(void) { return -ENOSYS; } extern int power_supply_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val); +#if IS_ENABLED(CONFIG_POWER_SUPPLY) extern int power_supply_set_property(struct power_supply *psy, enum power_supply_property psp, const union power_supply_propval *val); +#else +static inline int power_supply_set_property(struct power_supply *psy, + enum power_supply_property psp, + const union power_supply_propval *val) +{ return 0; } +#endif extern int power_supply_property_is_writeable(struct power_supply *psy, enum power_supply_property psp); extern void power_supply_external_power_changed(struct power_supply *psy);