mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <ahmad@a3f.at>
Subject: [PATCH master 2/2] bootsource: use /chosen instead of /aliases/barebox,bootsource-
Date: Tue, 21 Feb 2023 08:07:35 +0100	[thread overview]
Message-ID: <20230221070735.1130600-2-ahmad@a3f.at> (raw)
In-Reply-To: <20230221070735.1130600-1-ahmad@a3f.at>

Aliases were a bad choice for this as barebox could end up calling MMC
devices /dev/barebox,bootsource-mmc0, which was not intended.

Move over to using chosen instead.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 .../devicetree/bindings/barebox/aliases.rst     | 17 +++++++++++------
 arch/arm/dts/rk356x.dtsi                        |  2 +-
 common/bootsource.c                             |  6 +++---
 include/bootsource.h                            |  2 +-
 4 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/Documentation/devicetree/bindings/barebox/aliases.rst b/Documentation/devicetree/bindings/barebox/aliases.rst
index e6face2c3314..8d226cfab6eb 100644
--- a/Documentation/devicetree/bindings/barebox/aliases.rst
+++ b/Documentation/devicetree/bindings/barebox/aliases.rst
@@ -20,16 +20,21 @@ probing the node at ``&iwdg`` will be named ``wdog0``.
 By default, barebox will assume the aliases in the DT to align with
 the bootsource communicated by the firmware. If this is not the case,
 a device tree override is possible via an
-``/aliases/barebox,bootsource-${bootsource}${bootsource_instance}``
+``/chosen/barebox,bootsource-${bootsource}${bootsource_instance}``
 property:
 
 .. code-block:: none
 
-  &{/aliases} {
-	mmc0 = &sdmmc0;
-	mmc1 = &sdhci;
-	barebox,bootsource-mmc0 = &sdhci;
-	barebox,bootsource-mmc1 = &sdmmc0;
+   / {
+   	aliases {
+		mmc0 = &sdmmc0;
+		mmc1 = &sdhci;
+	};
+
+   	chosen {
+		barebox,bootsource-mmc0 = &sdhci;
+		barebox,bootsource-mmc1 = &sdmmc0;
+	};
   };
 
 This will ensure that when booting from MMC, ``/dev/mmc${bootsource_instance}``
diff --git a/arch/arm/dts/rk356x.dtsi b/arch/arm/dts/rk356x.dtsi
index 254450d78fa8..6a9cd14d2d5a 100644
--- a/arch/arm/dts/rk356x.dtsi
+++ b/arch/arm/dts/rk356x.dtsi
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
 
 / {
-	aliases {
+	chosen {
 		barebox,bootsource-mmc0 = &sdhci;
 		barebox,bootsource-mmc1 = &sdmmc0;
 		barebox,bootsource-mmc2 = &sdmmc1;
diff --git a/common/bootsource.c b/common/bootsource.c
index 66bddf2dacf4..da528a5b9b19 100644
--- a/common/bootsource.c
+++ b/common/bootsource.c
@@ -137,7 +137,7 @@ void bootsource_set_raw_instance(int instance)
 
 int bootsource_of_alias_xlate(enum bootsource src, int instance)
 {
-	char alias[sizeof("barebox,bootsource-harddisk4294967295")];
+	char chosen[sizeof("barebox,bootsource-harddisk4294967295")];
 	const char *bootsource_stem;
 	struct device_node *np;
 	int alias_id;
@@ -153,10 +153,10 @@ int bootsource_of_alias_xlate(enum bootsource src, int instance)
 	if (!bootsource_stem)
 		return BOOTSOURCE_INSTANCE_UNKNOWN;
 
-	scnprintf(alias, sizeof(alias), "barebox,bootsource-%s%u",
+	scnprintf(chosen, sizeof(chosen), "barebox,bootsource-%s%u",
 		  bootsource_stem, instance);
 
-	np = of_find_node_by_alias(NULL, alias);
+	np = of_find_node_by_chosen(chosen, NULL);
 	if (!np)
 		return BOOTSOURCE_INSTANCE_UNKNOWN;
 
diff --git a/include/bootsource.h b/include/bootsource.h
index 381776a85a4c..05935b64a763 100644
--- a/include/bootsource.h
+++ b/include/bootsource.h
@@ -46,7 +46,7 @@ int bootsource_of_alias_xlate(enum bootsource bs, int instance);
  * bootsource_set() will instead consult
  * /aliases/barebox,bootsource-mmc1 which may point at a different
  * device than mmc1. In absence of appropriate barebox,bootsource-*
- * alias, instance is set without translation.
+ * chosen property, instance is set without translation.
  */
 int bootsource_set(enum bootsource bs, int instance);
 
-- 
2.38.3




  reply	other threads:[~2023-02-21  7:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-21  7:07 [PATCH master 1/2] of: split part of of_get_stdoutpath into of_find_node_by_chosen Ahmad Fatoum
2023-02-21  7:07 ` Ahmad Fatoum [this message]
2023-02-21  7:52 ` Sascha Hauer

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=20230221070735.1130600-2-ahmad@a3f.at \
    --to=ahmad@a3f.at \
    --cc=barebox@lists.infradead.org \
    /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