diff mbox series

[u-boot-dm,+,u-boot-spi,v3,09/11] cmd: mtd: print device OF path in listing

Message ID 20210225141336.6149-10-marek.behun@nic.cz
State New
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series Support SPI NORs and OF partitions in `mtd list` | expand

Commit Message

Marek Behun Feb. 25, 2021, 2:13 p.m. UTC
Print MTD's device OF path in the output of `mtd list` command.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Cc: Jagan Teki <jagan@amarulasolutions.com>
Cc: Priyanka Jain <priyanka.jain@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Heiko Schocher <hs@denx.de>
Cc: Jagan Teki <jagan@amarulasolutions.com>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Patrice CHOTARD <patrice.chotard@foss.st.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
---
 cmd/mtd.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Simon Glass Feb. 25, 2021, 7:31 p.m. UTC | #1
Hi Marek,

On Thu, 25 Feb 2021 at 09:14, Marek Behún <marek.behun@nic.cz> wrote:
>
> Print MTD's device OF path in the output of `mtd list` command.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> Cc: Jagan Teki <jagan@amarulasolutions.com>
> Cc: Priyanka Jain <priyanka.jain@nxp.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Heiko Schocher <hs@denx.de>
> Cc: Jagan Teki <jagan@amarulasolutions.com>
> Cc: Patrick Delaunay <patrick.delaunay@st.com>
> Cc: Patrice CHOTARD <patrice.chotard@foss.st.com>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  cmd/mtd.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/cmd/mtd.c b/cmd/mtd.c
> index 485a963bdd..446cbc1038 100644
> --- a/cmd/mtd.c
> +++ b/cmd/mtd.c
> @@ -126,6 +126,15 @@ static void mtd_show_device(struct mtd_info *mtd)
>                 printf("  - driver: %s\n", mtd->dev->driver->name);
>         }
>  #endif
> +#if defined(CONFIG_OF_CONTROL)
> +       if (mtd->dev) {

Can you do:

if (IS_ENABLED(CONFIG_OF_CONTROL) && mtd->dev)

?

> +               char buf[256];
> +               int res;
> +
> +               res = ofnode_get_path(mtd_get_ofnode(mtd), buf, 256);
> +               printf("  - path: %s\n", res == 0 ? buf : "unavailable");
> +       }
> +#endif
>
>         /* MTD device information */
>         printf("  - type: ");
> --
> 2.26.2
>

Regards,
Simon
diff mbox series

Patch

diff --git a/cmd/mtd.c b/cmd/mtd.c
index 485a963bdd..446cbc1038 100644
--- a/cmd/mtd.c
+++ b/cmd/mtd.c
@@ -126,6 +126,15 @@  static void mtd_show_device(struct mtd_info *mtd)
 		printf("  - driver: %s\n", mtd->dev->driver->name);
 	}
 #endif
+#if defined(CONFIG_OF_CONTROL)
+	if (mtd->dev) {
+		char buf[256];
+		int res;
+
+		res = ofnode_get_path(mtd_get_ofnode(mtd), buf, 256);
+		printf("  - path: %s\n", res == 0 ? buf : "unavailable");
+	}
+#endif
 
 	/* MTD device information */
 	printf("  - type: ");