All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3 v3] mtd: partitions: Add OF support to RedBoot partitions
@ 2018-11-10 21:14 Linus Walleij
  2018-11-11  7:16 ` Boris Brezillon
  2018-11-15 19:19 ` [3/3,v3] " Boris Brezillon
  0 siblings, 2 replies; 4+ messages in thread
From: Linus Walleij @ 2018-11-10 21:14 UTC (permalink / raw)
  To: David Woodhouse, Brian Norris, Boris Brezillon, Marek Vasut,
	Richard Weinberger, linux-mtd
  Cc: Linus Walleij

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>
---
ChangeLog v2->v3:
- Fix copy/paste bug identified by the build robot.
ChangeLog v1->v2:
- Rebased on linux-mtd-next for v4.21
---
 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..cc04a36c8251 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_redboot_of_match_table);
+
 static struct mtd_part_parser redboot_parser = {
 	.parse_fn = parse_redboot_partitions,
 	.name = "RedBoot",
+	.of_match_table = mtd_parser_redboot_of_match_table,
 };
 module_mtd_part_parser(redboot_parser);
 
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 3/3 v3] mtd: partitions: Add OF support to RedBoot partitions
  2018-11-10 21:14 [PATCH 3/3 v3] mtd: partitions: Add OF support to RedBoot partitions Linus Walleij
@ 2018-11-11  7:16 ` Boris Brezillon
  2018-11-11 11:37   ` Linus Walleij
  2018-11-15 19:19 ` [3/3,v3] " Boris Brezillon
  1 sibling, 1 reply; 4+ messages in thread
From: Boris Brezillon @ 2018-11-11  7:16 UTC (permalink / raw)
  To: Linus Walleij
  Cc: David Woodhouse, Brian Norris, Boris Brezillon, Marek Vasut,
	Richard Weinberger, linux-mtd

Hi Linus,

On Sat, 10 Nov 2018 22:14:13 +0100
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>
> ---
> ChangeLog v2->v3:
> - Fix copy/paste bug identified by the build robot.
> ChangeLog v1->v2:
> - Rebased on linux-mtd-next for v4.21

Looks like the comments I made on v1 have not been taken into account,
or replied to.

> ---
>  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..cc04a36c8251 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;

nit: can you add a blank line here

> +	ret = of_property_read_u32(np, "fis-index-block", &dirblock);
> +	if (ret)
> +		return;

and here.

> +	/*
> +	 * 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

I keep thinking having one parse_redboot_of() for CONFIG_OF and a dummy
one for !CONFIG_OF is overkill given the size of the function. But if
you insist on keeping this #ifdef CONFIG_OF section, can we also put
mtd_parser_redboot_of_match_table in there (and use of_match_ptr() when
referencing it)?

> +
>  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

Can you add a blank line here as well?

> +	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_redboot_of_match_table);
> +
>  static struct mtd_part_parser redboot_parser = {
>  	.parse_fn = parse_redboot_partitions,
>  	.name = "RedBoot",
> +	.of_match_table = mtd_parser_redboot_of_match_table,
>  };
>  module_mtd_part_parser(redboot_parser);
>  

Those are all minor things I can fix when applying the patch. Let me
know if you're okay with the changes I suggest, and I'll take care of
that.

Regards,

Boris

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 3/3 v3] mtd: partitions: Add OF support to RedBoot partitions
  2018-11-11  7:16 ` Boris Brezillon
@ 2018-11-11 11:37   ` Linus Walleij
  0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2018-11-11 11:37 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: David Woodhouse, Brian Norris, Boris BREZILLON, Mark Vasut,
	Richard Weinberger, linux-mtd

On Sun, Nov 11, 2018 at 8:16 AM Boris Brezillon
<boris.brezillon@bootlin.com> wrote:

> > ChangeLog v2->v3:
> > - Fix copy/paste bug identified by the build robot.
> > ChangeLog v1->v2:
> > - Rebased on linux-mtd-next for v4.21
>
> Looks like the comments I made on v1 have not been taken into account,
> or replied to.

Sorry, my bad :(

> Those are all minor things I can fix when applying the patch. Let me
> know if you're okay with the changes I suggest, and I'll take care of
> that.

Of course you can do that, I have full confidence in you Boris!
Please go ahead.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [3/3,v3] mtd: partitions: Add OF support to RedBoot partitions
  2018-11-10 21:14 [PATCH 3/3 v3] mtd: partitions: Add OF support to RedBoot partitions Linus Walleij
  2018-11-11  7:16 ` Boris Brezillon
@ 2018-11-15 19:19 ` Boris Brezillon
  1 sibling, 0 replies; 4+ messages in thread
From: Boris Brezillon @ 2018-11-15 19:19 UTC (permalink / raw)
  To: Linus Walleij, David Woodhouse, Brian Norris, Boris Brezillon,
	Marek Vasut, Richard Weinberger, linux-mtd
  Cc: Boris Brezillon

On Sat, 2018-11-10 at 21:14:13 UTC, Linus Walleij 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>

Applied to http://git.infradead.org/linux-mtd.git mtd/next, thanks.

Boris

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-11-15 19:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-10 21:14 [PATCH 3/3 v3] mtd: partitions: Add OF support to RedBoot partitions Linus Walleij
2018-11-11  7:16 ` Boris Brezillon
2018-11-11 11:37   ` Linus Walleij
2018-11-15 19:19 ` [3/3,v3] " Boris Brezillon

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.