040-mtd-bcm47xxpart-backports-from-3.19.patch 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. --- a/drivers/mtd/bcm47xxpart.c
  2. +++ b/drivers/mtd/bcm47xxpart.c
  3. @@ -15,8 +15,12 @@
  4. #include <linux/mtd/mtd.h>
  5. #include <linux/mtd/partitions.h>
  6. -/* 10 parts were found on sflash on Netgear WNDR4500 */
  7. -#define BCM47XXPART_MAX_PARTS 12
  8. +/*
  9. + * NAND flash on Netgear R6250 was verified to contain 15 partitions.
  10. + * This will result in allocating too big array for some old devices, but the
  11. + * memory will be freed soon anyway (see mtd_device_parse_register).
  12. + */
  13. +#define BCM47XXPART_MAX_PARTS 20
  14. /*
  15. * Amount of bytes we read when analyzing each block of flash memory.
  16. @@ -168,18 +172,26 @@ static int bcm47xxpart_parse(struct mtd_
  17. i++;
  18. }
  19. - bcm47xxpart_add_part(&parts[curr_part++], "linux",
  20. - offset + trx->offset[i], 0);
  21. - i++;
  22. + if (trx->offset[i]) {
  23. + bcm47xxpart_add_part(&parts[curr_part++],
  24. + "linux",
  25. + offset + trx->offset[i],
  26. + 0);
  27. + i++;
  28. + }
  29. /*
  30. * Pure rootfs size is known and can be calculated as:
  31. * trx->length - trx->offset[i]. We don't fill it as
  32. * we want to have jffs2 (overlay) in the same mtd.
  33. */
  34. - bcm47xxpart_add_part(&parts[curr_part++], "rootfs",
  35. - offset + trx->offset[i], 0);
  36. - i++;
  37. + if (trx->offset[i]) {
  38. + bcm47xxpart_add_part(&parts[curr_part++],
  39. + "rootfs",
  40. + offset + trx->offset[i],
  41. + 0);
  42. + i++;
  43. + }
  44. last_trx_part = curr_part - 1;