Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 186347
b: refs/heads/master
c: adbf05e
h: refs/heads/master
i:
  186345: 412c685
  186343: 127fec2
v: v3
  • Loading branch information
Artem Bityutskiy authored and Artem Bityutskiy committed Feb 1, 2010
1 parent 0ce8612 commit d62841c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 42 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0bf1c4399afee6a2031b0ee943a4c016e53f727c
refs/heads/master: adbf05e3ec6ea380ba145b6fa89d9125ed76eb98
50 changes: 25 additions & 25 deletions trunk/drivers/mtd/ubi/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset,

err = paranoid_check_not_bad(ubi, pnum);
if (err)
return err > 0 ? -EINVAL : err;
return err;

addr = (loff_t)pnum * ubi->peb_size + offset;
retry:
Expand Down Expand Up @@ -236,12 +236,12 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,

err = paranoid_check_not_bad(ubi, pnum);
if (err)
return err > 0 ? -EINVAL : err;
return err;

/* The area we are writing to has to contain all 0xFF bytes */
err = ubi_dbg_check_all_ff(ubi, pnum, offset, len);
if (err)
return err > 0 ? -EINVAL : err;
return err;

if (offset >= ubi->leb_start) {
/*
Expand All @@ -250,10 +250,10 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
*/
err = paranoid_check_peb_ec_hdr(ubi, pnum);
if (err)
return err > 0 ? -EINVAL : err;
return err;
err = paranoid_check_peb_vid_hdr(ubi, pnum);
if (err)
return err > 0 ? -EINVAL : err;
return err;
}

if (ubi_dbg_is_write_failure()) {
Expand Down Expand Up @@ -348,7 +348,7 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum)

err = ubi_dbg_check_all_ff(ubi, pnum, 0, ubi->peb_size);
if (err)
return err > 0 ? -EINVAL : err;
return err;

if (ubi_dbg_is_erase_failure() && !err) {
dbg_err("cannot erase PEB %d (emulated)", pnum);
Expand Down Expand Up @@ -542,7 +542,7 @@ int ubi_io_sync_erase(struct ubi_device *ubi, int pnum, int torture)

err = paranoid_check_not_bad(ubi, pnum);
if (err != 0)
return err > 0 ? -EINVAL : err;
return err;

if (ubi->ro_mode) {
ubi_err("read-only mode");
Expand Down Expand Up @@ -819,7 +819,7 @@ int ubi_io_write_ec_hdr(struct ubi_device *ubi, int pnum,

err = paranoid_check_ec_hdr(ubi, pnum, ec_hdr);
if (err)
return -EINVAL;
return err;

err = ubi_io_write(ubi, ec_hdr, pnum, 0, ubi->ec_hdr_alsize);
return err;
Expand Down Expand Up @@ -1083,7 +1083,7 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,

err = paranoid_check_peb_ec_hdr(ubi, pnum);
if (err)
return err > 0 ? -EINVAL : err;
return err;

vid_hdr->magic = cpu_to_be32(UBI_VID_HDR_MAGIC);
vid_hdr->version = UBI_VERSION;
Expand All @@ -1092,7 +1092,7 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,

err = paranoid_check_vid_hdr(ubi, pnum, vid_hdr);
if (err)
return -EINVAL;
return err;

p = (char *)vid_hdr - ubi->vid_hdr_shift;
err = ubi_io_write(ubi, p, pnum, ubi->vid_hdr_aloffset,
Expand All @@ -1107,8 +1107,8 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
* @ubi: UBI device description object
* @pnum: physical eraseblock number to check
*
* This function returns zero if the physical eraseblock is good, a positive
* number if it is bad and a negative error code if an error occurred.
* This function returns zero if the physical eraseblock is good, %-EINVAL if
* it is bad and a negative error code if an error occurred.
*/
static int paranoid_check_not_bad(const struct ubi_device *ubi, int pnum)
{
Expand All @@ -1120,7 +1120,7 @@ static int paranoid_check_not_bad(const struct ubi_device *ubi, int pnum)

ubi_err("paranoid check failed for PEB %d", pnum);
ubi_dbg_dump_stack();
return err;
return err > 0 ? -EINVAL : err;
}

/**
Expand All @@ -1130,7 +1130,7 @@ static int paranoid_check_not_bad(const struct ubi_device *ubi, int pnum)
* @ec_hdr: the erase counter header to check
*
* This function returns zero if the erase counter header contains valid
* values, and %1 if not.
* values, and %-EINVAL if not.
*/
static int paranoid_check_ec_hdr(const struct ubi_device *ubi, int pnum,
const struct ubi_ec_hdr *ec_hdr)
Expand All @@ -1156,16 +1156,16 @@ static int paranoid_check_ec_hdr(const struct ubi_device *ubi, int pnum,
fail:
ubi_dbg_dump_ec_hdr(ec_hdr);
ubi_dbg_dump_stack();
return 1;
return -EINVAL;
}

/**
* paranoid_check_peb_ec_hdr - check erase counter header.
* @ubi: UBI device description object
* @pnum: the physical eraseblock number to check
*
* This function returns zero if the erase counter header is all right, %1 if
* not, and a negative error code if an error occurred.
* This function returns zero if the erase counter header is all right and and
* a negative error code if not or if an error occurred.
*/
static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum)
{
Expand All @@ -1188,7 +1188,7 @@ static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum)
ubi_err("paranoid check failed for PEB %d", pnum);
ubi_dbg_dump_ec_hdr(ec_hdr);
ubi_dbg_dump_stack();
err = 1;
err = -EINVAL;
goto exit;
}

Expand All @@ -1206,7 +1206,7 @@ static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum)
* @vid_hdr: the volume identifier header to check
*
* This function returns zero if the volume identifier header is all right, and
* %1 if not.
* %-EINVAL if not.
*/
static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum,
const struct ubi_vid_hdr *vid_hdr)
Expand All @@ -1233,7 +1233,7 @@ static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum,
ubi_err("paranoid check failed for PEB %d", pnum);
ubi_dbg_dump_vid_hdr(vid_hdr);
ubi_dbg_dump_stack();
return 1;
return -EINVAL;

}

Expand All @@ -1243,7 +1243,7 @@ static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum,
* @pnum: the physical eraseblock number to check
*
* This function returns zero if the volume identifier header is all right,
* %1 if not, and a negative error code if an error occurred.
* and a negative error code if not or if an error occurred.
*/
static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum)
{
Expand All @@ -1270,7 +1270,7 @@ static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum)
ubi_err("paranoid check failed for PEB %d", pnum);
ubi_dbg_dump_vid_hdr(vid_hdr);
ubi_dbg_dump_stack();
err = 1;
err = -EINVAL;
goto exit;
}

Expand All @@ -1289,8 +1289,8 @@ static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum)
* @len: the length of the region to check
*
* This function returns zero if only 0xFF bytes are present at offset
* @offset of the physical eraseblock @pnum, %1 if not, and a negative error
* code if an error occurred.
* @offset of the physical eraseblock @pnum, and a negative error code if not
* or if an error occurred.
*/
int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
{
Expand Down Expand Up @@ -1321,7 +1321,7 @@ int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
ubi_msg("hex dump of the %d-%d region", offset, offset + len);
print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
ubi->dbg_peb_buf, len, 1);
err = 1;
err = -EINVAL;
error:
ubi_dbg_dump_stack();
mutex_unlock(&ubi->dbg_buf_mutex);
Expand Down
11 changes: 4 additions & 7 deletions trunk/drivers/mtd/ubi/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -974,11 +974,8 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi)
seb->ec = si->mean_ec;

err = paranoid_check_si(ubi, si);
if (err) {
if (err > 0)
err = -EINVAL;
if (err)
goto out_vidh;
}

ubi_free_vid_hdr(ubi, vidh);
kfree(ech);
Expand Down Expand Up @@ -1086,8 +1083,8 @@ void ubi_scan_destroy_si(struct ubi_scan_info *si)
* @ubi: UBI device description object
* @si: scanning information
*
* This function returns zero if the scanning information is all right, %1 if
* not and a negative error code if an error occurred.
* This function returns zero if the scanning information is all right, and a
* negative error code if not or if an error occurred.
*/
static int paranoid_check_si(struct ubi_device *ubi, struct ubi_scan_info *si)
{
Expand Down Expand Up @@ -1346,7 +1343,7 @@ static int paranoid_check_si(struct ubi_device *ubi, struct ubi_scan_info *si)

out:
ubi_dbg_dump_stack();
return 1;
return -EINVAL;
}

#endif /* CONFIG_MTD_UBI_DEBUG_PARANOID */
17 changes: 8 additions & 9 deletions trunk/drivers/mtd/ubi/wl.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ int ubi_wl_get_peb(struct ubi_device *ubi, int dtype)
ubi->peb_size - ubi->vid_hdr_aloffset);
if (err) {
ubi_err("new PEB %d does not contain all 0xFF bytes", e->pnum);
return err > 0 ? -EINVAL : err;
return err;
}

return e->pnum;
Expand Down Expand Up @@ -513,7 +513,7 @@ static int sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e,
dbg_wl("erase PEB %d, old EC %llu", e->pnum, ec);

err = paranoid_check_ec(ubi, e->pnum, e->ec);
if (err > 0)
if (err)
return -EINVAL;

ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_NOFS);
Expand Down Expand Up @@ -1572,8 +1572,7 @@ void ubi_wl_close(struct ubi_device *ubi)
* @ec: the erase counter to check
*
* This function returns zero if the erase counter of physical eraseblock @pnum
* is equivalent to @ec, %1 if not, and a negative error code if an error
* occurred.
* is equivalent to @ec, and a negative error code if not or if an error occurred.
*/
static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec)
{
Expand Down Expand Up @@ -1611,8 +1610,8 @@ static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec)
* @e: the wear-leveling entry to check
* @root: the root of the tree
*
* This function returns zero if @e is in the @root RB-tree and %1 if it is
* not.
* This function returns zero if @e is in the @root RB-tree and %-EINVAL if it
* is not.
*/
static int paranoid_check_in_wl_tree(struct ubi_wl_entry *e,
struct rb_root *root)
Expand All @@ -1623,7 +1622,7 @@ static int paranoid_check_in_wl_tree(struct ubi_wl_entry *e,
ubi_err("paranoid check failed for PEB %d, EC %d, RB-tree %p ",
e->pnum, e->ec, root);
ubi_dbg_dump_stack();
return 1;
return -EINVAL;
}

/**
Expand All @@ -1632,7 +1631,7 @@ static int paranoid_check_in_wl_tree(struct ubi_wl_entry *e,
* @ubi: UBI device description object
* @e: the wear-leveling entry to check
*
* This function returns zero if @e is in @ubi->pq and %1 if it is not.
* This function returns zero if @e is in @ubi->pq and %-EINVAL if it is not.
*/
static int paranoid_check_in_pq(struct ubi_device *ubi, struct ubi_wl_entry *e)
{
Expand All @@ -1647,6 +1646,6 @@ static int paranoid_check_in_pq(struct ubi_device *ubi, struct ubi_wl_entry *e)
ubi_err("paranoid check failed for PEB %d, EC %d, Protect queue",
e->pnum, e->ec);
ubi_dbg_dump_stack();
return 1;
return -EINVAL;
}
#endif /* CONFIG_MTD_UBI_DEBUG_PARANOID */

0 comments on commit d62841c

Please sign in to comment.