The mmc fault injection is being refactored and the new version will not make it until 3.1 due to external dependencies. The current version works fine except that it can't be used if mmc is a module. This patch-set resolves that issue.
Per Forlin (4): fault-inject: make fault injection available for modules mmc: core: resolve build error for fault inject mmc: core: silence build warning for mmc fault inject fault-inject: make mmc fault-inject depend on MMC
drivers/mmc/core/core.c | 21 +++++++++++++++++++-- lib/Kconfig.debug | 2 +- lib/fault-inject.c | 2 ++ 3 files changed, 22 insertions(+), 3 deletions(-)
export symbols should_fail() and init_fault_attr_dentries() in order to make modules use the fault injection functionality
Signed-off-by: Per Forlin per.forlin@linaro.org --- lib/fault-inject.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/lib/fault-inject.c b/lib/fault-inject.c index 7e65af7..27783da 100644 --- a/lib/fault-inject.c +++ b/lib/fault-inject.c @@ -131,6 +131,7 @@ bool should_fail(struct fault_attr *attr, ssize_t size)
return true; } +EXPORT_SYMBOL_GPL(should_fail);
#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
@@ -311,5 +312,6 @@ fail: cleanup_fault_attr_dentries(attr); return -ENOMEM; } +EXPORT_SYMBOL_GPL(init_fault_attr_dentries);
#endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
Fault inject init can't be a module since core may be a module as well. Call fault inject init function from mmc_init instead.
Signed-off-by: Per Forlin per.forlin@linaro.org --- drivers/mmc/core/core.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index de99ec3..af09384 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -23,8 +23,11 @@ #include <linux/log2.h> #include <linux/regulator/consumer.h> #include <linux/pm_runtime.h> + +#ifdef CONFIG_FAIL_MMC_REQUEST #include <linux/fault-inject.h> #include <linux/random.h> +#endif
#include <linux/mmc/card.h> #include <linux/mmc/host.h> @@ -88,12 +91,20 @@ static void mmc_flush_scheduled_work(void)
static DECLARE_FAULT_ATTR(fail_mmc_request);
+/* + * Internal function. Pass the boot param fail_mmc_request to + * the setup fault injection attributes routine. + */ static int __init setup_fail_mmc_request(char *str) { return setup_fault_attr(&fail_mmc_request, str); } __setup("fail_mmc_request=", setup_fail_mmc_request);
+/* + * Internal function. Inject random data errors. + * If mmc_data is NULL no errors are injected. + */ static void mmc_should_fail_request(struct mmc_host *host, struct mmc_request *mrq) { @@ -122,8 +133,6 @@ static int __init fail_mmc_request_debugfs(void) "fail_mmc_request"); }
-late_initcall(fail_mmc_request_debugfs); - #else /* CONFIG_FAIL_MMC_REQUEST */
static void mmc_should_fail_request(struct mmc_host *host, @@ -131,6 +140,10 @@ static void mmc_should_fail_request(struct mmc_host *host, { }
+static int __init fail_mmc_request_debugfs(void) +{ + return 0; +} #endif /* CONFIG_FAIL_MMC_REQUEST */
@@ -1918,6 +1931,8 @@ static int __init mmc_init(void) if (ret) goto unregister_host_class;
+ fail_mmc_request_debugfs(); + return 0;
unregister_host_class:
Skip building fault inject boot param code in case of core being built as a module.
Signed-off-by: Per Forlin per.forlin@linaro.org --- drivers/mmc/core/core.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index af09384..2f4b77e 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -91,6 +91,7 @@ static void mmc_flush_scheduled_work(void)
static DECLARE_FAULT_ATTR(fail_mmc_request);
+#ifndef MODULE /* * Internal function. Pass the boot param fail_mmc_request to * the setup fault injection attributes routine. @@ -100,6 +101,7 @@ static int __init setup_fail_mmc_request(char *str) return setup_fault_attr(&fail_mmc_request, str); } __setup("fail_mmc_request=", setup_fail_mmc_request); +#endif /* MODULE */
/* * Internal function. Inject random data errors.
Make sure MMC is configured when selecting config for mmc fault-inject.
Signed-off-by: Per Forlin per.forlin@linaro.org --- lib/Kconfig.debug | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 330fc70..b135c5e 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1060,7 +1060,7 @@ config FAIL_IO_TIMEOUT config FAIL_MMC_REQUEST bool "Fault-injection capability for MMC IO" select DEBUG_FS - depends on FAULT_INJECTION + depends on FAULT_INJECTION && MMC help Provide fault-injection capability for MMC IO. This will make the mmc core return data errors. This is