diff options
author | Chris Packham <chris.packham@alliedtelesis.co.nz> | 2019-05-23 02:19:48 +0300 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2019-07-07 21:39:16 +0300 |
commit | 3bb4bba79254be87c86ef416d6b7f69882e6a02c (patch) | |
tree | 3322be295f0a523d2ec8d5df119cf842b42369e8 | |
parent | 6a08a2f12781ca788759ff73acf1f36f6ae3f9b7 (diff) | |
download | linux-3bb4bba79254be87c86ef416d6b7f69882e6a02c.tar.xz |
mtd: concat: implement _is_locked mtd operation
Add an implementation of the _is_locked operation for concatenated mtd
devices. This doesn't handle getting the lock status of a range that
spans chips, which is consistent with cfi_ppb_is_locked and
cfi_intelext_is_locked which only look at the first block in the range.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Richard Weinberger <richard@nod.at>
-rw-r--r-- | drivers/mtd/mtdconcat.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index c9785f96070e..170a7221b35f 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c @@ -485,6 +485,28 @@ static int concat_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) return concat_xxlock(mtd, ofs, len, false); } +static int concat_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) +{ + struct mtd_concat *concat = CONCAT(mtd); + int i, err = -EINVAL; + + for (i = 0; i < concat->num_subdev; i++) { + struct mtd_info *subdev = concat->subdev[i]; + + if (ofs >= subdev->size) { + ofs -= subdev->size; + continue; + } + + if (ofs + len > subdev->size) + break; + + return mtd_is_locked(subdev, ofs, len); + } + + return err; +} + static void concat_sync(struct mtd_info *mtd) { struct mtd_concat *concat = CONCAT(mtd); @@ -684,6 +706,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c concat->mtd._sync = concat_sync; concat->mtd._lock = concat_lock; concat->mtd._unlock = concat_unlock; + concat->mtd._is_locked = concat_is_locked; concat->mtd._suspend = concat_suspend; concat->mtd._resume = concat_resume; |