lkml.org 
[lkml]   [2012]   [Jul]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 25/25] leds: convert One-shot LED trigger driver to devm_kzalloc() and cleanup error exit path
Date
Cc: Fabio Baltieri <fabio.baltieri@gmail.com>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
---
drivers/leds/ledtrig-oneshot.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/leds/ledtrig-oneshot.c b/drivers/leds/ledtrig-oneshot.c
index 2c029aa..6395a38 100644
--- a/drivers/leds/ledtrig-oneshot.c
+++ b/drivers/leds/ledtrig-oneshot.c
@@ -127,7 +127,8 @@ static void oneshot_trig_activate(struct led_classdev *led_cdev)
struct oneshot_trig_data *oneshot_data;
int rc;

- oneshot_data = kzalloc(sizeof(*oneshot_data), GFP_KERNEL);
+ oneshot_data = devm_kzalloc(led_cdev->dev, sizeof(*oneshot_data),
+ GFP_KERNEL);
if (!oneshot_data)
return;

@@ -135,7 +136,7 @@ static void oneshot_trig_activate(struct led_classdev *led_cdev)

rc = device_create_file(led_cdev->dev, &dev_attr_delay_on);
if (rc)
- goto err_out_trig_data;
+ return;
rc = device_create_file(led_cdev->dev, &dev_attr_delay_off);
if (rc)
goto err_out_delayon;
@@ -159,8 +160,6 @@ err_out_delayoff:
device_remove_file(led_cdev->dev, &dev_attr_delay_off);
err_out_delayon:
device_remove_file(led_cdev->dev, &dev_attr_delay_on);
-err_out_trig_data:
- kfree(led_cdev->trigger_data);
}

static void oneshot_trig_deactivate(struct led_classdev *led_cdev)
@@ -172,7 +171,6 @@ static void oneshot_trig_deactivate(struct led_classdev *led_cdev)
device_remove_file(led_cdev->dev, &dev_attr_delay_off);
device_remove_file(led_cdev->dev, &dev_attr_invert);
device_remove_file(led_cdev->dev, &dev_attr_shot);
- kfree(oneshot_data);
led_cdev->activated = false;
}

--
1.7.10.4


\
 
 \ /
  Last update: 2012-07-04 08:01    [W:0.166 / U:10.448 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site