From patchwork Sat Dec 16 03:43:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Badhri Jagan Sridharan X-Patchwork-Id: 179793 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp19276dyi; Fri, 15 Dec 2023 19:44:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IGvXk8Vr/kJJcpR+kWld6DlYOOyuRphPDDoUmTW4355JHT92MslFO80JhO0+rf/HjEmn/lc X-Received: by 2002:a17:906:73cd:b0:a19:d66d:dc60 with SMTP id n13-20020a17090673cd00b00a19d66ddc60mr7086362ejl.67.1702698248660; Fri, 15 Dec 2023 19:44:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702698248; cv=none; d=google.com; s=arc-20160816; b=d2D+f//8J+kDRjfMBQ4xxoUnbV1skqkmA83uF1BydxS9jc0yU8mI1PyxTHHq+V7auZ BcB7qZrix5uJK7NUftcJ+EuNmgHADpmZT48XI3nVUnHEK9K+DNHOVFwpj9uN7nxmDDJ+ OKlwEdJS6Ilt9fam1pmkHoeRDBzSBoDEmy4NKvpHsfg7eGLfnf71r+1eSiTzWu80fwOW e74Lic5fw4n7JP5kzyZQoWjlwwbRxVIIaBjk6cVgkYcb6/kTG7vAT/lNWMFtsZMD7xjT VmFY7cb2vz87ZCmu+0Cy6Dilj3BxTU/zdbEg9LQrxPp2Cml4W6XoGipzat8e1Ts+AjeC WbwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=MJ2mISBcTBUnQo3gMwCpghdZw1VZrVIIe2xs3t2Tvxs=; fh=Cvtd4F/XzjLnQIT7tSgEEZzX8aMBtsloIRz7/SeSFVk=; b=FO0LSaiX/5rQdJqfwF8eVmzZGIZ+B/KrSzCpDlgXFCfNkTlkuHIX01jJnd1s2ktXea JWCB2HVm5eVfekmBEeAV6rufEcPz08Vh6O2q6BvSK/noGjRFVNczZb/4neHp453DtsDq 4jWe8GEfWGaE2uVprp/XZHwpnHuM1v78wFl1Y3X0u1A7aN306lda3DS82fXeXfRPyASu Yd818rkVXr8M5/MErdOrQiLzfK5qOK6BLkkZWAVbLyjjUHKCGS1qjNTEfXaQRO2I9jzv Z2Zwr4LqYGLeYzhBa5tRBabPUMFzVSefW7L9+SkZ+H9lSMB6D8tQ+QHr9k1rV1LwiVzi vOWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=1h6OsDVj; spf=pass (google.com: domain of linux-kernel+bounces-2032-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2032-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id kt4-20020a170906aac400b009b2b9810d8asi7946855ejb.415.2023.12.15.19.44.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 19:44:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2032-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=1h6OsDVj; spf=pass (google.com: domain of linux-kernel+bounces-2032-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2032-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4199B1F25869 for ; Sat, 16 Dec 2023 03:44:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F03410953; Sat, 16 Dec 2023 03:43:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="1h6OsDVj" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E4071384 for ; Sat, 16 Dec 2023 03:43:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--badhri.bounces.google.com Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-6cee48f2507so1028701b3a.2 for ; Fri, 15 Dec 2023 19:43:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702698221; x=1703303021; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=MJ2mISBcTBUnQo3gMwCpghdZw1VZrVIIe2xs3t2Tvxs=; b=1h6OsDVj2qvIwx32zTRf8Hvna5Z1o1nzGposLVdt7898uhM0XlIP3jCs6BVUsgM18O Y2Aka99/VfVQhwvW8fGDRiPsarNM8ZEhDLpzKcfXDIBOBSTpv1gsi1Ebtqd1dEPMUuUB Jr+SZtqNUbMti2bLarKoE47eMHJssEAewFIGQsxlgVxPhatK3++xPA4n578UH+wrzFDH 0gZMOlLaTZ9mZtzzRKwbH0/3qVtV0F/JoNl4sWfVcN/g7ZgBCZMaKVT0Yt/67R96xiM+ NUpfQo6h8MDu1PLwdegcflrS0EIigyGDkfeLohDPDSsIK3ZqU+gFiT0hKNWCJgq+yiQL QQcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702698221; x=1703303021; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=MJ2mISBcTBUnQo3gMwCpghdZw1VZrVIIe2xs3t2Tvxs=; b=ZEe+ZlOh2ki6mFDsFy96q3NUydJRFXjzU6ZA4pFKxmOb6hveGd0FOJyWLkOXeEKj1w dTRQg6BHaZpfrU5Yfperx9GPydBt4rxq+3xLZocSChqxnqlskFjFOixICs9CR3trDvXF FFYV87SHuRCHux+MVZgaxRPKdtYbxR3cfpGTqIqq8x8fkAoVTa/f2SMYm2jo7pMdE3uO qMp5VrCA8duuT/OCWatlC7hjkJ458s6XccF90IMFjWJphndsIMrkHLoDeOQwINXjIaJm XouGxgTKJjhG4gHNF+Sp3u3sTRGjj13qQZryVxbPSN+q4tOuJIKUD2FC25nQkQnOCDeO dr8g== X-Gm-Message-State: AOJu0Ywq0wJxFLY9Tzu/ReNYI3yp+PS4yH0zOzekKjr31nd52i+vqTUq SkdgrXkxSAfz04DWPz+eI5wgDCC9B5s= X-Received: from badhri.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:6442]) (user=badhri job=sendgmr) by 2002:a17:902:dacd:b0:1d3:9d94:3300 with SMTP id q13-20020a170902dacd00b001d39d943300mr474plx.4.1702698219736; Fri, 15 Dec 2023 19:43:39 -0800 (PST) Date: Sat, 16 Dec 2023 03:43:34 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231216034335.242168-1-badhri@google.com> Subject: [PATCH v1 1/2] usb: dwc3: Refactor usb-psy init From: Badhri Jagan Sridharan To: Thinh.Nguyen@synopsys.com, gregkh@linuxfoundation.org, raychi@google.com, royluo@google.com Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Badhri Jagan Sridharan , stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785408518445882309 X-GMAIL-MSGID: 1785408518445882309 Move usb-psy init to dwc3_populate_usb_psy() so that gadget can re-use it to retry setting up usb-psy when null. Cc: stable@vger.kernel.org Fixes: 6f0764b5adea ("usb: dwc3: add a power supply for current control") Signed-off-by: Badhri Jagan Sridharan --- drivers/usb/dwc3/core.c | 24 ++++++++++++++++-------- drivers/usb/dwc3/core.h | 1 + 2 files changed, 17 insertions(+), 8 deletions(-) base-commit: 51920207674e9e3475a91d2091583889792df99a diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index b101dbf8c5dc..a93425b9c1c0 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1495,6 +1495,19 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc) dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE); } +void dwc3_populate_usb_psy(struct dwc3 *dwc) +{ + const char *usb_psy_name; + int ret; + + if (dwc->usb_psy) + return; + + ret = device_property_read_string(dwc->dev, "usb-psy-name", &usb_psy_name); + if (ret >= 0) + dwc->usb_psy = power_supply_get_by_name(usb_psy_name); +} + static void dwc3_get_properties(struct dwc3 *dwc) { struct device *dev = dwc->dev; @@ -1510,8 +1523,6 @@ static void dwc3_get_properties(struct dwc3 *dwc) u8 tx_thr_num_pkt_prd = 0; u8 tx_max_burst_prd = 0; u8 tx_fifo_resize_max_num; - const char *usb_psy_name; - int ret; /* default to highest possible threshold */ lpm_nyet_threshold = 0xf; @@ -1544,12 +1555,9 @@ static void dwc3_get_properties(struct dwc3 *dwc) else dwc->sysdev = dwc->dev; - ret = device_property_read_string(dev, "usb-psy-name", &usb_psy_name); - if (ret >= 0) { - dwc->usb_psy = power_supply_get_by_name(usb_psy_name); - if (!dwc->usb_psy) - dev_err(dev, "couldn't get usb power supply\n"); - } + dwc3_populate_usb_psy(dwc); + if (!dwc->usb_psy) + dev_err(dev, "couldn't get usb power supply\n"); dwc->has_lpm_erratum = device_property_read_bool(dev, "snps,has-lpm-erratum"); diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index efe6caf4d0e8..6c65d76e6fe2 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -1526,6 +1526,7 @@ struct dwc3_gadget_ep_cmd_params { void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode); void dwc3_set_mode(struct dwc3 *dwc, u32 mode); u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type); +void dwc3_populate_usb_psy(struct dwc3 *dwc); #define DWC3_IP_IS(_ip) \ (dwc->ip == _ip##_IP) From patchwork Sat Dec 16 03:43:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Badhri Jagan Sridharan X-Patchwork-Id: 179794 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp19305dyi; Fri, 15 Dec 2023 19:44:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFdqzWinv+7SVCKNdTXD/T6Z6it2zBmR/sTFp8moT89hP8AFJBzjmpudXq8QQVjXaB/scm X-Received: by 2002:a05:620a:40ca:b0:77f:b027:8aaf with SMTP id g10-20020a05620a40ca00b0077fb0278aafmr2733346qko.97.1702698259306; Fri, 15 Dec 2023 19:44:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702698259; cv=none; d=google.com; s=arc-20160816; b=VaJAyXjNPMrZgHXl/znDpPID/4P43WjyVDOKYHWqVb/XnyKxN3b9k9A0jsHxHXWrdy 52Y18cbbhkpMGxY31lGX2vQRxRBIH3v1goyfkakTzbxDj/T1+L+TsKYr1pRZbareL5wm zP0uvBWEbzbVeTg9J22wlvpEhwuOX/ZGcQYh1GBuAw6uXpt/yoALHaN7V1rkewFaxQ26 5+Qmrj/uRC/ralO4mAA/Z8FjtgrGXZCfwuvpK4eKe8Os763lGSyo1LSeLjT0lex63Q8E aZudlKqB8SQlNkeE97saEb8Szc7AXbeG4EOL4Cv3gysu1hbcxH+3VeiONcH4IkGOagUZ MqDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=ejamfelkmThXdmiMH7xDujYdMZ8xHKUQpSO5wh3pdx0=; fh=Cvtd4F/XzjLnQIT7tSgEEZzX8aMBtsloIRz7/SeSFVk=; b=ii3kq6yK0jYEFR3xZsfkIsGamfKlpyy3l9FQuxIeBq3vmMoQ1S5X3aD5tOBX5N6y6a oN9nxqnNBBp6Ekj5lv22zbTyIZad9iJBWo1o6o9akxrs+dv29t6gkzx8ZQLX4Ky2zsgE s/ECNZtztgvo64wKsHx0ttS4eU8SwNlE67ArKOo2GY5Qht8/3g/nsFMdN7pViJrni1nK py0r+ameM6PZhEnMdJw2hiusL7F2G+j3sDgM54xKXKqCgSGi9JVK80sJQzpYlAPn+tEM 7cW0NMJP5M6u4JvBmd8LvKofXK+ZYN7PjKe6XlaQJuXibFrUaU1B3sreDz/6SoatnJtN BZYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Eceb7rIs; spf=pass (google.com: domain of linux-kernel+bounces-2033-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2033-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y11-20020a05620a44cb00b0077da5e2ff28si20798166qkp.289.2023.12.15.19.44.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 19:44:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2033-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Eceb7rIs; spf=pass (google.com: domain of linux-kernel+bounces-2033-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2033-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 191261C24AA1 for ; Sat, 16 Dec 2023 03:44:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 190E01118B; Sat, 16 Dec 2023 03:43:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Eceb7rIs" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37242883E for ; Sat, 16 Dec 2023 03:43:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--badhri.bounces.google.com Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-5ca4ee5b97aso699924a12.1 for ; Fri, 15 Dec 2023 19:43:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702698222; x=1703303022; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ejamfelkmThXdmiMH7xDujYdMZ8xHKUQpSO5wh3pdx0=; b=Eceb7rIs8bM69TfukcjBZoKCRWgojJkHk2deH7sbI/fLDd6VdOVB0R3oTceh1flGK/ jgLqX5cXX58F1nZzb5BSg0YbtJjIpG4y3sg56fzFjqBGGPN+/uEQkQSvCIp4peFvqV53 ih4mR3X9Tq51oVOdHQIU2XIvHI2m7wHVApqKR1SgnWtqJKOGp6W4U8H89Y2Y0qHPxtXM 0EZpTnDlVeDFnVff1QpawbslBDVXrqjDPXrdfYlbd2iRntQiad71Ni06xMSpTBNFix6o 1lXj3bd7PLLDuIjELtk/tMz/si98zwkIwpR0tzAHz76jYLORJz9WSjSP6YZ9pHJPJNL9 L6ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702698222; x=1703303022; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ejamfelkmThXdmiMH7xDujYdMZ8xHKUQpSO5wh3pdx0=; b=hFdce/Vj/dFyGTab+wDfWBgAIb6kx0r+5F3VC9b2890vtqcd4cpkUqYGAzGgS8XAUf U+99+nykjEgDqATjOe8epAMua0HL1pBSTH5rmMgX3NWWt2lSlFBghgTBzU1G06Vx3knc bCK80Ejje3eoR49gM5o5WSA49Udx/EGrNrl4J1ZJem79syN4qO2hoq1SVK9TvFacuCPn oRRCTsvvmHZ2ofHh1ucI7Hd1vc6AxY2gDV1u/bN7/xmKFBs+/EFYgJXvWtUgymWzl0Gs ZNDLruzEb7wOJIO8f25VQ9fELwyhh5Tvo2XsLKRxvjQLgcXBOvQ9kgwjdf4ddCZ2EqHi 8Cxg== X-Gm-Message-State: AOJu0YzBSHYT0WpsgYa3Ar/qNI/ADXZBBM0xCHSGwD8XnKhoJpY8m8EL B/MAogUjYiW4RenPmRhj0HrXUNDSIjQ= X-Received: from badhri.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:6442]) (user=badhri job=sendgmr) by 2002:a63:5c07:0:b0:5ca:4440:234c with SMTP id q7-20020a635c07000000b005ca4440234cmr738217pgb.12.1702698222327; Fri, 15 Dec 2023 19:43:42 -0800 (PST) Date: Sat, 16 Dec 2023 03:43:35 +0000 In-Reply-To: <20231216034335.242168-1-badhri@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20231216034335.242168-1-badhri@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231216034335.242168-2-badhri@google.com> Subject: [PATCH v1 2/2] usb: gadget: Retry populating usb-psy when null From: Badhri Jagan Sridharan To: Thinh.Nguyen@synopsys.com, gregkh@linuxfoundation.org, raychi@google.com, royluo@google.com Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Badhri Jagan Sridharan , stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785408529980695762 X-GMAIL-MSGID: 1785408529980695762 This patch allows populating usb-psy where usb-psy comes up after dwc3 is probed. Retry populating usb-psy when dwc->usb_psy is null while dwc3_gadget_vbus_draw() is executed. Cc: stable@vger.kernel.org Fixes: 99288de36020 ("usb: dwc3: add an alternate path in vbus_draw callback") Signed-off-by: Badhri Jagan Sridharan --- drivers/usb/dwc3/gadget.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 858fe4c299b7..b3470a5e5e26 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -3049,8 +3049,11 @@ static int dwc3_gadget_vbus_draw(struct usb_gadget *g, unsigned int mA) if (dwc->usb2_phy) return usb_phy_set_power(dwc->usb2_phy, mA); - if (!dwc->usb_psy) - return -EOPNOTSUPP; + if (!dwc->usb_psy) { + dwc3_populate_usb_psy(dwc); + if (!dwc->usb_psy) + return -EOPNOTSUPP; + } val.intval = 1000 * mA; ret = power_supply_set_property(dwc->usb_psy, POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, &val);