]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
video: Avoid using #ifdef in console_rotate.c
authorSimon Glass <sjg@chromium.org>
Sat, 21 Dec 2019 01:10:35 +0000 (18:10 -0700)
committerAnatolij Gustschin <agust@denx.de>
Thu, 2 Jan 2020 15:25:25 +0000 (16:25 +0100)
This code does not really need to use #ifdef. We can use if() instead and
gain build coverage without impacting code size.

Change the #ifdefs to use IS_ENABLED() instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/video/console_rotate.c

index 71a5c5efba3c0011a772ac6bcf8a769a306d1267..b4852555989adebc4ca41067cef1312417015215 100644 (file)
@@ -22,33 +22,30 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr)
                (row + 1) * VIDEO_FONT_HEIGHT * pbytes;
        for (j = 0; j < vid_priv->ysize; j++) {
                switch (vid_priv->bpix) {
-#ifdef CONFIG_VIDEO_BPP8
-               case VIDEO_BPP8: {
-                       uint8_t *dst = line;
+               case VIDEO_BPP8:
+                       if (IS_ENABLED(CONFIG_VIDEO_BPP8)) {
+                               uint8_t *dst = line;
 
-                       for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
-                               *dst++ = clr;
-                       break;
-               }
-#endif
-#ifdef CONFIG_VIDEO_BPP16
-               case VIDEO_BPP16: {
-                       uint16_t *dst = line;
+                               for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
+                                       *dst++ = clr;
+                               break;
+                       }
+               case VIDEO_BPP16:
+                       if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
+                               uint16_t *dst = line;
 
-                       for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
-                               *dst++ = clr;
-                       break;
-               }
-#endif
-#ifdef CONFIG_VIDEO_BPP32
-               case VIDEO_BPP32: {
-                       uint32_t *dst = line;
+                               for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
+                                       *dst++ = clr;
+                               break;
+                       }
+               case VIDEO_BPP32:
+                       if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
+                               uint32_t *dst = line;
 
-                       for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
-                               *dst++ = clr;
-                       break;
-               }
-#endif
+                               for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
+                                       *dst++ = clr;
+                               break;
+                       }
                default:
                        return -ENOSYS;
                }
@@ -99,39 +96,39 @@ static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, char ch)
 
        for (col = 0; col < VIDEO_FONT_HEIGHT; col++) {
                switch (vid_priv->bpix) {
-#ifdef CONFIG_VIDEO_BPP8
-               case VIDEO_BPP8: {
-                       uint8_t *dst = line;
-
-                       for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
-                               *dst-- = (pfont[i] & mask) ? vid_priv->colour_fg
-                                       : vid_priv->colour_bg;
+               case VIDEO_BPP8:
+                       if (IS_ENABLED(CONFIG_VIDEO_BPP8)) {
+                               uint8_t *dst = line;
+
+                               for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
+                                       *dst-- = (pfont[i] & mask) ?
+                                               vid_priv->colour_fg :
+                                               vid_priv->colour_bg;
+                               }
+                               break;
                        }
-                       break;
-               }
-#endif
-#ifdef CONFIG_VIDEO_BPP16
-               case VIDEO_BPP16: {
-                       uint16_t *dst = line;
-
-                       for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
-                               *dst-- = (pfont[i] & mask) ? vid_priv->colour_fg
-                                       : vid_priv->colour_bg;
+               case VIDEO_BPP16:
+                       if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
+                               uint16_t *dst = line;
+
+                               for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
+                                       *dst-- = (pfont[i] & mask) ?
+                                               vid_priv->colour_fg :
+                                               vid_priv->colour_bg;
+                               }
+                               break;
                        }
-                       break;
-               }
-#endif
-#ifdef CONFIG_VIDEO_BPP32
-               case VIDEO_BPP32: {
-                       uint32_t *dst = line;
-
-                       for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
-                               *dst-- = (pfont[i] & mask) ? vid_priv->colour_fg
-                                       : vid_priv->colour_bg;
+               case VIDEO_BPP32:
+                       if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
+                               uint32_t *dst = line;
+
+                               for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
+                                       *dst-- = (pfont[i] & mask) ?
+                                               vid_priv->colour_fg :
+                                               vid_priv->colour_bg;
+                               }
+                               break;
                        }
-                       break;
-               }
-#endif
                default:
                        return -ENOSYS;
                }
@@ -153,33 +150,30 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr)
        line = vid_priv->fb + vid_priv->ysize * vid_priv->line_length -
                (row + 1) * VIDEO_FONT_HEIGHT * vid_priv->line_length;
        switch (vid_priv->bpix) {
-#ifdef CONFIG_VIDEO_BPP8
-       case VIDEO_BPP8: {
-               uint8_t *dst = line;
+       case VIDEO_BPP8:
+               if (IS_ENABLED(CONFIG_VIDEO_BPP8)) {
+                       uint8_t *dst = line;
 
-               for (i = 0; i < pixels; i++)
-                       *dst++ = clr;
-               break;
-       }
-#endif
-#ifdef CONFIG_VIDEO_BPP16
-       case VIDEO_BPP16: {
-               uint16_t *dst = line;
-
-               for (i = 0; i < pixels; i++)
-                       *dst++ = clr;
-               break;
-       }
-#endif
-#ifdef CONFIG_VIDEO_BPP32
-       case VIDEO_BPP32: {
-               uint32_t *dst = line;
-
-               for (i = 0; i < pixels; i++)
-                       *dst++ = clr;
-               break;
-       }
-#endif
+                       for (i = 0; i < pixels; i++)
+                               *dst++ = clr;
+                       break;
+               }
+       case VIDEO_BPP16:
+               if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
+                       uint16_t *dst = line;
+
+                       for (i = 0; i < pixels; i++)
+                               *dst++ = clr;
+                       break;
+               }
+       case VIDEO_BPP32:
+               if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
+                       uint32_t *dst = line;
+
+                       for (i = 0; i < pixels; i++)
+                               *dst++ = clr;
+                       break;
+               }
        default:
                return -ENOSYS;
        }
@@ -226,42 +220,42 @@ static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, char ch)
                uchar bits = video_fontdata[idx];
 
                switch (vid_priv->bpix) {
-#ifdef CONFIG_VIDEO_BPP8
-               case VIDEO_BPP8: {
-                       uint8_t *dst = line;
-
-                       for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
-                               *dst-- = (bits & 0x80) ? vid_priv->colour_fg
-                                       : vid_priv->colour_bg;
-                               bits <<= 1;
+               case VIDEO_BPP8:
+                       if (IS_ENABLED(CONFIG_VIDEO_BPP8)) {
+                               uint8_t *dst = line;
+
+                               for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
+                                       *dst-- = (bits & 0x80) ?
+                                               vid_priv->colour_fg :
+                                               vid_priv->colour_bg;
+                                       bits <<= 1;
+                               }
+                               break;
                        }
-                       break;
-               }
-#endif
-#ifdef CONFIG_VIDEO_BPP16
-               case VIDEO_BPP16: {
-                       uint16_t *dst = line;
-
-                       for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
-                               *dst-- = (bits & 0x80) ? vid_priv->colour_fg
-                                       : vid_priv->colour_bg;
-                               bits <<= 1;
+               case VIDEO_BPP16:
+                       if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
+                               uint16_t *dst = line;
+
+                               for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
+                                       *dst-- = (bits & 0x80) ?
+                                               vid_priv->colour_fg :
+                                               vid_priv->colour_bg;
+                                       bits <<= 1;
+                               }
+                               break;
                        }
-                       break;
-               }
-#endif
-#ifdef CONFIG_VIDEO_BPP32
-               case VIDEO_BPP32: {
-                       uint32_t *dst = line;
-
-                       for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
-                               *dst-- = (bits & 0x80) ? vid_priv->colour_fg
-                                       : vid_priv->colour_bg;
-                               bits <<= 1;
+               case VIDEO_BPP32:
+                       if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
+                               uint32_t *dst = line;
+
+                               for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
+                                       *dst-- = (bits & 0x80) ?
+                                               vid_priv->colour_fg :
+                                               vid_priv->colour_bg;
+                                       bits <<= 1;
+                               }
+                               break;
                        }
-                       break;
-               }
-#endif
                default:
                        return -ENOSYS;
                }
@@ -281,33 +275,30 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr)
        line = vid_priv->fb + row * VIDEO_FONT_HEIGHT * pbytes;
        for (j = 0; j < vid_priv->ysize; j++) {
                switch (vid_priv->bpix) {
-#ifdef CONFIG_VIDEO_BPP8
-               case VIDEO_BPP8: {
-                       uint8_t *dst = line;
+               case VIDEO_BPP8:
+                       if (IS_ENABLED(CONFIG_VIDEO_BPP8)) {
+                               uint8_t *dst = line;
 
-                       for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
-                               *dst++ = clr;
-                       break;
-               }
-#endif
-#ifdef CONFIG_VIDEO_BPP16
-               case VIDEO_BPP16: {
-                       uint16_t *dst = line;
+                               for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
+                                       *dst++ = clr;
+                               break;
+                       }
+               case VIDEO_BPP16:
+                       if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
+                               uint16_t *dst = line;
 
-                       for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
-                               *dst++ = clr;
-                       break;
-               }
-#endif
-#ifdef CONFIG_VIDEO_BPP32
-               case VIDEO_BPP32: {
-                       uint32_t *dst = line;
+                               for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
+                                       *dst++ = clr;
+                               break;
+                       }
+               case VIDEO_BPP32:
+                       if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
+                               uint32_t *dst = line;
 
-                       for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
-                               *dst++ = clr;
-                       break;
-               }
-#endif
+                               for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
+                                       *dst++ = clr;
+                               break;
+                       }
                default:
                        return -ENOSYS;
                }
@@ -356,39 +347,39 @@ static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, char ch)
 
        for (col = 0; col < VIDEO_FONT_HEIGHT; col++) {
                switch (vid_priv->bpix) {
-#ifdef CONFIG_VIDEO_BPP8
-               case VIDEO_BPP8: {
-                       uint8_t *dst = line;
-
-                       for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
-                               *dst++ = (pfont[i] & mask) ? vid_priv->colour_fg
-                                       : vid_priv->colour_bg;
+               case VIDEO_BPP8:
+                       if (IS_ENABLED(CONFIG_VIDEO_BPP8)) {
+                               uint8_t *dst = line;
+
+                               for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
+                                       *dst++ = (pfont[i] & mask) ?
+                                               vid_priv->colour_fg :
+                                               vid_priv->colour_bg;
+                               }
+                               break;
                        }
-                       break;
-               }
-#endif
-#ifdef CONFIG_VIDEO_BPP16
-               case VIDEO_BPP16: {
-                       uint16_t *dst = line;
-
-                       for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
-                               *dst++ = (pfont[i] & mask) ? vid_priv->colour_fg
-                                       : vid_priv->colour_bg;
+               case VIDEO_BPP16:
+                       if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
+                               uint16_t *dst = line;
+
+                               for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
+                                       *dst++ = (pfont[i] & mask) ?
+                                               vid_priv->colour_fg :
+                                               vid_priv->colour_bg;
+                               }
+                               break;
                        }
-                       break;
-               }
-#endif
-#ifdef CONFIG_VIDEO_BPP32
-               case VIDEO_BPP32: {
-                       uint32_t *dst = line;
-
-                       for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
-                               *dst++ = (pfont[i] & mask) ? vid_priv->colour_fg
-                                       : vid_priv->colour_bg;
+               case VIDEO_BPP32:
+                       if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
+                               uint32_t *dst = line;
+
+                               for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
+                                       *dst++ = (pfont[i] & mask) ?
+                                               vid_priv->colour_fg :
+                                               vid_priv->colour_bg;
+                               }
+                               break;
                        }
-                       break;
-               }
-#endif
                default:
                        return -ENOSYS;
                }