1
0

140-redboot_boardconfig.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. --- a/drivers/mtd/redboot.c
  2. +++ b/drivers/mtd/redboot.c
  3. @@ -30,6 +30,8 @@
  4. #include <linux/mtd/partitions.h>
  5. #include <linux/module.h>
  6. +#define BOARD_CONFIG_PART "boardconfig"
  7. +
  8. struct fis_image_desc {
  9. unsigned char name[16]; // Null terminated name
  10. uint32_t flash_base; // Address within FLASH of image
  11. @@ -60,6 +62,7 @@ static int parse_redboot_partitions(stru
  12. const struct mtd_partition **pparts,
  13. struct mtd_part_parser_data *data)
  14. {
  15. + unsigned long max_offset = 0;
  16. int nrparts = 0;
  17. struct fis_image_desc *buf;
  18. struct mtd_partition *parts;
  19. @@ -225,14 +228,15 @@ static int parse_redboot_partitions(stru
  20. }
  21. }
  22. #endif
  23. - parts = kzalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL);
  24. + parts = kzalloc(sizeof(*parts) * (nrparts + 1) + nulllen + namelen +
  25. + sizeof(BOARD_CONFIG_PART), GFP_KERNEL);
  26. if (!parts) {
  27. ret = -ENOMEM;
  28. goto out;
  29. }
  30. - nullname = (char *)&parts[nrparts];
  31. + nullname = (char *)&parts[nrparts + 1];
  32. #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
  33. if (nulllen > 0) {
  34. strcpy(nullname, nullstring);
  35. @@ -251,6 +255,8 @@ static int parse_redboot_partitions(stru
  36. }
  37. #endif
  38. for ( ; i<nrparts; i++) {
  39. + if (max_offset < buf[i].flash_base + buf[i].size)
  40. + max_offset = buf[i].flash_base + buf[i].size;
  41. parts[i].size = fl->img->size;
  42. parts[i].offset = fl->img->flash_base;
  43. parts[i].name = names;
  44. @@ -284,6 +290,13 @@ static int parse_redboot_partitions(stru
  45. fl = fl->next;
  46. kfree(tmp_fl);
  47. }
  48. + if (master->size - max_offset >= master->erasesize) {
  49. + parts[nrparts].size = master->size - max_offset;
  50. + parts[nrparts].offset = max_offset;
  51. + parts[nrparts].name = names;
  52. + strcpy(names, BOARD_CONFIG_PART);
  53. + nrparts++;
  54. + }
  55. ret = nrparts;
  56. *pparts = parts;
  57. out: