* [PATCH v2] pwm: core: Use devm_kcalloc instead of kzalloc
@ 2014-01-07 6:45 Xiubo Li
0 siblings, 0 replies; only message in thread
From: Xiubo Li @ 2014-01-07 6:45 UTC (permalink / raw)
To: thierry.reding; +Cc: joe, linux-pwm, linux-kernel, Xiubo Li
Use devm_kcalloc instead of kzalloc to free automatically and make
the cleanup paths simpler and the code slightly shorter.
Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
---
Changed in v2:
- Use devm_kcalloc instead of devm_kzalloc.
Changed in v1:
- Use devm_kzalloc instead of kzalloc.
drivers/pwm/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 2ca9504..75220e8 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -80,7 +80,6 @@ static void free_pwms(struct pwm_chip *chip)
bitmap_clear(allocated_pwms, chip->base, chip->npwm);
- kfree(chip->pwms);
chip->pwms = NULL;
}
@@ -245,7 +244,8 @@ int pwmchip_add(struct pwm_chip *chip)
if (ret < 0)
goto out;
- chip->pwms = kzalloc(chip->npwm * sizeof(*pwm), GFP_KERNEL);
+ chip->pwms = devm_kcalloc(chip->dev, chip->npwm,
+ sizeof(*pwm), GFP_KERNEL);
if (!chip->pwms) {
ret = -ENOMEM;
goto out;
--
1.8.4
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-01-07 7:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-07 6:45 [PATCH v2] pwm: core: Use devm_kcalloc instead of kzalloc Xiubo Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®