* [PATCH] nvmem: mxs-ocotp: Use devm_add_action_or_reset() for cleanup
@ 2020-03-14 7:11 Anson Huang
2020-03-18 13:41 ` Srinivas Kandagatla
0 siblings, 1 reply; 2+ messages in thread
From: Anson Huang @ 2020-03-14 7:11 UTC (permalink / raw)
To: srinivas.kandagatla, shawnguo, s.hauer, kernel, festevam,
linux-arm-kernel, linux-kernel
Cc: Linux-imx
Use devm_add_action_or_reset() for cleanup to call clk_unprepare(),
which can simplify the error handling in .probe, and .remove callback
can be dropped.
Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
drivers/nvmem/mxs-ocotp.c | 30 +++++++++++-------------------
1 file changed, 11 insertions(+), 19 deletions(-)
diff --git a/drivers/nvmem/mxs-ocotp.c b/drivers/nvmem/mxs-ocotp.c
index 8e4898d..588ab56 100644
--- a/drivers/nvmem/mxs-ocotp.c
+++ b/drivers/nvmem/mxs-ocotp.c
@@ -130,6 +130,11 @@ static const struct of_device_id mxs_ocotp_match[] = {
};
MODULE_DEVICE_TABLE(of, mxs_ocotp_match);
+static void mxs_ocotp_action(void *data)
+{
+ clk_unprepare(data);
+}
+
static int mxs_ocotp_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -160,39 +165,26 @@ static int mxs_ocotp_probe(struct platform_device *pdev)
return ret;
}
+ ret = devm_add_action_or_reset(&pdev->dev, mxs_ocotp_action, otp->clk);
+ if (ret)
+ return ret;
+
data = match->data;
ocotp_config.size = data->size;
ocotp_config.priv = otp;
ocotp_config.dev = dev;
otp->nvmem = devm_nvmem_register(dev, &ocotp_config);
- if (IS_ERR(otp->nvmem)) {
- ret = PTR_ERR(otp->nvmem);
- goto err_clk;
- }
+ if (IS_ERR(otp->nvmem))
+ return PTR_ERR(otp->nvmem);
platform_set_drvdata(pdev, otp);
return 0;
-
-err_clk:
- clk_unprepare(otp->clk);
-
- return ret;
-}
-
-static int mxs_ocotp_remove(struct platform_device *pdev)
-{
- struct mxs_ocotp *otp = platform_get_drvdata(pdev);
-
- clk_unprepare(otp->clk);
-
- return 0;
}
static struct platform_driver mxs_ocotp_driver = {
.probe = mxs_ocotp_probe,
- .remove = mxs_ocotp_remove,
.driver = {
.name = "mxs-ocotp",
.of_match_table = mxs_ocotp_match,
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] nvmem: mxs-ocotp: Use devm_add_action_or_reset() for cleanup
2020-03-14 7:11 [PATCH] nvmem: mxs-ocotp: Use devm_add_action_or_reset() for cleanup Anson Huang
@ 2020-03-18 13:41 ` Srinivas Kandagatla
0 siblings, 0 replies; 2+ messages in thread
From: Srinivas Kandagatla @ 2020-03-18 13:41 UTC (permalink / raw)
To: Anson Huang, shawnguo, s.hauer, kernel, festevam,
linux-arm-kernel, linux-kernel
Cc: Linux-imx
On 14/03/2020 07:11, Anson Huang wrote:
> Use devm_add_action_or_reset() for cleanup to call clk_unprepare(),
> which can simplify the error handling in .probe, and .remove callback
> can be dropped.
>
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> ---
> drivers/nvmem/mxs-ocotp.c | 30 +++++++++++-------------------
> 1 file changed, 11 insertions(+), 19 deletions(-)
>
Applied thanks,
srini
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-03-18 13:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-14 7:11 [PATCH] nvmem: mxs-ocotp: Use devm_add_action_or_reset() for cleanup Anson Huang
2020-03-18 13:41 ` Srinivas Kandagatla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).