Skip to content
Commit 542fbaaa authored by Jean-Philippe Brucker's avatar Jean-Philippe Brucker Committed by Greg Kroah-Hartman
Browse files

mtd: cfi_cmdset_0001: Support the absence of protection registers

[ Upstream commit b359ed51

 ]

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: default avatarJean-Philippe Brucker <jean-philippe@linaro.org>
Tested-by: default avatarSudeep Holla <sudeep.holla@arm.com>
Tested-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Signed-off-by: default avatarVignesh Raghavendra <vigneshr@ti.com>
Stable-dep-of: 565fe150

 ("mtd: cfi_cmdset_0001: Byte swap OTP info")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 1e4f431c
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment