* [PATCH 1/2] mtd: partitions: redboot: seek fis-index-block in the right node
@ 2021-05-20 11:48 Corentin Labbe
2021-05-20 11:48 ` [PATCH 2/2] mtd: partitions: redboot: fix style issues Corentin Labbe
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Corentin Labbe @ 2021-05-20 11:48 UTC (permalink / raw)
To: boris.brezillon, linus.walleij, miquel.raynal, richard, vigneshr
Cc: linux-kernel, linux-mtd, Corentin Labbe
fis-index-block is seeked in the master node and not in the partitions node.
For following binding and current usage, the driver need to check the
partitions subnode.
Fixes: c0e118c8a1a3 ("mtd: partitions: Add OF support to RedBoot partitions")
Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
drivers/mtd/parsers/redboot.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/parsers/redboot.c b/drivers/mtd/parsers/redboot.c
index 91146bdc4713..3ccd6363ee8c 100644
--- a/drivers/mtd/parsers/redboot.c
+++ b/drivers/mtd/parsers/redboot.c
@@ -45,6 +45,7 @@ static inline int redboot_checksum(struct fis_image_desc *img)
static void parse_redboot_of(struct mtd_info *master)
{
struct device_node *np;
+ struct device_node *npart;
u32 dirblock;
int ret;
@@ -52,7 +53,11 @@ static void parse_redboot_of(struct mtd_info *master)
if (!np)
return;
- ret = of_property_read_u32(np, "fis-index-block", &dirblock);
+ npart = of_get_child_by_name(np, "partitions");
+ if (!npart)
+ return;
+
+ ret = of_property_read_u32(npart, "fis-index-block", &dirblock);
if (ret)
return;
--
2.26.3
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 2/2] mtd: partitions: redboot: fix style issues 2021-05-20 11:48 [PATCH 1/2] mtd: partitions: redboot: seek fis-index-block in the right node Corentin Labbe @ 2021-05-20 11:48 ` Corentin Labbe 2021-05-20 15:24 ` Linus Walleij 2021-05-26 9:02 ` Miquel Raynal 2021-05-20 15:21 ` [PATCH 1/2] mtd: partitions: redboot: seek fis-index-block in the right node Linus Walleij 2021-05-26 9:02 ` Miquel Raynal 2 siblings, 2 replies; 9+ messages in thread From: Corentin Labbe @ 2021-05-20 11:48 UTC (permalink / raw) To: boris.brezillon, linus.walleij, miquel.raynal, richard, vigneshr Cc: linux-kernel, linux-mtd, Corentin Labbe This patch fixes easy checkpatch issues. Signed-off-by: Corentin Labbe <clabbe@baylibre.com> --- drivers/mtd/parsers/redboot.c | 69 +++++++++++++++++------------------ 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/drivers/mtd/parsers/redboot.c b/drivers/mtd/parsers/redboot.c index 3ccd6363ee8c..feb44a573d44 100644 --- a/drivers/mtd/parsers/redboot.c +++ b/drivers/mtd/parsers/redboot.c @@ -17,15 +17,15 @@ #include <linux/module.h> struct fis_image_desc { - unsigned char name[16]; // Null terminated name - uint32_t flash_base; // Address within FLASH of image - uint32_t mem_base; // Address in memory where it executes - uint32_t size; // Length of image - uint32_t entry_point; // Execution entry point - uint32_t data_length; // Length of actual data - unsigned char _pad[256-(16+7*sizeof(uint32_t))]; - uint32_t desc_cksum; // Checksum over image descriptor - uint32_t file_cksum; // Checksum over image data + unsigned char name[16]; // Null terminated name + u32 flash_base; // Address within FLASH of image + u32 mem_base; // Address in memory where it executes + u32 size; // Length of image + u32 entry_point; // Execution entry point + u32 data_length; // Length of actual data + unsigned char _pad[256 - (16 + 7 * sizeof(u32))]; + u32 desc_cksum; // Checksum over image descriptor + u32 file_cksum; // Checksum over image data }; struct fis_list { @@ -90,12 +90,12 @@ static int parse_redboot_partitions(struct mtd_info *master, parse_redboot_of(master); - if ( directory < 0 ) { + if (directory < 0) { offset = master->size + directory * master->erasesize; while (mtd_block_isbad(master, offset)) { if (!offset) { - nogood: - printk(KERN_NOTICE "Failed to find a non-bad block to check for RedBoot partition table\n"); +nogood: + pr_notice("Failed to find a non-bad block to check for RedBoot partition table\n"); return -EIO; } offset -= master->erasesize; @@ -113,8 +113,8 @@ static int parse_redboot_partitions(struct mtd_info *master, if (!buf) return -ENOMEM; - printk(KERN_NOTICE "Searching for RedBoot partition table in %s at offset 0x%lx\n", - master->name, offset); + pr_notice("Searching for RedBoot partition table in %s at offset 0x%lx\n", + master->name, offset); ret = mtd_read(master, offset, master->erasesize, &retlen, (void *)buf); @@ -150,14 +150,13 @@ static int parse_redboot_partitions(struct mtd_info *master, && swab32(buf[i].size) < master->erasesize)) { int j; /* Update numslots based on actual FIS directory size */ - numslots = swab32(buf[i].size) / sizeof (struct fis_image_desc); + numslots = swab32(buf[i].size) / sizeof(struct fis_image_desc); for (j = 0; j < numslots; ++j) { - /* A single 0xff denotes a deleted entry. * Two of them in a row is the end of the table. */ if (buf[j].name[0] == 0xff) { - if (buf[j].name[1] == 0xff) { + if (buf[j].name[1] == 0xff) { break; } else { continue; @@ -184,8 +183,8 @@ static int parse_redboot_partitions(struct mtd_info *master, } if (i == numslots) { /* Didn't find it */ - printk(KERN_NOTICE "No RedBoot partition table detected in %s\n", - master->name); + pr_notice("No RedBoot partition table detected in %s\n", + master->name); ret = 0; goto out; } @@ -204,7 +203,7 @@ static int parse_redboot_partitions(struct mtd_info *master, break; new_fl = kmalloc(sizeof(struct fis_list), GFP_KERNEL); - namelen += strlen(buf[i].name)+1; + namelen += strlen(buf[i].name) + 1; if (!new_fl) { ret = -ENOMEM; goto out; @@ -213,13 +212,13 @@ static int parse_redboot_partitions(struct mtd_info *master, if (data && data->origin) buf[i].flash_base -= data->origin; else - buf[i].flash_base &= master->size-1; + buf[i].flash_base &= master->size - 1; /* I'm sure the JFFS2 code has done me permanent damage. * I now think the following is _normal_ */ prev = &fl; - while(*prev && (*prev)->img->flash_base < new_fl->img->flash_base) + while (*prev && (*prev)->img->flash_base < new_fl->img->flash_base) prev = &(*prev)->next; new_fl->next = *prev; *prev = new_fl; @@ -239,7 +238,7 @@ static int parse_redboot_partitions(struct mtd_info *master, } } #endif - parts = kzalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL); + parts = kzalloc(sizeof(*parts) * nrparts + nulllen + namelen, GFP_KERNEL); if (!parts) { ret = -ENOMEM; @@ -248,23 +247,22 @@ static int parse_redboot_partitions(struct mtd_info *master, nullname = (char *)&parts[nrparts]; #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED - if (nulllen > 0) { + if (nulllen > 0) strcpy(nullname, nullstring); - } #endif names = nullname + nulllen; - i=0; + i = 0; #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED if (fl->img->flash_base) { - parts[0].name = nullname; - parts[0].size = fl->img->flash_base; - parts[0].offset = 0; + parts[0].name = nullname; + parts[0].size = fl->img->flash_base; + parts[0].offset = 0; i++; } #endif - for ( ; i<nrparts; i++) { + for ( ; i < nrparts; i++) { parts[i].size = fl->img->size; parts[i].offset = fl->img->flash_base; parts[i].name = names; @@ -272,17 +270,17 @@ static int parse_redboot_partitions(struct mtd_info *master, strcpy(names, fl->img->name); #ifdef CONFIG_MTD_REDBOOT_PARTS_READONLY if (!memcmp(names, "RedBoot", 8) || - !memcmp(names, "RedBoot config", 15) || - !memcmp(names, "FIS directory", 14)) { + !memcmp(names, "RedBoot config", 15) || + !memcmp(names, "FIS directory", 14)) { parts[i].mask_flags = MTD_WRITEABLE; } #endif - names += strlen(names)+1; + names += strlen(names) + 1; #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED - if(fl->next && fl->img->flash_base + fl->img->size + master->erasesize <= fl->next->img->flash_base) { + if (fl->next && fl->img->flash_base + fl->img->size + master->erasesize <= fl->next->img->flash_base) { i++; - parts[i].offset = parts[i-1].size + parts[i-1].offset; + parts[i].offset = parts[i - 1].size + parts[i - 1].offset; parts[i].size = fl->next->img->flash_base - parts[i].offset; parts[i].name = nullname; } @@ -296,6 +294,7 @@ static int parse_redboot_partitions(struct mtd_info *master, out: while (fl) { struct fis_list *old = fl; + fl = fl->next; kfree(old); } -- 2.26.3 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] mtd: partitions: redboot: fix style issues 2021-05-20 11:48 ` [PATCH 2/2] mtd: partitions: redboot: fix style issues Corentin Labbe @ 2021-05-20 15:24 ` Linus Walleij 2021-05-20 15:36 ` Miquel Raynal 2021-05-26 9:02 ` Miquel Raynal 1 sibling, 1 reply; 9+ messages in thread From: Linus Walleij @ 2021-05-20 15:24 UTC (permalink / raw) To: Corentin Labbe Cc: Boris Brezillon, Miquèl Raynal, Richard Weinberger, Vignesh R, linux-kernel, linux-mtd On Thu, May 20, 2021 at 1:49 PM Corentin Labbe <clabbe@baylibre.com> wrote: > This patch fixes easy checkpatch issues. > > Signed-off-by: Corentin Labbe <clabbe@baylibre.com> (...) > - uint32_t flash_base; // Address within FLASH of image (...) > + u32 flash_base; // Address within FLASH of image Does checkpatch complain about this? At one point the MTD maintainer disliked the u32/u16/u8 types and explicitly wanted to use the C standard library types, and it's the kind of eccentric maintainer deviations we accommodate for. From my personal side: Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] mtd: partitions: redboot: fix style issues 2021-05-20 15:24 ` Linus Walleij @ 2021-05-20 15:36 ` Miquel Raynal 2021-05-20 16:00 ` Linus Walleij 0 siblings, 1 reply; 9+ messages in thread From: Miquel Raynal @ 2021-05-20 15:36 UTC (permalink / raw) To: Linus Walleij Cc: Corentin Labbe, Boris Brezillon, Richard Weinberger, Vignesh R, linux-kernel, linux-mtd Hello, Linus Walleij <linus.walleij@linaro.org> wrote on Thu, 20 May 2021 17:24:26 +0200: > On Thu, May 20, 2021 at 1:49 PM Corentin Labbe <clabbe@baylibre.com> wrote: > > > This patch fixes easy checkpatch issues. > > > > Signed-off-by: Corentin Labbe <clabbe@baylibre.com> > (...) > > - uint32_t flash_base; // Address within FLASH of image > (...) > > + u32 flash_base; // Address within FLASH of image > > Does checkpatch complain about this? At one point the MTD maintainer > disliked the u32/u16/u8 types and explicitly wanted to use the C > standard library types, and it's the kind of eccentric maintainer > deviations we accommodate for. I suppose this happened quite some time ago? :) I've never heard Richard nor Boris complaining about it, nor will I. Cheers, Miquèl ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] mtd: partitions: redboot: fix style issues 2021-05-20 15:36 ` Miquel Raynal @ 2021-05-20 16:00 ` Linus Walleij 2021-05-20 16:07 ` Miquel Raynal 0 siblings, 1 reply; 9+ messages in thread From: Linus Walleij @ 2021-05-20 16:00 UTC (permalink / raw) To: Miquel Raynal Cc: Corentin Labbe, Boris Brezillon, Richard Weinberger, Vignesh R, linux-kernel, linux-mtd On Thu, May 20, 2021 at 5:36 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote: > Linus Walleij <linus.walleij@linaro.org> wrote on Thu, 20 May 2021 > 17:24:26 +0200: > > On Thu, May 20, 2021 at 1:49 PM Corentin Labbe <clabbe@baylibre.com> wrote: > > > > > This patch fixes easy checkpatch issues. > > > > > > Signed-off-by: Corentin Labbe <clabbe@baylibre.com> > > (...) > > > - uint32_t flash_base; // Address within FLASH of image > > (...) > > > + u32 flash_base; // Address within FLASH of image > > > > Does checkpatch complain about this? At one point the MTD maintainer > > disliked the u32/u16/u8 types and explicitly wanted to use the C > > standard library types, and it's the kind of eccentric maintainer > > deviations we accommodate for. > > I suppose this happened quite some time ago? :) > > I've never heard Richard nor Boris complaining about it, nor will I. Yes that was a specific David Woodhouse preference. I'm too old! Yours, Linus Walleij ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] mtd: partitions: redboot: fix style issues 2021-05-20 16:00 ` Linus Walleij @ 2021-05-20 16:07 ` Miquel Raynal 0 siblings, 0 replies; 9+ messages in thread From: Miquel Raynal @ 2021-05-20 16:07 UTC (permalink / raw) To: Linus Walleij Cc: Corentin Labbe, Boris Brezillon, Richard Weinberger, Vignesh R, linux-kernel, linux-mtd Linus Walleij <linus.walleij@linaro.org> wrote on Thu, 20 May 2021 18:00:04 +0200: > On Thu, May 20, 2021 at 5:36 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote: > > Linus Walleij <linus.walleij@linaro.org> wrote on Thu, 20 May 2021 > > 17:24:26 +0200: > > > On Thu, May 20, 2021 at 1:49 PM Corentin Labbe <clabbe@baylibre.com> wrote: > > > > > > > This patch fixes easy checkpatch issues. > > > > > > > > Signed-off-by: Corentin Labbe <clabbe@baylibre.com> > > > (...) > > > > - uint32_t flash_base; // Address within FLASH of image > > > (...) > > > > + u32 flash_base; // Address within FLASH of image > > > > > > Does checkpatch complain about this? At one point the MTD maintainer > > > disliked the u32/u16/u8 types and explicitly wanted to use the C > > > standard library types, and it's the kind of eccentric maintainer > > > deviations we accommodate for. > > > > I suppose this happened quite some time ago? :) > > > > I've never heard Richard nor Boris complaining about it, nor will I. > > Yes that was a specific David Woodhouse preference. > I'm too old! Don't be sad, the new trend is to be sleek. In the dark I worship variables declaration in a reverse Christmas tree order ;-) ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] mtd: partitions: redboot: fix style issues 2021-05-20 11:48 ` [PATCH 2/2] mtd: partitions: redboot: fix style issues Corentin Labbe 2021-05-20 15:24 ` Linus Walleij @ 2021-05-26 9:02 ` Miquel Raynal 1 sibling, 0 replies; 9+ messages in thread From: Miquel Raynal @ 2021-05-26 9:02 UTC (permalink / raw) To: Corentin Labbe, boris.brezillon, linus.walleij, miquel.raynal, richard, vigneshr Cc: linux-kernel, linux-mtd On Thu, 2021-05-20 at 11:48:51 UTC, Corentin Labbe wrote: > This patch fixes easy checkpatch issues. > > Signed-off-by: Corentin Labbe <clabbe@baylibre.com> > Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks. Miquel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] mtd: partitions: redboot: seek fis-index-block in the right node 2021-05-20 11:48 [PATCH 1/2] mtd: partitions: redboot: seek fis-index-block in the right node Corentin Labbe 2021-05-20 11:48 ` [PATCH 2/2] mtd: partitions: redboot: fix style issues Corentin Labbe @ 2021-05-20 15:21 ` Linus Walleij 2021-05-26 9:02 ` Miquel Raynal 2 siblings, 0 replies; 9+ messages in thread From: Linus Walleij @ 2021-05-20 15:21 UTC (permalink / raw) To: Corentin Labbe Cc: Boris Brezillon, Miquèl Raynal, Richard Weinberger, Vignesh R, linux-kernel, linux-mtd On Thu, May 20, 2021 at 1:49 PM Corentin Labbe <clabbe@baylibre.com> wrote: > fis-index-block is seeked in the master node and not in the partitions node. > For following binding and current usage, the driver need to check the > partitions subnode. > > Fixes: c0e118c8a1a3 ("mtd: partitions: Add OF support to RedBoot partitions") > Signed-off-by: Corentin Labbe <clabbe@baylibre.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] mtd: partitions: redboot: seek fis-index-block in the right node 2021-05-20 11:48 [PATCH 1/2] mtd: partitions: redboot: seek fis-index-block in the right node Corentin Labbe 2021-05-20 11:48 ` [PATCH 2/2] mtd: partitions: redboot: fix style issues Corentin Labbe 2021-05-20 15:21 ` [PATCH 1/2] mtd: partitions: redboot: seek fis-index-block in the right node Linus Walleij @ 2021-05-26 9:02 ` Miquel Raynal 2 siblings, 0 replies; 9+ messages in thread From: Miquel Raynal @ 2021-05-26 9:02 UTC (permalink / raw) To: Corentin Labbe, boris.brezillon, linus.walleij, miquel.raynal, richard, vigneshr Cc: linux-kernel, linux-mtd On Thu, 2021-05-20 at 11:48:50 UTC, Corentin Labbe wrote: > fis-index-block is seeked in the master node and not in the partitions node. > For following binding and current usage, the driver need to check the > partitions subnode. > > Fixes: c0e118c8a1a3 ("mtd: partitions: Add OF support to RedBoot partitions") > Signed-off-by: Corentin Labbe <clabbe@baylibre.com> > Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks. Miquel ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-05-26 9:02 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-05-20 11:48 [PATCH 1/2] mtd: partitions: redboot: seek fis-index-block in the right node Corentin Labbe 2021-05-20 11:48 ` [PATCH 2/2] mtd: partitions: redboot: fix style issues Corentin Labbe 2021-05-20 15:24 ` Linus Walleij 2021-05-20 15:36 ` Miquel Raynal 2021-05-20 16:00 ` Linus Walleij 2021-05-20 16:07 ` Miquel Raynal 2021-05-26 9:02 ` Miquel Raynal 2021-05-20 15:21 ` [PATCH 1/2] mtd: partitions: redboot: seek fis-index-block in the right node Linus Walleij 2021-05-26 9:02 ` Miquel Raynal
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox