From patchwork Wed Sep 14 12:10:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Per Forlin X-Patchwork-Id: 4067 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 75C3123E51 for ; Wed, 14 Sep 2011 12:10:45 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 56722A18A41 for ; Wed, 14 Sep 2011 12:10:45 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id 23so2202652fxe.11 for ; Wed, 14 Sep 2011 05:10:45 -0700 (PDT) Received: by 10.223.34.143 with SMTP id l15mr605781fad.46.1316002245238; Wed, 14 Sep 2011 05:10:45 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.11.8 with SMTP id m8cs46959lab; Wed, 14 Sep 2011 05:10:44 -0700 (PDT) Received: by 10.204.144.2 with SMTP id x2mr2977308bku.315.1316002244416; Wed, 14 Sep 2011 05:10:44 -0700 (PDT) Received: from mail-bw0-f50.google.com (mail-bw0-f50.google.com [209.85.214.50]) by mx.google.com with ESMTPS id n1si1876bke.97.2011.09.14.05.10.43 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Sep 2011 05:10:44 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of per.forlin@linaro.org) client-ip=209.85.214.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of per.forlin@linaro.org) smtp.mail=per.forlin@linaro.org Received: by mail-bw0-f50.google.com with SMTP id zt19so1675025bkb.37 for ; Wed, 14 Sep 2011 05:10:43 -0700 (PDT) Received: by 10.204.6.214 with SMTP id a22mr1572404bka.377.1316002243076; Wed, 14 Sep 2011 05:10:43 -0700 (PDT) Received: from localhost.localdomain (c-c37f71d5.029-82-6c756e10.cust.bredbandsbolaget.se. [213.113.127.195]) by mx.google.com with ESMTPS id t16sm3297bkv.11.2011.09.14.05.10.41 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Sep 2011 05:10:42 -0700 (PDT) From: Per Forlin To: linaro-dev@lists.linaro.org, Akinobu Mita , Linus Walleij , linux-mmc@vger.kernel.org Cc: Chris Ball , Randy Dunlap , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Per Forlin Subject: [PATCH v3 2/3] mmc: add module param to set fault injection attributes Date: Wed, 14 Sep 2011 14:10:17 +0200 Message-Id: <1316002218-3408-3-git-send-email-per.forlin@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1316002218-3408-1-git-send-email-per.forlin@linaro.org> References: <1316002218-3408-1-git-send-email-per.forlin@linaro.org> 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 --- 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..13e44c9 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 int fail_mmc_request_param_set(const char *val, + const struct kernel_param *kp) +{ + if (setup_fault_attr(&fail_default_attr, (char *) val) == 0) + return -EINVAL; + + 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, NULL, 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)))