diff mbox series

drm/mediatek: remove unnecessary conversion to bool

Message ID 20200612124007.4990-1-bernard@vivo.com (mailing list archive)
State New, archived
Headers show
Series drm/mediatek: remove unnecessary conversion to bool | expand

Commit Message

Bernard Zhao June 12, 2020, 12:40 p.m. UTC
In function mtk_dsi_clk_hs_state, remove unnecessary conversion
to bool return, this change is to make the code a bit readable.

Signed-off-by: Bernard Zhao <bernard@vivo.com>
---
 drivers/gpu/drm/mediatek/mtk_dsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Robin Murphy June 12, 2020, 1:09 p.m. UTC | #1
On 2020-06-12 13:40, Bernard Zhao wrote:
> In function mtk_dsi_clk_hs_state, remove unnecessary conversion
> to bool return, this change is to make the code a bit readable.
> 
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
> ---
>   drivers/gpu/drm/mediatek/mtk_dsi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
> index 270bf22c98fe..4491e64b3f06 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
> @@ -319,7 +319,7 @@ static bool mtk_dsi_clk_hs_state(struct mtk_dsi *dsi)
>   	u32 tmp_reg1;
>   
>   	tmp_reg1 = readl(dsi->regs + DSI_PHY_LCCON);
> -	return ((tmp_reg1 & LC_HS_TX_EN) == 1) ? true : false;
> +	return ((tmp_reg1 & LC_HS_TX_EN) == 1);

FWIW the "== 1" is also redundant, not to mention a little confusing - 
unless you go and look up the definition of LC_HS_TX_EN, it looks like 
this is doing something more than simply testing if a single bit is set.

Robin.

>   }
>   
>   static void mtk_dsi_clk_hs_mode(struct mtk_dsi *dsi, bool enter)
>
Joe Perches June 14, 2020, 8:41 p.m. UTC | #2
On Fri, 2020-06-12 at 20:40 +0800, Bernard Zhao wrote:
> In function mtk_dsi_clk_hs_state, remove unnecessary conversion
> to bool return, this change is to make the code a bit readable.
[]
> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
[]
> @@ -319,7 +319,7 @@ static bool mtk_dsi_clk_hs_state(struct mtk_dsi *dsi)
>  	u32 tmp_reg1;
>  
>  	tmp_reg1 = readl(dsi->regs + DSI_PHY_LCCON);
> -	return ((tmp_reg1 & LC_HS_TX_EN) == 1) ? true : false;
> +	return ((tmp_reg1 & LC_HS_TX_EN) == 1);

Given:

drivers/gpu/drm/mediatek/mtk_dsi.c:#define LC_HS_TX_EN                  BIT(0)

This is likely clearer as

	return tmp_reg1 & LC_HS_TX_EN;

or even

static bool mtk_dsi_clk_hs_state(struct mtk_dsi *dsi)
{
	return readl(dsi->regs + DSI_PHY_LCCON) & LC_HS_TX_EN;
}
Chun-Kuang Hu June 15, 2020, 2 p.m. UTC | #3
Joe Perches <joe@perches.com> 於 2020年6月15日 週一 上午4:41寫道:
>
> On Fri, 2020-06-12 at 20:40 +0800, Bernard Zhao wrote:
> > In function mtk_dsi_clk_hs_state, remove unnecessary conversion
> > to bool return, this change is to make the code a bit readable.
> []
> > diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
> []
> > @@ -319,7 +319,7 @@ static bool mtk_dsi_clk_hs_state(struct mtk_dsi *dsi)
> >       u32 tmp_reg1;
> >
> >       tmp_reg1 = readl(dsi->regs + DSI_PHY_LCCON);
> > -     return ((tmp_reg1 & LC_HS_TX_EN) == 1) ? true : false;
> > +     return ((tmp_reg1 & LC_HS_TX_EN) == 1);
>
> Given:
>
> drivers/gpu/drm/mediatek/mtk_dsi.c:#define LC_HS_TX_EN                  BIT(0)
>
> This is likely clearer as
>
>         return tmp_reg1 & LC_HS_TX_EN;
>
> or even
>
> static bool mtk_dsi_clk_hs_state(struct mtk_dsi *dsi)
> {
>         return readl(dsi->regs + DSI_PHY_LCCON) & LC_HS_TX_EN;
> }

I like the second one.

>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Bernard Zhao June 16, 2020, 2:16 a.m. UTC | #4
发件人:Chun-Kuang Hu <chunkuang.hu@kernel.org>
发送日期:2020-06-15 22:00:52
收件人:Joe Perches <joe@perches.com>
抄送人:Bernard Zhao <bernard@vivo.com>,Chun-Kuang Hu <chunkuang.hu@kernel.org>,Philipp Zabel <p.zabel@pengutronix.de>,David Airlie <airlied@linux.ie>,Daniel Vetter <daniel@ffwll.ch>,Matthias Brugger <matthias.bgg@gmail.com>,DRI Development <dri-devel@lists.freedesktop.org>,Linux ARM <linux-arm-kernel@lists.infradead.org>,"moderated list:ARM/Mediatek SoC support" <linux-mediatek@lists.infradead.org>,linux-kernel <linux-kernel@vger.kernel.org>,opensource.kernel@vivo.com
主题:Re: [PATCH] drm/mediatek: remove unnecessary conversion to bool>Joe Perches <joe@perches.com> 於 2020年6月15日 週一 上午4:41寫道:
>>
>> On Fri, 2020-06-12 at 20:40 +0800, Bernard Zhao wrote:
>> > In function mtk_dsi_clk_hs_state, remove unnecessary conversion
>> > to bool return, this change is to make the code a bit readable.
>> []
>> > diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
>> []
>> > @@ -319,7 +319,7 @@ static bool mtk_dsi_clk_hs_state(struct mtk_dsi *dsi)
>> >       u32 tmp_reg1;
>> >
>> >       tmp_reg1 = readl(dsi->regs + DSI_PHY_LCCON);
>> > -     return ((tmp_reg1 & LC_HS_TX_EN) == 1) ? true : false;
>> > +     return ((tmp_reg1 & LC_HS_TX_EN) == 1);
>>
>> Given:
>>
>> drivers/gpu/drm/mediatek/mtk_dsi.c:#define LC_HS_TX_EN                  BIT(0)
>>
>> This is likely clearer as
>>
>>         return tmp_reg1 & LC_HS_TX_EN;
>>
>> or even
>>
>> static bool mtk_dsi_clk_hs_state(struct mtk_dsi *dsi)
>> {
>>         return readl(dsi->regs + DSI_PHY_LCCON) & LC_HS_TX_EN;
>> }
>
>I like the second one.

Hi:

This modification is clear and easy to understand.
I will update the patch and resubmit.
Thanks!

BR//Bernard

>>
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox series

Patch

diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
index 270bf22c98fe..4491e64b3f06 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -319,7 +319,7 @@  static bool mtk_dsi_clk_hs_state(struct mtk_dsi *dsi)
 	u32 tmp_reg1;
 
 	tmp_reg1 = readl(dsi->regs + DSI_PHY_LCCON);
-	return ((tmp_reg1 & LC_HS_TX_EN) == 1) ? true : false;
+	return ((tmp_reg1 & LC_HS_TX_EN) == 1);
 }
 
 static void mtk_dsi_clk_hs_mode(struct mtk_dsi *dsi, bool enter)