Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp578835ybl; Wed, 28 Aug 2019 02:14:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqw9Vh83YDUimztGGLTjdVBJbBnidD1s8q78rxN4LgzrOSPkrL1W2EelVUftWnj2r5ehyyzT X-Received: by 2002:a17:902:1121:: with SMTP id d30mr3272930pla.174.1566983646335; Wed, 28 Aug 2019 02:14:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566983646; cv=none; d=google.com; s=arc-20160816; b=NilsAjf7IBDnRkDoieO3gKONvkvICDHcS2gwb9A024dU8AKej8BvP7hbTjDFCgR4k9 75bXg+Sp33afGQG01br2DyC+be9v+BP3ahSnoe6aIi3SctFff6xnO5Lh44OqluoOyYej seSuqdJYdOnSvyn/OHWMWPXIaTIWzKatSHA0Iba2f6FuGa8uk1UdM5+U0GoiT3J63FHT fPO371Jq9YUdhkqOEt+gPAnpic+hLcU2LTDraKZT7R9MXinUnMxjcrsxC5r4WdXJHttc cxBjRcD49iZam6pCZMvYk7JjLS8QiVYQUcVIDfrWY0UUJBk5einodZwsAxwuM1C5jzVn g41w== 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=c6HuPlvBB5GByHHUkre3bFKd2gGgNr5bZK09r1YriZ4ZlxYQHggcNH3vWR22xEM8x1 oSBbD1eK6kjqSvZuzGo73uNbSbrMX7WbtDl9ZZQBGTJ58sjs4Uuddhb4afq280b5TZKr NCZUGsxNSh6zU82xiEKVEZa0x3XPp97PofDawn32Ya/b4JIKBNGbd01WYDpduPSpqQZ1 arsXPdW/TErRncvkgMTjDLnwkz7BodmsdGGtgoHit6yj84cJozFsDGHsJv4R4SzOj0+r u3+Lb7QDYVksbpH1DKQoZl0J31/OYhEcrhBTgMMwyrT2Le0K2PvhwA7BiUF6vMM9gPGA sxTQ== 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 h69si1685356pge.543.2019.08.28.02.13.50; Wed, 28 Aug 2019 02:14:06 -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 S1726971AbfH1JMd (ORCPT + 99 others); Wed, 28 Aug 2019 05:12:33 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:15642 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726246AbfH1JMH (ORCPT ); Wed, 28 Aug 2019 05:12:07 -0400 X-UUID: 6acb42ef8b9a43818ee091a15fa781d8-20190828 X-UUID: 6acb42ef8b9a43818ee091a15fa781d8-20190828 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1062980437; Wed, 28 Aug 2019 17:11:58 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 28 Aug 2019 17:12:04 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 28 Aug 2019 17:12:04 +0800 From: Weiyi Lu To: Nicolas Boichat , Matthias Brugger , Rob Herring CC: James Liao , Fan Chen , , , , , Weiyi Lu , Yong Wu Subject: [PATCH v7 04/13] soc: mediatek: Refactor regulator control Date: Wed, 28 Aug 2019 17:11:37 +0800 Message-ID: <1566983506-26598-5-git-send-email-weiyi.lu@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1566983506-26598-1-git-send-email-weiyi.lu@mediatek.com> References: <1566983506-26598-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