backlight: blackfin - Fix missing registration failure handling
authorBruno Prémont <bonbons@linux-vserver.org>
Fri, 26 Feb 2010 12:04:54 +0000 (13:04 +0100)
committerRichard Purdie <rpurdie@linux.intel.com>
Tue, 16 Mar 2010 20:10:17 +0000 (20:10 +0000)
Check newly registered backlight_device for error and properly
return error to parent
Mark struct backlight_ops as const.

Signed-off-by: Bruno Prémont <bonbons@linux-vserver.org>
Acked-by: Mike Frysinger <vapier@gentoo.org> (constify struct backlight_ops)
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
drivers/video/bf54x-lq043fb.c
drivers/video/bfin-t350mcqb-fb.c

index 54df3d44af8f34c42cc5d1b023d9f46b76c6ff77..23b2a8c0dbfcbdee211e253a5df9fd7b19aad80a 100644 (file)
@@ -433,7 +433,7 @@ static int bl_get_brightness(struct backlight_device *bd)
        return 0;
 }
 
-static struct backlight_ops bfin_lq043fb_bl_ops = {
+static const struct backlight_ops bfin_lq043fb_bl_ops = {
        .get_brightness = bl_get_brightness,
 };
 
@@ -650,6 +650,12 @@ static int __devinit bfin_bf54x_probe(struct platform_device *pdev)
        props.max_brightness = 255;
        bl_dev = backlight_device_register("bf54x-bl", NULL, NULL,
                                           &bfin_lq043fb_bl_ops, &props);
+       if (IS_ERR(bl_dev)) {
+               printk(KERN_ERR DRIVER_NAME
+                       ": unable to register backlight.\n");
+               ret = -EINVAL;
+               goto out9;
+       }
 
        lcd_dev = lcd_device_register(DRIVER_NAME, &pdev->dev, NULL, &bfin_lcd_ops);
        lcd_dev->props.max_contrast = 255, printk(KERN_INFO "Done.\n");
@@ -657,6 +663,8 @@ static int __devinit bfin_bf54x_probe(struct platform_device *pdev)
 
        return 0;
 
+out9:
+       unregister_framebuffer(fbinfo);
 out8:
        free_irq(info->irq, info);
 out7:
index 3a8e811a7e9ffe56da3e04ec76ba80f9a0456da7..31a2dec927bb4da2615b1023307a83c2a0e10061 100644 (file)
@@ -352,7 +352,7 @@ static int bl_get_brightness(struct backlight_device *bd)
        return 0;
 }
 
-static struct backlight_ops bfin_lq043fb_bl_ops = {
+static const struct backlight_ops bfin_lq043fb_bl_ops = {
        .get_brightness = bl_get_brightness,
 };
 
@@ -545,6 +545,12 @@ static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev)
        props.max_brightness = 255;
        bl_dev = backlight_device_register("bf52x-bl", NULL, NULL,
                                           &bfin_lq043fb_bl_ops, &props);
+       if (IS_ERR(bl_dev)) {
+               printk(KERN_ERR DRIVER_NAME
+                       ": unable to register backlight.\n");
+               ret = -EINVAL;
+               goto out9;
+       }
 
        lcd_dev = lcd_device_register(DRIVER_NAME, NULL, &bfin_lcd_ops);
        lcd_dev->props.max_contrast = 255, printk(KERN_INFO "Done.\n");
@@ -552,6 +558,8 @@ static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev)
 
        return 0;
 
+out9:
+       unregister_framebuffer(fbinfo);
 out8:
        free_irq(info->irq, info);
 out7: