[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210423095743.v5.5.I5fe072753290c6a77eda736ebd5778e17b7cb0fb@changeid>
Date: Fri, 23 Apr 2021 09:58:51 -0700
From: Douglas Anderson <dianders@...omium.org>
To: Andrzej Hajda <a.hajda@...sung.com>,
Neil Armstrong <narmstrong@...libre.com>,
Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
Jonas Karlman <jonas@...boo.se>,
Jernej Skrabec <jernej.skrabec@...l.net>,
Sam Ravnborg <sam@...nborg.org>, Wolfram Sang <wsa@...nel.org>
Cc: linux-arm-msm@...r.kernel.org, robdclark@...omium.org,
Stanislav Lisovskiy <stanislav.lisovskiy@...el.com>,
Stephen Boyd <swboyd@...omium.org>,
Steev Klimaszewski <steev@...i.org>,
Linus W <linus.walleij@...aro.org>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
linux-i2c@...r.kernel.org,
Bjorn Andersson <bjorn.andersson@...aro.org>,
dri-devel@...ts.freedesktop.org,
Douglas Anderson <dianders@...omium.org>,
Daniel Vetter <daniel@...ll.ch>,
David Airlie <airlied@...ux.ie>,
Robert Foss <robert.foss@...aro.org>,
linux-kernel@...r.kernel.org
Subject: [PATCH v5 05/20] drm/bridge: ti-sn65dsi86: Clean debugfs code
Let's cleanup the debugfs code to:
- Check for errors.
- Use devm to manage freeing, which also means we don't need to store
a pointer in our structure.
Signed-off-by: Douglas Anderson <dianders@...omium.org>
---
Bjorn: I left off your tag on this patch since I made changes compared
to v4. Can you re-add if it still looks OK? This is now ordered
_after_ the pm_runtime patch so I believe the ordering problem you
pointed out should be fixed as well?
Changes in v5:
- Don't print debugfs creation errors.
- Handle NULL from debugfs_create_dir() which is documented possible.
drivers/gpu/drm/bridge/ti-sn65dsi86.c | 33 +++++++++++++++++----------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
index 44d8395505f0..8aa36074aab9 100644
--- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c
+++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
@@ -118,7 +118,6 @@
* @aux: Our aux channel.
* @bridge: Our bridge.
* @connector: Our connector.
- * @debugfs: Used for managing our debugfs.
* @host_node: Remote DSI node.
* @dsi: Our MIPI DSI source.
* @edid: Detected EDID of eDP panel.
@@ -146,7 +145,6 @@ struct ti_sn65dsi86 {
struct drm_dp_aux aux;
struct drm_bridge bridge;
struct drm_connector connector;
- struct dentry *debugfs;
struct edid *edid;
struct device_node *host_node;
struct mipi_dsi_device *dsi;
@@ -245,18 +243,31 @@ static int status_show(struct seq_file *s, void *data)
DEFINE_SHOW_ATTRIBUTE(status);
-static void ti_sn65dsi86_debugfs_init(struct ti_sn65dsi86 *pdata)
+static void ti_sn65dsi86_debugfs_remove(void *data)
{
- pdata->debugfs = debugfs_create_dir(dev_name(pdata->dev), NULL);
-
- debugfs_create_file("status", 0600, pdata->debugfs, pdata,
- &status_fops);
+ debugfs_remove_recursive(data);
}
-static void ti_sn65dsi86_debugfs_remove(struct ti_sn65dsi86 *pdata)
+static void ti_sn65dsi86_debugfs_init(struct ti_sn65dsi86 *pdata)
{
- debugfs_remove_recursive(pdata->debugfs);
- pdata->debugfs = NULL;
+ struct device *dev = pdata->dev;
+ struct dentry *debugfs;
+ int ret;
+
+ debugfs = debugfs_create_dir(dev_name(dev), NULL);
+
+ /*
+ * We might get an error back if debugfs wasn't enabled in the kernel
+ * so let's just silently return upon failure.
+ */
+ if (IS_ERR_OR_NULL(debugfs))
+ return;
+
+ ret = devm_add_action_or_reset(dev, ti_sn65dsi86_debugfs_remove, debugfs);
+ if (ret)
+ return;
+
+ debugfs_create_file("status", 0600, debugfs, pdata, &status_fops);
}
/* Connector funcs */
@@ -1316,8 +1327,6 @@ static int ti_sn65dsi86_remove(struct i2c_client *client)
kfree(pdata->edid);
- ti_sn65dsi86_debugfs_remove(pdata);
-
drm_bridge_remove(&pdata->bridge);
of_node_put(pdata->host_node);
--
2.31.1.498.g6c1eba8ee3d-goog
Powered by blists - more mailing lists