aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2012-05-29 18:07:24 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-29 19:22:31 -0400
commitd073adc5caf03a928a230baf2d8a86b1f9a03710 (patch)
treea6f0236ab2b2c9b052e87476977e10bee3a75464 /drivers
parent541f936f5d3993c5bbed33bdb53acd6de2403b04 (diff)
backlight: tdo24m: use devm_ functions
The devm_ functions allocate memory that is released when a driver detaches. This patch uses devm_kzalloc of these functions. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Cc: Eric Miao <eric.y.miao@gmail.com> Cc: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/backlight/tdo24m.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/drivers/video/backlight/tdo24m.c b/drivers/video/backlight/tdo24m.c
index 2368b8e5f89e..02444d042cd5 100644
--- a/drivers/video/backlight/tdo24m.c
+++ b/drivers/video/backlight/tdo24m.c
@@ -349,7 +349,7 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
349 if (err) 349 if (err)
350 return err; 350 return err;
351 351
352 lcd = kzalloc(sizeof(struct tdo24m), GFP_KERNEL); 352 lcd = devm_kzalloc(&spi->dev, sizeof(struct tdo24m), GFP_KERNEL);
353 if (!lcd) 353 if (!lcd)
354 return -ENOMEM; 354 return -ENOMEM;
355 355
@@ -357,11 +357,9 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
357 lcd->power = FB_BLANK_POWERDOWN; 357 lcd->power = FB_BLANK_POWERDOWN;
358 lcd->mode = MODE_VGA; /* default to VGA */ 358 lcd->mode = MODE_VGA; /* default to VGA */
359 359
360 lcd->buf = kmalloc(TDO24M_SPI_BUFF_SIZE, GFP_KERNEL); 360 lcd->buf = devm_kzalloc(&spi->dev, TDO24M_SPI_BUFF_SIZE, GFP_KERNEL);
361 if (lcd->buf == NULL) { 361 if (lcd->buf == NULL)
362 kfree(lcd);
363 return -ENOMEM; 362 return -ENOMEM;
364 }
365 363
366 m = &lcd->msg; 364 m = &lcd->msg;
367 x = &lcd->xfer; 365 x = &lcd->xfer;
@@ -383,15 +381,13 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
383 break; 381 break;
384 default: 382 default:
385 dev_err(&spi->dev, "Unsupported model"); 383 dev_err(&spi->dev, "Unsupported model");
386 goto out_free; 384 return -EINVAL;
387 } 385 }
388 386
389 lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev, 387 lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev,
390 lcd, &tdo24m_ops); 388 lcd, &tdo24m_ops);
391 if (IS_ERR(lcd->lcd_dev)) { 389 if (IS_ERR(lcd->lcd_dev))
392 err = PTR_ERR(lcd->lcd_dev); 390 return PTR_ERR(lcd->lcd_dev);
393 goto out_free;
394 }
395 391
396 dev_set_drvdata(&spi->dev, lcd); 392 dev_set_drvdata(&spi->dev, lcd);
397 err = tdo24m_power(lcd, FB_BLANK_UNBLANK); 393 err = tdo24m_power(lcd, FB_BLANK_UNBLANK);
@@ -402,9 +398,6 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
402 398
403out_unregister: 399out_unregister:
404 lcd_device_unregister(lcd->lcd_dev); 400 lcd_device_unregister(lcd->lcd_dev);
405out_free:
406 kfree(lcd->buf);
407 kfree(lcd);
408 return err; 401 return err;
409} 402}
410 403
@@ -414,8 +407,6 @@ static int __devexit tdo24m_remove(struct spi_device *spi)
414 407
415 tdo24m_power(lcd, FB_BLANK_POWERDOWN); 408 tdo24m_power(lcd, FB_BLANK_POWERDOWN);
416 lcd_device_unregister(lcd->lcd_dev); 409 lcd_device_unregister(lcd->lcd_dev);
417 kfree(lcd->buf);
418 kfree(lcd);
419 410
420 return 0; 411 return 0;
421} 412}