提交 b359ed51 编写于 作者: J Jean-Philippe Brucker 提交者: Vignesh Raghavendra

mtd: cfi_cmdset_0001: Support the absence of protection registers

The flash controller implemented by the Arm Base platform behaves like
the Intel StrataFlash J3 device, but omits several features. In
particular it doesn't implement a protection register, so "Number of
Protection register fields" in the Primary Vendor-Specific Extended
Query, is 0.

The Intel StrataFlash J3 datasheet only lists 1 as a valid value for
NumProtectionFields. It describes the field as:

	"Number of Protection register fields in JEDEC ID space.
	“00h,” indicates that 256 protection bytes are available"

While a value of 0 may arguably not be architecturally valid, the
driver's current behavior is certainly wrong: if NumProtectionFields is
0, read_pri_intelext() adds a negative value to the unsigned extra_size,
and ends up in an infinite loop.

Fix it by ignoring a NumProtectionFields of 0.
Signed-off-by: NJean-Philippe Brucker <jean-philippe@linaro.org>
Tested-by: NSudeep Holla <sudeep.holla@arm.com>
Tested-by: NCatalin Marinas <catalin.marinas@arm.com>
Signed-off-by: NVignesh Raghavendra <vigneshr@ti.com>
上级 ae83d0b4
...@@ -420,6 +420,7 @@ read_pri_intelext(struct map_info *map, __u16 adr) ...@@ -420,6 +420,7 @@ read_pri_intelext(struct map_info *map, __u16 adr)
extra_size = 0; extra_size = 0;
/* Protection Register info */ /* Protection Register info */
if (extp->NumProtectionFields)
extra_size += (extp->NumProtectionFields - 1) * extra_size += (extp->NumProtectionFields - 1) *
sizeof(struct cfi_intelext_otpinfo); sizeof(struct cfi_intelext_otpinfo);
} }
...@@ -695,12 +696,14 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd, ...@@ -695,12 +696,14 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
*/ */
if (extp && extp->MajorVersion == '1' && extp->MinorVersion >= '3' if (extp && extp->MajorVersion == '1' && extp->MinorVersion >= '3'
&& extp->FeatureSupport & (1 << 9)) { && extp->FeatureSupport & (1 << 9)) {
int offs = 0;
struct cfi_private *newcfi; struct cfi_private *newcfi;
struct flchip *chip; struct flchip *chip;
struct flchip_shared *shared; struct flchip_shared *shared;
int offs, numregions, numparts, partshift, numvirtchips, i, j; int numregions, numparts, partshift, numvirtchips, i, j;
/* Protection Register info */ /* Protection Register info */
if (extp->NumProtectionFields)
offs = (extp->NumProtectionFields - 1) * offs = (extp->NumProtectionFields - 1) *
sizeof(struct cfi_intelext_otpinfo); sizeof(struct cfi_intelext_otpinfo);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册