lkml.org 
[lkml]   [2014]   [Jan]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] pwm: core: Use devm_kzalloc instead of kzalloc
Date
Use devm_kzalloc 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>
---
drivers/pwm/core.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 2ca9504..74c9f9a 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,9 @@ int pwmchip_add(struct pwm_chip *chip)
if (ret < 0)
goto out;

- chip->pwms = kzalloc(chip->npwm * sizeof(*pwm), GFP_KERNEL);
+ chip->pwms = devm_kzalloc(chip->dev,
+ chip->npwm * sizeof(*pwm),
+ GFP_KERNEL);
if (!chip->pwms) {
ret = -ENOMEM;
goto out;
--
1.8.4



\
 
 \ /
  Last update: 2014-01-07 08:41    [W:0.042 / U:0.800 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site