mtd: partitions: redboot: seek fis-index-block in the right node
PATCH 1/2 mtd: partitions: redboot: seek fis-index-block in the right node
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.
--- drivers/mtd/parsers/redboot.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mtd/parsers/redboot.c +6 -1
@@ -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 ;
Signature · 6 lines
2.26.3 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 2/2 mtd: partitions: redboot: fix style issues
This patch fixes easy checkpatch issues.
--- drivers/mtd/parsers/redboot.c | 69 +++++++++++++++++------------------ 1 file changed, 34 insertions(+), 35 deletions(-)
drivers/mtd/parsers/redboot.c +34 -35
@@ -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); }
Signature · 6 lines
2.26.3 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 2/2] mtd: partitions: redboot: fix style issues
Quoted 3 lines · Corentin Labbe
This patch fixes easy checkpatch issues.
Signed-off-by Corentin Labbe <[email protected]>
(...)
Quoted 1 line
-
uint32_tflash_base; // Address within FLASH of image
(...)
Quoted 1 line
+ 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:
Yours,
Linus Walleij
Miquel Raynal
maintainerRe: [PATCH 2/2] mtd: partitions: redboot: fix style issues
Hello,
Linus Walleij <[email protected]> wrote on Thu, 20 May 2021 17:24:26 +0200:
Quoted 6 lines · Corentin Labbe
Quoted 4 lines
This patch fixes easy checkpatch issues.
Signed-off-by Corentin Labbe <[email protected]>(...)
Quoted 8 lines
Quoted 1 line
-
uint32_tflash_base; // Address within FLASH of image(...)
Quoted 1 line
+ u32
flash_base; // Address within FLASH of imageDoes 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
Re: [PATCH 2/2] mtd: partitions: redboot: fix style issues
Quoted 12 lines · Miquel Raynal
Linus Walleij <[email protected]> wrote on Thu, 20 May 2021 17:24:26 +0200:
Quoted 10 lines · Corentin Labbe
Quoted 4 lines
This patch fixes easy checkpatch issues.
Signed-off-by Corentin Labbe <[email protected]>(...)
Quoted 1 line
-
uint32_tflash_base; // Address within FLASH of image(...)
Quoted 1 line
+ u32
flash_base; // Address within FLASH of image
Quoted 8 lines
Quoted 4 lines
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
Miquel Raynal
maintainerRe: [PATCH 2/2] mtd: partitions: redboot: fix style issues
Linus Walleij <[email protected]> wrote on Thu, 20 May 2021 18:00:04 +0200:
Quoted 18 lines · Miquel Raynal
Quoted 17 lines
Linus Walleij <[email protected]> wrote on Thu, 20 May 2021 17:24:26 +0200:
Quoted 14 lines · Corentin Labbe
Quoted 4 lines
This patch fixes easy checkpatch issues.
Signed-off-by Corentin Labbe <[email protected]>(...)
Quoted 1 line
-
uint32_tflash_base; // Address within FLASH of image(...)
Quoted 1 line
+ u32
flash_base; // Address within FLASH of imageDoes 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.
Quoted 6 lines
Quoted 3 lines
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 ;-)
Re: [PATCH 2/2] mtd: partitions: redboot: fix style issues
In reply to Corentin LabbeQuoted 4 lines · Corentin Labbe
This patch fixes easy checkpatch issues.
Signed-off-by Corentin Labbe <[email protected]>Reviewed-by Linus Walleij <[email protected]>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel
Quoted 6 lines · 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 <[email protected]>
Yours,
Linus Walleij
Quoted 7 lines · 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 <[email protected]>Reviewed-by Linus Walleij <[email protected]>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel