mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-30 10:39:04 +00:00
4a9acacf53
It it used by brcm47xx and bcm53xx targets, so put patches in generic. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> SVN-Revision: 42212
60 lines
1.8 KiB
Diff
60 lines
1.8 KiB
Diff
--- a/drivers/mtd/Kconfig
|
|
+++ b/drivers/mtd/Kconfig
|
|
@@ -150,7 +150,7 @@ config MTD_BCM63XX_PARTS
|
|
|
|
config MTD_BCM47XX_PARTS
|
|
tristate "BCM47XX partitioning support"
|
|
- depends on BCM47XX
|
|
+ depends on BCM47XX || ARCH_BCM_5301X
|
|
help
|
|
This provides partitions parser for devices based on BCM47xx
|
|
boards.
|
|
--- a/drivers/mtd/bcm47xxpart.c
|
|
+++ b/drivers/mtd/bcm47xxpart.c
|
|
@@ -14,7 +14,6 @@
|
|
#include <linux/slab.h>
|
|
#include <linux/mtd/mtd.h>
|
|
#include <linux/mtd/partitions.h>
|
|
-#include <bcm47xx_nvram.h>
|
|
|
|
/* 10 parts were found on sflash on Netgear WNDR4500 */
|
|
#define BCM47XXPART_MAX_PARTS 12
|
|
@@ -30,6 +29,7 @@
|
|
#define BOARD_DATA_MAGIC2 0xBD0D0BBD
|
|
#define CFE_MAGIC 0x43464531 /* 1EFC */
|
|
#define FACTORY_MAGIC 0x59544346 /* FCTY */
|
|
+#define NVRAM_HEADER 0x48534C46 /* FLSH */
|
|
#define POT_MAGIC1 0x54544f50 /* POTT */
|
|
#define POT_MAGIC2 0x504f /* OP */
|
|
#define ML_MAGIC1 0x39685a42
|
|
@@ -91,7 +91,7 @@ static int bcm47xxpart_parse(struct mtd_
|
|
if (offset >= 0x2000000)
|
|
break;
|
|
|
|
- if (curr_part > BCM47XXPART_MAX_PARTS) {
|
|
+ if (curr_part >= BCM47XXPART_MAX_PARTS) {
|
|
pr_warn("Reached maximum number of partitions, scanning stopped!\n");
|
|
break;
|
|
}
|
|
@@ -147,6 +147,11 @@ static int bcm47xxpart_parse(struct mtd_
|
|
|
|
/* TRX */
|
|
if (buf[0x000 / 4] == TRX_MAGIC) {
|
|
+ if (BCM47XXPART_MAX_PARTS - curr_part < 4) {
|
|
+ pr_warn("Not enough partitions left to register trx, scanning stopped!\n");
|
|
+ break;
|
|
+ }
|
|
+
|
|
trx = (struct trx_header *)buf;
|
|
|
|
trx_part = curr_part;
|
|
@@ -212,7 +217,7 @@ static int bcm47xxpart_parse(struct mtd_
|
|
|
|
/* Look for NVRAM at the end of the last block. */
|
|
for (i = 0; i < ARRAY_SIZE(possible_nvram_sizes); i++) {
|
|
- if (curr_part > BCM47XXPART_MAX_PARTS) {
|
|
+ if (curr_part >= BCM47XXPART_MAX_PARTS) {
|
|
pr_warn("Reached maximum number of partitions, scanning stopped!\n");
|
|
break;
|
|
}
|