From patchwork Fri Oct 13 14:59:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 10005061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 93B8560216 for ; Fri, 13 Oct 2017 15:03:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 845F5290A4 for ; Fri, 13 Oct 2017 15:03:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79769290A6; Fri, 13 Oct 2017 15:03:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CEE64290A4 for ; Fri, 13 Oct 2017 15:03:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A92786EB71; Fri, 13 Oct 2017 15:00:24 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from galahad.ideasonboard.com (galahad.ideasonboard.com [185.26.127.97]) by gabe.freedesktop.org (Postfix) with ESMTPS id B80956EBEB for ; Fri, 13 Oct 2017 15:00:18 +0000 (UTC) Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 2400920D30; Fri, 13 Oct 2017 16:59:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1507906766; bh=VX8MC4JeOd9VSvOjj8GfdjaaWJrP5N4AIl7V3nUCfng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZlDbO2aJPXovP9LwEWlPbiNm+DGimnY/onduXvtZot7acqa2VOpntbTmt2jOECYpw xkn2C4iTJXZ3L8ulWotE7q0wOpnwbcaqOYB8ScriJW7j4PoG1wFwuD/1jVXS1Q9aR9 L+7K+70/rZG4LEgwtjQMHW9SCrIKYB/RacPBXU/4= From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Subject: [PATCH 47/48] drm: omapdrm: dss: Store the debugfs root directory in struct dss_device Date: Fri, 13 Oct 2017 17:59:43 +0300 Message-Id: <20171013145944.26557-48-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171013145944.26557-1-laurent.pinchart@ideasonboard.com> References: <20171013145944.26557-1-laurent.pinchart@ideasonboard.com> Cc: Tomi Valkeinen X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Sebastian Reichel --- drivers/gpu/drm/omapdrm/dss/dispc.c | 2 +- drivers/gpu/drm/omapdrm/dss/dsi.c | 8 ++++---- drivers/gpu/drm/omapdrm/dss/dss.c | 39 +++++++++++++++++++------------------ drivers/gpu/drm/omapdrm/dss/dss.h | 9 ++++++--- drivers/gpu/drm/omapdrm/dss/hdmi4.c | 3 ++- drivers/gpu/drm/omapdrm/dss/hdmi5.c | 3 ++- drivers/gpu/drm/omapdrm/dss/venc.c | 3 ++- 7 files changed, 37 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index aaf7396f0273..5eacf4cdac54 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -4772,7 +4772,7 @@ static int dispc_bind(struct device *dev, struct device *master, void *data) dispc_set_ops(&dispc_ops); dss->dispc = dispc; - dispc->debugfs = dss_debugfs_create_file("dispc", dispc_dump_regs, + dispc->debugfs = dss_debugfs_create_file(dss, "dispc", dispc_dump_regs, dispc); return 0; diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index c7700dfccc08..48ea5285cf20 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -5453,20 +5453,20 @@ static int dsi_bind(struct device *dev, struct device *master, void *data) dsi_runtime_put(dsi); 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 diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c index 5d927dfe0a7f..f4e15850cc9d 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.c +++ b/drivers/gpu/drm/omapdrm/dss/dss.c @@ -906,25 +906,23 @@ 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); + static 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); + if (dss->debugfs.root) + debugfs_remove_recursive(dss->debugfs.root); } struct dss_debugfs_entry { @@ -947,8 +945,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; @@ -960,7 +960,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); @@ -985,7 +985,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 */ @@ -1382,9 +1382,10 @@ static int dss_bind(struct device *dev) if (r) goto err_component; - 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); pm_set_vt_switch(0); @@ -1511,7 +1512,7 @@ static int dss_probe(struct platform_device *pdev) return 0; err_debugfs: - dss_uninitialize_debugfs(); + dss_uninitialize_debugfs(dss); err_free_dss: kfree(dss); return r; @@ -1523,7 +1524,7 @@ static int dss_remove(struct platform_device *pdev) component_master_del(&pdev->dev, &dss_component_ops); - dss_uninitialize_debugfs(); + dss_uninitialize_debugfs(dss); kfree(dss); return 0; diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index ceba8441c7cc..76a2561dfd22 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h @@ -271,6 +271,7 @@ struct dss_device { const struct dss_features *feat; struct { + struct dentry *root; struct dss_debugfs_entry *clk; struct dss_debugfs_entry *dss; } debugfs; @@ -299,12 +300,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) { diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c index 2050601fef0a..f523b426420f 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c @@ -800,7 +800,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; diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c index ec3b044925d0..9017d78a9756 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c @@ -794,7 +794,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; diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c index 449a82b84d03..5e475cafb7a4 100644 --- a/drivers/gpu/drm/omapdrm/dss/venc.c +++ b/drivers/gpu/drm/omapdrm/dss/venc.c @@ -940,7 +940,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(venc);