lkml.org 
[lkml]   [2020]   [May]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] drivers: ipa: use devm_kzalloc for simplicity
Date
Make a substitution of kzalloc with devm_kzalloc to simplify the
ipa_probe() process.

Signed-off-by: Wang Wenhu <wenhu.wang@vivo.com>
Cc: Alex Elder <elder@kernel.org>
---
drivers/net/ipa/ipa_clock.c | 7 ++-----
drivers/net/ipa/ipa_main.c | 7 ++-----
2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ipa/ipa_clock.c b/drivers/net/ipa/ipa_clock.c
index 374491ea11cf..ddbd687fe64b 100644
--- a/drivers/net/ipa/ipa_clock.c
+++ b/drivers/net/ipa/ipa_clock.c
@@ -276,7 +276,7 @@ struct ipa_clock *ipa_clock_init(struct device *dev)
goto err_clk_put;
}

- clock = kzalloc(sizeof(*clock), GFP_KERNEL);
+ clock = devm_kzalloc(dev, sizeof(*clock), GFP_KERNEL);
if (!clock) {
ret = -ENOMEM;
goto err_clk_put;
@@ -285,15 +285,13 @@ struct ipa_clock *ipa_clock_init(struct device *dev)

ret = ipa_interconnect_init(clock, dev);
if (ret)
- goto err_kfree;
+ goto err_clk_put;

mutex_init(&clock->mutex);
atomic_set(&clock->count, 0);

return clock;

-err_kfree:
- kfree(clock);
err_clk_put:
clk_put(clk);

@@ -308,6 +306,5 @@ void ipa_clock_exit(struct ipa_clock *clock)
WARN_ON(atomic_read(&clock->count) != 0);
mutex_destroy(&clock->mutex);
ipa_interconnect_exit(clock);
- kfree(clock);
clk_put(clk);
}
diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c
index 28998dcce3d2..b7b348b863f7 100644
--- a/drivers/net/ipa/ipa_main.c
+++ b/drivers/net/ipa/ipa_main.c
@@ -760,7 +760,7 @@ static int ipa_probe(struct platform_device *pdev)
}

/* Allocate and initialize the IPA structure */
- ipa = kzalloc(sizeof(*ipa), GFP_KERNEL);
+ ipa = devm_kzalloc(dev, sizeof(*ipa), GFP_KERNEL);
if (!ipa) {
ret = -ENOMEM;
goto err_wakeup_source_unregister;
@@ -776,7 +776,7 @@ static int ipa_probe(struct platform_device *pdev)

ret = ipa_reg_init(ipa);
if (ret)
- goto err_kfree_ipa;
+ goto err_wakeup_source_unregister;

ret = ipa_mem_init(ipa, data->mem_count, data->mem_data);
if (ret)
@@ -848,8 +848,6 @@ static int ipa_probe(struct platform_device *pdev)
ipa_mem_exit(ipa);
err_reg_exit:
ipa_reg_exit(ipa);
-err_kfree_ipa:
- kfree(ipa);
err_wakeup_source_unregister:
wakeup_source_unregister(wakeup_source);
err_clock_exit:
@@ -885,7 +883,6 @@ static int ipa_remove(struct platform_device *pdev)
gsi_exit(&ipa->gsi);
ipa_mem_exit(ipa);
ipa_reg_exit(ipa);
- kfree(ipa);
wakeup_source_unregister(wakeup_source);
ipa_clock_exit(clock);
rproc_put(rproc);
--
2.17.1
\
 
 \ /
  Last update: 2020-05-14 05:57    [W:0.079 / U:7.812 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site