Skip to contentSkip to conversation

drivers/vidfeo/backlight: ld9040 cleanups

PATCH New Axel Lin 1 participant 1 message Jun 28, 2011

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 drivers/vidfeo/backlight: ld9040 cleanups

This patch includes below fixes:
1. Fix checking wrong return value for backlight_device_register.
2. Properly free allocated resources in ld9040_probe() error path and ld9040_remove().

---
 drivers/video/backlight/ld9040.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
drivers/video/backlight/ld9040.c +6 -3
index 7281b25..62bcde3 100644
@@ -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;
@@ -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;
@@ -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);
 
Signature · 1 line
1.7.4.1