Commit 06c96f189bf94448779db66944836a827517d6c9
Committed by
Linus Torvalds
1 parent
80629efcae
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
backlight: corgi_lcd: 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>
Showing 1 changed file with 4 additions and 8 deletions Side-by-side Diff
drivers/video/backlight/corgi_lcd.c
... | ... | @@ -544,7 +544,7 @@ |
544 | 544 | return -EINVAL; |
545 | 545 | } |
546 | 546 | |
547 | - lcd = kzalloc(sizeof(struct corgi_lcd), GFP_KERNEL); | |
547 | + lcd = devm_kzalloc(&spi->dev, sizeof(struct corgi_lcd), GFP_KERNEL); | |
548 | 548 | if (!lcd) { |
549 | 549 | dev_err(&spi->dev, "failed to allocate memory\n"); |
550 | 550 | return -ENOMEM; |
... | ... | @@ -554,10 +554,9 @@ |
554 | 554 | |
555 | 555 | lcd->lcd_dev = lcd_device_register("corgi_lcd", &spi->dev, |
556 | 556 | lcd, &corgi_lcd_ops); |
557 | - if (IS_ERR(lcd->lcd_dev)) { | |
558 | - ret = PTR_ERR(lcd->lcd_dev); | |
559 | - goto err_free_lcd; | |
560 | - } | |
557 | + if (IS_ERR(lcd->lcd_dev)) | |
558 | + return PTR_ERR(lcd->lcd_dev); | |
559 | + | |
561 | 560 | lcd->power = FB_BLANK_POWERDOWN; |
562 | 561 | lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA; |
563 | 562 | |
... | ... | @@ -591,8 +590,6 @@ |
591 | 590 | backlight_device_unregister(lcd->bl_dev); |
592 | 591 | err_unregister_lcd: |
593 | 592 | lcd_device_unregister(lcd->lcd_dev); |
594 | -err_free_lcd: | |
595 | - kfree(lcd); | |
596 | 593 | return ret; |
597 | 594 | } |
598 | 595 | |
... | ... | @@ -613,7 +610,6 @@ |
613 | 610 | |
614 | 611 | corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN); |
615 | 612 | lcd_device_unregister(lcd->lcd_dev); |
616 | - kfree(lcd); | |
617 | 613 | |
618 | 614 | return 0; |
619 | 615 | } |