Commit eb1765c4 authored by Corentin Labbe's avatar Corentin Labbe Committed by Miquel Raynal

mtd: partitions: redboot: fix style issues

This patch fixes easy checkpatch issues.
Signed-off-by: default avatarCorentin Labbe <clabbe@baylibre.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210520114851.1274609-2-clabbe@baylibre.com
parent 23796088
...@@ -17,15 +17,15 @@ ...@@ -17,15 +17,15 @@
#include <linux/module.h> #include <linux/module.h>
struct fis_image_desc { struct fis_image_desc {
unsigned char name[16]; // Null terminated name unsigned char name[16]; // Null terminated name
uint32_t flash_base; // Address within FLASH of image u32 flash_base; // Address within FLASH of image
uint32_t mem_base; // Address in memory where it executes u32 mem_base; // Address in memory where it executes
uint32_t size; // Length of image u32 size; // Length of image
uint32_t entry_point; // Execution entry point u32 entry_point; // Execution entry point
uint32_t data_length; // Length of actual data u32 data_length; // Length of actual data
unsigned char _pad[256-(16+7*sizeof(uint32_t))]; unsigned char _pad[256 - (16 + 7 * sizeof(u32))];
uint32_t desc_cksum; // Checksum over image descriptor u32 desc_cksum; // Checksum over image descriptor
uint32_t file_cksum; // Checksum over image data u32 file_cksum; // Checksum over image data
}; };
struct fis_list { struct fis_list {
...@@ -90,12 +90,12 @@ static int parse_redboot_partitions(struct mtd_info *master, ...@@ -90,12 +90,12 @@ static int parse_redboot_partitions(struct mtd_info *master,
parse_redboot_of(master); parse_redboot_of(master);
if ( directory < 0 ) { if (directory < 0) {
offset = master->size + directory * master->erasesize; offset = master->size + directory * master->erasesize;
while (mtd_block_isbad(master, offset)) { while (mtd_block_isbad(master, offset)) {
if (!offset) { if (!offset) {
nogood: nogood:
printk(KERN_NOTICE "Failed to find a non-bad block to check for RedBoot partition table\n"); pr_notice("Failed to find a non-bad block to check for RedBoot partition table\n");
return -EIO; return -EIO;
} }
offset -= master->erasesize; offset -= master->erasesize;
...@@ -113,8 +113,8 @@ static int parse_redboot_partitions(struct mtd_info *master, ...@@ -113,8 +113,8 @@ static int parse_redboot_partitions(struct mtd_info *master,
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
printk(KERN_NOTICE "Searching for RedBoot partition table in %s at offset 0x%lx\n", pr_notice("Searching for RedBoot partition table in %s at offset 0x%lx\n",
master->name, offset); master->name, offset);
ret = mtd_read(master, offset, master->erasesize, &retlen, ret = mtd_read(master, offset, master->erasesize, &retlen,
(void *)buf); (void *)buf);
...@@ -150,14 +150,13 @@ static int parse_redboot_partitions(struct mtd_info *master, ...@@ -150,14 +150,13 @@ static int parse_redboot_partitions(struct mtd_info *master,
&& swab32(buf[i].size) < master->erasesize)) { && swab32(buf[i].size) < master->erasesize)) {
int j; int j;
/* Update numslots based on actual FIS directory size */ /* 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) { for (j = 0; j < numslots; ++j) {
/* A single 0xff denotes a deleted entry. /* A single 0xff denotes a deleted entry.
* Two of them in a row is the end of the table. * Two of them in a row is the end of the table.
*/ */
if (buf[j].name[0] == 0xff) { if (buf[j].name[0] == 0xff) {
if (buf[j].name[1] == 0xff) { if (buf[j].name[1] == 0xff) {
break; break;
} else { } else {
continue; continue;
...@@ -184,8 +183,8 @@ static int parse_redboot_partitions(struct mtd_info *master, ...@@ -184,8 +183,8 @@ static int parse_redboot_partitions(struct mtd_info *master,
} }
if (i == numslots) { if (i == numslots) {
/* Didn't find it */ /* Didn't find it */
printk(KERN_NOTICE "No RedBoot partition table detected in %s\n", pr_notice("No RedBoot partition table detected in %s\n",
master->name); master->name);
ret = 0; ret = 0;
goto out; goto out;
} }
...@@ -204,7 +203,7 @@ static int parse_redboot_partitions(struct mtd_info *master, ...@@ -204,7 +203,7 @@ static int parse_redboot_partitions(struct mtd_info *master,
break; break;
new_fl = kmalloc(sizeof(struct fis_list), GFP_KERNEL); new_fl = kmalloc(sizeof(struct fis_list), GFP_KERNEL);
namelen += strlen(buf[i].name)+1; namelen += strlen(buf[i].name) + 1;
if (!new_fl) { if (!new_fl) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
...@@ -213,13 +212,13 @@ static int parse_redboot_partitions(struct mtd_info *master, ...@@ -213,13 +212,13 @@ static int parse_redboot_partitions(struct mtd_info *master,
if (data && data->origin) if (data && data->origin)
buf[i].flash_base -= data->origin; buf[i].flash_base -= data->origin;
else 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'm sure the JFFS2 code has done me permanent damage.
* I now think the following is _normal_ * I now think the following is _normal_
*/ */
prev = &fl; 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; prev = &(*prev)->next;
new_fl->next = *prev; new_fl->next = *prev;
*prev = new_fl; *prev = new_fl;
...@@ -239,7 +238,7 @@ static int parse_redboot_partitions(struct mtd_info *master, ...@@ -239,7 +238,7 @@ static int parse_redboot_partitions(struct mtd_info *master,
} }
} }
#endif #endif
parts = kzalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL); parts = kzalloc(sizeof(*parts) * nrparts + nulllen + namelen, GFP_KERNEL);
if (!parts) { if (!parts) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -248,23 +247,22 @@ static int parse_redboot_partitions(struct mtd_info *master, ...@@ -248,23 +247,22 @@ static int parse_redboot_partitions(struct mtd_info *master,
nullname = (char *)&parts[nrparts]; nullname = (char *)&parts[nrparts];
#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
if (nulllen > 0) { if (nulllen > 0)
strcpy(nullname, nullstring); strcpy(nullname, nullstring);
}
#endif #endif
names = nullname + nulllen; names = nullname + nulllen;
i=0; i = 0;
#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
if (fl->img->flash_base) { if (fl->img->flash_base) {
parts[0].name = nullname; parts[0].name = nullname;
parts[0].size = fl->img->flash_base; parts[0].size = fl->img->flash_base;
parts[0].offset = 0; parts[0].offset = 0;
i++; i++;
} }
#endif #endif
for ( ; i<nrparts; i++) { for ( ; i < nrparts; i++) {
parts[i].size = fl->img->size; parts[i].size = fl->img->size;
parts[i].offset = fl->img->flash_base; parts[i].offset = fl->img->flash_base;
parts[i].name = names; parts[i].name = names;
...@@ -272,17 +270,17 @@ static int parse_redboot_partitions(struct mtd_info *master, ...@@ -272,17 +270,17 @@ static int parse_redboot_partitions(struct mtd_info *master,
strcpy(names, fl->img->name); strcpy(names, fl->img->name);
#ifdef CONFIG_MTD_REDBOOT_PARTS_READONLY #ifdef CONFIG_MTD_REDBOOT_PARTS_READONLY
if (!memcmp(names, "RedBoot", 8) || if (!memcmp(names, "RedBoot", 8) ||
!memcmp(names, "RedBoot config", 15) || !memcmp(names, "RedBoot config", 15) ||
!memcmp(names, "FIS directory", 14)) { !memcmp(names, "FIS directory", 14)) {
parts[i].mask_flags = MTD_WRITEABLE; parts[i].mask_flags = MTD_WRITEABLE;
} }
#endif #endif
names += strlen(names)+1; names += strlen(names) + 1;
#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED #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++; 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].size = fl->next->img->flash_base - parts[i].offset;
parts[i].name = nullname; parts[i].name = nullname;
} }
...@@ -296,6 +294,7 @@ static int parse_redboot_partitions(struct mtd_info *master, ...@@ -296,6 +294,7 @@ static int parse_redboot_partitions(struct mtd_info *master,
out: out:
while (fl) { while (fl) {
struct fis_list *old = fl; struct fis_list *old = fl;
fl = fl->next; fl = fl->next;
kfree(old); kfree(old);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment