Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers/video/backlight/wm831x_bl.c: use devm_ functions

The various devm_ functions allocate memory that is released when a driver
detaches. This patch uses these functions for data that is allocated in
the probe function of a platform device and is only freed in the remove
function.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Julia Lawall and committed by
Linus Torvalds
1107d40a 462dd838

+1 -5
+1 -5
drivers/video/backlight/wm831x_bl.c
··· 186 186 if (ret < 0) 187 187 return ret; 188 188 189 - data = kzalloc(sizeof(*data), GFP_KERNEL); 189 + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 190 190 if (data == NULL) 191 191 return -ENOMEM; 192 192 ··· 200 200 &wm831x_backlight_ops, &props); 201 201 if (IS_ERR(bl)) { 202 202 dev_err(&pdev->dev, "failed to register backlight\n"); 203 - kfree(data); 204 203 return PTR_ERR(bl); 205 204 } 206 205 ··· 210 211 /* Disable the DCDC if it was started so we can bootstrap */ 211 212 wm831x_set_bits(wm831x, WM831X_DCDC_ENABLE, WM831X_DC4_ENA, 0); 212 213 213 - 214 214 backlight_update_status(bl); 215 215 216 216 return 0; ··· 218 220 static int wm831x_backlight_remove(struct platform_device *pdev) 219 221 { 220 222 struct backlight_device *bl = platform_get_drvdata(pdev); 221 - struct wm831x_backlight_data *data = bl_get_data(bl); 222 223 223 224 backlight_device_unregister(bl); 224 - kfree(data); 225 225 return 0; 226 226 } 227 227