diff mbox series

[2/2] drm/mcde: Do not needlessly logically and with 3

Message ID 20191122072508.25677-1-linus.walleij@linaro.org
State Accepted
Commit b23490cbb2027bb37287d73a050e3a9c2e4e1f39
Headers show
Series [1/2] drm/mcde: Reuse global DSI command defs | expand

Commit Message

Linus Walleij Nov. 22, 2019, 7:25 a.m. UTC
The i index i always 0..3 in these statements so there
is no need to tag "& 3" to clamp it to 3 here. Make
the operator precedence explicit even if it's correct
as it is, the paranthesis creates less cognitive stress
for humans.

Cc: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpu/drm/mcde/mcde_dsi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Stephan Gerhold Nov. 22, 2019, 12:01 p.m. UTC | #1
On Fri, Nov 22, 2019 at 08:25:08AM +0100, Linus Walleij wrote:
> The i index i always 0..3 in these statements so there
> is no need to tag "& 3" to clamp it to 3 here. Make
> the operator precedence explicit even if it's correct
> as it is, the paranthesis creates less cognitive stress
> for humans.
> 
> Cc: Stephan Gerhold <stephan@gerhold.net>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Reviewed-by: Stephan Gerhold <stephan@gerhold.net>

> ---
>  drivers/gpu/drm/mcde/mcde_dsi.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mcde/mcde_dsi.c b/drivers/gpu/drm/mcde/mcde_dsi.c
> index dc07b534f01f..21cee4d9d2fd 100644
> --- a/drivers/gpu/drm/mcde/mcde_dsi.c
> +++ b/drivers/gpu/drm/mcde/mcde_dsi.c
> @@ -237,25 +237,25 @@ static ssize_t mcde_dsi_host_transfer(struct mipi_dsi_host *host,
>  	if (txlen > 0) {
>  		val = 0;
>  		for (i = 0; i < 4 && i < txlen; i++)
> -			val |= tx[i] << (i & 3) * 8;
> +			val |= tx[i] << (i * 8);
>  	}
>  	writel(val, d->regs + DSI_DIRECT_CMD_WRDAT0);
>  	if (txlen > 4) {
>  		val = 0;
>  		for (i = 0; i < 4 && (i + 4) < txlen; i++)
> -			val |= tx[i + 4] << (i & 3) * 8;
> +			val |= tx[i + 4] << (i * 8);
>  		writel(val, d->regs + DSI_DIRECT_CMD_WRDAT1);
>  	}
>  	if (txlen > 8) {
>  		val = 0;
>  		for (i = 0; i < 4 && (i + 8) < txlen; i++)
> -			val |= tx[i + 8] << (i & 3) * 8;
> +			val |= tx[i + 8] << (i * 8);
>  		writel(val, d->regs + DSI_DIRECT_CMD_WRDAT2);
>  	}
>  	if (txlen > 12) {
>  		val = 0;
>  		for (i = 0; i < 4 && (i + 12) < txlen; i++)
> -			val |= tx[i + 12] << (i & 3) * 8;
> +			val |= tx[i + 12] << (i * 8);
>  		writel(val, d->regs + DSI_DIRECT_CMD_WRDAT3);
>  	}
>  
> -- 
> 2.21.0
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/mcde/mcde_dsi.c b/drivers/gpu/drm/mcde/mcde_dsi.c
index dc07b534f01f..21cee4d9d2fd 100644
--- a/drivers/gpu/drm/mcde/mcde_dsi.c
+++ b/drivers/gpu/drm/mcde/mcde_dsi.c
@@ -237,25 +237,25 @@  static ssize_t mcde_dsi_host_transfer(struct mipi_dsi_host *host,
 	if (txlen > 0) {
 		val = 0;
 		for (i = 0; i < 4 && i < txlen; i++)
-			val |= tx[i] << (i & 3) * 8;
+			val |= tx[i] << (i * 8);
 	}
 	writel(val, d->regs + DSI_DIRECT_CMD_WRDAT0);
 	if (txlen > 4) {
 		val = 0;
 		for (i = 0; i < 4 && (i + 4) < txlen; i++)
-			val |= tx[i + 4] << (i & 3) * 8;
+			val |= tx[i + 4] << (i * 8);
 		writel(val, d->regs + DSI_DIRECT_CMD_WRDAT1);
 	}
 	if (txlen > 8) {
 		val = 0;
 		for (i = 0; i < 4 && (i + 8) < txlen; i++)
-			val |= tx[i + 8] << (i & 3) * 8;
+			val |= tx[i + 8] << (i * 8);
 		writel(val, d->regs + DSI_DIRECT_CMD_WRDAT2);
 	}
 	if (txlen > 12) {
 		val = 0;
 		for (i = 0; i < 4 && (i + 12) < txlen; i++)
-			val |= tx[i + 12] << (i & 3) * 8;
+			val |= tx[i + 12] << (i * 8);
 		writel(val, d->regs + DSI_DIRECT_CMD_WRDAT3);
 	}