diff mbox series

[V2,03/12] clk: mediatek: reset: Refine functions of set_clr

Message ID 20220420130527.23200-4-rex-bc.chen@mediatek.com (mailing list archive)
State Changes Requested, archived
Headers show
Series Cleanup MediaTek clk reset drivers and support MT8192/MT8195 | expand

Commit Message

Rex-BC Chen (陳柏辰) April 20, 2022, 1:05 p.m. UTC
To make driver more readable, revise functions of set_clr.
- Add to_rst_data().
- Extract common code within assert and deassert to
  mtk_reset_update_set_clr().

Signed-off-by: Rex-BC Chen <rex-bc.chen@mediatek.com>
---
 drivers/clk/mediatek/reset.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

Comments

AngeloGioacchino Del Regno April 21, 2022, 9:07 a.m. UTC | #1
Il 20/04/22 15:05, Rex-BC Chen ha scritto:
> To make driver more readable, revise functions of set_clr.
> - Add to_rst_data().
> - Extract common code within assert and deassert to
>    mtk_reset_update_set_clr().
> 
> Signed-off-by: Rex-BC Chen <rex-bc.chen@mediatek.com>
> ---
>   drivers/clk/mediatek/reset.c | 32 +++++++++++++++++++++-----------
>   1 file changed, 21 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/clk/mediatek/reset.c b/drivers/clk/mediatek/reset.c
> index 9110d0b4229f..6574b19daf0f 100644
> --- a/drivers/clk/mediatek/reset.c
> +++ b/drivers/clk/mediatek/reset.c
> @@ -20,26 +20,36 @@ struct mtk_reset {
>   	struct reset_controller_dev rcdev;
>   };
>   
> -static int mtk_reset_assert_set_clr(struct reset_controller_dev *rcdev,
> -	unsigned long id)
> +static inline struct mtk_reset *to_rst_data(struct reset_controller_dev *rcdev)

to_mtk_reset() looks more consistent, as many developers are using the naming
"to_{struct_name}".

Also, can you please mention the indentation fixes in the commit description?

Thanks,
Angelo
Rex-BC Chen (陳柏辰) April 22, 2022, 5 a.m. UTC | #2
On Thu, 2022-04-21 at 11:07 +0200, AngeloGioacchino Del Regno wrote:
> Il 20/04/22 15:05, Rex-BC Chen ha scritto:
> > To make driver more readable, revise functions of set_clr.
> > - Add to_rst_data().
> > - Extract common code within assert and deassert to
> >    mtk_reset_update_set_clr().
> > 
> > Signed-off-by: Rex-BC Chen <rex-bc.chen@mediatek.com>
> > ---
> >   drivers/clk/mediatek/reset.c | 32 +++++++++++++++++++++--------
> > ---
> >   1 file changed, 21 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/clk/mediatek/reset.c
> > b/drivers/clk/mediatek/reset.c
> > index 9110d0b4229f..6574b19daf0f 100644
> > --- a/drivers/clk/mediatek/reset.c
> > +++ b/drivers/clk/mediatek/reset.c
> > @@ -20,26 +20,36 @@ struct mtk_reset {
> >   	struct reset_controller_dev rcdev;
> >   };
> >   
> > -static int mtk_reset_assert_set_clr(struct reset_controller_dev
> > *rcdev,
> > -	unsigned long id)
> > +static inline struct mtk_reset *to_rst_data(struct
> > reset_controller_dev *rcdev)
> 
> to_mtk_reset() looks more consistent, as many developers are using
> the naming
> "to_{struct_name}".

Hello Angelo,

ok, I will fix this in next version.

> 
> Also, can you please mention the indentation fixes in the commit
> description?
> 

I add another refinement patch in next version.

BRs,
Rex

> Thanks,
> Angelo
>
diff mbox series

Patch

diff --git a/drivers/clk/mediatek/reset.c b/drivers/clk/mediatek/reset.c
index 9110d0b4229f..6574b19daf0f 100644
--- a/drivers/clk/mediatek/reset.c
+++ b/drivers/clk/mediatek/reset.c
@@ -20,26 +20,36 @@  struct mtk_reset {
 	struct reset_controller_dev rcdev;
 };
 
-static int mtk_reset_assert_set_clr(struct reset_controller_dev *rcdev,
-	unsigned long id)
+static inline struct mtk_reset *to_rst_data(struct reset_controller_dev *rcdev)
 {
-	struct mtk_reset *data = container_of(rcdev, struct mtk_reset, rcdev);
-	unsigned int reg = data->regofs + ((id / 32) << 4);
+	return container_of(rcdev, struct mtk_reset, rcdev);
+}
 
-	return regmap_write(data->regmap, reg, BIT(id % 32));
+static int mtk_reset_update_set_clr(struct reset_controller_dev *rcdev,
+				    unsigned long id, bool deassert)
+{
+	struct mtk_reset *data = to_rst_data(rcdev);
+	unsigned int deassert_ofs = deassert ? 0x4 : 0;
+
+	return regmap_write(data->regmap,
+			    data->regofs + ((id / 32) << 4) + deassert_ofs,
+			    BIT(id % 32));
 }
 
-static int mtk_reset_deassert_set_clr(struct reset_controller_dev *rcdev,
-	unsigned long id)
+static int mtk_reset_assert_set_clr(struct reset_controller_dev *rcdev,
+				    unsigned long id)
 {
-	struct mtk_reset *data = container_of(rcdev, struct mtk_reset, rcdev);
-	unsigned int reg = data->regofs + ((id / 32) << 4) + 0x4;
+	return mtk_reset_update_set_clr(rcdev, id, false);
+}
 
-	return regmap_write(data->regmap, reg, BIT(id % 32));
+static int mtk_reset_deassert_set_clr(struct reset_controller_dev *rcdev,
+				      unsigned long id)
+{
+	return mtk_reset_update_set_clr(rcdev, id, true);
 }
 
 static int mtk_reset_set_clr(struct reset_controller_dev *rcdev,
-	unsigned long id)
+			     unsigned long id)
 {
 	int ret;