From patchwork Sat Dec 21 01:10:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1214405 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="fmhYq15Q"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47fnch0gXMz9sP3 for ; Sat, 21 Dec 2019 12:11:16 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 816388163F; Sat, 21 Dec 2019 02:10:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="fmhYq15Q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 744D0814DE; Sat, 21 Dec 2019 02:10:49 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9D175808B2 for ; Sat, 21 Dec 2019 02:10:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x144.google.com with SMTP id x5so9497458ila.6 for ; Fri, 20 Dec 2019 17:10:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NknhtjGpQNP2AQd4m6C63mzRbUnapQOb1bqqtPbUKkk=; b=fmhYq15QdddCk/uAJ30JVzFKCLW7Q3TBVy20bTTUvY4FqJW3Sgr4r17DwN0H2y1fxt 2UnLBfKlAZwCoWCYdAyVUkvKzvPeKr5Mc8NvOPoq8AZphAQELNVL6rUvGPIlZPN4kdeT b7o+fFsbrHpyu/a/YcoZfKYIq4Pt1a187vQEk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NknhtjGpQNP2AQd4m6C63mzRbUnapQOb1bqqtPbUKkk=; b=FKAsPGehr/yMyibcHMUa1S2ZlaOoUDbE1uGQjB5nXzMJMjohRIh1LYh8G0n1KkebNY 0WUz/xEM5gyujYSNjhZOt3SXRC/g05vNLdJQsemWC6efgCpMzBQw2N9Fiw9DK1TudqKw yEf/96LBQBVx5/b/7Sm/xEmECA/7RpeXZob6tbVLjHR67dMBcIdrcciWqT2suy8YNpdl GsMMaCnOxD6oNIzNiEzPv059uvy82eHDxtX5d7i5RMAZezlS9GTo+oitRcP9TM6mdYDy HudCqGXecQeW4aV1J3/oiclwwdjZ+pwYCgnInPWm3JqkI/m1Dm4Az4NQ0MGiv4avT+GA sl6A== X-Gm-Message-State: APjAAAUyBrrsfMA655xXrBt1ok4GdBAYY1XQvZ90CQ2WaVBiNGPx5Jnn J81WVy5TPCIzRcRAwoLcDFFzOdijzCQ= X-Google-Smtp-Source: APXvYqx+QwREc2hD/WVDVP+pm6rEjPMSX/IjWSiHwjYGoHw4/w5mZx+HQEyHgQG/ac9Y4KSkubSslA== X-Received: by 2002:a92:8fdb:: with SMTP id r88mr4191095ilk.84.1576890645338; Fri, 20 Dec 2019 17:10:45 -0800 (PST) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id c1sm4049513ioi.50.2019.12.20.17.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 17:10:45 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 2/5] video: Avoid using #ifdef in video blitting code Date: Fri, 20 Dec 2019 18:10:34 -0700 Message-Id: <20191221011037.143972-3-sjg@chromium.org> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog In-Reply-To: <20191221011037.143972-1-sjg@chromium.org> References: <20191221011037.143972-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean 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 --- drivers/video/console_normal.c | 125 ++++++++++++++++----------------- 1 file changed, 61 insertions(+), 64 deletions(-) diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c index 2f25af7332..c3f7ef8add 100644 --- a/drivers/video/console_normal.c +++ b/drivers/video/console_normal.c @@ -16,39 +16,36 @@ static int console_normal_set_row(struct udevice *dev, uint row, int clr) { struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); - void * __maybe_unused line; - int __maybe_unused pixels = VIDEO_FONT_HEIGHT * vid_priv->xsize; - int __maybe_unused i; + void *line; + int pixels = VIDEO_FONT_HEIGHT * vid_priv->xsize; + int i; line = vid_priv->fb + row * 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; } @@ -76,7 +73,7 @@ static int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y, struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); struct udevice *vid = dev->parent; struct video_priv *vid_priv = dev_get_uclass_priv(vid); - int __maybe_unused i, row; + int i, row; void *line = vid_priv->fb + y * vid_priv->line_length + VID_TO_PIXEL(x_frac) * VNBYTES(vid_priv->bpix); @@ -85,45 +82,45 @@ static int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y, for (row = 0; row < VIDEO_FONT_HEIGHT; row++) { unsigned int idx = (u8)ch * VIDEO_FONT_HEIGHT + row; - uchar __maybe_unused bits = video_fontdata[idx]; + 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; }