summaryrefslogtreecommitdiffstats
path: root/net/nfc
diff options
context:
space:
mode:
authorBrian Norris <computersforpeace@gmail.com>2016-01-29 11:25:32 -0800
committerBrian Norris <computersforpeace@gmail.com>2016-03-07 18:01:54 -0800
commitf8860802da84aa2bbc9f316e549a349fb40cda63 (patch)
treed2d263ccf2e6bf5b12ce704692f6c12b0b55b68d /net/nfc
parent4c0dba447ef4a97dfbae6e876312e952667eddc4 (diff)
downloadop-kernel-dev-f8860802da84aa2bbc9f316e549a349fb40cda63.zip
op-kernel-dev-f8860802da84aa2bbc9f316e549a349fb40cda63.tar.gz
mtd: spi-nor: make lock/unlock bounds checks more obvious and robust
There are a few different corner cases to the current logic that seem undesirable: * mtd_lock() with offs==0 trips a bounds issue on ofs - mtd->erasesize < 0 * mtd_unlock() on the middle of a flash that is already unlocked will return -EINVAL * probably other corner cases So, let's stop doing "smart" checks like "check the block below us", let's just do the following: (a) pass only non-negative offsets/lengths to stm_is_locked_sr() (b) add a similar stm_is_unlocked_sr() function, so we can check if the *entire* range is unlocked (and not just whether some part of it is unlocked) Then armed with (b), we can make lock() and unlock() much more symmetric: (c) short-circuit the procedure if there is no work to be done, and (d) check the entire range above/below This also aligns well with the structure needed for proper TB (Top/Bottom) support. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Tested-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Diffstat (limited to 'net/nfc')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud