Skip to content

Commit 2fe48aa

Browse files
ZhaoLong Wangrichardweinberger
authored andcommitted
mtd: Add several functions to the fail_function list
add mtd_read(), mtd_write(), mtd_erase(), mtd_block_markbad() to fail_function list for testing purpose - Specify the function to inject the fault echo mtd_read > /sys/kernel/debug/fail_function/inject - Specifies the return value of the function to inject the fault printf %#x -12 > /sys/kernel/debug/fail_function/mtd_read/retval - Specify other fault injection configuration parameters. echo -1 > /sys/kernel/debug/fail_function/times echo 100 > /sys/kernel/debug/fail_function/probability echo 15 > /sys/kernel/debug/fail_function/space Signed-off-by: ZhaoLong Wang <wangzhaolong1@huawei.com> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent 4d0deb3 commit 2fe48aa

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/mtd/mtdcore.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/debugfs.h>
3131
#include <linux/nvmem-provider.h>
3232
#include <linux/root_dev.h>
33+
#include <linux/error-injection.h>
3334

3435
#include <linux/mtd/mtd.h>
3536
#include <linux/mtd/partitions.h>
@@ -1412,6 +1413,7 @@ int mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
14121413
return ret;
14131414
}
14141415
EXPORT_SYMBOL_GPL(mtd_erase);
1416+
ALLOW_ERROR_INJECTION(mtd_erase, ERRNO);
14151417

14161418
/*
14171419
* This stuff for eXecute-In-Place. phys is optional and may be set to NULL.
@@ -1511,6 +1513,7 @@ int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
15111513
return ret;
15121514
}
15131515
EXPORT_SYMBOL_GPL(mtd_read);
1516+
ALLOW_ERROR_INJECTION(mtd_read, ERRNO);
15141517

15151518
int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
15161519
const u_char *buf)
@@ -1527,6 +1530,7 @@ int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
15271530
return ret;
15281531
}
15291532
EXPORT_SYMBOL_GPL(mtd_write);
1533+
ALLOW_ERROR_INJECTION(mtd_write, ERRNO);
15301534

15311535
/*
15321536
* In blackbox flight recorder like scenarios we want to make successful writes
@@ -2347,6 +2351,7 @@ int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs)
23472351
return 0;
23482352
}
23492353
EXPORT_SYMBOL_GPL(mtd_block_markbad);
2354+
ALLOW_ERROR_INJECTION(mtd_block_markbad, ERRNO);
23502355

23512356
/*
23522357
* default_mtd_writev - the default writev method

0 commit comments

Comments
 (0)