* [PATCH] drivers: ipa: use devm_kzalloc for simplicity
@ 2020-05-14 3:55 Wang Wenhu
2020-05-14 17:15 ` Jakub Kicinski
0 siblings, 1 reply; 4+ messages in thread
From: Wang Wenhu @ 2020-05-14 3:55 UTC (permalink / raw)
To: Alex Elder, David S. Miller, netdev, linux-kernel; +Cc: kernel, Wang Wenhu
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drivers: ipa: use devm_kzalloc for simplicity
2020-05-14 3:55 [PATCH] drivers: ipa: use devm_kzalloc for simplicity Wang Wenhu
@ 2020-05-14 17:15 ` Jakub Kicinski
2020-05-14 19:47 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2020-05-14 17:15 UTC (permalink / raw)
To: Wang Wenhu; +Cc: Alex Elder, David S. Miller, netdev, linux-kernel, kernel
On Wed, 13 May 2020 20:55:20 -0700 Wang Wenhu wrote:
> Make a substitution of kzalloc with devm_kzalloc to simplify the
> ipa_probe() process.
>
> Signed-off-by: Wang Wenhu <wenhu.wang@vivo.com>
The code is perfectly fine as is. What problem are you trying to solve?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drivers: ipa: use devm_kzalloc for simplicity
2020-05-14 17:15 ` Jakub Kicinski
@ 2020-05-14 19:47 ` David Miller
2020-05-18 15:03 ` Alex Elder
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2020-05-14 19:47 UTC (permalink / raw)
To: kuba; +Cc: wenhu.wang, elder, netdev, linux-kernel, kernel
From: Jakub Kicinski <kuba@kernel.org>
Date: Thu, 14 May 2020 10:15:16 -0700
> On Wed, 13 May 2020 20:55:20 -0700 Wang Wenhu wrote:
>> Make a substitution of kzalloc with devm_kzalloc to simplify the
>> ipa_probe() process.
>>
>> Signed-off-by: Wang Wenhu <wenhu.wang@vivo.com>
>
> The code is perfectly fine as is. What problem are you trying to solve?
I agree, these kinds of transformations are kind of excessive.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drivers: ipa: use devm_kzalloc for simplicity
2020-05-14 19:47 ` David Miller
@ 2020-05-18 15:03 ` Alex Elder
0 siblings, 0 replies; 4+ messages in thread
From: Alex Elder @ 2020-05-18 15:03 UTC (permalink / raw)
To: David Miller, kuba; +Cc: wenhu.wang, elder, netdev, linux-kernel, kernel
On 5/14/20 2:47 PM, David Miller wrote:
> From: Jakub Kicinski <kuba@kernel.org>
> Date: Thu, 14 May 2020 10:15:16 -0700
>
>> On Wed, 13 May 2020 20:55:20 -0700 Wang Wenhu wrote:
>>> Make a substitution of kzalloc with devm_kzalloc to simplify the
>>> ipa_probe() process.
>>>
>>> Signed-off-by: Wang Wenhu <wenhu.wang@vivo.com>
>>
>> The code is perfectly fine as is. What problem are you trying to solve?
>
> I agree, these kinds of transformations are kind of excessive.
I have considered using the devm_*() functions, but if I were to
make such a switch it would be done comprehensively, throughout
the driver. It is not something I plan to do in the near term
though.
-Alex
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-05-18 15:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-14 3:55 [PATCH] drivers: ipa: use devm_kzalloc for simplicity Wang Wenhu
2020-05-14 17:15 ` Jakub Kicinski
2020-05-14 19:47 ` David Miller
2020-05-18 15:03 ` Alex Elder
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).