[PATCH v2 2/3] mmc: add module param to set fault injection attributes
Replace setup(fail_mmc_request) and faulty ifdef KERNEL with a module_param_cb(). The module param mmc_core.fail_request may be used to set the fault injection attributes during boot time or module load time. Signed-off-by: Per Forlin per.for...@linaro.org --- drivers/mmc/core/debugfs.c | 38 -- 1 files changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index 5acd707..d80e234 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -20,6 +20,25 @@ #include core.h #include mmc_ops.h +#ifdef CONFIG_FAIL_MMC_REQUEST + +static DECLARE_FAULT_ATTR(fail_default_attr); +static char *fail_request; +static int fail_mmc_request_param_set(const char *val, + const struct kernel_param *kp) +{ + setup_fault_attr(fail_default_attr, (char *) val); + return 0; +} + +static const struct kernel_param_ops fail_mmc_request_param_ops = { + .set = fail_mmc_request_param_set +}; +module_param_cb(fail_request, fail_mmc_request_param_ops, + fail_request, 0); + +#endif /* CONFIG_FAIL_MMC_REQUEST */ + /* The debugfs functions are optimized away when CONFIG_DEBUG_FS isn't set. */ static int mmc_ios_show(struct seq_file *s, void *data) { @@ -159,23 +178,6 @@ static int mmc_clock_opt_set(void *data, u64 val) return 0; } -#ifdef CONFIG_FAIL_MMC_REQUEST - -static DECLARE_FAULT_ATTR(fail_mmc_request); - -#ifdef KERNEL -/* - * 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); -#endif /* KERNEL */ -#endif /* CONFIG_FAIL_MMC_REQUEST */ - DEFINE_SIMPLE_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set, %llu\n); @@ -207,7 +209,7 @@ void mmc_add_host_debugfs(struct mmc_host *host) goto err_node; #endif #ifdef CONFIG_FAIL_MMC_REQUEST - host-fail_mmc_request = fail_mmc_request; + host-fail_mmc_request = fail_default_attr; if (IS_ERR(fault_create_debugfs_attr(fail_mmc_request, root, host-fail_mmc_request))) -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/3] mmc: add module param to set fault injection attributes
2011/9/14 Per Forlin per.for...@linaro.org: +#ifdef CONFIG_FAIL_MMC_REQUEST + +static DECLARE_FAULT_ATTR(fail_default_attr); +static char *fail_request; This is not used anymore and ... +static int fail_mmc_request_param_set(const char *val, + const struct kernel_param *kp) +{ + setup_fault_attr(fail_default_attr, (char *) val); + return 0; +} + +static const struct kernel_param_ops fail_mmc_request_param_ops = { + .set = fail_mmc_request_param_set +}; +module_param_cb(fail_request, fail_mmc_request_param_ops, + fail_request, 0); you can change this third parameter to NULL. + +#endif /* CONFIG_FAIL_MMC_REQUEST */ -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/3] mmc: add module param to set fault injection attributes
On 14 September 2011 12:05, Akinobu Mita akinobu.m...@gmail.com wrote: 2011/9/14 Per Forlin per.for...@linaro.org: +#ifdef CONFIG_FAIL_MMC_REQUEST + +static DECLARE_FAULT_ATTR(fail_default_attr); +static char *fail_request; This is not used anymore and ... Yes of course. Will remove it. +static int fail_mmc_request_param_set(const char *val, + const struct kernel_param *kp) +{ + setup_fault_attr(fail_default_attr, (char *) val); + return 0; +} + +static const struct kernel_param_ops fail_mmc_request_param_ops = { + .set = fail_mmc_request_param_set +}; +module_param_cb(fail_request, fail_mmc_request_param_ops, + fail_request, 0); you can change this third parameter to NULL. Absolutely.. Thanks, Per -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/3] mmc: add module param to set fault injection attributes
On 14 September 2011 12:18, Per Forlin per.for...@linaro.org wrote: On 14 September 2011 12:05, Akinobu Mita akinobu.m...@gmail.com wrote: 2011/9/14 Per Forlin per.for...@linaro.org: +#ifdef CONFIG_FAIL_MMC_REQUEST + +static DECLARE_FAULT_ATTR(fail_default_attr); +static char *fail_request; This is not used anymore and ... Yes of course. Will remove it. +static int fail_mmc_request_param_set(const char *val, + const struct kernel_param *kp) +{ + setup_fault_attr(fail_default_attr, (char *) val); I am thinking of returning failure here if setup_fault_attr() fails. if (setup_fault_attr(fail_default_attr, (char *) val) == 0) return -EINVAL; There will be a printk(KERN_WARNING FAULT_INJECTION: failed to parse arguments) it setup() fails. Is it too harsh to return failure? Regards, Per -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/3] mmc: add module param to set fault injection attributes
On 14 September 2011 12:38, Per Forlin per.for...@linaro.org wrote: On 14 September 2011 12:18, Per Forlin per.for...@linaro.org wrote: On 14 September 2011 12:05, Akinobu Mita akinobu.m...@gmail.com wrote: 2011/9/14 Per Forlin per.for...@linaro.org: +#ifdef CONFIG_FAIL_MMC_REQUEST + +static DECLARE_FAULT_ATTR(fail_default_attr); +static char *fail_request; This is not used anymore and ... Yes of course. Will remove it. +static int fail_mmc_request_param_set(const char *val, + const struct kernel_param *kp) +{ + setup_fault_attr(fail_default_attr, (char *) val); I am thinking of returning failure here if setup_fault_attr() fails. if (setup_fault_attr(fail_default_attr, (char *) val) == 0) return -EINVAL; There will be a printk(KERN_WARNING FAULT_INJECTION: failed to parse arguments) it setup() fails. Is it too harsh to return failure? If error is returned here the kernel prints: invalid for parameter `mmc_core.fail_request' This piece of information is a reason for returning error on failure. Regards, Per -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/3] mmc: add module param to set fault injection attributes
2011/9/14 Per Forlin per.for...@linaro.org: +static int fail_mmc_request_param_set(const char *val, + const struct kernel_param *kp) +{ + setup_fault_attr(fail_default_attr, (char *) val); I am thinking of returning failure here if setup_fault_attr() fails. if (setup_fault_attr(fail_default_attr, (char *) val) == 0) return -EINVAL; It's good idea and it also prevents from loading the module if invalid parameter is specified. There will be a printk(KERN_WARNING FAULT_INJECTION: failed to parse arguments) it setup() fails. Is it too harsh to return failure? Yes. I'll try to fix in the future. -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html