mtd: move zero length verification to MTD API functions
In many places in drivers we verify for the zero length, but this is very inconsistent across drivers. This is obviously the right thing to do, though. This patch moves the check to the MTD API functions instead and removes a lot of duplication. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:

committed by
David Woodhouse

parent
0dd5235f51
commit
bcb1d23871
@@ -1614,9 +1614,6 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
|
||||
struct mtd_oob_ops ops;
|
||||
int ret;
|
||||
|
||||
if (!len)
|
||||
return 0;
|
||||
|
||||
nand_get_device(chip, mtd, FL_READING);
|
||||
ops.len = len;
|
||||
ops.datbuf = buf;
|
||||
@@ -2313,10 +2310,6 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
|
||||
struct mtd_oob_ops ops;
|
||||
int ret;
|
||||
|
||||
/* Do not allow reads past end of device */
|
||||
if (!len)
|
||||
return 0;
|
||||
|
||||
/* Wait for the device to get ready */
|
||||
panic_nand_wait(mtd, chip, 400);
|
||||
|
||||
@@ -2351,9 +2344,6 @@ static int nand_write(struct mtd_info *mtd, loff_t to, size_t len,
|
||||
struct mtd_oob_ops ops;
|
||||
int ret;
|
||||
|
||||
if (!len)
|
||||
return 0;
|
||||
|
||||
nand_get_device(chip, mtd, FL_WRITING);
|
||||
ops.len = len;
|
||||
ops.datbuf = (uint8_t *)buf;
|
||||
|
Reference in New Issue
Block a user