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 X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00B8BC4338F for ; Sat, 7 Aug 2021 13:24:47 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5259E61058 for ; Sat, 7 Aug 2021 13:24:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5259E61058 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C1C0383211; Sat, 7 Aug 2021 15:24:35 +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="hUp+Vpvh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4F57883208; Sat, 7 Aug 2021 15:24:31 +0200 (CEST) Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) (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 7C63F82C4D for ; Sat, 7 Aug 2021 15:24:20 +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-oi1-x22e.google.com with SMTP id o20so16513781oiw.12 for ; Sat, 07 Aug 2021 06:24:20 -0700 (PDT) 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=Qw9SeKpYUJ1FfZ0NnCUfk0ElZHWQNriwouWQEIdMrQw=; b=hUp+Vpvhwdam/S9YGlSrv6UBH+7pKyGZZH6xNe6OoAvsuGwmjnRjM5rkYkxrcOISbB YPD/iMIbN80Ox/VKSDVTqin7KaEXeEEabic2bnxCnb/RKHL9jxI4GB3vmjzoiw9u76uZ H0clWohxOjhhWokZXazSuPhDhhshZsWa6tnug= 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=Qw9SeKpYUJ1FfZ0NnCUfk0ElZHWQNriwouWQEIdMrQw=; b=nmN9id2He6T9tpKWp8OAYPAhNwaBLYYCq+vo5FL89Uls0VHCwtRKoA78mdm+q6bWvC KlxJAnfkllK3YirmVqnTUxDv97h2UNTJUj/4YRZPCwkFZ4Gtr/mGHXzpD1nVYsQgShfA bf3XNghjYPMdTKznKtiqEq+DmQCE0T9+4/KtYftbog1Lbs7LhL3yXX3BlzA+8N4pOuso pl+FQ88ulStmlO2SUkRjEAkN4xmmy5YPhJZfHbEwP+QHogqfin2qXk30zjEiv5CqLT3a gQT6fVrc9MXMG1pl39n7xZywPNxPK/XqXtBwGDZiMlY6CIzoQr82r/nXCqlxSuP+3e/b TpPw== X-Gm-Message-State: AOAM530ONgK/DuM3h670rL1mKN3RAALyLl1uk+Q7vKKo9PbA513fMHjk 387RS2WdJXeljeQbavB3FBF9PubpGWjP8TE9 X-Google-Smtp-Source: ABdhPJyRSHn6+L8LRmRM/PH2vu7uvF/H1esp+BHaufMhzRt2GkBvN8kvrOlw+WDyetjnNa0LJJ2rgw== X-Received: by 2002:a05:6808:1386:: with SMTP id c6mr9570355oiw.18.1628342658596; Sat, 07 Aug 2021 06:24:18 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x16sm1866417ooj.1.2021.08.07.06.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Aug 2021 06:24:18 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Jerry Van Baren Subject: [PATCH 01/12] treewide: fdt: Move fdt_get_config_... to ofnode_conf_read... Date: Sat, 7 Aug 2021 07:24:01 -0600 Message-Id: <20210807132413.3513724-2-sjg@chromium.org> X-Mailer: git-send-email 2.32.0.605.g8dce9f2422-goog In-Reply-To: <20210807132413.3513724-1-sjg@chromium.org> References: <20210807132413.3513724-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean The current API is outdated as it requires a devicetree pointer. Move these functions to use the ofnode API and update this globally. Add some tests while we are here. Correct the call in exynos_dsim_config_parse_dt() which is obviously wrong. Signed-off-by: Simon Glass --- arch/arm/mach-rockchip/rk3188/rk3188.c | 4 +- arch/sandbox/dts/test.dts | 3 ++ arch/x86/cpu/coreboot/coreboot.c | 5 +-- board/dhelectronics/dh_stm32mp1/board.c | 5 ++- board/firefly/firefly-rk3288/firefly-rk3288.c | 4 +- board/st/stm32mp1/stm32mp1.c | 5 ++- common/autoboot.c | 8 ++-- common/board_r.c | 4 +- common/cli.c | 7 ++- common/spl/spl_spi.c | 8 ++-- disk/part_efi.c | 8 ++-- doc/device-tree-bindings/config.txt | 4 +- drivers/core/ofnode.c | 33 ++++++++++++++ drivers/video/cfb_console.c | 4 +- drivers/video/exynos/exynos_mipi_dsi.c | 4 +- env/mmc.c | 5 ++- include/dm/ofnode.h | 37 ++++++++++++++++ include/fdtdec.h | 33 -------------- lib/fdtdec.c | 44 ------------------- test/dm/ofnode.c | 15 +++++++ 20 files changed, 124 insertions(+), 116 deletions(-) diff --git a/arch/arm/mach-rockchip/rk3188/rk3188.c b/arch/arm/mach-rockchip/rk3188/rk3188.c index ad8c6cd1d79..5a02914e1b0 100644 --- a/arch/arm/mach-rockchip/rk3188/rk3188.c +++ b/arch/arm/mach-rockchip/rk3188/rk3188.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #define GRF_BASE 0x20008000 @@ -107,7 +108,6 @@ int rk_board_late_init(void) } #ifdef CONFIG_SPL_BUILD -DECLARE_GLOBAL_DATA_PTR; static int setup_led(void) { #ifdef CONFIG_SPL_LED @@ -115,7 +115,7 @@ static int setup_led(void) char *led_name; int ret; - led_name = fdtdec_get_config_string(gd->fdt_blob, "u-boot,boot-led"); + led_name = ofnode_conf_read_str("u-boot,boot-led"); if (!led_name) return 0; ret = led_get_by_label(led_name, &dev); diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index d5976318d1c..77d54e39d73 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -53,6 +53,9 @@ }; config { + testing-bool; + testing-int = <123>; + testing-str = "testing"; environment { from_fdt = "yes"; fdt_env_path = ""; diff --git a/arch/x86/cpu/coreboot/coreboot.c b/arch/x86/cpu/coreboot/coreboot.c index 69cf8f417c7..aaa5ae112e4 100644 --- a/arch/x86/cpu/coreboot/coreboot.c +++ b/arch/x86/cpu/coreboot/coreboot.c @@ -16,8 +16,7 @@ #include #include #include - -DECLARE_GLOBAL_DATA_PTR; +#include int arch_cpu_init(void) { @@ -65,7 +64,7 @@ static void board_final_init(void) mtrr_close(&state, true); } - if (!fdtdec_get_config_bool(gd->fdt_blob, "u-boot,no-apm-finalize")) { + if (!ofnode_conf_read_bool("u-boot,no-apm-finalize")) { /* * Issue SMI to coreboot to lock down ME and registers * when allowed via device tree diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c index d7c1857c168..4b3167f69d2 100644 --- a/board/dhelectronics/dh_stm32mp1/board.c +++ b/board/dhelectronics/dh_stm32mp1/board.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "../../st/common/stpmic1.h" /* SYSCFG registers */ @@ -382,10 +383,10 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) #ifdef CONFIG_LED static int get_led(struct udevice **dev, char *led_string) { - char *led_name; + const char *led_name; int ret; - led_name = fdtdec_get_config_string(gd->fdt_blob, led_string); + led_name = ofnode_conf_read_str(led_string); if (!led_name) { pr_debug("%s: could not find %s config string\n", __func__, led_string); diff --git a/board/firefly/firefly-rk3288/firefly-rk3288.c b/board/firefly/firefly-rk3288/firefly-rk3288.c index 41c49e5daa7..95d8b00924d 100644 --- a/board/firefly/firefly-rk3288/firefly-rk3288.c +++ b/board/firefly/firefly-rk3288/firefly-rk3288.c @@ -8,9 +8,9 @@ #include #include #include +#include #ifdef CONFIG_SPL_BUILD -DECLARE_GLOBAL_DATA_PTR; static int setup_led(void) { #ifdef CONFIG_SPL_LED @@ -18,7 +18,7 @@ static int setup_led(void) char *led_name; int ret; - led_name = fdtdec_get_config_string(gd->fdt_blob, "u-boot,boot-led"); + led_name = ofnode_conf_read_str("u-boot,boot-led"); if (!led_name) return 0; ret = led_get_by_label(led_name, &dev); diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index 59fb6e548c0..1a217c0e7e7 100644 --- a/board/st/stm32mp1/stm32mp1.c +++ b/board/st/stm32mp1/stm32mp1.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -231,10 +232,10 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) static int get_led(struct udevice **dev, char *led_string) { - char *led_name; + const char *led_name; int ret; - led_name = fdtdec_get_config_string(gd->fdt_blob, led_string); + led_name = ofnode_conf_read_str(led_string); if (!led_name) { log_debug("could not find %s config string\n", led_string); return -ENOENT; diff --git a/common/autoboot.c b/common/autoboot.c index 5bb2e190895..6251c683108 100644 --- a/common/autoboot.c +++ b/common/autoboot.c @@ -24,6 +24,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -424,12 +425,12 @@ static void process_fdt_options(const void *blob) ulong addr; /* Add an env variable to point to a kernel payload, if available */ - addr = fdtdec_get_config_int(gd->fdt_blob, "kernel-offset", 0); + addr = ofnode_conf_read_int("kernel-offset", 0); if (addr) env_set_addr("kernaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr)); /* Add an env variable to point to a root disk, if available */ - addr = fdtdec_get_config_int(gd->fdt_blob, "rootdisk-offset", 0); + addr = ofnode_conf_read_int("rootdisk-offset", 0); if (addr) env_set_addr("rootaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr)); #endif /* CONFIG_SYS_TEXT_BASE */ @@ -446,8 +447,7 @@ const char *bootdelay_process(void) bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY; if (IS_ENABLED(CONFIG_OF_CONTROL)) - bootdelay = fdtdec_get_config_int(gd->fdt_blob, "bootdelay", - bootdelay); + bootdelay = ofnode_conf_read_int("bootdelay", bootdelay); debug("### main_loop entered: bootdelay=%d\n\n", bootdelay); diff --git a/common/board_r.c b/common/board_r.c index e3e6248a1fd..68d3b1fb1ce 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -67,6 +67,7 @@ #endif #include #include +#include #include #include #include @@ -448,8 +449,7 @@ static int initr_pvblock(void) static int should_load_env(void) { if (IS_ENABLED(CONFIG_OF_CONTROL)) - return fdtdec_get_config_int(gd->fdt_blob, - "load-environment", 1); + return ofnode_conf_read_int("load-environment", 1); if (IS_ENABLED(CONFIG_DELAY_ENVIRONMENT)) return 0; diff --git a/common/cli.c b/common/cli.c index 048eacb9ef9..d86046a728b 100644 --- a/common/cli.c +++ b/common/cli.c @@ -19,8 +19,7 @@ #include #include #include - -DECLARE_GLOBAL_DATA_PTR; +#include #ifdef CONFIG_CMDLINE /* @@ -157,7 +156,7 @@ int do_run(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) bool cli_process_fdt(const char **cmdp) { /* Allow the fdt to override the boot command */ - char *env = fdtdec_get_config_string(gd->fdt_blob, "bootcmd"); + const char *env = ofnode_conf_read_str("bootcmd"); if (env) *cmdp = env; /* @@ -165,7 +164,7 @@ bool cli_process_fdt(const char **cmdp) * Always use 'env' in this case, since bootsecure requres that the * bootcmd was specified in the FDT too. */ - return fdtdec_get_config_int(gd->fdt_blob, "bootsecure", 0) != 0; + return ofnode_conf_read_int("bootsecure", 0); } /* diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c index 9884e7c1850..f92ce37384c 100644 --- a/common/spl/spl_spi.c +++ b/common/spl/spl_spi.c @@ -16,8 +16,7 @@ #include #include #include - -DECLARE_GLOBAL_DATA_PTR; +#include #ifdef CONFIG_SPL_OS_BOOT /* @@ -104,9 +103,8 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, header = spl_get_load_buffer(-sizeof(*header), sizeof(*header)); #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) - payload_offs = fdtdec_get_config_int(gd->fdt_blob, - "u-boot,spl-payload-offset", - payload_offs); + payload_offs = ofnode_conf_read_int("u-boot,spl-payload-offset", + payload_offs); #endif #ifdef CONFIG_SPL_OS_BOOT diff --git a/disk/part_efi.c b/disk/part_efi.c index fdca91a6974..0ca7effc327 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -23,12 +23,11 @@ #include #include #include +#include #include #include #include -DECLARE_GLOBAL_DATA_PTR; - #ifdef CONFIG_HAVE_BLOCK_DEVICE /* GUID for basic data partitons */ @@ -563,9 +562,8 @@ static uint32_t partition_entries_offset(struct blk_desc *dev_desc) * from the start of the device) to be specified as a property * of the device tree '/config' node. */ - config_offset = fdtdec_get_config_int(gd->fdt_blob, - "u-boot,efi-partition-entries-offset", - -EINVAL); + config_offset = ofnode_conf_read_int( + "u-boot,efi-partition-entries-offset", -EINVAL); if (config_offset != -EINVAL) { offset_bytes = PAD_TO_BLOCKSIZE(config_offset, dev_desc); offset_blks = offset_bytes / dev_desc->blksz; diff --git a/doc/device-tree-bindings/config.txt b/doc/device-tree-bindings/config.txt index 6cdc16da5b5..d53b0aa3347 100644 --- a/doc/device-tree-bindings/config.txt +++ b/doc/device-tree-bindings/config.txt @@ -2,8 +2,8 @@ The /config node (Configuration Options) ---------------------------------------- A number of run-time configuration options are provided in the /config node -of the control device tree. You can access these using fdtdec_get_config_int(), -fdtdec_get_config_bool() and fdtdec_get_config_string(). +of the control device tree. You can access these using ofnode_conf_read_int(), +ofnode_conf_read_bool() and ofnode_conf_read_str(). Available options are: diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 701b23e2c91..08705ef8d99 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -1103,3 +1103,36 @@ int ofnode_set_enabled(ofnode node, bool value) else return ofnode_write_string(node, "status", "disabled"); } + +bool ofnode_conf_read_bool(const char *prop_name) +{ + ofnode node; + + node = ofnode_path("/config"); + if (!ofnode_valid(node)) + return false; + + return ofnode_read_bool(node, prop_name); +} + +int ofnode_conf_read_int(const char *prop_name, int default_val) +{ + ofnode node; + + node = ofnode_path("/config"); + if (!ofnode_valid(node)) + return default_val; + + return ofnode_read_u32_default(node, prop_name, default_val); +} + +const char *ofnode_conf_read_str(const char *prop_name) +{ + ofnode node; + + node = ofnode_path("/config"); + if (!ofnode_valid(node)) + return NULL; + + return ofnode_read_string(node, prop_name); +} diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c index 5e1ee061e8e..b24a511c4e1 100644 --- a/drivers/video/cfb_console.c +++ b/drivers/video/cfb_console.c @@ -75,6 +75,7 @@ #include #include #include +#include #include #if defined(CONFIG_VIDEO_MXS) @@ -2138,8 +2139,7 @@ int drv_video_init(void) #if defined(CONFIG_VGA_AS_SINGLE_DEVICE) have_keyboard = false; #elif defined(CONFIG_OF_CONTROL) - have_keyboard = !fdtdec_get_config_bool(gd->fdt_blob, - "u-boot,no-keyboard"); + have_keyboard = !ofnode_conf_read_bool("u-boot,no-keyboard"); #else have_keyboard = true; #endif diff --git a/drivers/video/exynos/exynos_mipi_dsi.c b/drivers/video/exynos/exynos_mipi_dsi.c index c56eadc8237..804fcd0b248 100644 --- a/drivers/video/exynos/exynos_mipi_dsi.c +++ b/drivers/video/exynos/exynos_mipi_dsi.c @@ -288,8 +288,8 @@ int exynos_dsim_config_parse_dt(const void *blob, struct mipi_dsim_config *dt, dt->rx_timeout = fdtdec_get_int(blob, node, "samsung,dsim-config-rx-timeout", 0); - lcd_dt->name = fdtdec_get_config_string(blob, - "samsung,dsim-device-name"); + lcd_dt->name = fdt_getprop(blob, node, "samsung,dsim-device-name", + NULL); lcd_dt->id = fdtdec_get_int(blob, node, "samsung,dsim-device-id", 0); diff --git a/env/mmc.c b/env/mmc.c index 09e94f0bd3b..c4cb1639914 100644 --- a/env/mmc.c +++ b/env/mmc.c @@ -19,6 +19,7 @@ #include #include #include +#include #define __STR(X) #X #define STR(X) __STR(X) @@ -73,7 +74,7 @@ static inline s64 mmc_offset(int copy) int err; /* look for the partition in mmc CONFIG_SYS_MMC_ENV_DEV */ - str = fdtdec_get_config_string(gd->fdt_blob, dt_prop.partition); + str = ofnode_conf_read_str(dt_prop.partition); if (str) { /* try to place the environment at end of the partition */ err = mmc_offset_try_partition(str, copy, &val); @@ -90,7 +91,7 @@ static inline s64 mmc_offset(int copy) propname = dt_prop.offset_redund; } #endif - return fdtdec_get_config_int(gd->fdt_blob, propname, defvalue); + return ofnode_conf_read_int(propname, defvalue); } #else static inline s64 mmc_offset(int copy) diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 4e1a8447e65..6a714d0c7b5 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -1117,4 +1117,41 @@ int ofnode_write_string(ofnode node, const char *propname, const char *value); */ int ofnode_set_enabled(ofnode node, bool value); +/** + * ofnode_conf_read_bool() - Read a boolean value from the U-Boot config + * + * This reads a property from the /config node of the devicetree. + * + * See doc/config.txt for bindings + * + * @prop_name property name to look up + * @return true, if it exists, false if not + */ +bool ofnode_conf_read_bool(const char *prop_name); + +/** + * ofnode_conf_read_int() - Read an integer value from the U-Boot config + * + * This reads a property from the /config node of the devicetree. + * + * See doc/config.txt for bindings + * + * @prop_name: property name to look up + * @default_val: default value to return if the property is not found + * @return integer value, if found, or @default_val if not + */ +int ofnode_conf_read_int(const char *prop_name, int default_val); + +/** + * ofnode_conf_read_str() - Read a string value from the U-Boot config + * + * This reads a property from the /config node of the devicetree. + * + * See doc/config.txt for bindings + * + * @prop_name: property name to look up + * @return string value, if found, or NULL if not + */ +const char *ofnode_conf_read_str(const char *prop_name); + #endif diff --git a/include/fdtdec.h b/include/fdtdec.h index 8ac20c9a64f..23efbe710cb 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -746,39 +746,6 @@ int fdtdec_get_bool(const void *blob, int node, const char *prop_name); */ int fdtdec_get_child_count(const void *blob, int node); -/** - * Look in the FDT for a config item with the given name and return its value - * as a 32-bit integer. The property must have at least 4 bytes of data. The - * value of the first cell is returned. - * - * @param blob FDT blob to use - * @param prop_name Node property name - * @param default_val default value to return if the property is not found - * @return integer value, if found, or default_val if not - */ -int fdtdec_get_config_int(const void *blob, const char *prop_name, - int default_val); - -/** - * Look in the FDT for a config item with the given name - * and return whether it exists. - * - * @param blob FDT blob - * @param prop_name property name to look up - * @return 1, if it exists, or 0 if not - */ -int fdtdec_get_config_bool(const void *blob, const char *prop_name); - -/** - * Look in the FDT for a config item with the given name and return its value - * as a string. - * - * @param blob FDT blob - * @param prop_name property name to look up - * @returns property string, NULL on error. - */ -char *fdtdec_get_config_string(const void *blob, const char *prop_name); - /* * Look up a property in a node and return its contents in a byte * array of given length. The property must have at least enough data for diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 337c4443b03..1590eb5050e 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -864,50 +864,6 @@ const u8 *fdtdec_locate_byte_array(const void *blob, int node, return cell; } -int fdtdec_get_config_int(const void *blob, const char *prop_name, - int default_val) -{ - int config_node; - - debug("%s: %s\n", __func__, prop_name); - config_node = fdt_path_offset(blob, "/config"); - if (config_node < 0) - return default_val; - return fdtdec_get_int(blob, config_node, prop_name, default_val); -} - -int fdtdec_get_config_bool(const void *blob, const char *prop_name) -{ - int config_node; - const void *prop; - - debug("%s: %s\n", __func__, prop_name); - config_node = fdt_path_offset(blob, "/config"); - if (config_node < 0) - return 0; - prop = fdt_get_property(blob, config_node, prop_name, NULL); - - return prop != NULL; -} - -char *fdtdec_get_config_string(const void *blob, const char *prop_name) -{ - const char *nodep; - int nodeoffset; - int len; - - debug("%s: %s\n", __func__, prop_name); - nodeoffset = fdt_path_offset(blob, "/config"); - if (nodeoffset < 0) - return NULL; - - nodep = fdt_getprop(blob, nodeoffset, prop_name, &len); - if (!nodep) - return NULL; - - return (char *)nodep; -} - u64 fdtdec_get_number(const fdt32_t *ptr, unsigned int cells) { u64 number = 0; diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 44e51de0854..49efabe871c 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -318,3 +318,18 @@ static int dm_test_ofnode_get_path(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_ofnode_get_path, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); + +static int dm_test_ofnode_conf(struct unit_test_state *uts) +{ + ut_assert(!ofnode_conf_read_bool("missing")); + ut_assert(ofnode_conf_read_bool("testing-bool")); + + ut_asserteq(123, ofnode_conf_read_int("testing-int", 0)); + ut_asserteq(6, ofnode_conf_read_int("missing", 6)); + + ut_assertnull(ofnode_conf_read_str("missing")); + ut_asserteq_str("testing", ofnode_conf_read_str("testing-str")); + + return 0; +} +DM_TEST(dm_test_ofnode_conf, 0); -- 2.32.0.605.g8dce9f2422-goog