Commit 9cf075f8 authored by Artem Bityutskiy's avatar Artem Bityutskiy Committed by David Woodhouse

mtd: always initialize retlen to zero

Make sure that the retlen is set to 0 in case of error. This harmonizes
drivers - some set it to 0 in some error cases and do not write anything
in other error cases. Now we can do this consistently for all drivers.
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent bea7fe03
...@@ -258,6 +258,7 @@ static inline int mtd_erase(struct mtd_info *mtd, struct erase_info *instr) ...@@ -258,6 +258,7 @@ static inline int mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
static inline int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, static inline int mtd_point(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, void **virt, resource_size_t *phys) size_t *retlen, void **virt, resource_size_t *phys)
{ {
*retlen = 0;
return mtd->point(mtd, from, len, retlen, virt, phys); return mtd->point(mtd, from, len, retlen, virt, phys);
} }
...@@ -289,6 +290,7 @@ static inline int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, ...@@ -289,6 +290,7 @@ static inline int mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
static inline int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, static inline int mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf) size_t *retlen, const u_char *buf)
{ {
*retlen = 0;
return mtd->write(mtd, to, len, retlen, buf); return mtd->write(mtd, to, len, retlen, buf);
} }
...@@ -302,18 +304,21 @@ static inline int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, ...@@ -302,18 +304,21 @@ static inline int mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
static inline int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, static inline int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf) size_t *retlen, const u_char *buf)
{ {
*retlen = 0;
return mtd->panic_write(mtd, to, len, retlen, buf); return mtd->panic_write(mtd, to, len, retlen, buf);
} }
static inline int mtd_read_oob(struct mtd_info *mtd, loff_t from, static inline int mtd_read_oob(struct mtd_info *mtd, loff_t from,
struct mtd_oob_ops *ops) struct mtd_oob_ops *ops)
{ {
ops->retlen = ops->oobretlen = 0;
return mtd->read_oob(mtd, from, ops); return mtd->read_oob(mtd, from, ops);
} }
static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to, static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to,
struct mtd_oob_ops *ops) struct mtd_oob_ops *ops)
{ {
ops->retlen = ops->oobretlen = 0;
return mtd->write_oob(mtd, to, ops); return mtd->write_oob(mtd, to, ops);
} }
...@@ -332,6 +337,7 @@ static inline int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, ...@@ -332,6 +337,7 @@ static inline int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from,
size_t len, size_t *retlen, size_t len, size_t *retlen,
u_char *buf) u_char *buf)
{ {
*retlen = 0;
return mtd->read_fact_prot_reg(mtd, from, len, retlen, buf); return mtd->read_fact_prot_reg(mtd, from, len, retlen, buf);
} }
...@@ -346,6 +352,7 @@ static inline int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, ...@@ -346,6 +352,7 @@ static inline int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from,
size_t len, size_t *retlen, size_t len, size_t *retlen,
u_char *buf) u_char *buf)
{ {
*retlen = 0;
return mtd->read_user_prot_reg(mtd, from, len, retlen, buf); return mtd->read_user_prot_reg(mtd, from, len, retlen, buf);
} }
...@@ -353,6 +360,7 @@ static inline int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, ...@@ -353,6 +360,7 @@ static inline int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to,
size_t len, size_t *retlen, size_t len, size_t *retlen,
u_char *buf) u_char *buf)
{ {
*retlen = 0;
return mtd->write_user_prot_reg(mtd, to, len, retlen, buf); return mtd->write_user_prot_reg(mtd, to, len, retlen, buf);
} }
...@@ -369,6 +377,7 @@ static inline int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, ...@@ -369,6 +377,7 @@ static inline int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from,
static inline int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, static inline int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
unsigned long count, loff_t to, size_t *retlen) unsigned long count, loff_t to, size_t *retlen)
{ {
*retlen = 0;
return mtd->writev(mtd, vecs, count, to, retlen); return mtd->writev(mtd, vecs, count, to, retlen);
} }
......
Markdown is supported
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