Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DF943C433FE for ; Thu, 6 Oct 2022 14:37:44 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7290884E45; Thu, 6 Oct 2022 16:37:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (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=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Hfa9erOk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BBE4A84DC1; Thu, 6 Oct 2022 16:37:17 +0200 (CEST) Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) (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 A0F3A84E51 for ; Thu, 6 Oct 2022 16:36:58 +0200 (CEST) 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-x130.google.com with SMTP id h18so1099921ilh.3 for ; Thu, 06 Oct 2022 07:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NjtNk28bJi0OHLknJZEvaU3gW+DE/u7L7qT+73KFsl8=; b=Hfa9erOkV4ZrUh25N5bpvXRapMsW4Ty8IfwENU2KVM6n41G1GqMSowARnM3yNrXJPt 9rOrS9n5izcZMv/vrjn3xbLUrBUduXwAGpGJkojZwiC94vk6azrJBLIUR/nITg3syJ9n bwzGHoYWRdJVLwbH5ng90XIkmBkJBpkSBe8Sk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NjtNk28bJi0OHLknJZEvaU3gW+DE/u7L7qT+73KFsl8=; b=rq2yuJM4pNGV0Fg00UGFVRe9q5YrUr0/KwMFeyPJbpgPEVAT5xJ6ULV8S8xo5hwHMF sfleAx9H2cODaal0EAdg2ZtY5o8URAnF9/mjhu+9vvNVBBHoDrSEaEmIXYa8BT7FNfvP qG6meodqDlmv3MrDFY2q1SUEinXV++bq63fZ0/Wik+uHKhqH+9Y/l5X1RdQtlOI6cag0 FfaFgbFt4xma+Qn1tQsNu6JGuxGZYA+isNBcg5UW3OjiOjpRK0lNl9KxBdaQM+ZWrenM vsyU8D3V63pNotE9EVYF+d+0cTPIHWCwqMy/zeKbdT0YUpK3+L5T9w2sKy+XPVWSH3AL yG8Q== X-Gm-Message-State: ACrzQf3ggJUZZVrpJif0bMuoJliDe2/tO6P3e0RPhhoisIQxnHilRJoN WzvJBJr9uXep1LKY3xPUf/BAF0EmwjqEog== X-Google-Smtp-Source: AMsMyM6bXujiz44/iAD3zrC5Inb41DnKDWiWCzeTYPasP1+5ljQmu5+JZB+/+rJSDMZx4qJoJUpioA== X-Received: by 2002:a92:c561:0:b0:2fa:3ca6:1672 with SMTP id b1-20020a92c561000000b002fa3ca61672mr2550007ilj.23.1665067014351; Thu, 06 Oct 2022 07:36:54 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id g22-20020a056602073600b006a102cb4900sm388573iox.39.2022.10.06.07.36.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 07:36:53 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Anatolij Gustschin , Simon Glass Subject: [PATCH 08/16] video: Tidy up the check for valid fonts Date: Thu, 6 Oct 2022 08:36:10 -0600 Message-Id: <20221006143619.354301-9-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221006143619.354301-1-sjg@chromium.org> References: <20221006143619.354301-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean Put this check into a function so we can use it elsewhere. Also drop the macros which do the same thing but are not actually used. Signed-off-by: Simon Glass --- drivers/video/console_truetype.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index c04b449a6d5..1331ce8d896 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -526,9 +526,18 @@ static struct font_info font_table[] = { {} /* sentinel */ }; -#define FONT_BEGIN(name) __ttf_ ## name ## _begin -#define FONT_END(name) __ttf_ ## name ## _end -#define FONT_IS_VALID(name) (abs(FONT_END(name) - FONT_BEGIN) > 4) +/** + * font_valid() - Check if a font-table entry is valid + * + * Depending on available files in the build system, fonts may end up being + * empty. + * + * @return true if the entry is valid + */ +static inline bool font_valid(struct font_info *tab) +{ + return abs(tab->begin - tab->end) > 4; +} /** * console_truetype_find_font() - Find a suitable font @@ -542,7 +551,7 @@ static u8 *console_truetype_find_font(void) struct font_info *tab; for (tab = font_table; tab->begin; tab++) { - if (abs(tab->begin - tab->end) > 4) { + if (font_valid(tab)) { debug("%s: Font '%s', at %p, size %lx\n", __func__, tab->name, tab->begin, (ulong)(tab->end - tab->begin)); -- 2.38.0.rc1.362.ged0d419d3c-goog