summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek BehĂșn <kabel@kernel.org>2024-08-31 11:20:43 +0200
committerArnd Bergmann <arnd@arndb.de>2024-09-02 09:42:10 +0000
commitfbd48bd8cf0c4063465e2713bfaedfa71709a116 (patch)
tree5a9a82a94303703f26f4786e588d7435a70f12f6
parent1b649ec180d41dbcdcd6d38a49cbab885661514b (diff)
firmware: turris-mox-rwtm: Convert rest to devm_* and get rid of driver .remove()
Use devm resource management for driver's mailbox. This allows us to get rid of the driver's .remove() method and the gotos in .probe(). Signed-off-by: Marek BehĂșn <kabel@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20240831092050.23093-10-kabel@kernel.org Signed-off-by: Arnd Bergmann <arnd@arndb.de>
-rw-r--r--drivers/firmware/turris-mox-rwtm.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
index 0462c345778c..dd0dbaa9de72 100644
--- a/drivers/firmware/turris-mox-rwtm.c
+++ b/drivers/firmware/turris-mox-rwtm.c
@@ -424,6 +424,11 @@ static inline void rwtm_register_debugfs(struct mox_rwtm *rwtm)
}
#endif
+static void rwtm_devm_mbox_release(void *mbox)
+{
+ mbox_free_channel(mbox);
+}
+
static void rwtm_firmware_symlink_drop(void *parent)
{
sysfs_remove_link(parent, DRIVER_NAME);
@@ -462,6 +467,10 @@ static int turris_mox_rwtm_probe(struct platform_device *pdev)
return ret;
}
+ ret = devm_add_action_or_reset(dev, rwtm_devm_mbox_release, rwtm->mbox);
+ if (ret)
+ return ret;
+
ret = mox_get_board_info(rwtm);
if (ret < 0)
dev_warn(dev, "Cannot read board information: %i\n", ret);
@@ -470,7 +479,7 @@ static int turris_mox_rwtm_probe(struct platform_device *pdev)
if (ret < 0) {
dev_notice(dev,
"Firmware does not support the GET_RANDOM command\n");
- goto free_channel;
+ return ret;
}
rwtm->hwrng.name = DRIVER_NAME "_hwrng";
@@ -480,7 +489,7 @@ static int turris_mox_rwtm_probe(struct platform_device *pdev)
ret = devm_hwrng_register(dev, &rwtm->hwrng);
if (ret < 0) {
dev_err(dev, "Cannot register HWRNG: %i\n", ret);
- goto free_channel;
+ return ret;
}
rwtm_register_debugfs(rwtm);
@@ -497,17 +506,6 @@ static int turris_mox_rwtm_probe(struct platform_device *pdev)
firmware_kobj);
return 0;
-
-free_channel:
- mbox_free_channel(rwtm->mbox);
- return ret;
-}
-
-static void turris_mox_rwtm_remove(struct platform_device *pdev)
-{
- struct mox_rwtm *rwtm = platform_get_drvdata(pdev);
-
- mbox_free_channel(rwtm->mbox);
}
static const struct of_device_id turris_mox_rwtm_match[] = {
@@ -520,7 +518,6 @@ MODULE_DEVICE_TABLE(of, turris_mox_rwtm_match);
static struct platform_driver turris_mox_rwtm_driver = {
.probe = turris_mox_rwtm_probe,
- .remove_new = turris_mox_rwtm_remove,
.driver = {
.name = DRIVER_NAME,
.of_match_table = turris_mox_rwtm_match,