diff mbox series

[5/5] video: Avoid using #ifdef in video-uclass.c

Message ID 20191221011037.143972-6-sjg@chromium.org
State Accepted
Commit 0c20aafe0b54ae9c924104bd1024e5b7e6359ca2
Delegated to: Anatolij Gustschin
Headers show
Series video: Avoid #ifdef to increase build coverage | expand

Commit Message

Simon Glass Dec. 21, 2019, 1:10 a.m. UTC
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(), etc., instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/video/video-uclass.c | 54 +++++++++++++++++-------------------
 1 file changed, 26 insertions(+), 28 deletions(-)
diff mbox series

Patch

diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index 5ea7568fa4..12057c8a5b 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -92,26 +92,24 @@  int video_clear(struct udevice *dev)
 	struct video_priv *priv = dev_get_uclass_priv(dev);
 
 	switch (priv->bpix) {
-#ifdef CONFIG_VIDEO_BPP16
-	case VIDEO_BPP16: {
-		u16 *ppix = priv->fb;
-		u16 *end = priv->fb + priv->fb_size;
-
-		while (ppix < end)
-			*ppix++ = priv->colour_bg;
-		break;
-	}
-#endif
-#ifdef CONFIG_VIDEO_BPP32
-	case VIDEO_BPP32: {
-		u32 *ppix = priv->fb;
-		u32 *end = priv->fb + priv->fb_size;
-
-		while (ppix < end)
-			*ppix++ = priv->colour_bg;
-		break;
-	}
-#endif
+	case VIDEO_BPP16:
+		if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
+			u16 *ppix = priv->fb;
+			u16 *end = priv->fb + priv->fb_size;
+
+			while (ppix < end)
+				*ppix++ = priv->colour_bg;
+			break;
+		}
+	case VIDEO_BPP32:
+		if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
+			u32 *ppix = priv->fb;
+			u32 *end = priv->fb + priv->fb_size;
+
+			while (ppix < end)
+				*ppix++ = priv->colour_bg;
+			break;
+		}
 	default:
 		memset(priv->fb, priv->colour_bg, priv->fb_size);
 		break;
@@ -125,14 +123,14 @@  void video_set_default_colors(struct udevice *dev, bool invert)
 	struct video_priv *priv = dev_get_uclass_priv(dev);
 	int fore, back;
 
-#ifdef CONFIG_SYS_WHITE_ON_BLACK
-	/* White is used when switching to bold, use light gray here */
-	fore = VID_LIGHT_GRAY;
-	back = VID_BLACK;
-#else
-	fore = VID_BLACK;
-	back = VID_WHITE;
-#endif
+	if (CONFIG_IS_ENABLED(SYS_WHITE_ON_BLACK)) {
+		/* White is used when switching to bold, use light gray here */
+		fore = VID_LIGHT_GRAY;
+		back = VID_BLACK;
+	} else {
+		fore = VID_BLACK;
+		back = VID_WHITE;
+	}
 	if (invert) {
 		int temp;