Message ID | 20240301193831.3346-4-linux.amoon@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-89036-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp113821dyc; Fri, 1 Mar 2024 11:40:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVxxnYMnrvWaZmskCfHOteBaqQ790XrMUiIpDmTjosQYagOT4O6RxXdJfZWrVJi5MAw/hwtKnei6HmTxw55q49WPEtg/w== X-Google-Smtp-Source: AGHT+IHF0jeNVtzWaRQIl4TdRqJXz+ChGeXx/kvUxiVCNYjbwHk593pOXi3dW3edtIvGdGb+1RQp X-Received: by 2002:ac8:5888:0:b0:42e:76fd:dbba with SMTP id t8-20020ac85888000000b0042e76fddbbamr2722604qta.10.1709322010591; Fri, 01 Mar 2024 11:40:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709322010; cv=pass; d=google.com; s=arc-20160816; b=fgEQFQUN6JKqUZszSY2KO27Qq9S5UB9KIaykFQm4lLJgWvMCIzkb7rHQ4E8B2ZTihm ipGbzDclrAPrvkjP/zM21eeFeLFd7Crab+6XWzUMILg6COM1fNqJASFYBkHigB/cDfDe M1/Yb81CCezihqYzCboR3NIRph+Ja+TH/tfZbRmtqUIyeZcCTnLOm51cn5UoXJ6K0t5F hsgylvm9StV0td6NqP9bfCO5IwtiSfuzcuGFVXQiJg+wRjIsnSkfzM4YECwchlU3Fy+7 djBGCQSaTO3KRCq20syautTDXM4RO6Bk9gADZ+bpszsm+ubYO0pA8DTG56Oe0JEaE8I8 a09A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hb4CG876O8rufa4kt9vTuzRMAqAQvWAjs5KW+CbhAMc=; fh=5iN8/yBJob+qom5rNNZz5KHVQ1qCvgsIwVla9Ou0Uos=; b=Aobt20fKMPLbCucYFrSRZStJ3OhmyPgoDwcfz7ygVPmP59ZmtC+WktrGNcoaLU5qVc 4mLpJsSgMhXhsXvs5d5tfsJqM4VQMNkrsmaRJoAzd4beNn2lx+yjz+rXOpUBy/ML80di 4Px6MAo1FuEsje+zWoIL0xtqMt+Uy3p+PS7UiFQSRP2lB65Zte5tJUkhar0+3tNz+mSi G68E/1i+LzMzYk+R3lxcIvIyu9rxW1oGkGzlQ+2o5sun3aJ5ZQa+WVijX2dRYhBXx+Mx DQWCANUhEIkRft3LOXVv5bhpW3aWJdV4Id/TIUt9+nBBHnuc8JPbwTcojfFFw3vAR858 b6cQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cJVK1JXZ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-89036-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89036-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i20-20020ac85c14000000b0042ece00339fsi1420004qti.111.2024.03.01.11.40.10 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 11:40:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89036-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cJVK1JXZ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-89036-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89036-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 62A251C2452F for <ouuuleilei@gmail.com>; Fri, 1 Mar 2024 19:40:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E09343C680; Fri, 1 Mar 2024 19:39:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cJVK1JXZ" Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 7E7F53A8E1; Fri, 1 Mar 2024 19:39:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709321965; cv=none; b=LkLn/wTY5Vdntg/f2hbJXCDNYTlOY6Q95djDTSWod37thAGHDrONUa/FkDhIlW+r8Ck11thrfMJitMDZVOwKkC91ALIT5Aj9tTMoJ/2Mod9fshZsh2wO0TDHJJOcE+4nY1CmUZ7z3yd+J/P1NYgwoYjbTHzIs3R6LuwAEdAaV1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709321965; c=relaxed/simple; bh=u7ate3YnbRh4cS/ZoxbBaCkSYj8kc6vJSZdj383mVgs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qh8LqUrHrel3xde/8gIC4XUFkTW+GKechg43X3Q3GHM27Vkjm9DXen9NSLH5Zg2BEZ3k7iouh5VgamgklsXj8/4M5op8JjOMzxUO9pwrmpyYWCVK9QSv4wSylBAonECd8cZjkT6ktyeG/VxpNkFuWvpJgrs9/NWTRou+D+PPEl4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cJVK1JXZ; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1dc0e5b223eso24311475ad.1; Fri, 01 Mar 2024 11:39:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709321963; x=1709926763; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hb4CG876O8rufa4kt9vTuzRMAqAQvWAjs5KW+CbhAMc=; b=cJVK1JXZxDMHmKrHAE3FcMqpRbDLI4OEkMtj0DmwxoXkPSgGN3j4pq96KkFBeo2+tL U/OPYGqz0MLrQV9vXmfk5yeTxNtoUzeRoMBQqCHMyKRpLPbpefHdrWP21Z7JKaD8lJES NwTv+VT66TERN2KbuDVkzhjK/ER7fzunQCLvHANeWsR3IrMaalPRk9znxs9CSnvKsEM6 FkVO1F5irQwrjVlna+aJIJGEmKeCrxdp3xh5DRdOZ+d633Q5qXpBGEpAPck3Wgrds9Na PGiaSRQjHic5WGUM/4RZmb0ueRHU6ogPPUBl8N8PLSAgphwzqnlr/lovfaE8xQfm0FKo KnOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709321963; x=1709926763; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hb4CG876O8rufa4kt9vTuzRMAqAQvWAjs5KW+CbhAMc=; b=NxJEQwsc18YvjRXk6RYaTBZwLjPWCVzXwhSHr4wWGj0ViLiNsnnZAj7oTq1vBJCTWo S68GLCmORLJYGoTAUFnz5Y2vibavy8osCv3k15N0ohDmD08DsokjeCSOb4K+QNfYdXd9 LO0YIMCmPkO+o9hy3YPhp7ewZSW3/FPdp2oAd8gIOp58vyGouVb22U3ugOb0x5dYBngL HcObhGXJjYujsNTXw1HbOR7PD4Zy/gH9Cojjah63K7aSvOXukSowprXZyTWDBlrCdjUH MgY2Bt1+X6xuUvKh5mAhTh8jvPGwKznLU3MhJV2UsSyy4S6XC/QE8YxtIO10tss1AAJD km0A== X-Forwarded-Encrypted: i=1; AJvYcCXmuD/mBvNmEBQncZyYUdTgqhCeAhwx/dh1OJHpz0+y+ou3djPr7bgo/aRqt1teg+MHkotuNm6rcELaRl8YK9OI80pVv1SeHwdX0ntY7SjmLLyTBWAjn5AFsAxYjlhMZKhFkOxW1yIq4V83BSMTzEgjf1IIJNDpc/YOspKcJ9tfGV0qa9/ouEEzbIE= X-Gm-Message-State: AOJu0YzZFozBAca2dtLGZIe7jOp7G3l6TDGuAz96ysCpa2HYc/ko0Oc5 o5ehATReleQ23LAiW6lmTsPGYIolU3O2udFUmjOdPbJcDfzWonqN X-Received: by 2002:a17:902:ed82:b0:1dc:2f30:e0dc with SMTP id e2-20020a170902ed8200b001dc2f30e0dcmr2171759plj.36.1709321962783; Fri, 01 Mar 2024 11:39:22 -0800 (PST) Received: from localhost.localdomain ([113.30.217.222]) by smtp.gmail.com with ESMTPSA id u8-20020a170902e5c800b001dca6d1d572sm3837474plf.63.2024.03.01.11.39.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 11:39:22 -0800 (PST) From: Anand Moon <linux.amoon@gmail.com> To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>, Alim Akhtar <alim.akhtar@samsung.com> Cc: Anand Moon <linux.amoon@gmail.com>, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 3/4] usb: dwc3: exynos: Use devm_regulator_bulk_get_enable() helper function Date: Sat, 2 Mar 2024 01:08:10 +0530 Message-ID: <20240301193831.3346-4-linux.amoon@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240301193831.3346-1-linux.amoon@gmail.com> References: <20240301193831.3346-1-linux.amoon@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792354036309990169 X-GMAIL-MSGID: 1792354036309990169 |
Series |
[v1,1/4] usb: ehci-exynos: Use devm_clk_get_enabled() helpers
|
|
Commit Message
Anand Moon
March 1, 2024, 7:38 p.m. UTC
Use devm_regulator_bulk_get_enable() instead of open coded
'devm_regulator_get(), regulator_enable(), regulator_disable().
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
drivers/usb/dwc3/dwc3-exynos.c | 49 +++-------------------------------
1 file changed, 4 insertions(+), 45 deletions(-)
Comments
Le 01/03/2024 à 20:38, Anand Moon a écrit : > Use devm_regulator_bulk_get_enable() instead of open coded > 'devm_regulator_get(), regulator_enable(), regulator_disable(). > > Signed-off-by: Anand Moon <linux.amoon@gmail.com> > --- > drivers/usb/dwc3/dwc3-exynos.c | 49 +++------------------------------- > 1 file changed, 4 insertions(+), 45 deletions(-) > > diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c > index 5d365ca51771..7c77f3c69825 100644 > --- a/drivers/usb/dwc3/dwc3-exynos.c > +++ b/drivers/usb/dwc3/dwc3-exynos.c > @@ -32,9 +32,6 @@ struct dwc3_exynos { > struct clk *clks[DWC3_EXYNOS_MAX_CLOCKS]; > int num_clks; > int suspend_clk_idx; > - > - struct regulator *vdd33; > - struct regulator *vdd10; > }; > > static int dwc3_exynos_probe(struct platform_device *pdev) > @@ -44,6 +41,7 @@ static int dwc3_exynos_probe(struct platform_device *pdev) > struct device_node *node = dev->of_node; > const struct dwc3_exynos_driverdata *driver_data; > int i, ret; > + static const char * const regulators[] = { "vdd33", "vdd10" }; > > exynos = devm_kzalloc(dev, sizeof(*exynos), GFP_KERNEL); > if (!exynos) > @@ -78,27 +76,9 @@ static int dwc3_exynos_probe(struct platform_device *pdev) > if (exynos->suspend_clk_idx >= 0) > clk_prepare_enable(exynos->clks[exynos->suspend_clk_idx]); > > - exynos->vdd33 = devm_regulator_get(dev, "vdd33"); > - if (IS_ERR(exynos->vdd33)) { > - ret = PTR_ERR(exynos->vdd33); > - goto vdd33_err; > - } > - ret = regulator_enable(exynos->vdd33); > - if (ret) { > - dev_err(dev, "Failed to enable VDD33 supply\n"); > - goto vdd33_err; > - } > - > - exynos->vdd10 = devm_regulator_get(dev, "vdd10"); > - if (IS_ERR(exynos->vdd10)) { > - ret = PTR_ERR(exynos->vdd10); > - goto vdd10_err; > - } > - ret = regulator_enable(exynos->vdd10); > - if (ret) { > - dev_err(dev, "Failed to enable VDD10 supply\n"); > - goto vdd10_err; > - } > + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulators), regulators); > + if (ret) > + return dev_err_probe(dev, ret, "Failed to enable regulators\n"); > > if (node) { > ret = of_platform_populate(node, NULL, NULL, dev); > @@ -115,10 +95,6 @@ static int dwc3_exynos_probe(struct platform_device *pdev) > return 0; > > populate_err: > - regulator_disable(exynos->vdd10); > -vdd10_err: > - regulator_disable(exynos->vdd33); > -vdd33_err: > for (i = exynos->num_clks - 1; i >= 0; i--) > clk_disable_unprepare(exynos->clks[i]); > > @@ -140,9 +116,6 @@ static void dwc3_exynos_remove(struct platform_device *pdev) > > if (exynos->suspend_clk_idx >= 0) > clk_disable_unprepare(exynos->clks[exynos->suspend_clk_idx]); > - > - regulator_disable(exynos->vdd33); > - regulator_disable(exynos->vdd10); > } > > static const struct dwc3_exynos_driverdata exynos5250_drvdata = { > @@ -196,9 +169,6 @@ static int dwc3_exynos_suspend(struct device *dev) > for (i = exynos->num_clks - 1; i >= 0; i--) > clk_disable_unprepare(exynos->clks[i]); > > - regulator_disable(exynos->vdd33); > - regulator_disable(exynos->vdd10); Hi, Same here, I don't think that removing regulator_[en|dis]able from the suspend and resume function is correct. The goal is to stop some hardware when the system is suspended, in order to save some power. Why did you removed it? CJ > - > return 0; > } > > @@ -207,17 +177,6 @@ static int dwc3_exynos_resume(struct device *dev) > struct dwc3_exynos *exynos = dev_get_drvdata(dev); > int i, ret; > > - ret = regulator_enable(exynos->vdd33); > - if (ret) { > - dev_err(dev, "Failed to enable VDD33 supply\n"); > - return ret; > - } > - ret = regulator_enable(exynos->vdd10); > - if (ret) { > - dev_err(dev, "Failed to enable VDD10 supply\n"); > - return ret; > - } > - > for (i = 0; i < exynos->num_clks; i++) { > ret = clk_prepare_enable(exynos->clks[i]); > if (ret) {
Hi Christophe, On Sat, 2 Mar 2024 at 21:20, Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote: > > Le 01/03/2024 à 20:38, Anand Moon a écrit : > > Use devm_regulator_bulk_get_enable() instead of open coded > > 'devm_regulator_get(), regulator_enable(), regulator_disable(). > > > > Signed-off-by: Anand Moon <linux.amoon@gmail.com> > > --- > > drivers/usb/dwc3/dwc3-exynos.c | 49 +++------------------------------- > > 1 file changed, 4 insertions(+), 45 deletions(-) > > > > diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c > > index 5d365ca51771..7c77f3c69825 100644 > > --- a/drivers/usb/dwc3/dwc3-exynos.c > > +++ b/drivers/usb/dwc3/dwc3-exynos.c > > @@ -32,9 +32,6 @@ struct dwc3_exynos { > > struct clk *clks[DWC3_EXYNOS_MAX_CLOCKS]; > > int num_clks; > > int suspend_clk_idx; > > - > > - struct regulator *vdd33; > > - struct regulator *vdd10; > > }; > > > > static int dwc3_exynos_probe(struct platform_device *pdev) > > @@ -44,6 +41,7 @@ static int dwc3_exynos_probe(struct platform_device *pdev) > > struct device_node *node = dev->of_node; > > const struct dwc3_exynos_driverdata *driver_data; > > int i, ret; > > + static const char * const regulators[] = { "vdd33", "vdd10" }; > > > > exynos = devm_kzalloc(dev, sizeof(*exynos), GFP_KERNEL); > > if (!exynos) > > @@ -78,27 +76,9 @@ static int dwc3_exynos_probe(struct platform_device *pdev) > > if (exynos->suspend_clk_idx >= 0) > > clk_prepare_enable(exynos->clks[exynos->suspend_clk_idx]); > > > > - exynos->vdd33 = devm_regulator_get(dev, "vdd33"); > > - if (IS_ERR(exynos->vdd33)) { > > - ret = PTR_ERR(exynos->vdd33); > > - goto vdd33_err; > > - } > > - ret = regulator_enable(exynos->vdd33); > > - if (ret) { > > - dev_err(dev, "Failed to enable VDD33 supply\n"); > > - goto vdd33_err; > > - } > > - > > - exynos->vdd10 = devm_regulator_get(dev, "vdd10"); > > - if (IS_ERR(exynos->vdd10)) { > > - ret = PTR_ERR(exynos->vdd10); > > - goto vdd10_err; > > - } > > - ret = regulator_enable(exynos->vdd10); > > - if (ret) { > > - dev_err(dev, "Failed to enable VDD10 supply\n"); > > - goto vdd10_err; > > - } > > + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulators), regulators); > > + if (ret) > > + return dev_err_probe(dev, ret, "Failed to enable regulators\n"); > > > > if (node) { > > ret = of_platform_populate(node, NULL, NULL, dev); > > @@ -115,10 +95,6 @@ static int dwc3_exynos_probe(struct platform_device *pdev) > > return 0; > > > > populate_err: > > - regulator_disable(exynos->vdd10); > > -vdd10_err: > > - regulator_disable(exynos->vdd33); > > -vdd33_err: > > for (i = exynos->num_clks - 1; i >= 0; i--) > > clk_disable_unprepare(exynos->clks[i]); > > > > @@ -140,9 +116,6 @@ static void dwc3_exynos_remove(struct platform_device *pdev) > > > > if (exynos->suspend_clk_idx >= 0) > > clk_disable_unprepare(exynos->clks[exynos->suspend_clk_idx]); > > - > > - regulator_disable(exynos->vdd33); > > - regulator_disable(exynos->vdd10); > > } > > > > static const struct dwc3_exynos_driverdata exynos5250_drvdata = { > > @@ -196,9 +169,6 @@ static int dwc3_exynos_suspend(struct device *dev) > > for (i = exynos->num_clks - 1; i >= 0; i--) > > clk_disable_unprepare(exynos->clks[i]); > > > > - regulator_disable(exynos->vdd33); > > - regulator_disable(exynos->vdd10); > > Hi, > > Same here, I don't think that removing regulator_[en|dis]able from the > suspend and resume function is correct. > > The goal is to stop some hardware when the system is suspended, in order > to save some power. Ok, > > Why did you removed it? As per the description of the function devm_regulator_bulk_get_enable * This helper function allows drivers to get several regulator * consumers in one operation with management, the regulators will * automatically be freed when the device is unbound. If any of the * regulators cannot be acquired then any regulators that were * allocated will be freed before returning to the caller. [0] https://elixir.bootlin.com/linux/latest/source/drivers/regulator/devresc#L330 I have tested with rtc suspend resume and did not find any issue with this.patch. > > CJ > Thanks -Anand
Le 02/03/2024 à 17:48, Anand Moon a écrit : > Hi Christophe, > > On Sat, 2 Mar 2024 at 21:20, Christophe JAILLET > <christophe.jaillet@wanadoo.fr> wrote: >> >> Le 01/03/2024 à 20:38, Anand Moon a écrit : >>> Use devm_regulator_bulk_get_enable() instead of open coded >>> 'devm_regulator_get(), regulator_enable(), regulator_disable(). >>> >>> Signed-off-by: Anand Moon <linux.amoon@gmail.com> >>> --- >>> drivers/usb/dwc3/dwc3-exynos.c | 49 +++------------------------------- >>> 1 file changed, 4 insertions(+), 45 deletions(-) >>> >>> diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c >>> index 5d365ca51771..7c77f3c69825 100644 >>> --- a/drivers/usb/dwc3/dwc3-exynos.c >>> +++ b/drivers/usb/dwc3/dwc3-exynos.c >>> @@ -32,9 +32,6 @@ struct dwc3_exynos { >>> struct clk *clks[DWC3_EXYNOS_MAX_CLOCKS]; >>> int num_clks; >>> int suspend_clk_idx; >>> - >>> - struct regulator *vdd33; >>> - struct regulator *vdd10; >>> }; >>> >>> static int dwc3_exynos_probe(struct platform_device *pdev) >>> @@ -44,6 +41,7 @@ static int dwc3_exynos_probe(struct platform_device *pdev) >>> struct device_node *node = dev->of_node; >>> const struct dwc3_exynos_driverdata *driver_data; >>> int i, ret; >>> + static const char * const regulators[] = { "vdd33", "vdd10" }; >>> >>> exynos = devm_kzalloc(dev, sizeof(*exynos), GFP_KERNEL); >>> if (!exynos) >>> @@ -78,27 +76,9 @@ static int dwc3_exynos_probe(struct platform_device *pdev) >>> if (exynos->suspend_clk_idx >= 0) >>> clk_prepare_enable(exynos->clks[exynos->suspend_clk_idx]); >>> >>> - exynos->vdd33 = devm_regulator_get(dev, "vdd33"); >>> - if (IS_ERR(exynos->vdd33)) { >>> - ret = PTR_ERR(exynos->vdd33); >>> - goto vdd33_err; >>> - } >>> - ret = regulator_enable(exynos->vdd33); >>> - if (ret) { >>> - dev_err(dev, "Failed to enable VDD33 supply\n"); >>> - goto vdd33_err; >>> - } >>> - >>> - exynos->vdd10 = devm_regulator_get(dev, "vdd10"); >>> - if (IS_ERR(exynos->vdd10)) { >>> - ret = PTR_ERR(exynos->vdd10); >>> - goto vdd10_err; >>> - } >>> - ret = regulator_enable(exynos->vdd10); >>> - if (ret) { >>> - dev_err(dev, "Failed to enable VDD10 supply\n"); >>> - goto vdd10_err; >>> - } >>> + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulators), regulators); >>> + if (ret) >>> + return dev_err_probe(dev, ret, "Failed to enable regulators\n"); >>> >>> if (node) { >>> ret = of_platform_populate(node, NULL, NULL, dev); >>> @@ -115,10 +95,6 @@ static int dwc3_exynos_probe(struct platform_device *pdev) >>> return 0; >>> >>> populate_err: >>> - regulator_disable(exynos->vdd10); >>> -vdd10_err: >>> - regulator_disable(exynos->vdd33); >>> -vdd33_err: >>> for (i = exynos->num_clks - 1; i >= 0; i--) >>> clk_disable_unprepare(exynos->clks[i]); >>> >>> @@ -140,9 +116,6 @@ static void dwc3_exynos_remove(struct platform_device *pdev) >>> >>> if (exynos->suspend_clk_idx >= 0) >>> clk_disable_unprepare(exynos->clks[exynos->suspend_clk_idx]); >>> - >>> - regulator_disable(exynos->vdd33); >>> - regulator_disable(exynos->vdd10); >>> } >>> >>> static const struct dwc3_exynos_driverdata exynos5250_drvdata = { >>> @@ -196,9 +169,6 @@ static int dwc3_exynos_suspend(struct device *dev) >>> for (i = exynos->num_clks - 1; i >= 0; i--) >>> clk_disable_unprepare(exynos->clks[i]); >>> >>> - regulator_disable(exynos->vdd33); >>> - regulator_disable(exynos->vdd10); >> >> Hi, >> >> Same here, I don't think that removing regulator_[en|dis]able from the >> suspend and resume function is correct. >> >> The goal is to stop some hardware when the system is suspended, in order >> to save some power. > Ok, >> >> Why did you removed it? > > As per the description of the function devm_regulator_bulk_get_enable > > * This helper function allows drivers to get several regulator > * consumers in one operation with management, the regulators will > * automatically be freed when the device is unbound. If any of the > * regulators cannot be acquired then any regulators that were > * allocated will be freed before returning to the caller. The code in suspend/resume is not about freeing some resources. It is about enabling/disabling some hardware to save some power. Think to the probe/remove functions as the software in the kernel that knows how to handle some hardawre, and the suspend/resume as the on/off button to power-on and off the electrical chips. When the system is suspended, the software is still around. But some hardware can be set in a low consumption mode to save some power. IMHO, part of the code you removed changed this behaviour and increase the power consumption when the system is suspended. CJ > > [0] https://elixir.bootlin.com/linux/latest/source/drivers/regulator/devres.c#L330 > > I have tested with rtc suspend resume and did not find any issue with > this.patch. > >> >> CJ >> > Thanks > -Anand > >
Hi Christophe, On Sun, 3 Mar 2024 at 00:07, Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote: > > Le 02/03/2024 à 17:48, Anand Moon a écrit : > > Hi Christophe, > > > > On Sat, 2 Mar 2024 at 21:20, Christophe JAILLET > > <christophe.jaillet@wanadoo.fr> wrote: > >> > >> Le 01/03/2024 à 20:38, Anand Moon a écrit : > >>> Use devm_regulator_bulk_get_enable() instead of open coded > >>> 'devm_regulator_get(), regulator_enable(), regulator_disable(). > >>> > >>> Signed-off-by: Anand Moon <linux.amoon@gmail.com> > >>> --- > >>> drivers/usb/dwc3/dwc3-exynos.c | 49 +++------------------------------- > >>> 1 file changed, 4 insertions(+), 45 deletions(-) > >>> > >>> diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c > >>> index 5d365ca51771..7c77f3c69825 100644 > >>> --- a/drivers/usb/dwc3/dwc3-exynos.c > >>> +++ b/drivers/usb/dwc3/dwc3-exynos.c > >>> @@ -32,9 +32,6 @@ struct dwc3_exynos { > >>> struct clk *clks[DWC3_EXYNOS_MAX_CLOCKS]; > >>> int num_clks; > >>> int suspend_clk_idx; > >>> - > >>> - struct regulator *vdd33; > >>> - struct regulator *vdd10; > >>> }; > >>> > >>> static int dwc3_exynos_probe(struct platform_device *pdev) > >>> @@ -44,6 +41,7 @@ static int dwc3_exynos_probe(struct platform_device *pdev) > >>> struct device_node *node = dev->of_node; > >>> const struct dwc3_exynos_driverdata *driver_data; > >>> int i, ret; > >>> + static const char * const regulators[] = { "vdd33", "vdd10" }; > >>> > >>> exynos = devm_kzalloc(dev, sizeof(*exynos), GFP_KERNEL); > >>> if (!exynos) > >>> @@ -78,27 +76,9 @@ static int dwc3_exynos_probe(struct platform_device *pdev) > >>> if (exynos->suspend_clk_idx >= 0) > >>> clk_prepare_enable(exynos->clks[exynos->suspend_clk_idx]); > >>> > >>> - exynos->vdd33 = devm_regulator_get(dev, "vdd33"); > >>> - if (IS_ERR(exynos->vdd33)) { > >>> - ret = PTR_ERR(exynos->vdd33); > >>> - goto vdd33_err; > >>> - } > >>> - ret = regulator_enable(exynos->vdd33); > >>> - if (ret) { > >>> - dev_err(dev, "Failed to enable VDD33 supply\n"); > >>> - goto vdd33_err; > >>> - } > >>> - > >>> - exynos->vdd10 = devm_regulator_get(dev, "vdd10"); > >>> - if (IS_ERR(exynos->vdd10)) { > >>> - ret = PTR_ERR(exynos->vdd10); > >>> - goto vdd10_err; > >>> - } > >>> - ret = regulator_enable(exynos->vdd10); > >>> - if (ret) { > >>> - dev_err(dev, "Failed to enable VDD10 supply\n"); > >>> - goto vdd10_err; > >>> - } > >>> + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulators), regulators); > >>> + if (ret) > >>> + return dev_err_probe(dev, ret, "Failed to enable regulators\n"); > >>> > >>> if (node) { > >>> ret = of_platform_populate(node, NULL, NULL, dev); > >>> @@ -115,10 +95,6 @@ static int dwc3_exynos_probe(struct platform_device *pdev) > >>> return 0; > >>> > >>> populate_err: > >>> - regulator_disable(exynos->vdd10); > >>> -vdd10_err: > >>> - regulator_disable(exynos->vdd33); > >>> -vdd33_err: > >>> for (i = exynos->num_clks - 1; i >= 0; i--) > >>> clk_disable_unprepare(exynos->clks[i]); > >>> > >>> @@ -140,9 +116,6 @@ static void dwc3_exynos_remove(struct platform_device *pdev) > >>> > >>> if (exynos->suspend_clk_idx >= 0) > >>> clk_disable_unprepare(exynos->clks[exynos->suspend_clk_idx]); > >>> - > >>> - regulator_disable(exynos->vdd33); > >>> - regulator_disable(exynos->vdd10); > >>> } > >>> > >>> static const struct dwc3_exynos_driverdata exynos5250_drvdata = { > >>> @@ -196,9 +169,6 @@ static int dwc3_exynos_suspend(struct device *dev) > >>> for (i = exynos->num_clks - 1; i >= 0; i--) > >>> clk_disable_unprepare(exynos->clks[i]); > >>> > >>> - regulator_disable(exynos->vdd33); > >>> - regulator_disable(exynos->vdd10); > >> > >> Hi, > >> > >> Same here, I don't think that removing regulator_[en|dis]able from the > >> suspend and resume function is correct. > >> > >> The goal is to stop some hardware when the system is suspended, in order > >> to save some power. > > Ok, > >> > >> Why did you removed it? > > > > As per the description of the function devm_regulator_bulk_get_enable > > > > * This helper function allows drivers to get several regulator > > * consumers in one operation with management, the regulators will > > * automatically be freed when the device is unbound. If any of the > > * regulators cannot be acquired then any regulators that were > > * allocated will be freed before returning to the caller. > > The code in suspend/resume is not about freeing some resources. It is > about enabling/disabling some hardware to save some power. > > Think to the probe/remove functions as the software in the kernel that > knows how to handle some hardawre, and the suspend/resume as the on/off > button to power-on and off the electrical chips. > > When the system is suspended, the software is still around. But some > hardware can be set in a low consumption mode to save some power. > > IMHO, part of the code you removed changed this behaviour and increase > the power consumption when the system is suspended. > You are correct, I have changed the regulator API from devm_regulator_get_enable to devm_regulator_bulk_get_enable which changes this behavior. I will fix it in the next version. > CJ Thanks -Anand
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index 5d365ca51771..7c77f3c69825 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c @@ -32,9 +32,6 @@ struct dwc3_exynos { struct clk *clks[DWC3_EXYNOS_MAX_CLOCKS]; int num_clks; int suspend_clk_idx; - - struct regulator *vdd33; - struct regulator *vdd10; }; static int dwc3_exynos_probe(struct platform_device *pdev) @@ -44,6 +41,7 @@ static int dwc3_exynos_probe(struct platform_device *pdev) struct device_node *node = dev->of_node; const struct dwc3_exynos_driverdata *driver_data; int i, ret; + static const char * const regulators[] = { "vdd33", "vdd10" }; exynos = devm_kzalloc(dev, sizeof(*exynos), GFP_KERNEL); if (!exynos) @@ -78,27 +76,9 @@ static int dwc3_exynos_probe(struct platform_device *pdev) if (exynos->suspend_clk_idx >= 0) clk_prepare_enable(exynos->clks[exynos->suspend_clk_idx]); - exynos->vdd33 = devm_regulator_get(dev, "vdd33"); - if (IS_ERR(exynos->vdd33)) { - ret = PTR_ERR(exynos->vdd33); - goto vdd33_err; - } - ret = regulator_enable(exynos->vdd33); - if (ret) { - dev_err(dev, "Failed to enable VDD33 supply\n"); - goto vdd33_err; - } - - exynos->vdd10 = devm_regulator_get(dev, "vdd10"); - if (IS_ERR(exynos->vdd10)) { - ret = PTR_ERR(exynos->vdd10); - goto vdd10_err; - } - ret = regulator_enable(exynos->vdd10); - if (ret) { - dev_err(dev, "Failed to enable VDD10 supply\n"); - goto vdd10_err; - } + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulators), regulators); + if (ret) + return dev_err_probe(dev, ret, "Failed to enable regulators\n"); if (node) { ret = of_platform_populate(node, NULL, NULL, dev); @@ -115,10 +95,6 @@ static int dwc3_exynos_probe(struct platform_device *pdev) return 0; populate_err: - regulator_disable(exynos->vdd10); -vdd10_err: - regulator_disable(exynos->vdd33); -vdd33_err: for (i = exynos->num_clks - 1; i >= 0; i--) clk_disable_unprepare(exynos->clks[i]); @@ -140,9 +116,6 @@ static void dwc3_exynos_remove(struct platform_device *pdev) if (exynos->suspend_clk_idx >= 0) clk_disable_unprepare(exynos->clks[exynos->suspend_clk_idx]); - - regulator_disable(exynos->vdd33); - regulator_disable(exynos->vdd10); } static const struct dwc3_exynos_driverdata exynos5250_drvdata = { @@ -196,9 +169,6 @@ static int dwc3_exynos_suspend(struct device *dev) for (i = exynos->num_clks - 1; i >= 0; i--) clk_disable_unprepare(exynos->clks[i]); - regulator_disable(exynos->vdd33); - regulator_disable(exynos->vdd10); - return 0; } @@ -207,17 +177,6 @@ static int dwc3_exynos_resume(struct device *dev) struct dwc3_exynos *exynos = dev_get_drvdata(dev); int i, ret; - ret = regulator_enable(exynos->vdd33); - if (ret) { - dev_err(dev, "Failed to enable VDD33 supply\n"); - return ret; - } - ret = regulator_enable(exynos->vdd10); - if (ret) { - dev_err(dev, "Failed to enable VDD10 supply\n"); - return ret; - } - for (i = 0; i < exynos->num_clks; i++) { ret = clk_prepare_enable(exynos->clks[i]); if (ret) {