Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3074700ybg; Mon, 28 Oct 2019 07:05:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfkTvU/YKUrdRRBaTXbJzDPypCePZaFBcrPvUL3MswkO3tyRjaLNc8voWKB8BpOOWj9h/8 X-Received: by 2002:a50:c3c5:: with SMTP id i5mr4009161edf.137.1572271546492; Mon, 28 Oct 2019 07:05:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572271546; cv=none; d=google.com; s=arc-20160816; b=FWxGjVn9qJ33NnhWoTQMpGu+DW8iSKNoDq8bBO4kKgD/bYXboCQ4Ym2fQg5KgeIHCU HYYOeeDB/ceomwO6g+SGowBjcof4XPTKogGeA7wXtas9xdY7TMECgfwSQgjWaxmk4UBd LZu2DifNQVAdvDpj5FdHsLsB5RDeMPWJDWzhEKNlOgyTUR30PtcI6WZrHBeFO5tLgv7f C5VHCSNuRm6k/JrdstDmHQ6aF5/RKCdfa+9ZiUShfRODfvDEq5SL8mmcPSlgw4aSxnyy b3FjI8mF9Qzg8i+cQe1TaPORTI86KJaQTwUp3C72Oy3I0+DtbCCFOyPkssQiBNp+Z6f0 Ed3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=VpI07KSBMyKGJguxVGgSsiE/8oyo5R4Ue4PvZKJ3XtU=; b=pmbT742vj0o4CWM0xsXz6DXcIMn+/VKln+4sI/9Wm9d6PYUFy4zL/ST7L+wE0a2OKg 0dvGkUBKZVA6lYu2IHrkOkmoyoZ7fzxisfSgptpiVDnPMhj4hHL/UvsXvStaK1MBv8He sHe2Ud574ZJWXsONU6p/2s6Llo4TVc1p9qwi7C/eCsykc+S4RWEVbHvYVzUfrS1B+f1V tJ5W+bBOE4nYMv+zn8weChTNWy95heQju9BJYyaWHIYci6FKufneEx/tfydvIRy+h9Db UF9WoX/Kw9PAgehKpQWGLlHYIK1dw64KMr0RbfMbpfMP8jjlPv8BTBq0lg8w/3VyfIF5 ArxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qw15si6328755ejb.137.2019.10.28.07.05.15; Mon, 28 Oct 2019 07:05:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730951AbfJ1CtB (ORCPT + 99 others); Sun, 27 Oct 2019 22:49:01 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:47938 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729524AbfJ1Cse (ORCPT ); Sun, 27 Oct 2019 22:48:34 -0400 X-UUID: 712b3a6bb0f64f3c8953826d16742a7d-20191028 X-UUID: 712b3a6bb0f64f3c8953826d16742a7d-20191028 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1975519279; Mon, 28 Oct 2019 10:48:27 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 28 Oct 2019 10:48:25 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 28 Oct 2019 10:48:26 +0800 From: Weiyi Lu To: Nicolas Boichat , Matthias Brugger , Rob Herring CC: James Liao , Fan Chen , , , , , Weiyi Lu , Yong Wu Subject: [PATCH v8 04/14] soc: mediatek: Refactor regulator control Date: Mon, 28 Oct 2019 10:48:08 +0800 Message-ID: <1572230898-7860-5-git-send-email-weiyi.lu@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1572230898-7860-1-git-send-email-weiyi.lu@mediatek.com> References: <1572230898-7860-1-git-send-email-weiyi.lu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Put regulator enable and disable control in separate functions. Signed-off-by: Weiyi Lu --- drivers/soc/mediatek/mtk-scpsys.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c index e97fc0e..aed540d 100644 --- a/drivers/soc/mediatek/mtk-scpsys.c +++ b/drivers/soc/mediatek/mtk-scpsys.c @@ -191,6 +191,22 @@ static int scpsys_domain_is_on(struct scp_domain *scpd) return -EINVAL; } +static int scpsys_regulator_enable(struct scp_domain *scpd) +{ + if (!scpd->supply) + return 0; + + return regulator_enable(scpd->supply); +} + +static int scpsys_regulator_disable(struct scp_domain *scpd) +{ + if (!scpd->supply) + return 0; + + return regulator_disable(scpd->supply); +} + static int scpsys_power_on(struct generic_pm_domain *genpd) { struct scp_domain *scpd = container_of(genpd, struct scp_domain, genpd); @@ -201,11 +217,9 @@ static int scpsys_power_on(struct generic_pm_domain *genpd) int ret, tmp; int i; - if (scpd->supply) { - ret = regulator_enable(scpd->supply); - if (ret) - return ret; - } + ret = scpsys_regulator_enable(scpd); + if (ret < 0) + return ret; for (i = 0; i < MAX_CLKS && scpd->clk[i]; i++) { ret = clk_prepare_enable(scpd->clk[i]); @@ -273,8 +287,7 @@ static int scpsys_power_on(struct generic_pm_domain *genpd) clk_disable_unprepare(scpd->clk[i]); } err_clk: - if (scpd->supply) - regulator_disable(scpd->supply); + scpsys_regulator_disable(scpd); dev_err(scp->dev, "Failed to power on domain %s\n", genpd->name); @@ -333,8 +346,9 @@ static int scpsys_power_off(struct generic_pm_domain *genpd) for (i = 0; i < MAX_CLKS && scpd->clk[i]; i++) clk_disable_unprepare(scpd->clk[i]); - if (scpd->supply) - regulator_disable(scpd->supply); + ret = scpsys_regulator_disable(scpd); + if (ret < 0) + goto out; return 0; -- 1.8.1.1.dirty