MLK-11719-2: mtd: gpmi: save the bch layout setting in debugfs
authorHan Xu <b45815@freescale.com>
Fri, 9 Oct 2015 15:18:20 +0000 (10:18 -0500)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:49:20 +0000 (14:49 -0500)
save the bch layout setting in debugfs for the upper layer applications,
such as kobs-ng.

Signed-off-by: Han Xu <b45815@freescale.com>
(cherry picked from commit 8a373e796c21f4e9b714039e5f0b7d9388ef5a32)

drivers/mtd/nand/gpmi-nand/gpmi-lib.c

index 016758b..1fac130 100644 (file)
 #include <linux/clk.h>
 #include <linux/slab.h>
 #include <linux/pm_runtime.h>
+#include <linux/debugfs.h>
 
 
 #include "gpmi-nand.h"
 #include "gpmi-regs.h"
 #include "bch-regs.h"
 
+/* export the bch geometry to dbgfs */
+static struct debugfs_blob_wrapper dbg_bch_geo;
+
 static struct timing_threshod timing_default_threshold = {
        .max_data_setup_cycles       = (BM_GPMI_TIMING0_DATA_SETUP >>
                                                BP_GPMI_TIMING0_DATA_SETUP),
@@ -260,6 +264,7 @@ int bch_set_geometry(struct gpmi_nand_data *this)
        unsigned int page_size;
        unsigned int gf_len;
        int ret;
+       struct dentry *dbg_root;
 
        if (common_nfc_set_geometry(this))
                return !0;
@@ -271,6 +276,20 @@ int bch_set_geometry(struct gpmi_nand_data *this)
        page_size     = bch_geo->page_size;
        gf_len        = bch_geo->gf_len;
 
+       dbg_root = debugfs_create_dir("gpmi-nand", NULL);
+       if (!dbg_root) {
+               dev_err(this->dev, "failed to create debug directory\n");
+               return -EINVAL;
+       }
+
+       dbg_bch_geo.data = (void *)bch_geo;
+       dbg_bch_geo.size = sizeof(struct bch_geometry);
+       if (!debugfs_create_blob("bch_geometry", S_IRUGO,
+                               dbg_root, &dbg_bch_geo)) {
+               dev_err(this->dev, "failed to create debug bch geometry\n");
+               return -EINVAL;
+       }
+
        ret = pm_runtime_get_sync(this->dev);
        if (ret < 0) {
                dev_err(this->dev, "Failed to enable clock\n");