From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
Boris Brezillon <boris.brezillon@free-electrons.com>,
Marek Vasut <marek.vasut@gmail.com>,
Richard Weinberger <richard@nod.at>,
linux-mtd@lists.infradead.org
Subject: Re: [PATCH 3/3] mtd: partitions: Add OF support to RedBoot partitions
Date: Fri, 19 Oct 2018 09:59:03 +0200 [thread overview]
Message-ID: <20181019095903.5dee8dd4@bbrezillon> (raw)
In-Reply-To: <20181019070622.26661-3-linus.walleij@linaro.org>
On Fri, 19 Oct 2018 09:06:22 +0200
Linus Walleij <linus.walleij@linaro.org> wrote:
> This adds device tree support for RedBoot partitioning. We
> read out the FIS directory block information from the device
> tree and then parse the partition table from there.
>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/mtd/parsers/redboot.c | 35 ++++++++++++++++++++++++++++++++++-
> 1 file changed, 34 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/parsers/redboot.c b/drivers/mtd/parsers/redboot.c
> index 7623ac5fc586..fb816825aa19 100644
> --- a/drivers/mtd/parsers/redboot.c
> +++ b/drivers/mtd/parsers/redboot.c
> @@ -25,7 +25,7 @@
> #include <linux/slab.h>
> #include <linux/init.h>
> #include <linux/vmalloc.h>
> -
> +#include <linux/of.h>
> #include <linux/mtd/mtd.h>
> #include <linux/mtd/partitions.h>
> #include <linux/module.h>
> @@ -56,6 +56,31 @@ static inline int redboot_checksum(struct fis_image_desc *img)
> return 1;
> }
>
> +#ifdef CONFIG_OF
> +static void parse_redboot_of(struct mtd_info *master)
> +{
> + struct device_node *np;
> + u32 dirblock;
> + int ret;
> +
> + np = mtd_get_of_node(master);
> + if (!np)
> + return;
> + ret = of_property_read_u32(np, "fis-index-block", &dirblock);
> + if (ret)
> + return;
> + /*
> + * Assign the block found in the device tree to the local
> + * directory block pointer.
> + */
> + directory = dirblock;
> +}
> +#else
> +static void parse_redboot_of(struct mtd_info *master)
> +{
> +}
> +#endif
> +
> static int parse_redboot_partitions(struct mtd_info *master,
> const struct mtd_partition **pparts,
> struct mtd_part_parser_data *data)
> @@ -75,6 +100,7 @@ static int parse_redboot_partitions(struct mtd_info *master,
> #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
> static char nullstring[] = "unallocated";
> #endif
> + parse_redboot_of(master);
>
> if ( directory < 0 ) {
> offset = master->size + directory * master->erasesize;
> @@ -289,9 +315,16 @@ static int parse_redboot_partitions(struct mtd_info *master,
> return ret;
> }
>
> +static const struct of_device_id mtd_parser_redboot_of_match_table[] = {
> + { .compatible = "redboot-fis" },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, mtd_parser_trx_of_match_table);
You might want to have this match table definition enclosed in a #ifdef
CONFIG_OF section...
> +
> static struct mtd_part_parser redboot_parser = {
> .parse_fn = parse_redboot_partitions,
> .name = "RedBoot",
> + .of_match_table = mtd_parser_redboot_of_match_table,
... and use of_match_ptr(mtd_parser_redboot_of_match_table) here.
I'm proposing that to make it consistent with the
approach you've taken for the parse_redboot_of() function.
Alternatively, you could just drop the #ifdef CONFIG_OF section around
parse_redboot_of() (there's already a dummy of_property_read_u32()
func returning -ENOSYS when CONFIG_OF is not set, so it should work
just fine).
> };
> module_mtd_part_parser(redboot_parser);
>
next prev parent reply other threads:[~2018-10-19 8:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-19 7:06 [PATCH 1/3] mtd: Move Redboot partition parser Linus Walleij
2018-10-19 7:06 ` [PATCH 2/3] mtd: partitions: Add RedBoot FIS DT bindings Linus Walleij
2018-10-19 7:06 ` Linus Walleij
2018-10-19 7:27 ` Linus Walleij
2018-10-19 7:27 ` Linus Walleij
2018-10-19 7:52 ` Boris Brezillon
2018-10-19 7:52 ` Boris Brezillon
2018-10-25 19:08 ` Rob Herring
2018-10-25 19:08 ` Rob Herring
2018-10-28 19:24 ` Linus Walleij
2018-10-28 19:24 ` Linus Walleij
2018-10-25 19:08 ` Rob Herring
2018-10-25 19:08 ` Rob Herring
2018-10-19 7:06 ` [PATCH 3/3] mtd: partitions: Add OF support to RedBoot partitions Linus Walleij
2018-10-19 7:59 ` Boris Brezillon [this message]
2018-10-22 9:36 ` [PATCH 1/3] mtd: Move Redboot partition parser Boris Brezillon
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=20181019095903.5dee8dd4@bbrezillon \
--to=boris.brezillon@bootlin.com \
--cc=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linus.walleij@linaro.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=richard@nod.at \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.