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 23/25] leds: convert Backlight emulation LED trigger driver to devm_kzalloc() and cleanup error exit path
Date
Cc: Rodolfo Giometti <giometti@linux.it>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
---
drivers/leds/ledtrig-backlight.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/leds/ledtrig-backlight.c b/drivers/leds/ledtrig-backlight.c
index b941685..3fa20a9 100644
--- a/drivers/leds/ledtrig-backlight.c
+++ b/drivers/leds/ledtrig-backlight.c
@@ -101,7 +101,8 @@ static void bl_trig_activate(struct led_classdev *led)

struct bl_trig_notifier *n;

- n = kzalloc(sizeof(struct bl_trig_notifier), GFP_KERNEL);
+ n = devm_kzalloc(led->dev, sizeof(struct bl_trig_notifier),
+ GFP_KERNEL);
led->trigger_data = n;
if (!n) {
dev_err(led->dev, "unable to allocate backlight trigger\n");
@@ -110,7 +111,7 @@ static void bl_trig_activate(struct led_classdev *led)

ret = device_create_file(led->dev, &dev_attr_inverted);
if (ret)
- goto err_invert;
+ led->trigger_data = NULL;

n->led = led;
n->brightness = led->brightness;
@@ -123,10 +124,6 @@ static void bl_trig_activate(struct led_classdev *led)
led->activated = true;

return;
-
-err_invert:
- led->trigger_data = NULL;
- kfree(n);
}

static void bl_trig_deactivate(struct led_classdev *led)
@@ -137,7 +134,6 @@ static void bl_trig_deactivate(struct led_classdev *led)
if (led->activated) {
device_remove_file(led->dev, &dev_attr_inverted);
fb_unregister_client(&n->notifier);
- kfree(n);
led->activated = false;
}
}
--
1.7.10.4


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