diff options
Diffstat (limited to 'drivers/video/backlight/backlight.c')
-rw-r--r-- | drivers/video/backlight/backlight.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 08703299ef61..80d292fb92d8 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c | |||
@@ -19,6 +19,12 @@ | |||
19 | #include <asm/backlight.h> | 19 | #include <asm/backlight.h> |
20 | #endif | 20 | #endif |
21 | 21 | ||
22 | static const char const *backlight_types[] = { | ||
23 | [BACKLIGHT_RAW] = "raw", | ||
24 | [BACKLIGHT_PLATFORM] = "platform", | ||
25 | [BACKLIGHT_FIRMWARE] = "firmware", | ||
26 | }; | ||
27 | |||
22 | #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \ | 28 | #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \ |
23 | defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)) | 29 | defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)) |
24 | /* This callback gets called when something important happens inside a | 30 | /* This callback gets called when something important happens inside a |
@@ -169,6 +175,14 @@ static ssize_t backlight_store_brightness(struct device *dev, | |||
169 | return rc; | 175 | return rc; |
170 | } | 176 | } |
171 | 177 | ||
178 | static ssize_t backlight_show_type(struct device *dev, | ||
179 | struct device_attribute *attr, char *buf) | ||
180 | { | ||
181 | struct backlight_device *bd = to_backlight_device(dev); | ||
182 | |||
183 | return sprintf(buf, "%s\n", backlight_types[bd->props.type]); | ||
184 | } | ||
185 | |||
172 | static ssize_t backlight_show_max_brightness(struct device *dev, | 186 | static ssize_t backlight_show_max_brightness(struct device *dev, |
173 | struct device_attribute *attr, char *buf) | 187 | struct device_attribute *attr, char *buf) |
174 | { | 188 | { |
@@ -234,6 +248,7 @@ static struct device_attribute bl_device_attributes[] = { | |||
234 | __ATTR(actual_brightness, 0444, backlight_show_actual_brightness, | 248 | __ATTR(actual_brightness, 0444, backlight_show_actual_brightness, |
235 | NULL), | 249 | NULL), |
236 | __ATTR(max_brightness, 0444, backlight_show_max_brightness, NULL), | 250 | __ATTR(max_brightness, 0444, backlight_show_max_brightness, NULL), |
251 | __ATTR(type, 0444, backlight_show_type, NULL), | ||
237 | __ATTR_NULL, | 252 | __ATTR_NULL, |
238 | }; | 253 | }; |
239 | 254 | ||
@@ -292,9 +307,16 @@ struct backlight_device *backlight_device_register(const char *name, | |||
292 | dev_set_drvdata(&new_bd->dev, devdata); | 307 | dev_set_drvdata(&new_bd->dev, devdata); |
293 | 308 | ||
294 | /* Set default properties */ | 309 | /* Set default properties */ |
295 | if (props) | 310 | if (props) { |
296 | memcpy(&new_bd->props, props, | 311 | memcpy(&new_bd->props, props, |
297 | sizeof(struct backlight_properties)); | 312 | sizeof(struct backlight_properties)); |
313 | if (props->type <= 0 || props->type >= BACKLIGHT_TYPE_MAX) { | ||
314 | WARN(1, "%s: invalid backlight type", name); | ||
315 | new_bd->props.type = BACKLIGHT_RAW; | ||
316 | } | ||
317 | } else { | ||
318 | new_bd->props.type = BACKLIGHT_RAW; | ||
319 | } | ||
298 | 320 | ||
299 | rc = device_register(&new_bd->dev); | 321 | rc = device_register(&new_bd->dev); |
300 | if (rc) { | 322 | if (rc) { |