linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/mediatek: remove unnecessary conversion to bool
@ 2020-06-12 12:40 Bernard Zhao
  2020-06-12 13:09 ` Robin Murphy
  2020-06-14 20:41 ` Joe Perches
  0 siblings, 2 replies; 5+ messages in thread
From: Bernard Zhao @ 2020-06-12 12:40 UTC (permalink / raw)
  To: Chun-Kuang Hu, Philipp Zabel, David Airlie, Daniel Vetter,
	Matthias Brugger, dri-devel, linux-arm-kernel, linux-mediatek,
	linux-kernel
  Cc: opensource.kernel, Bernard Zhao

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);
 }
 
 static void mtk_dsi_clk_hs_mode(struct mtk_dsi *dsi, bool enter)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/mediatek: remove unnecessary conversion to bool
  2020-06-12 12:40 [PATCH] drm/mediatek: remove unnecessary conversion to bool Bernard Zhao
@ 2020-06-12 13:09 ` Robin Murphy
  2020-06-14 20:41 ` Joe Perches
  1 sibling, 0 replies; 5+ messages in thread
From: Robin Murphy @ 2020-06-12 13:09 UTC (permalink / raw)
  To: Bernard Zhao, Chun-Kuang Hu, Philipp Zabel, David Airlie,
	Daniel Vetter, Matthias Brugger, dri-devel, linux-arm-kernel,
	linux-mediatek, linux-kernel
  Cc: opensource.kernel

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)
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/mediatek: remove unnecessary conversion to bool
  2020-06-12 12:40 [PATCH] drm/mediatek: remove unnecessary conversion to bool Bernard Zhao
  2020-06-12 13:09 ` Robin Murphy
@ 2020-06-14 20:41 ` Joe Perches
  2020-06-15 14:00   ` Chun-Kuang Hu
  1 sibling, 1 reply; 5+ messages in thread
From: Joe Perches @ 2020-06-14 20:41 UTC (permalink / raw)
  To: Bernard Zhao, Chun-Kuang Hu, Philipp Zabel, David Airlie,
	Daniel Vetter, Matthias Brugger, dri-devel, linux-arm-kernel,
	linux-mediatek, linux-kernel
  Cc: opensource.kernel

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;
}



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/mediatek: remove unnecessary conversion to bool
  2020-06-14 20:41 ` Joe Perches
@ 2020-06-15 14:00   ` Chun-Kuang Hu
  2020-06-16  2:16     ` Bernard
  0 siblings, 1 reply; 5+ messages in thread
From: Chun-Kuang Hu @ 2020-06-15 14:00 UTC (permalink / raw)
  To: Joe Perches
  Cc: Bernard Zhao, Chun-Kuang Hu, Philipp Zabel, David Airlie,
	Daniel Vetter, Matthias Brugger, DRI Development, Linux ARM,
	moderated list:ARM/Mediatek SoC support, linux-kernel,
	opensource.kernel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re:Re: [PATCH] drm/mediatek: remove unnecessary conversion to bool
  2020-06-15 14:00   ` Chun-Kuang Hu
@ 2020-06-16  2:16     ` Bernard
  0 siblings, 0 replies; 5+ messages in thread
From: Bernard @ 2020-06-16  2:16 UTC (permalink / raw)
  To: Chun-Kuang Hu
  Cc: Joe Perches, Chun-Kuang Hu, Philipp Zabel, David Airlie,
	Daniel Vetter, Matthias Brugger, DRI Development, Linux ARM,
	moderated list:ARM/Mediatek SoC support, linux-kernel,
	opensource.kernel



发件人: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



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-16  2:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-12 12:40 [PATCH] drm/mediatek: remove unnecessary conversion to bool Bernard Zhao
2020-06-12 13:09 ` Robin Murphy
2020-06-14 20:41 ` Joe Perches
2020-06-15 14:00   ` Chun-Kuang Hu
2020-06-16  2:16     ` Bernard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).