]> git.hungrycats.org Git - linux/commit
mtd: spi-nor: swp: Simplify checking the locked/unlocked range
authorMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 26 May 2026 14:56:39 +0000 (16:56 +0200)
committerPratyush Yadav <pratyush@kernel.org>
Tue, 26 May 2026 15:21:04 +0000 (17:21 +0200)
commitc672673c4b7b82d21537cd5aa32b98f48c20a2b2
tree102f0842713da8041b048328475eed007403b2c1
parent290e83833688b4df0da746af4c5fb87dbed2834a
mtd: spi-nor: swp: Simplify checking the locked/unlocked range

In both the locking/unlocking steps, at the end we verify whether we do
not lock/unlock more than requested (in which case an error must be
returned).

While being possible to do that with very simple mask comparisons, it
does not scale when adding extra locking features such as the CMP
possibility. In order to make these checks slightly easier to read and
more future proof, use existing helpers to read the (future) status
register, extract the covered range, and compare it with very usual
algebric comparisons.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Pratyush Yadav <pratyush@kernel.org>
drivers/mtd/spi-nor/swp.c