Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp571751ioo; Sat, 21 May 2022 07:24:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlrYaAU0UKwXBda/H5q3NGNuj6pB8uXbskcBC4CsaH6L2N7QC1x7912JADDu2imwhYG3zq X-Received: by 2002:a17:906:c102:b0:6f8:d325:bb82 with SMTP id do2-20020a170906c10200b006f8d325bb82mr13258694ejc.197.1653143070445; Sat, 21 May 2022 07:24:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653143070; cv=none; d=google.com; s=arc-20160816; b=UCi1IXgbBbyHiSxcLDp2+Pfr4NghwZC8Q2kfW1pvXtpHtLmZaMKCvw4lwZSL3GSLpW bNdc2msMyCww0OIQgCl9p0HkVi/avjbDsWwD3jnI5QuNddcUKJN0oXhimHHOM+lBQAIN 1tyZ4SXkRH41Kn6TQOy05G5c0Rq3hUjf2ON45vV17/kPsuImzB5mCIEYJiHHoaTn8bOb BD7tIKE01L3WmiSVOm2VXuTp5Q8YDjKuT98IbOCNmNEw7BQ5OMv2aOuD1orJHvnXwA4q NJ19fur/U4c9NPgbMiRpJLzrjy6JAniqk/JBJHLGm6PPCION4qZE+Re/aX1BohsMeSEY 4Asw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=evSEioY6p83CwgOBmo4AQCANjeDMiz6sqWGwdV49zqM=; b=TtR7V6uoNjOlJvnd7VUjQQlFajWbpwVglHvyYsJMH0rUDw04w/uAIeOjmM1vFlQMHD hGbKTHu2IxXN9Y+l7s+SYNfLVMhWJiCbpDQxDb9FpZR8YPF5xLmtiDnoF4XUDpRPauon GBcLzqdVzUlbUafrOFj4IHWLRb9MPdyjPBsbe4nkxVXM6chMW7rcdfJSFNBubYtG5nE5 AQAynfueRdiREJ7JPKVVkAQs8nW72R/O1BhBOD3v1DzclOKes4FsIFSTs/GRd1o4qf2C axySw0epw1RI3mH5atdzQ+JjJQtqNU2rMVaE7Diqwh+7sUbEXULWtvFUO2xUUlS1eo+7 ovGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Qp+eGoXC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i15-20020a05640242cf00b0042ae6ef4f98si2226147edc.126.2022.05.21.07.24.04; Sat, 21 May 2022 07:24:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Qp+eGoXC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348564AbiETO4N (ORCPT + 99 others); Fri, 20 May 2022 10:56:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350525AbiETO4B (ORCPT ); Fri, 20 May 2022 10:56:01 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5F0115814; Fri, 20 May 2022 07:55:58 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: nfraprado) with ESMTPSA id AACB51F46542 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1653058557; bh=jxX878QWawgfvMOXk/YfULJcGJes7LLWJjg8hH9kCTI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Qp+eGoXC12xS0US+up3AlAeSEDKDGEXAPjch3KWyCwzTClULych8zz0ibHqnTODRR G4rG2kxigej4l/KJ0XIgq5nph59Dym7LEXSDLoqZ7WdA9BJL2jAdofZS+0UiB7P7GK UQ8hg2zb7DWeq0g/pElSQw1ktp2ekGitloZsfJ0Xzznf7LsGa9zimN5TcwVFR/C7ib TI9pOyWzqApc7fhRwNSI815uGNqXDLnXsWajfm93QhDnkksdfKGXkAQtKmGdQ5cvWg w8tB+P+d2GF10vgVOHyflekvmgd9D60EqKj1xMxVE7lQjZMcr0rZwYZSJbmUicXt0W T5nUb3G2ru02w== Date: Fri, 20 May 2022 10:55:51 -0400 From: =?utf-8?B?TsOtY29sYXMgRi4gUi4gQS4=?= Prado To: Rex-BC Chen Cc: mturquette@baylibre.com, sboyd@kernel.org, matthias.bgg@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, p.zabel@pengutronix.de, angelogioacchino.delregno@collabora.com, chun-jie.chen@mediatek.com, wenst@chromium.org, runyang.chen@mediatek.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Project_Global_Chrome_Upstream_Group@mediatek.com Subject: Re: [PATCH v7 04/19] clk: mediatek: reset: Extract common drivers to update function Message-ID: <20220520145551.b2sqheaizkegna3n@notapiano> References: <20220519125527.18544-1-rex-bc.chen@mediatek.com> <20220519125527.18544-5-rex-bc.chen@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220519125527.18544-5-rex-bc.chen@mediatek.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 19, 2022 at 08:55:12PM +0800, Rex-BC Chen wrote: > To make drivers more clear and readable, we extract common code > within assert and deassert to mtk_reset_update_set_clr() and > mtk_reset_update(). > > Signed-off-by: Rex-BC Chen > Reviewed-by: AngeloGioacchino Del Regno > --- > drivers/clk/mediatek/reset.c | 38 +++++++++++++++++++++--------------- > 1 file changed, 22 insertions(+), 16 deletions(-) > > diff --git a/drivers/clk/mediatek/reset.c b/drivers/clk/mediatek/reset.c > index 5cbbcc22a4fc..22fa9f09752c 100644 > --- a/drivers/clk/mediatek/reset.c > +++ b/drivers/clk/mediatek/reset.c > @@ -12,24 +12,27 @@ > > #include "reset.h" > > -static int mtk_reset_assert(struct reset_controller_dev *rcdev, > - unsigned long id) > +static int mtk_reset_update(struct reset_controller_dev *rcdev, > + unsigned long id, bool deassert) I'd have called the bool 'assert', and then passed true on assert and false on deassert, as I think that's slightly more intuitive, but that's just personal preference. It's fine like this as well. Thanks, N?colas > { > struct mtk_reset *data = container_of(rcdev, struct mtk_reset, rcdev); > + unsigned int val = deassert ? 0 : ~0; > > return regmap_update_bits(data->regmap, > data->regofs + ((id / 32) << 2), > - BIT(id % 32), ~0); > + BIT(id % 32), val); > +} > + > +static int mtk_reset_assert(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + return mtk_reset_update(rcdev, id, false); > } > > static int mtk_reset_deassert(struct reset_controller_dev *rcdev, > unsigned long id) > { > - struct mtk_reset *data = container_of(rcdev, struct mtk_reset, rcdev); > - > - return regmap_update_bits(data->regmap, > - data->regofs + ((id / 32) << 2), > - BIT(id % 32), 0); > + return mtk_reset_update(rcdev, id, true); > } > > static int mtk_reset(struct reset_controller_dev *rcdev, unsigned long id) > @@ -43,24 +46,27 @@ static int mtk_reset(struct reset_controller_dev *rcdev, unsigned long id) > return mtk_reset_deassert(rcdev, id); > } > > -static int mtk_reset_assert_set_clr(struct reset_controller_dev *rcdev, > - unsigned long id) > +static int mtk_reset_update_set_clr(struct reset_controller_dev *rcdev, > + unsigned long id, bool deassert) > { > struct mtk_reset *data = container_of(rcdev, struct mtk_reset, rcdev); > + unsigned int deassert_ofs = deassert ? 0x4 : 0; > > return regmap_write(data->regmap, > - data->regofs + ((id / 32) << 4), > + data->regofs + ((id / 32) << 4) + deassert_ofs, > BIT(id % 32)); > } > > +static int mtk_reset_assert_set_clr(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + return mtk_reset_update_set_clr(rcdev, id, false); > +} > + > static int mtk_reset_deassert_set_clr(struct reset_controller_dev *rcdev, > unsigned long id) > { > - struct mtk_reset *data = container_of(rcdev, struct mtk_reset, rcdev); > - > - return regmap_write(data->regmap, > - data->regofs + ((id / 32) << 4) + 0x4, > - BIT(id % 32)); > + return mtk_reset_update_set_clr(rcdev, id, true); > } > > static int mtk_reset_set_clr(struct reset_controller_dev *rcdev, > -- > 2.18.0 > >