summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek BehĂșn <kabel@kernel.org>2024-08-31 11:20:42 +0200
committerArnd Bergmann <arnd@arndb.de>2024-09-02 09:42:10 +0000
commit1b649ec180d41dbcdcd6d38a49cbab885661514b (patch)
treec544c977f937e58d4c3afc994863be881934231b
parent579e05ee1bfbc76bd270074916882471e88c7af3 (diff)
firmware: turris-mox-rwtm: Simplify debugfs code
Simplify debugfs code: do not check for errors, as debugfs errors should be ignored, and use devm action for dropping the debugfs directory. Signed-off-by: Marek BehĂșn <kabel@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20240831092050.23093-9-kabel@kernel.org Signed-off-by: Arnd Bergmann <arnd@arndb.de>
-rw-r--r--drivers/firmware/turris-mox-rwtm.c44
1 files changed, 11 insertions, 33 deletions
diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
index 97b40982a3e7..0462c345778c 100644
--- a/drivers/firmware/turris-mox-rwtm.c
+++ b/drivers/firmware/turris-mox-rwtm.c
@@ -91,7 +91,6 @@ struct mox_rwtm {
* It should be rewritten via crypto API once akcipher API is available
* from userspace.
*/
- struct dentry *debugfs_root;
u32 last_sig[MOX_ECC_SIGNATURE_WORDS];
bool last_sig_done;
#endif
@@ -404,39 +403,23 @@ static const struct file_operations do_sign_fops = {
.llseek = no_llseek,
};
-static int rwtm_register_debugfs(struct mox_rwtm *rwtm)
+static void rwtm_debugfs_release(void *root)
{
- struct dentry *root, *entry;
-
- root = debugfs_create_dir("turris-mox-rwtm", NULL);
-
- if (IS_ERR(root))
- return PTR_ERR(root);
-
- entry = debugfs_create_file_unsafe("do_sign", 0600, root, rwtm,
- &do_sign_fops);
- if (IS_ERR(entry))
- goto err_remove;
-
- rwtm->debugfs_root = root;
-
- return 0;
-err_remove:
debugfs_remove_recursive(root);
- return PTR_ERR(entry);
}
-static void rwtm_unregister_debugfs(struct mox_rwtm *rwtm)
+static void rwtm_register_debugfs(struct mox_rwtm *rwtm)
{
- debugfs_remove_recursive(rwtm->debugfs_root);
+ struct dentry *root;
+
+ root = debugfs_create_dir("turris-mox-rwtm", NULL);
+
+ debugfs_create_file_unsafe("do_sign", 0600, root, rwtm, &do_sign_fops);
+
+ devm_add_action_or_reset(rwtm->dev, rwtm_debugfs_release, root);
}
#else
-static inline int rwtm_register_debugfs(struct mox_rwtm *rwtm)
-{
- return 0;
-}
-
-static inline void rwtm_unregister_debugfs(struct mox_rwtm *rwtm)
+static inline void rwtm_register_debugfs(struct mox_rwtm *rwtm)
{
}
#endif
@@ -500,11 +483,7 @@ static int turris_mox_rwtm_probe(struct platform_device *pdev)
goto free_channel;
}
- ret = rwtm_register_debugfs(rwtm);
- if (ret < 0) {
- dev_err(dev, "Failed creating debugfs entries: %i\n", ret);
- goto free_channel;
- }
+ rwtm_register_debugfs(rwtm);
dev_info(dev, "HWRNG successfully registered\n");
@@ -528,7 +507,6 @@ static void turris_mox_rwtm_remove(struct platform_device *pdev)
{
struct mox_rwtm *rwtm = platform_get_drvdata(pdev);
- rwtm_unregister_debugfs(rwtm);
mbox_free_channel(rwtm->mbox);
}