[PATCH] backlight, classmate-laptop: fix missing registrationfailure handling

From: Bruno PrÃmont
Date: Fri Feb 26 2010 - 07:22:28 EST


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@xxxxxxxxxxxxxxxxx>
---
drivers/platform/x86/classmate-laptop.c | 2 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index bfae789..66f6aad 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -452,7 +452,7 @@ static int cmpc_bl_update_status(struct backlight_device *bd)
return -1;
}

-static struct backlight_ops cmpc_bl_ops = {
+static const struct backlight_ops cmpc_bl_ops = {
.get_brightness = cmpc_bl_get_brightness,
.update_status = cmpc_bl_update_status
};
@@ -463,6 +463,8 @@ static int cmpc_bl_add(struct acpi_device *acpi)

bd = backlight_device_register("cmpc_bl", &acpi->dev,
acpi->handle, &cmpc_bl_ops);
+ if (IS_ERR(bd))
+ return PTR_ERR(bd);
bd->props.max_brightness = 7;
dev_set_drvdata(&acpi->dev, bd);
return 0;
--
1.6.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/