[PATCH v1] drm/mipi_dbi: Use simple right shift instead of double negation

Noralf Trønnes noralf at tronnes.org
Thu Oct 17 16:27:41 UTC 2019



Den 17.10.2019 13.49, skrev Andy Shevchenko:
> GCC complains about dubious bitwise OR operand:
> 
> drivers/gpu/drm/drm_mipi_dbi.c:1024:49: warning: dubious: x | !y
>   CC [M]  drivers/gpu/drm/drm_mipi_dbi.o
> 
> As long as buffer is consist of byte (u8) values, we may use
> simple right shift and satisfy compiler. It also reduces amount of
> operations needed.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
> ---

Thanks, it's even more readable now, for me at least. And since I don't
trust my in-head C compiler/parser, I ran a test and
/sys/kernel/debug/dri/0/command returns the same for commands 04H and
09h which are the ones affected by this change.

Reviewed-by: Noralf Trønnes <noralf at tronnes.org>
Tested-by: Noralf Trønnes <noralf at tronnes.org>

This patch hasn't shown up in dri-devel patchwork, I hope it's just a
hiccup and it'll show up later since I apply patches from patchwork.
I don't see it in the mailinglist archive either, only Sean's replies,
not yours. But I do see your replies to other patches. We'll see. If not
then I'll have to export it from Windows Thunderbird and fix newlines :/

Noralf.

>  drivers/gpu/drm/drm_mipi_dbi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
> index 1961f713aaab..445e88b1fc9a 100644
> --- a/drivers/gpu/drm/drm_mipi_dbi.c
> +++ b/drivers/gpu/drm/drm_mipi_dbi.c
> @@ -1021,7 +1021,7 @@ static int mipi_dbi_typec3_command_read(struct mipi_dbi *dbi, u8 *cmd,
>  		unsigned int i;
>  
>  		for (i = 0; i < len; i++)
> -			data[i] = (buf[i] << 1) | !!(buf[i + 1] & BIT(7));
> +			data[i] = (buf[i] << 1) | (buf[i + 1] >> 7);
>  	}
>  
>  	MIPI_DBI_DEBUG_COMMAND(*cmd, data, len);
> 


More information about the dri-devel mailing list