diff options
author | david.oberhollenzer@sigma-star.at <david.oberhollenzer@sigma-star.at> | 2015-03-26 18:59:50 -0400 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2015-04-13 15:05:17 -0400 |
commit | 502690674281a047abd45f81e64c498bc23a8bb3 (patch) | |
tree | 5aa08ca80d7de94bf0b3050a7f458ad0ed25d004 /drivers/mtd/ubi/io.c | |
parent | 1a7e985dd1bf5939af0f56bbd6d13d2caf48dd63 (diff) |
UBI: power cut emulation for testing
Emulate random power cuts by switching device to ro after a number of
writes to allow simple power cut testing with nand-sim.
Maximum and minimum number of successful writes before power cut and
what kind of writes (EC header, VID header or none) to interrupt
configurable via debugfs.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'drivers/mtd/ubi/io.c')
-rw-r--r-- | drivers/mtd/ubi/io.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index ed0bcb35472f..5bbd1f094f4e 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c | |||
@@ -859,6 +859,9 @@ int ubi_io_write_ec_hdr(struct ubi_device *ubi, int pnum, | |||
859 | if (err) | 859 | if (err) |
860 | return err; | 860 | return err; |
861 | 861 | ||
862 | if (ubi_dbg_power_cut(ubi, POWER_CUT_EC_WRITE)) | ||
863 | return -EROFS; | ||
864 | |||
862 | err = ubi_io_write(ubi, ec_hdr, pnum, 0, ubi->ec_hdr_alsize); | 865 | err = ubi_io_write(ubi, ec_hdr, pnum, 0, ubi->ec_hdr_alsize); |
863 | return err; | 866 | return err; |
864 | } | 867 | } |
@@ -1106,6 +1109,9 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum, | |||
1106 | if (err) | 1109 | if (err) |
1107 | return err; | 1110 | return err; |
1108 | 1111 | ||
1112 | if (ubi_dbg_power_cut(ubi, POWER_CUT_VID_WRITE)) | ||
1113 | return -EROFS; | ||
1114 | |||
1109 | p = (char *)vid_hdr - ubi->vid_hdr_shift; | 1115 | p = (char *)vid_hdr - ubi->vid_hdr_shift; |
1110 | err = ubi_io_write(ubi, p, pnum, ubi->vid_hdr_aloffset, | 1116 | err = ubi_io_write(ubi, p, pnum, ubi->vid_hdr_aloffset, |
1111 | ubi->vid_hdr_alsize); | 1117 | ubi->vid_hdr_alsize); |