Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp463662ybi; Wed, 19 Jun 2019 02:32:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmIEVlxTdZDxhOfPxGePQItGtlhGHIHiptFDNb7NYfG7XKwAyDtv0mDL2mfxbeALM64J0A X-Received: by 2002:a17:90a:3590:: with SMTP id r16mr10294558pjb.44.1560936745461; Wed, 19 Jun 2019 02:32:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560936745; cv=none; d=google.com; s=arc-20160816; b=K5MuIn/fY5MeDniK4j3XHA382SuxylyISuqJcc0KplZoEwKRzPNkee0tArWpAUcisd LoMah7nQs78qnw+ye58F2h1z6W2M+U5EnUZ6rU1LNWrGSpb0hmVDSfgjAHaExP9ua1+T Mr2QgtkZr0JwiwBM+543bNSEvfJwp9JUuLbrp0w1BAY8WIgjqgiovV114/Xa3TSrTpeX +FD7cTJJUoosKLv3MV0HfHplmBrOczqBIhe2ClN7gkwy6suv0QQQZdkKKNzoIMQPy8Is htC3RY+/enxrVbsFx54WRcPjDtLXreeUNv39crii4Yd5Ch2DDQtCv4R2YOKAbBMZPJ/F ZHgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=c1sug4k4ijnU3mfyEgSuK71hGbXHWb3XR3SD0t9VAzA=; b=pXUyryAvWIimVRPmrN523nh20jGppvfp8LpozWLQ927J4rWz/I20yytO4BvWZY4WTX OxZCvOM75U3dOu0EWD5SazyES9T1ZwJpNCT26YN1N2AaAkI7hK/Dyllr8uXa1mTqO73G L4lWs5+0DVjfEOHS1irZY7YOIohkxTO+K2p0arfffT4fHe/MvATw0UnYP1Pr4PQ+IRuP 2SypokgXkFQiA0SnfaaWu9/fnpeTkcMvWUTDpJuWKIWyrxjLFA+EFSWiEflCNrhEfd1K IEQkekublGujz3y9s9WLlg2AFChyqyDO2rmC1h745uLdj0kcPXXCmJ4dETx3ykRW9oMv Qd+Q== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5si15719398pfc.245.2019.06.19.02.32.09; Wed, 19 Jun 2019 02:32:25 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731493AbfFSJb1 (ORCPT + 99 others); Wed, 19 Jun 2019 05:31:27 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:33181 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726826AbfFSJb1 (ORCPT ); Wed, 19 Jun 2019 05:31:27 -0400 X-UUID: 541ef4796dac45c487a734321625e303-20190619 X-UUID: 541ef4796dac45c487a734321625e303-20190619 Received: from mtkmrs01.mediatek.inc [(172.21.131.159)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 2122254576; Wed, 19 Jun 2019 17:31:22 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 19 Jun 2019 17:31:20 +0800 Received: from [172.21.77.4] (172.21.77.4) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 19 Jun 2019 17:31:21 +0800 Message-ID: <1560936681.2158.16.camel@mtksdaap41> Subject: Re: [PATCH v5 08/14] soc: mediatek: Refactor bus protection control From: Weiyi Lu To: Nicolas Boichat CC: Rob Herring , srv_heupstream , James Liao , lkml , Fan Chen , "moderated list:ARM/Mediatek SoC support" , Matthias Brugger , linux-arm Mailing List Date: Wed, 19 Jun 2019 17:31:21 +0800 In-Reply-To: References: <20190319080140.24055-1-weiyi.lu@mediatek.com> <20190319080140.24055-9-weiyi.lu@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2019-03-19 at 20:09 +0800, Nicolas Boichat wrote: > On Tue, Mar 19, 2019 at 4:02 PM Weiyi Lu wrote: > > > > Put bus protection enable and disable control in separate functions. > > > > Signed-off-by: Weiyi Lu > > --- > > drivers/soc/mediatek/mtk-scpsys.c | 48 ++++++++++++++++++++++--------- > > 1 file changed, 34 insertions(+), 14 deletions(-) > > > > diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c > > index 65b734b40098..6bf846cb1893 100644 > > --- a/drivers/soc/mediatek/mtk-scpsys.c > > +++ b/drivers/soc/mediatek/mtk-scpsys.c > > @@ -279,6 +279,34 @@ static int scpsys_sram_disable(struct scp_domain *scpd, void __iomem *ctl_addr) > > MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); > > } > > > > +static int scpsys_bus_protect_enable(struct scp_domain *scpd) > > +{ > > + struct scp *scp = scpd->scp; > > + int ret = 0; > > + > > + if (scpd->data->bus_prot_mask) { > > + ret = mtk_infracfg_set_bus_protection(scp->infracfg, > > + scpd->data->bus_prot_mask, > > + scp->bus_prot_reg_update); > > + } > > + > > + return ret; > > Maybe other people have different opinions, but I prefer: > > if (!scpd->data->bus_prot_mask) > return 0; > > return mtk_infracfg_set_bus_protection(...); > ok, I'll update in next version. > > +} > > + > > +static int scpsys_bus_protect_disable(struct scp_domain *scpd) > > +{ > > + struct scp *scp = scpd->scp; > > + int ret = 0; > > + > > + if (scpd->data->bus_prot_mask) { > > + ret = mtk_infracfg_clear_bus_protection(scp->infracfg, > > + scpd->data->bus_prot_mask, > > + scp->bus_prot_reg_update); > > + } > > + > > + return ret; > > +} > > + > > static int scpsys_power_on(struct generic_pm_domain *genpd) > > { > > struct scp_domain *scpd = container_of(genpd, struct scp_domain, genpd); > > @@ -321,13 +349,9 @@ static int scpsys_power_on(struct generic_pm_domain *genpd) > > if (ret < 0) > > goto err_pwr_ack; > > > > - if (scpd->data->bus_prot_mask) { > > - ret = mtk_infracfg_clear_bus_protection(scp->infracfg, > > - scpd->data->bus_prot_mask, > > - scp->bus_prot_reg_update); > > - if (ret) > > - goto err_pwr_ack; > > - } > > + ret = scpsys_bus_protect_disable(scpd); > > + if (ret < 0) > > + goto err_pwr_ack; > > > > return 0; > > > > @@ -349,13 +373,9 @@ static int scpsys_power_off(struct generic_pm_domain *genpd) > > u32 val; > > int ret, tmp; > > > > - if (scpd->data->bus_prot_mask) { > > - ret = mtk_infracfg_set_bus_protection(scp->infracfg, > > - scpd->data->bus_prot_mask, > > - scp->bus_prot_reg_update); > > - if (ret) > > - goto out; > > - } > > + ret = scpsys_bus_protect_enable(scpd); > > + if (ret < 0) > > + goto out; > > > > ret = scpsys_sram_disable(scpd, ctl_addr); > > if (ret < 0) > > -- > > 2.18.0 > > > > _______________________________________________ > Linux-mediatek mailing list > Linux-mediatek@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-mediatek