drm: omapdrm: dss: Store the debugfs root directory in struct dss_device
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tue, 13 Feb 2018 12:00:31 +0000 (14:00 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Thu, 1 Mar 2018 07:18:18 +0000 (09:18 +0200)
As part of an effort to remove the usage of global variables in the
driver, store the debugfs root directory in the dss_device structure
instead of a global variable.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
drivers/gpu/drm/omapdrm/dss/dispc.c
drivers/gpu/drm/omapdrm/dss/dsi.c
drivers/gpu/drm/omapdrm/dss/dss.c
drivers/gpu/drm/omapdrm/dss/dss.h
drivers/gpu/drm/omapdrm/dss/hdmi4.c
drivers/gpu/drm/omapdrm/dss/hdmi5.c
drivers/gpu/drm/omapdrm/dss/venc.c

index 285d297db229c208449024fd24a29b02c04a762c..8019cc9f4f9775ca96f4d7505283836957576bdd 100644 (file)
@@ -4624,7 +4624,7 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
 
        dispc_set_ops(&dispc_ops);
 
-       dispc.debugfs = dss_debugfs_create_file("dispc", dispc_dump_regs,
+       dispc.debugfs = dss_debugfs_create_file(dss, "dispc", dispc_dump_regs,
                                                &dispc);
 
        return 0;
index 448986031a6aaab6d56c70a0089c567af77b05c3..05030dc25c72c6a145eee3fbb335c7a76387863d 100644 (file)
@@ -5576,20 +5576,20 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
        dsi_runtime_put(dsidev);
 
        if (dsi->module_id == 0)
-               dsi->debugfs.regs = dss_debugfs_create_file("dsi1_regs",
+               dsi->debugfs.regs = dss_debugfs_create_file(dss, "dsi1_regs",
                                                            dsi1_dump_regs,
                                                            &dsi);
        else
-               dsi->debugfs.regs = dss_debugfs_create_file("dsi2_regs",
+               dsi->debugfs.regs = dss_debugfs_create_file(dss, "dsi2_regs",
                                                            dsi2_dump_regs,
                                                            &dsi);
 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
        if (dsi->module_id == 0)
-               dsi->debugfs.irqs = dss_debugfs_create_file("dsi1_irqs",
+               dsi->debugfs.irqs = dss_debugfs_create_file(dss, "dsi1_irqs",
                                                            dsi1_dump_irqs,
                                                            &dsi);
        else
-               dsi->debugfs.irqs = dss_debugfs_create_file("dsi2_irqs",
+               dsi->debugfs.irqs = dss_debugfs_create_file(dss, "dsi2_irqs",
                                                            dsi2_dump_irqs,
                                                            &dsi);
 #endif
index 14a86e2c6d83e2d7cf6cbb2136d4a5347f9461b8..7a5f5f233ad0d6100cf8ee80a15adface623c3f2 100644 (file)
@@ -901,25 +901,22 @@ static int dss_debug_dump_clocks(struct seq_file *s, void *p)
        return 0;
 }
 
-static struct dentry *dss_debugfs_dir;
-
 static int dss_initialize_debugfs(struct dss_device *dss)
 {
-       dss_debugfs_dir = debugfs_create_dir("omapdss", NULL);
-       if (IS_ERR(dss_debugfs_dir)) {
-               int err = PTR_ERR(dss_debugfs_dir);
+       struct dentry *dir;
 
-               dss_debugfs_dir = NULL;
-               return err;
-       }
+       dir = debugfs_create_dir("omapdss", NULL);
+       if (IS_ERR(dir))
+               return PTR_ERR(dir);
+
+       dss->debugfs.root = dir;
 
        return 0;
 }
 
-static void dss_uninitialize_debugfs(void)
+static void dss_uninitialize_debugfs(struct dss_device *dss)
 {
-       if (dss_debugfs_dir)
-               debugfs_remove_recursive(dss_debugfs_dir);
+       debugfs_remove_recursive(dss->debugfs.root);
 }
 
 struct dss_debugfs_entry {
@@ -942,8 +939,10 @@ static const struct file_operations dss_debug_fops = {
        .release        = single_release,
 };
 
-struct dss_debugfs_entry *dss_debugfs_create_file(const char *name,
-               int (*show_fn)(struct seq_file *s, void *data), void *data)
+struct dss_debugfs_entry *
+dss_debugfs_create_file(struct dss_device *dss, const char *name,
+                       int (*show_fn)(struct seq_file *s, void *data),
+                       void *data)
 {
        struct dss_debugfs_entry *entry;
        struct dentry *d;
@@ -955,7 +954,7 @@ struct dss_debugfs_entry *dss_debugfs_create_file(const char *name,
        entry->show_fn = show_fn;
        entry->data = data;
 
-       d = debugfs_create_file(name, 0444, dss_debugfs_dir, entry,
+       d = debugfs_create_file(name, 0444, dss->debugfs.root, entry,
                                &dss_debug_fops);
        if (IS_ERR(d)) {
                kfree(entry);
@@ -980,7 +979,7 @@ static inline int dss_initialize_debugfs(struct dss_device *dss)
 {
        return 0;
 }
-static inline void dss_uninitialize_debugfs(void)
+static inline void dss_uninitialize_debugfs(struct dss_device *dss)
 {
 }
 #endif /* CONFIG_OMAP2_DSS_DEBUGFS */
@@ -1472,9 +1471,10 @@ static int dss_probe(struct platform_device *pdev)
        if (r)
                goto err_pm_runtime_disable;
 
-       dss->debugfs.clk = dss_debugfs_create_file("clk", dss_debug_dump_clocks,
+       dss->debugfs.clk = dss_debugfs_create_file(dss, "clk",
+                                                  dss_debug_dump_clocks, dss);
+       dss->debugfs.dss = dss_debugfs_create_file(dss, "dss", dss_dump_regs,
                                                   dss);
-       dss->debugfs.dss = dss_debugfs_create_file("dss", dss_dump_regs, dss);
 
        /* Add all the child devices as components. */
        device_for_each_child(&pdev->dev, &match, dss_add_child_component);
@@ -1488,7 +1488,7 @@ static int dss_probe(struct platform_device *pdev)
 err_uninit_debugfs:
        dss_debugfs_remove_file(dss->debugfs.clk);
        dss_debugfs_remove_file(dss->debugfs.dss);
-       dss_uninitialize_debugfs();
+       dss_uninitialize_debugfs(dss);
 
 err_pm_runtime_disable:
        pm_runtime_disable(&pdev->dev);
@@ -1517,7 +1517,7 @@ static int dss_remove(struct platform_device *pdev)
 
        dss_debugfs_remove_file(dss->debugfs.clk);
        dss_debugfs_remove_file(dss->debugfs.dss);
-       dss_uninitialize_debugfs();
+       dss_uninitialize_debugfs(dss);
 
        pm_runtime_disable(&pdev->dev);
 
index 8cc4b6ca203e89be44eabbe7c7d7414382d99926..764c52025a2744bed10efabac1c3204689151179 100644 (file)
@@ -263,6 +263,7 @@ struct dss_device {
        const struct dss_features *feat;
 
        struct {
+               struct dentry *root;
                struct dss_debugfs_entry *clk;
                struct dss_debugfs_entry *dss;
        } debugfs;
@@ -290,12 +291,14 @@ static inline bool dss_mgr_is_lcd(enum omap_channel id)
 
 /* DSS */
 #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
-struct dss_debugfs_entry *dss_debugfs_create_file(const char *name,
-               int (*show_fn)(struct seq_file *s, void *data), void *data);
+struct dss_debugfs_entry *
+dss_debugfs_create_file(struct dss_device *dss, const char *name,
+                       int (*show_fn)(struct seq_file *s, void *data),
+                       void *data);
 void dss_debugfs_remove_file(struct dss_debugfs_entry *entry);
 #else
 static inline struct dss_debugfs_entry *
-dss_debugfs_create_file(const char *name,
+dss_debugfs_create_file(struct dss_device *dss, const char *name,
                        int (*show_fn)(struct seq_file *s, void *data),
                        void *data)
 {
index e528b7a223e19d7ac72bb56fe2b04ab4968efdfc..48608ebfeb0c4f0e048252032fc06bb8ba0092d5 100644 (file)
@@ -780,7 +780,8 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data)
                return r;
        }
 
-       hdmi.debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, &hdmi);
+       hdmi.debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
+                                              &hdmi);
 
        return 0;
 err:
index b3b9d17eb0e21475d2c583ea181c8634d5aa11f6..8ede19c3d8e7a6e62a7e5b21ad262487440918c6 100644 (file)
@@ -777,7 +777,8 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data)
                return r;
        }
 
-       hdmi.debugfs = dss_debugfs_create_file("hdmi", hdmi_dump_regs, &hdmi);
+       hdmi.debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
+                                              &hdmi);
 
        return 0;
 err:
index 967a192e178996417d48cb64f92bf28cd885dd20..ed756d4c7210b2fd72eafa565b4c814de1aac687 100644 (file)
@@ -917,7 +917,8 @@ static int venc_bind(struct device *dev, struct device *master, void *data)
                goto err_probe_of;
        }
 
-       venc.debugfs = dss_debugfs_create_file("venc", venc_dump_regs, &venc);
+       venc.debugfs = dss_debugfs_create_file(dss, "venc", venc_dump_regs,
+                                               &venc);
 
        venc_init_output(pdev);