diff options
| author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2011-12-28 11:14:49 -0500 |
|---|---|---|
| committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-01-09 13:25:54 -0500 |
| commit | 9cf075f8656524abc44ad3ff2ec3834fe76f186f (patch) | |
| tree | f4d1bc3254b24d3f032134088ba83f9e79a6a01b /include/linux/mtd | |
| parent | bea7fe031e5b81629f264f48335f1af74900f4b9 (diff) | |
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: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'include/linux/mtd')
| -rw-r--r-- | include/linux/mtd/mtd.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 8ae37e9d45de..a09077aca45b 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h | |||
| @@ -258,6 +258,7 @@ static inline int mtd_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
| 258 | static inline int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, | 258 | static inline int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, |
| 259 | size_t *retlen, void **virt, resource_size_t *phys) | 259 | size_t *retlen, void **virt, resource_size_t *phys) |
| 260 | { | 260 | { |
| 261 | *retlen = 0; | ||
| 261 | return mtd->point(mtd, from, len, retlen, virt, phys); | 262 | return mtd->point(mtd, from, len, retlen, virt, phys); |
| 262 | } | 263 | } |
| 263 | 264 | ||
| @@ -289,6 +290,7 @@ static inline int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
| 289 | static inline int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, | 290 | static inline int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, |
| 290 | size_t *retlen, const u_char *buf) | 291 | size_t *retlen, const u_char *buf) |
| 291 | { | 292 | { |
| 293 | *retlen = 0; | ||
| 292 | return mtd->write(mtd, to, len, retlen, buf); | 294 | return mtd->write(mtd, to, len, retlen, buf); |
| 293 | } | 295 | } |
| 294 | 296 | ||
| @@ -302,18 +304,21 @@ static inline int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
| 302 | static inline int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, | 304 | static inline int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, |
| 303 | size_t *retlen, const u_char *buf) | 305 | size_t *retlen, const u_char *buf) |
| 304 | { | 306 | { |
| 307 | *retlen = 0; | ||
| 305 | return mtd->panic_write(mtd, to, len, retlen, buf); | 308 | return mtd->panic_write(mtd, to, len, retlen, buf); |
| 306 | } | 309 | } |
| 307 | 310 | ||
| 308 | static inline int mtd_read_oob(struct mtd_info *mtd, loff_t from, | 311 | static inline int mtd_read_oob(struct mtd_info *mtd, loff_t from, |
| 309 | struct mtd_oob_ops *ops) | 312 | struct mtd_oob_ops *ops) |
| 310 | { | 313 | { |
| 314 | ops->retlen = ops->oobretlen = 0; | ||
| 311 | return mtd->read_oob(mtd, from, ops); | 315 | return mtd->read_oob(mtd, from, ops); |
| 312 | } | 316 | } |
| 313 | 317 | ||
| 314 | static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to, | 318 | static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to, |
| 315 | struct mtd_oob_ops *ops) | 319 | struct mtd_oob_ops *ops) |
| 316 | { | 320 | { |
| 321 | ops->retlen = ops->oobretlen = 0; | ||
| 317 | return mtd->write_oob(mtd, to, ops); | 322 | return mtd->write_oob(mtd, to, ops); |
| 318 | } | 323 | } |
| 319 | 324 | ||
| @@ -332,6 +337,7 @@ static inline int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, | |||
| 332 | size_t len, size_t *retlen, | 337 | size_t len, size_t *retlen, |
| 333 | u_char *buf) | 338 | u_char *buf) |
| 334 | { | 339 | { |
| 340 | *retlen = 0; | ||
| 335 | return mtd->read_fact_prot_reg(mtd, from, len, retlen, buf); | 341 | return mtd->read_fact_prot_reg(mtd, from, len, retlen, buf); |
| 336 | } | 342 | } |
| 337 | 343 | ||
| @@ -346,6 +352,7 @@ static inline int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, | |||
| 346 | size_t len, size_t *retlen, | 352 | size_t len, size_t *retlen, |
| 347 | u_char *buf) | 353 | u_char *buf) |
| 348 | { | 354 | { |
| 355 | *retlen = 0; | ||
| 349 | return mtd->read_user_prot_reg(mtd, from, len, retlen, buf); | 356 | return mtd->read_user_prot_reg(mtd, from, len, retlen, buf); |
| 350 | } | 357 | } |
| 351 | 358 | ||
| @@ -353,6 +360,7 @@ static inline int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, | |||
| 353 | size_t len, size_t *retlen, | 360 | size_t len, size_t *retlen, |
| 354 | u_char *buf) | 361 | u_char *buf) |
| 355 | { | 362 | { |
| 363 | *retlen = 0; | ||
| 356 | return mtd->write_user_prot_reg(mtd, to, len, retlen, buf); | 364 | return mtd->write_user_prot_reg(mtd, to, len, retlen, buf); |
| 357 | } | 365 | } |
| 358 | 366 | ||
| @@ -369,6 +377,7 @@ static inline int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, | |||
| 369 | static inline int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, | 377 | static inline int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, |
| 370 | unsigned long count, loff_t to, size_t *retlen) | 378 | unsigned long count, loff_t to, size_t *retlen) |
| 371 | { | 379 | { |
| 380 | *retlen = 0; | ||
| 372 | return mtd->writev(mtd, vecs, count, to, retlen); | 381 | return mtd->writev(mtd, vecs, count, to, retlen); |
| 373 | } | 382 | } |
| 374 | 383 | ||
