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 50F3EC77B73 for ; Thu, 4 May 2023 23:08:39 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0D05A861A6; Fri, 5 May 2023 00:59:44 +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="HLGqqXZr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9B385860F2; Fri, 5 May 2023 00:59:22 +0200 (CEST) Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) (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 45554860AE for ; Fri, 5 May 2023 00:59:12 +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-io1-xd30.google.com with SMTP id ca18e2360f4ac-7606d460da7so25069039f.1 for ; Thu, 04 May 2023 15:59:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683241151; x=1685833151; 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=wZzqh+76Iu1734swhyc9SHa9NjNnKwh8XUgvBICmWr0=; b=HLGqqXZrhpWtta8A+dr/of83i1muNcTL9NNROKTZkd0CR2tN03b3kh/wYEww201Nc2 4xg0Nr7xT83h2mQcIAsu9RGLaovnBKyk306Tete+F2jWCtj7l8HRZTFC3tMFVrjOmXPU LFqADBLnPmbgC9McL45DE0aBvDxD/UvXFwXJw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683241151; x=1685833151; 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=wZzqh+76Iu1734swhyc9SHa9NjNnKwh8XUgvBICmWr0=; b=dvcH6STCDc2tRZjGicyjlW++p6Y+kuVggSSgXpxXohQ7b53FF1Q6HZsDI/v1FbIteb aLuU8aKznDjcfk4clOyf7I5XpH+tZ5bcfNrIi9m6RMfLW/5DYHs0PtG638Ew3OxC2rc4 TwwE9oaTevbq+hUYbqcaZ2ckLULhaZwvxfXe1kTByymkTGGWRPUADA4x5gZWAPWyktoN 6xFxiTai5zPLog++xJmXUeDmShfOxCbHcub3/Ha5xcHPmy04riwD7+j+ZTdYep65pkW5 UFeYyJlr5HlZq8fswpzNdqXW8qcwXqqBD8TC69RDXO/d731npZFRG+VcW6TXcWfgBar4 koXQ== X-Gm-Message-State: AC+VfDx1xTb724GQpIe+DaG4ScaraD7OVgkyGscaEA4roTyuIoyK7Xmd WzUD5IANr6EParSp03T+2LWFfpN0YNjte/zodzI= X-Google-Smtp-Source: ACHHUZ5QsTLldPTytPHlDUNzIIAdcZNTxApz98HA0cpmvp/n3n6P0Ur7R9DsEj7mm8e/+iyNB/tKlQ== X-Received: by 2002:a6b:a10:0:b0:763:5f1b:2f6f with SMTP id z16-20020a6b0a10000000b007635f1b2f6fmr288092ioi.7.1683241151729; Thu, 04 May 2023 15:59:11 -0700 (PDT) Received: from kea.bld.corp.google.com ([2620:15c:183:200:b5a:9fa0:3da:54ec]) by smtp.gmail.com with ESMTPSA id e11-20020a5ede0b000000b007608af6dfb4sm39506iok.31.2023.05.04.15.59.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:59:11 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Nikhil M Jain , Bin Meng , Simon Glass Subject: [PATCH v3 34/43] x86: Refactor table-writing code a litlle Date: Thu, 4 May 2023 16:58:20 -0600 Message-ID: <20230504225829.2537050-4-sjg@chromium.org> X-Mailer: git-send-email 2.40.1.521.gf1e218fcd8-goog In-Reply-To: <20230504225829.2537050-1-sjg@chromium.org> References: <20230504225829.2537050-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.8 at phobos.denx.de X-Virus-Status: Clean The implementation of write_tables() is confusing because it uses the rom_table_start variable as the address pointer as it progresses. Rename it to rom_addr to make the code clearer. Move the rom_table_end variable into the block where it is used. Also update logging to use the ACPI category, now that it is available. Signed-off-by: Simon Glass --- Changes in v3: - Add new patch to refactor table-writing code a ltitle arch/x86/lib/tables.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c index ea834a5035f..132c02ee80f 100644 --- a/arch/x86/lib/tables.c +++ b/arch/x86/lib/tables.c @@ -3,7 +3,7 @@ * Copyright (C) 2015, Bin Meng */ -#define LOG_CATEGORY LOGC_BOARD +#define LOG_CATEGORY LOGC_ACPI #include #include @@ -78,33 +78,33 @@ void table_fill_string(char *dest, const char *src, size_t n, char pad) int write_tables(void) { - u32 rom_table_start; - u32 rom_table_end; u32 high_table, table_size; struct memory_area cfg_tables[ARRAY_SIZE(table_list) + 1]; + u32 rom_addr; int i; - rom_table_start = ROM_TABLE_ADDR; + rom_addr = ROM_TABLE_ADDR; - debug("Writing tables to %x:\n", rom_table_start); + debug("Writing tables to %x:\n", rom_addr); for (i = 0; i < ARRAY_SIZE(table_list); i++) { const struct table_info *table = &table_list[i]; int size = table->size ? : CONFIG_ROM_TABLE_SIZE; + u32 rom_table_end; if (IS_ENABLED(CONFIG_BLOBLIST_TABLES) && table->tag) { - rom_table_start = (ulong)bloblist_add(table->tag, size, + rom_addr = (ulong)bloblist_add(table->tag, size, table->align); - if (!rom_table_start) + if (!rom_addr) return log_msg_ret("bloblist", -ENOBUFS); } - rom_table_end = table->write(rom_table_start); + rom_table_end = table->write(rom_addr); if (!rom_table_end) { log_err("Can't create configuration table %d\n", i); return -EINTR; } if (IS_ENABLED(CONFIG_SEABIOS)) { - table_size = rom_table_end - rom_table_start; + table_size = rom_table_end - rom_addr; high_table = (u32)(ulong)high_table_malloc(table_size); if (high_table) { if (!table->write(high_table)) { @@ -123,13 +123,13 @@ int write_tables(void) } debug("- wrote '%s' to %x, end %x\n", table->name, - rom_table_start, rom_table_end); - if (rom_table_end - rom_table_start > size) { + rom_addr, rom_table_end); + if (rom_table_end - rom_addr > size) { log_err("Out of space for configuration tables: need %x, have %x\n", - rom_table_end - rom_table_start, size); + rom_table_end - rom_addr, size); return log_msg_ret("bloblist", -ENOSPC); } - rom_table_start = rom_table_end; + rom_addr = rom_table_end; } if (IS_ENABLED(CONFIG_SEABIOS)) { -- 2.40.1.521.gf1e218fcd8-goog