From: "André Przywara" <andre.przywara@arm.com>
To: u-boot@lists.denx.de
Subject: [PATCH 2/8] sunxi: board: Add a helper to get the SPL DT name
Date: Tue, 22 Sep 2020 01:38:27 +0100 [thread overview]
Message-ID: <8a0ff79f-ac55-9fe8-50a3-7f6b9d5a52ec@arm.com> (raw)
In-Reply-To: <20200903050716.48488-3-samuel@sholland.org>
On 03/09/2020 06:07, Samuel Holland wrote:
> This moves the validity checking and typecasts all to one place away
> from the string comparison logic, and it detangles the compile-time
> and runtime control flow.
>
> The new helper will also be used by U-Boot proper in a future commit.
>
> Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Thanks,
Andre
> ---
> board/sunxi/board.c | 26 +++++++++++++++++---------
> 1 file changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index 674e6816d2d..5c9b811f27a 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -319,6 +319,17 @@ static struct boot_file_head * get_spl_header(uint8_t req_version)
> return spl;
> }
>
> +static const char *get_spl_dt_name(void)
> +{
> + struct boot_file_head *spl = get_spl_header(SPL_DT_HEADER_VERSION);
> +
> + /* Check if there is a DT name stored in the SPL header. */
> + if (spl != INVALID_SPL_HEADER && spl->dt_name_offset)
> + return (char *)spl + spl->dt_name_offset;
> +
> + return NULL;
> +}
> +
> int dram_init(void)
> {
> struct boot_file_head *spl = get_spl_header(SPL_DRAM_HEADER_VERSION);
> @@ -891,20 +902,17 @@ int ft_board_setup(void *blob, struct bd_info *bd)
> #ifdef CONFIG_SPL_LOAD_FIT
> int board_fit_config_name_match(const char *name)
> {
> - struct boot_file_head *spl = get_spl_header(SPL_DT_HEADER_VERSION);
> - const char *best_dt_name = (const char *)spl;
> + const char *best_dt_name = get_spl_dt_name();
>
> - /* Check if there is a DT name stored in the SPL header and use that. */
> - if (spl != INVALID_SPL_HEADER && spl->dt_name_offset) {
> - best_dt_name += spl->dt_name_offset;
> - } else {
> #ifdef CONFIG_DEFAULT_DEVICE_TREE
> + if (best_dt_name == NULL)
> best_dt_name = CONFIG_DEFAULT_DEVICE_TREE;
> -#else
> - return 0;
> #endif
> - };
>
> + if (best_dt_name == NULL) {
> + /* No DT name was provided, so accept the first config. */
> + return 0;
> + }
> #ifdef CONFIG_PINE64_DT_SELECTION
> /* Differentiate the two Pine64 board DTs by their DRAM size. */
> if (strstr(name, "-pine64") && strstr(best_dt_name, "-pine64")) {
>
next prev parent reply other threads:[~2020-09-22 0:38 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-03 5:07 [PATCH 0/8] PinePhone automatic device tree selection Samuel Holland
2020-09-03 5:07 ` [PATCH 1/8] sunxi: board: Use a more descriptive variable name Samuel Holland
2020-09-22 0:37 ` André Przywara
2020-09-03 5:07 ` [PATCH 2/8] sunxi: board: Add a helper to get the SPL DT name Samuel Holland
2020-09-22 0:38 ` André Przywara [this message]
2020-09-03 5:07 ` [PATCH 3/8] sunxi: board: Simplify Pine A64 DT selection logic Samuel Holland
2020-09-22 0:40 ` André Przywara
2020-09-03 5:07 ` [PATCH 4/8] sunxi: board: Add PinePhone " Samuel Holland
2020-09-22 0:41 ` André Przywara
2020-10-21 18:56 ` Jagan Teki
2020-10-22 1:38 ` Samuel Holland
2020-10-22 6:26 ` Jagan Teki
2020-10-22 15:50 ` Maxime Ripard
2020-09-03 5:07 ` [PATCH 5/8] sunxi: board: Save the chosen DT name in the SPL header Samuel Holland
2020-09-22 0:41 ` André Przywara
2020-09-22 1:12 ` Samuel Holland
2020-09-22 7:46 ` André Przywara
2020-09-03 5:07 ` [PATCH 6/8] sunxi: board: Set fdtfile to match the DT chosen by SPL Samuel Holland
2020-09-22 0:43 ` André Przywara
2020-09-22 1:33 ` Samuel Holland
2020-09-24 14:22 ` Andre Przywara
2020-09-03 5:07 ` [PATCH 7/8] sunxi: DT: A64: update device tree files Samuel Holland
2020-09-03 5:07 ` [PATCH 8/8] sunxi: a64: Add a defconfig for the PinePhone Samuel Holland
2020-09-03 7:31 ` [PATCH 0/8] PinePhone automatic device tree selection Maxime Ripard
2020-09-07 0:01 ` André Przywara
2020-10-24 16:50 ` Peter Robinson
2020-10-24 14:45 ` Jagan Teki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8a0ff79f-ac55-9fe8-50a3-7f6b9d5a52ec@arm.com \
--to=andre.przywara@arm.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox