From mboxrd@z Thu Jan 1 00:00:00 1970 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 F03C1C38142 for ; Tue, 31 Jan 2023 15:31:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 914BC85B2B; Tue, 31 Jan 2023 16:29:30 +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=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="SGsCEIs3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7EA0A85AF2; Tue, 31 Jan 2023 16:28:25 +0100 (CET) Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) (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 454E185AF3 for ; Tue, 31 Jan 2023 16:27:55 +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-x12f.google.com with SMTP id u8so6604133ilq.13 for ; Tue, 31 Jan 2023 07:27:55 -0800 (PST) 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=h2fiF2/CQP91SNjB3LgukxdDeDOrS7nFmT6fq+n3CwY=; b=SGsCEIs38+iYf7IaWuTQXolmUWxm4a3vf+uzXfY67d9V9VQFI7vohriRP3hn35sDC5 WVGQCzFAeLT0RYzJwcS15+V+dF9Yc4a/O/AuS0XQTEC/ITlIfVwk0WcQWFgCdxcEGf4n molVPI1cepjZbo12aqPgata8E3ZD2DWA4H3x0= 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=h2fiF2/CQP91SNjB3LgukxdDeDOrS7nFmT6fq+n3CwY=; b=pwZEN6u9nF9zx1eGNDAQU+E2N6VfAaewBkYzdvhk8Idc932h6Chg/21MmN6gJhlBsu DmZDsM7B/QFdyUkahqtes/PNkXtROC2gjZgXZNH2xafMPVDvGi0N+REY1Z3l69DFVDW2 3ck7noVW6SluNxIhAkThtUQEDkuy6zvNx3RDDw7a/rjiLtCVmNGSmFpyfVWt038hLU20 62i+ptuJqXBx/UUM7BZIGrhgyvoKsJN0AQyKoHbmUMxKsHrqAais7h7LiFQ4w0JOkCnn K6fmJzRKxDEPINC0A4Ab1ZkiKhiWP8fFO3xA7zd5IrBr3ZA18CJ971tBLKUVUEufQ4lW ZCBA== X-Gm-Message-State: AO0yUKUc8bVa0n7p48MkZz2IdsYfeJru42MDpUF0VX6Ty79l41O1vuYp sWaAzLexDyC6T8nBrddUDpq5S4YPIyKMEt5X X-Google-Smtp-Source: AK7set+WJpI5+hSj2fZRffHC3i3DLVKYldb9J2ezkQ27VJn8AML0LSNizJpQBlbVeGAby9U8C39pRw== X-Received: by 2002:a05:6e02:144c:b0:311:478:f282 with SMTP id p12-20020a056e02144c00b003110478f282mr4941113ilo.26.1675178874731; Tue, 31 Jan 2023 07:27:54 -0800 (PST) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id u4-20020a02cb84000000b0039db6cffcbasm5649328jap.71.2023.01.31.07.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 07:27:54 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Masahiro Yamada Subject: [PATCH 20/32] kconfig: Refactor code into separate writer functions Date: Tue, 31 Jan 2023 08:26:50 -0700 Message-Id: <20230131152702.249197-21-sjg@chromium.org> X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog In-Reply-To: <20230131152702.249197-1-sjg@chromium.org> References: <20230131152702.249197-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 Separate out the code that writes the Makefile and headers so we can reuse these functions when writing out SPL files. This makes no functional change. Signed-off-by: Simon Glass --- scripts/kconfig/confdata.c | 65 ++++++++++++++++++++++---------------- scripts/kconfig/expr.h | 9 ++++++ scripts/kconfig/lkc.h | 9 ++++++ 3 files changed, 56 insertions(+), 27 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index d587b10d7f8..73bf43bcb95 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -509,27 +509,18 @@ int conf_read(const char *name) return 0; } -/* - * Kconfig configuration printer - * - * This printer is used when generating the resulting configuration after - * kconfig invocation and `defconfig' files. Unset symbol might be omitted by - * passing a non-NULL argument to the printer. - * - */ -static void -kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) +/* Print a symbol for a Makefile */ +static void print_makefile_sym(FILE *fp, const char *name, + enum symbol_type type, const char *value, + bool skip_unset) { - - switch (sym->type) { + switch (type) { case S_BOOLEAN: case S_TRISTATE: if (*value == 'n') { - bool skip_unset = (arg != NULL); - if (!skip_unset) fprintf(fp, "# %s%s is not set\n", - CONFIG_, sym->name); + CONFIG_, name); return; } break; @@ -537,7 +528,21 @@ kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) break; } - fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, value); + fprintf(fp, "%s%s=%s\n", CONFIG_, name, value); +} + +/* + * Kconfig configuration printer + * + * This printer is used when generating the resulting configuration after + * kconfig invocation and `defconfig' files. Unset symbol might be omitted by + * passing a non-NULL argument to the printer. + * + */ +static void +kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) +{ + print_makefile_sym(fp, sym->name, sym->type, value, arg != NULL); } static void @@ -566,16 +571,12 @@ static struct conf_printer kconfig_printer_cb = .print_comment = kconfig_print_comment, }; -/* - * Header printer - * - * This printer is used when generating the `include/generated/autoconf.h' file. - */ -static void -header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) +/* Print a symbol for a header file */ +static void print_header_sym(FILE *fp, const char *name, enum symbol_type type, + const char *value) { - switch (sym->type) { + switch (type) { case S_BOOLEAN: case S_TRISTATE: { const char *suffix = ""; @@ -588,7 +589,7 @@ header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) /* fall through */ default: fprintf(fp, "#define %s%s%s 1\n", - CONFIG_, sym->name, suffix); + CONFIG_, name, suffix); } break; } @@ -598,18 +599,28 @@ header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) if (value[0] != '0' || (value[1] != 'x' && value[1] != 'X')) prefix = "0x"; fprintf(fp, "#define %s%s %s%s\n", - CONFIG_, sym->name, prefix, value); + CONFIG_, name, prefix, value); break; } case S_STRING: case S_INT: fprintf(fp, "#define %s%s %s\n", - CONFIG_, sym->name, value); + CONFIG_, name, value); break; default: break; } +} +/* + * Header printer + * + * This printer is used when generating the `include/generated/autoconf.h' file. + */ +static void +header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) +{ + print_header_sym(fp, sym->name, sym->type, value); } static void diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 7c329e17900..656c87fb4f3 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -158,6 +158,15 @@ struct symbol { /* Set symbol to y if allnoconfig; used for symbols that hide others */ #define SYMBOL_ALLNOCONFIG_Y 0x200000 +/* U-Boot: Marks an SPL symbol */ +#define SYMBOL_SPL 0x400000 + +/* U-Boot: Marks a non-SPL symbol that also has an SPL version */ +#define SYMBOL_HAS_SPL 0x800000 + +/* U-Boot: Marks an-SPL symbol that does not have a non-SPL version */ +#define SYMBOL_SPL_ONLY 0x1000000 + #define SYMBOL_MAXLENGTH 256 #define SYMBOL_HASHSIZE 9973 diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 9eb7c837cd8..dec03cc927a 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -71,6 +71,15 @@ void sym_add_change_count(int count); bool conf_set_all_new_symbols(enum conf_def_mode mode); void set_all_choice_values(struct symbol *csym); +/** + * conf_mark_spl_symbols() - Mark SPL symbols + * + * Symbols which don't start with SPL_ (TPL_, etc.) but have an SPL version + * should be marked with the SYMBOL_SPL flag, so we know to avoid writing them + * in the SPL autoconf.h files. + */ +void conf_mark_spl_symbols(void); + /* confdata.c and expr.c */ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) { -- 2.39.1.456.gfc5497dd1b-goog