Skip to content

Commit

Permalink
drivers/video/backlight/ld9040.c: small fixes
Browse files Browse the repository at this point in the history
- Fix checking of wrong return value for backlight_device_register()

- Properly free allocated resources in ld9040_probe() error path and
  ld9040_remove().

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Cc: Donghwa Lee <dh09.lee@samsung.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>
  • Loading branch information
Axel Lin authored and Linus Torvalds committed Jul 26, 2011
1 parent ccb6108 commit e2e7da9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/video/backlight/ld9040.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,9 @@ static int ld9040_probe(struct spi_device *spi)

bd = backlight_device_register("ld9040-bl", &spi->dev,
lcd, &ld9040_backlight_ops, NULL);
if (IS_ERR(ld)) {
ret = PTR_ERR(ld);
goto out_free_lcd;
if (IS_ERR(bd)) {
ret = PTR_ERR(bd);
goto out_unregister_lcd;
}

bd->props.max_brightness = MAX_BRIGHTNESS;
Expand Down Expand Up @@ -731,6 +731,8 @@ static int ld9040_probe(struct spi_device *spi)
dev_info(&spi->dev, "ld9040 panel driver has been probed.\n");
return 0;

out_unregister_lcd:
lcd_device_unregister(lcd->ld);
out_free_lcd:
kfree(lcd);
return ret;
Expand All @@ -741,6 +743,7 @@ static int __devexit ld9040_remove(struct spi_device *spi)
struct ld9040 *lcd = dev_get_drvdata(&spi->dev);

ld9040_power(lcd, FB_BLANK_POWERDOWN);
backlight_device_unregister(lcd->bd);
lcd_device_unregister(lcd->ld);
kfree(lcd);

Expand Down

0 comments on commit e2e7da9

Please sign in to comment.