OSDN Git Service

mmc: mmc-debugfs: add error state
authorLiangliang Lu <luliang@codeaurora.org>
Sat, 3 Dec 2016 02:34:26 +0000 (10:34 +0800)
committerSayali Lokhande <sayalil@codeaurora.org>
Mon, 6 Mar 2017 03:38:10 +0000 (09:08 +0530)
This change adds support to allow user space query if low level eMMC
driver has encountered any error or not, this state can be read/cleared
via debugfs.

CRs-Fixed: 1056483
Change-Id: Idc4ea375e9f308446dec04d443d062fe502658bd
Signed-off-by: Liangliang Lu <luliang@codeaurora.org>
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
drivers/mmc/core/debugfs.c
include/linux/mmc/host.h

index a0d31de..594fba0 100644 (file)
@@ -348,6 +348,33 @@ static int mmc_force_err_set(void *data, u64 val)
 
 DEFINE_SIMPLE_ATTRIBUTE(mmc_force_err_fops, NULL, mmc_force_err_set, "%llu\n");
 
+static int mmc_err_state_get(void *data, u64 *val)
+{
+       struct mmc_host *host = data;
+
+       if (!host)
+               return -EINVAL;
+
+       *val = host->err_occurred ? 1 : 0;
+
+       return 0;
+}
+
+static int mmc_err_state_clear(void *data, u64 val)
+{
+       struct mmc_host *host = data;
+
+       if (!host)
+               return -EINVAL;
+
+       host->err_occurred = false;
+
+       return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(mmc_err_state, mmc_err_state_get,
+               mmc_err_state_clear, "%llu\n");
+
 void mmc_add_host_debugfs(struct mmc_host *host)
 {
        struct dentry *root;
@@ -393,6 +420,10 @@ void mmc_add_host_debugfs(struct mmc_host *host)
                                root, host, &mmc_ring_buffer_fops))
                goto err_node;
 #endif
+       if (!debugfs_create_file("err_state", S_IRUSR | S_IWUSR, root, host,
+               &mmc_err_state))
+               goto err_node;
+
 #ifdef CONFIG_MMC_CLKGATE
        if (!debugfs_create_u32("clk_delay", (S_IRUSR | S_IWUSR),
                                root, &host->clk_delay))
index 804d89a..b056055 100644 (file)
@@ -533,6 +533,8 @@ struct mmc_host {
 
        struct dentry           *debugfs_root;
 
+       bool                    err_occurred;
+
        struct mmc_async_req    *areq;          /* active async req */
        struct mmc_context_info context_info;   /* async synchronization info */