Skip to content

Commit

Permalink
mtd: partitions: redboot: fix style issues
Browse files Browse the repository at this point in the history
This patch fixes easy checkpatch issues.

Signed-off-by: Corentin Labbe <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
Signed-off-by: Miquel Raynal <[email protected]>
Link: https://lore.kernel.org/linux-mtd/[email protected]
  • Loading branch information
montjoie authored and miquelraynal committed May 26, 2021
1 parent 2379608 commit eb1765c
Showing 1 changed file with 34 additions and 35 deletions.
69 changes: 34 additions & 35 deletions drivers/mtd/parsers/redboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -248,41 +247,40 @@ 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;

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;
}
Expand All @@ -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);
}
Expand Down

0 comments on commit eb1765c

Please sign in to comment.