400-mtd-bcm47xxpart-get-nvram.patch 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. --- a/drivers/mtd/bcm47xxpart.c
  2. +++ b/drivers/mtd/bcm47xxpart.c
  3. @@ -127,6 +127,7 @@ static int bcm47xxpart_parse(struct mtd_
  4. int last_trx_part = -1;
  5. int possible_nvram_sizes[] = { 0x8000, 0xF000, 0x10000, };
  6. int err;
  7. + bool found_nvram = false;
  8. /*
  9. * Some really old flashes (like AT45DB*) had smaller erasesize-s, but
  10. @@ -332,12 +333,23 @@ static int bcm47xxpart_parse(struct mtd_
  11. if (buf[0] == NVRAM_HEADER) {
  12. bcm47xxpart_add_part(&parts[curr_part++], "nvram",
  13. master->size - blocksize, 0);
  14. + found_nvram = true;
  15. break;
  16. }
  17. }
  18. kfree(buf);
  19. + if (!found_nvram) {
  20. + pr_err("can not find a nvram partition reserve last block\n");
  21. + bcm47xxpart_add_part(&parts[curr_part++], "nvram_guess",
  22. + master->size - blocksize * 2, MTD_WRITEABLE);
  23. + for (i = 0; i < curr_part; i++) {
  24. + if (parts[i].size + parts[i].offset == master->size)
  25. + parts[i].offset -= blocksize * 2;
  26. + }
  27. + }
  28. +
  29. /*
  30. * Assume that partitions end at the beginning of the one they are
  31. * followed by.