Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1311985img; Tue, 19 Mar 2019 05:10:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzR+HkjFqIfu2H0vlGwkwUUe818jGDlTXVdsMIwnL+gn3e0DDvWgblPxz2WoE0UcVOpX6md X-Received: by 2002:aa7:809a:: with SMTP id v26mr1636635pff.103.1552997428735; Tue, 19 Mar 2019 05:10:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552997428; cv=none; d=google.com; s=arc-20160816; b=vTZ965ZjBHHLj8AuTAAnjrtqmFZktDEEiPrNKCNem6wt0GdSaUlD0BKjsYXVLHCdEx 5Zk4ztqkzxJIt6WeCxua5DE4zP0nOVN//eDf/92Dy9dd9rOlbvJb/WuuteI7Z5HR9WKN Aa+NCq7MyTCyGZfwt/6RhnjJbFLUq5S2dW+1drY25PI5JaEy1hQc8m2Cslc8gygVszeQ B5IGRBmDIlySZlcslzRnbw60NexdpC7dEQtaga0DSGKze+1C6yr8W3kW+Z7/Nq8WKdTk OUEBKAp+T/x7FLk9jsDZiOAIukgjMQ3w0SA6wKog5mz83XfI4K1QX3S1LGx/MOBpDn91 xU+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=UMI5Cgc11e2yU8u3j1DQCbpem4FZZKd0yljARClXFro=; b=ubxbqVROpWkeRU8iR8alPavOFT/jfIcrvR4Rw9OtejIYQ4VQxDjkZX9VVCtXhV5HG7 jmbe40pdTb2+hzkS/gEsMKxslF5P88zDVX2/JRAKkYM4GxpaffFhTXRgG7UfpPv3+8Ep G5L+z99t1BXmk5lyj1EGx1O4q1wBsgbvUHGOyEEj3R7LhQAC/wwPJRt+OzzJyu/+RlaI Qmaof/362S8OT4GtbLybG2jLGGu7Ke5GFb3kj1JgFj1+rcaSkblgQte85FRZAPB11a0i P8gE+6r7ylL74g/DRq88yAnaD+v0tlRJlDYM+f2I4lSoyc/kV5EhlDX3fTSKWX/C+WCj QP1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GeV00N6Y; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b20si12609318plz.50.2019.03.19.05.10.13; Tue, 19 Mar 2019 05:10:28 -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; dkim=pass header.i=@chromium.org header.s=google header.b=GeV00N6Y; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727532AbfCSMJ1 (ORCPT + 99 others); Tue, 19 Mar 2019 08:09:27 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:44512 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726688AbfCSMJ1 (ORCPT ); Tue, 19 Mar 2019 08:09:27 -0400 Received: by mail-qk1-f195.google.com with SMTP id m65so4032952qkl.11 for ; Tue, 19 Mar 2019 05:09:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UMI5Cgc11e2yU8u3j1DQCbpem4FZZKd0yljARClXFro=; b=GeV00N6YFNcSkdveLp3qbBsP25FpiClQyosN8YpStzmygrX9G0ko+F80dXzXIolrwp L9b7XW+t3wXDX8eNHpPDrCRb5gsHeoqLvRkhdsWwdJUlGpbMvPiQFng0q2R1FTpOm9dV Uq86ESLpoUR4Px3rhBWah3eoYPuPUCOfl3+0M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UMI5Cgc11e2yU8u3j1DQCbpem4FZZKd0yljARClXFro=; b=MC/i/vTQYH0I4lYNkuJtJYnRc1nvgvqT1xMoN+3NX+m1g4XbFSjzaA9amdmzSFKUz/ 4Iuz2D7hm0jXCiNmNRmmE1enybZ5dupcjum/nhKROfTwt4KoQ+uhTjXynYQGDs/vORcb aa3e/450URY4Wnt2pB+kUxgdLwFA/NEWxjTNEQA2NqzvOo46AaN0gmLj9V9spgH5DIPp BoiGvOipVr87Ql5xRfKXw1lHfxkusraot+r3GfHwuxhAK0nhlP3N0PgCYc1KOPUEMLNK 26nDHqpkCBe3ZLxCxa2qIjX0iG6j9T0Hfve16Mq+fptunYykJMVgLySmnKncEBauXJm+ fu9A== X-Gm-Message-State: APjAAAXrYCldGc3/IQunf/chKB5y9KRkLBcU59qnlQ5hM1sKafi/JY0U F4iawyahi08khh1Zwl/g9J4gZNeL6raR2MWrrsSepw== X-Received: by 2002:a05:620a:1428:: with SMTP id k8mr1452326qkj.185.1552997366008; Tue, 19 Mar 2019 05:09:26 -0700 (PDT) MIME-Version: 1.0 References: <20190319080140.24055-1-weiyi.lu@mediatek.com> <20190319080140.24055-9-weiyi.lu@mediatek.com> In-Reply-To: <20190319080140.24055-9-weiyi.lu@mediatek.com> From: Nicolas Boichat Date: Tue, 19 Mar 2019 20:09:14 +0800 Message-ID: Subject: Re: [PATCH v5 08/14] soc: mediatek: Refactor bus protection control To: Weiyi Lu Cc: Matthias Brugger , Rob Herring , James Liao , Fan Chen , linux-arm Mailing List , lkml , "moderated list:ARM/Mediatek SoC support" , srv_heupstream Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(...); > +} > + > +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 >