From: Boris Brezillon <boris.brezillon@bootlin.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v7 10/12] cmd: mtdparts: try to probe the MTD devices as a fallback
Date: Thu, 6 Sep 2018 11:46:33 +0200 [thread overview]
Message-ID: <20180906114633.1015eda3@bbrezillon> (raw)
In-Reply-To: <20180906070854.9717-11-miquel.raynal@bootlin.com>
On Thu, 6 Sep 2018 09:08:52 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> Current implementation of mtdparts command errors out if the desired MTD
> device is not found. Fallback to the new probe function in this case
> before erroring out.
>
> This will the save the user the need to call something like 'mtd list'
> before mtdparts.
>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Acked-by: Jagan Teki <jagan@openedev.com>
> Reviewed-by: Stefan Roese <sr@denx.de>
> ---
> cmd/mtdparts.c | 16 +++++++++++++---
> 1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
> index f7ed1a0779..a1102c3fc5 100644
> --- a/cmd/mtdparts.c
> +++ b/cmd/mtdparts.c
> @@ -79,6 +79,10 @@
> #include <linux/err.h>
> #include <linux/mtd/mtd.h>
>
> +#if defined(CONFIG_MTD)
> +#include <mtd.h>
> +#endif
> +
> #if defined(CONFIG_CMD_NAND)
> #include <linux/mtd/rawnand.h>
> #include <nand.h>
> @@ -307,9 +311,15 @@ static int get_mtd_info(u8 type, u8 num, struct mtd_info **mtd)
>
> sprintf(mtd_dev, "%s%d", MTD_DEV_TYPE(type), num);
> *mtd = get_mtd_device_nm(mtd_dev);
> - if (IS_ERR(*mtd)) {
> - printf("Device %s not found!\n", mtd_dev);
> - return 1;
> + if (IS_ERR_OR_NULL(*mtd)) {
> +#ifdef CONFIG_MTD
In its current state, it should #ifdef CONFIG_CMD_MTD, since
mtd_probe_devices() is implemented in cmd/mtd.c. Anyway, as I
suggested, I think it's better to just move that in mtd_uboot.c and
drop the #ifdef.
> + mtd_probe_devices();
> + *mtd = get_mtd_device_nm(mtd_dev);
> +#endif
BTW, I'm not sure why we need to call mtd_probe_devices() here. If we
really want to deprecate this command, then I'd recommend not adding new
features to it.
> + if (IS_ERR_OR_NULL(*mtd)) {
> + printf("Device %s not found!\n", mtd_dev);
> + return 1;
> + }
> }
> put_mtd_device(*mtd);
>
next prev parent reply other threads:[~2018-09-06 9:46 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-06 7:08 [U-Boot] [PATCH v7 00/12] SPI-NAND support Miquel Raynal
2018-09-06 7:08 ` [U-Boot] [PATCH v7 01/12] lib: strto: parse all lowercase metric prefixes in ustrtoul[l] Miquel Raynal
2018-09-06 7:08 ` [U-Boot] [PATCH v7 02/12] lib: strto: fix metric suffix parsing in strtoul[l] Miquel Raynal
2018-09-06 7:08 ` [U-Boot] [PATCH v7 03/12] cmd: mtdparts: accept spi-nand devices Miquel Raynal
2018-09-06 7:08 ` [U-Boot] [PATCH v7 04/12] cmd: mtdparts: remove mandatory 'mtdparts=' prefix Miquel Raynal
2018-09-06 7:08 ` [U-Boot] [PATCH v7 05/12] mtd: uclass: add probe function Miquel Raynal
2018-09-06 7:08 ` [U-Boot] [PATCH v7 06/12] mtd: uclass: add a generic 'mtdparts' parser Miquel Raynal
2018-09-06 7:08 ` [U-Boot] [PATCH v7 07/12] mtd: uclass: search for an equivalent MTD name with the mtdids Miquel Raynal
2018-09-06 7:08 ` [U-Boot] [PATCH v7 08/12] mtd: mtdpart: implement proper partition handling Miquel Raynal
2018-09-06 7:08 ` [U-Boot] [PATCH v7 09/12] cmd: mtd: add 'mtd' command Miquel Raynal
2018-09-06 9:42 ` Boris Brezillon
2018-09-06 7:08 ` [U-Boot] [PATCH v7 10/12] cmd: mtdparts: try to probe the MTD devices as a fallback Miquel Raynal
2018-09-06 9:46 ` Boris Brezillon [this message]
2018-09-06 7:08 ` [U-Boot] [PATCH v7 11/12] cmd: ubi: clean the partition handling Miquel Raynal
2018-09-06 9:52 ` Boris Brezillon
2018-09-06 7:08 ` [U-Boot] [PATCH v7 12/12] cmd: mtdparts: describe as legacy Miquel Raynal
2018-09-06 9:57 ` Boris Brezillon
2018-09-06 7:15 ` [U-Boot] [PATCH v7 00/12] SPI-NAND support Miquel Raynal
2018-09-20 14:06 ` Frieder Schrempf
2018-09-20 14:46 ` Jagan Teki
2018-09-20 14:59 ` Miquel Raynal
2018-09-20 15:22 ` Frieder Schrempf
2018-09-21 8:15 ` Jagan Teki
2018-09-21 8:25 ` Miquel Raynal
2018-09-26 15:14 ` Miquel Raynal
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=20180906114633.1015eda3@bbrezillon \
--to=boris.brezillon@bootlin.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