[U-Boot] [PATCH 2/5] lcd: cleanup lcd_drawchars

Simon Glass sjg at chromium.org
Thu Nov 20 19:30:12 CET 2014


Hi Nikita,

On 20 November 2014 16:13, Nikita Kiryanov <nikita at compulab.co.il> wrote:
> Remove code duplication from lcd_drawchars().
>
> Signed-off-by: Nikita Kiryanov <nikita at compulab.co.il>
> Cc: Anatolij Gustschin <agust at denx.de>

Acked-by: Simon Glass <sjg at chromium.org>

Although I'm not sure it is an improvement - using a different type
for the variable based on an #ifdef is pretty horrible. Another option
would be to move the declarations down to above each loop.

> ---
>  common/lcd.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)
>
> diff --git a/common/lcd.c b/common/lcd.c
> index 2f711c6..ff53cf1 100644
> --- a/common/lcd.c
> +++ b/common/lcd.c
> @@ -345,19 +345,7 @@ static void lcd_drawchars(ushort x, ushort y, uchar *str, int count)
>
>                         *d++ = rest | (sym >> off);
>                         rest = sym << (8-off);
> -#elif LCD_BPP == LCD_COLOR8
> -                       for (c = 0; c < 8; ++c) {
> -                               *d++ = (bits & 0x80) ?
> -                                               lcd_color_fg : lcd_color_bg;
> -                               bits <<= 1;
> -                       }
> -#elif LCD_BPP == LCD_COLOR16
> -                       for (c = 0; c < 8; ++c) {
> -                               *d++ = (bits & 0x80) ?
> -                                               lcd_color_fg : lcd_color_bg;
> -                               bits <<= 1;
> -                       }
> -#elif LCD_BPP == LCD_COLOR32
> +#else /* LCD_BPP == LCD_COLOR8 or LCD_COLOR16 or LCD_COLOR32 */
>                         for (c = 0; c < 8; ++c) {
>                                 *d++ = (bits & 0x80) ?
>                                                 lcd_color_fg : lcd_color_bg;
> --
> 1.9.1

Regards,
Simon


More information about the U-Boot mailing list