blob: 345f6660d4b39bd7f312e8958760e3c54d51ae24 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Backlight Lowlevel Control Abstraction
3 *
4 * Copyright (C) 2003,2004 Hewlett-Packard Company
5 *
6 */
7
Jingoo Han35f96162012-05-29 15:07:16 -07008#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <linux/module.h>
11#include <linux/init.h>
12#include <linux/device.h>
13#include <linux/backlight.h>
14#include <linux/notifier.h>
15#include <linux/ctype.h>
16#include <linux/err.h>
17#include <linux/fb.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090018#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
Richard Purdie321709c2007-02-10 15:04:08 +000020#ifdef CONFIG_PMAC_BACKLIGHT
21#include <asm/backlight.h>
22#endif
James Simmons3d5eead2006-12-08 02:40:47 -080023
Bart Van Asschec338bfb2011-09-10 20:13:01 +020024static const char *const backlight_types[] = {
Matthew Garrettbb7ca742011-03-22 16:30:21 -070025 [BACKLIGHT_RAW] = "raw",
26 [BACKLIGHT_PLATFORM] = "platform",
27 [BACKLIGHT_FIRMWARE] = "firmware",
28};
29
James Simmons3d5eead2006-12-08 02:40:47 -080030#if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
31 defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE))
32/* This callback gets called when something important happens inside a
33 * framebuffer driver. We're looking if that important event is blanking,
34 * and if it is, we're switching backlight power as well ...
35 */
36static int fb_notifier_callback(struct notifier_block *self,
37 unsigned long event, void *data)
38{
39 struct backlight_device *bd;
40 struct fb_event *evdata = data;
41
42 /* If we aren't interested in this event, skip it immediately ... */
Richard Purdie994efac2007-02-09 09:46:45 +000043 if (event != FB_EVENT_BLANK && event != FB_EVENT_CONBLANK)
James Simmons3d5eead2006-12-08 02:40:47 -080044 return 0;
45
46 bd = container_of(self, struct backlight_device, fb_notif);
Richard Purdie599a52d2007-02-10 23:07:48 +000047 mutex_lock(&bd->ops_lock);
48 if (bd->ops)
49 if (!bd->ops->check_fb ||
Bruno Prémont57e148b2010-02-21 00:20:01 +010050 bd->ops->check_fb(bd, evdata->info)) {
Richard Purdie599a52d2007-02-10 23:07:48 +000051 bd->props.fb_blank = *(int *)evdata->data;
Richard Purdiec835ee72009-01-06 21:00:19 +000052 if (bd->props.fb_blank == FB_BLANK_UNBLANK)
53 bd->props.state &= ~BL_CORE_FBBLANK;
54 else
55 bd->props.state |= BL_CORE_FBBLANK;
Richard Purdie28ee0862007-02-08 22:25:09 +000056 backlight_update_status(bd);
James Simmons3d5eead2006-12-08 02:40:47 -080057 }
Richard Purdie599a52d2007-02-10 23:07:48 +000058 mutex_unlock(&bd->ops_lock);
James Simmons3d5eead2006-12-08 02:40:47 -080059 return 0;
60}
61
62static int backlight_register_fb(struct backlight_device *bd)
63{
64 memset(&bd->fb_notif, 0, sizeof(bd->fb_notif));
65 bd->fb_notif.notifier_call = fb_notifier_callback;
66
67 return fb_register_client(&bd->fb_notif);
68}
69
70static void backlight_unregister_fb(struct backlight_device *bd)
71{
72 fb_unregister_client(&bd->fb_notif);
73}
74#else
75static inline int backlight_register_fb(struct backlight_device *bd)
76{
77 return 0;
78}
79
80static inline void backlight_unregister_fb(struct backlight_device *bd)
81{
82}
83#endif /* CONFIG_FB */
84
Matthew Garrett325253a2009-07-14 17:06:02 +010085static void backlight_generate_event(struct backlight_device *bd,
86 enum backlight_update_reason reason)
87{
88 char *envp[2];
89
90 switch (reason) {
91 case BACKLIGHT_UPDATE_SYSFS:
92 envp[0] = "SOURCE=sysfs";
93 break;
94 case BACKLIGHT_UPDATE_HOTKEY:
95 envp[0] = "SOURCE=hotkey";
96 break;
97 default:
98 envp[0] = "SOURCE=unknown";
99 break;
100 }
101 envp[1] = NULL;
102 kobject_uevent_env(&bd->dev.kobj, KOBJ_CHANGE, envp);
Henrique de Moraes Holschuh89dfc282009-09-20 14:44:47 -0300103 sysfs_notify(&bd->dev.kobj, NULL, "actual_brightness");
Matthew Garrett325253a2009-07-14 17:06:02 +0100104}
105
Richard Purdie655bfd72007-07-09 12:17:24 +0100106static ssize_t backlight_show_power(struct device *dev,
Jingoo Han66655762012-01-10 15:09:19 -0800107 struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108{
Richard Purdie655bfd72007-07-09 12:17:24 +0100109 struct backlight_device *bd = to_backlight_device(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110
Richard Purdie599a52d2007-02-10 23:07:48 +0000111 return sprintf(buf, "%d\n", bd->props.power);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112}
113
Richard Purdie655bfd72007-07-09 12:17:24 +0100114static ssize_t backlight_store_power(struct device *dev,
115 struct device_attribute *attr, const char *buf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116{
Pavel Machek9a2c61a2008-12-03 08:43:48 +0000117 int rc;
Richard Purdie655bfd72007-07-09 12:17:24 +0100118 struct backlight_device *bd = to_backlight_device(dev);
Pavel Machek9a2c61a2008-12-03 08:43:48 +0000119 unsigned long power;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
Jingoo Han66655762012-01-10 15:09:19 -0800121 rc = kstrtoul(buf, 0, &power);
Pavel Machek9a2c61a2008-12-03 08:43:48 +0000122 if (rc)
123 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124
Pavel Machek9a2c61a2008-12-03 08:43:48 +0000125 rc = -ENXIO;
Richard Purdie599a52d2007-02-10 23:07:48 +0000126 mutex_lock(&bd->ops_lock);
127 if (bd->ops) {
Jingoo Han35f96162012-05-29 15:07:16 -0700128 pr_debug("set power to %lu\n", power);
Helge Deller51552452008-01-13 23:01:13 +0000129 if (bd->props.power != power) {
130 bd->props.power = power;
131 backlight_update_status(bd);
132 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 rc = count;
Richard Purdie6ca01762006-03-31 02:31:49 -0800134 }
Richard Purdie599a52d2007-02-10 23:07:48 +0000135 mutex_unlock(&bd->ops_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
137 return rc;
138}
139
Richard Purdie655bfd72007-07-09 12:17:24 +0100140static ssize_t backlight_show_brightness(struct device *dev,
141 struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142{
Richard Purdie655bfd72007-07-09 12:17:24 +0100143 struct backlight_device *bd = to_backlight_device(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
Richard Purdie599a52d2007-02-10 23:07:48 +0000145 return sprintf(buf, "%d\n", bd->props.brightness);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146}
147
Richard Purdie655bfd72007-07-09 12:17:24 +0100148static ssize_t backlight_store_brightness(struct device *dev,
149 struct device_attribute *attr, const char *buf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150{
Pavel Machek9a2c61a2008-12-03 08:43:48 +0000151 int rc;
Richard Purdie655bfd72007-07-09 12:17:24 +0100152 struct backlight_device *bd = to_backlight_device(dev);
Pavel Machek9a2c61a2008-12-03 08:43:48 +0000153 unsigned long brightness;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154
Jingoo Han66655762012-01-10 15:09:19 -0800155 rc = kstrtoul(buf, 0, &brightness);
Pavel Machek9a2c61a2008-12-03 08:43:48 +0000156 if (rc)
157 return rc;
158
159 rc = -ENXIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160
Richard Purdie599a52d2007-02-10 23:07:48 +0000161 mutex_lock(&bd->ops_lock);
162 if (bd->ops) {
163 if (brightness > bd->props.max_brightness)
Richard Purdie6ca01762006-03-31 02:31:49 -0800164 rc = -EINVAL;
165 else {
Jingoo Han35f96162012-05-29 15:07:16 -0700166 pr_debug("set brightness to %lu\n", brightness);
Zhang Rui9be1df92009-01-08 14:11:30 +0000167 bd->props.brightness = brightness;
168 backlight_update_status(bd);
Richard Purdie6ca01762006-03-31 02:31:49 -0800169 rc = count;
170 }
171 }
Richard Purdie599a52d2007-02-10 23:07:48 +0000172 mutex_unlock(&bd->ops_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
Matthew Garrett325253a2009-07-14 17:06:02 +0100174 backlight_generate_event(bd, BACKLIGHT_UPDATE_SYSFS);
175
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 return rc;
177}
178
Matthew Garrettbb7ca742011-03-22 16:30:21 -0700179static ssize_t backlight_show_type(struct device *dev,
180 struct device_attribute *attr, char *buf)
181{
182 struct backlight_device *bd = to_backlight_device(dev);
183
184 return sprintf(buf, "%s\n", backlight_types[bd->props.type]);
185}
186
Richard Purdie655bfd72007-07-09 12:17:24 +0100187static ssize_t backlight_show_max_brightness(struct device *dev,
188 struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189{
Richard Purdie655bfd72007-07-09 12:17:24 +0100190 struct backlight_device *bd = to_backlight_device(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191
Richard Purdie599a52d2007-02-10 23:07:48 +0000192 return sprintf(buf, "%d\n", bd->props.max_brightness);
Richard Purdie6ca01762006-03-31 02:31:49 -0800193}
194
Richard Purdie655bfd72007-07-09 12:17:24 +0100195static ssize_t backlight_show_actual_brightness(struct device *dev,
196 struct device_attribute *attr, char *buf)
Richard Purdie6ca01762006-03-31 02:31:49 -0800197{
198 int rc = -ENXIO;
Richard Purdie655bfd72007-07-09 12:17:24 +0100199 struct backlight_device *bd = to_backlight_device(dev);
Richard Purdie6ca01762006-03-31 02:31:49 -0800200
Richard Purdie599a52d2007-02-10 23:07:48 +0000201 mutex_lock(&bd->ops_lock);
202 if (bd->ops && bd->ops->get_brightness)
203 rc = sprintf(buf, "%d\n", bd->ops->get_brightness(bd));
204 mutex_unlock(&bd->ops_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
206 return rc;
207}
208
Adrian Bunk0ad90ef2007-08-11 10:27:19 +0100209static struct class *backlight_class;
Richard Purdie655bfd72007-07-09 12:17:24 +0100210
Richard Purdiec835ee72009-01-06 21:00:19 +0000211static int backlight_suspend(struct device *dev, pm_message_t state)
212{
213 struct backlight_device *bd = to_backlight_device(dev);
214
Uwe Kleine-Königd1d73572010-11-24 12:57:14 -0800215 mutex_lock(&bd->ops_lock);
216 if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) {
Richard Purdiec835ee72009-01-06 21:00:19 +0000217 bd->props.state |= BL_CORE_SUSPENDED;
218 backlight_update_status(bd);
Richard Purdiec835ee72009-01-06 21:00:19 +0000219 }
Uwe Kleine-Königd1d73572010-11-24 12:57:14 -0800220 mutex_unlock(&bd->ops_lock);
Richard Purdiec835ee72009-01-06 21:00:19 +0000221
222 return 0;
223}
224
225static int backlight_resume(struct device *dev)
226{
227 struct backlight_device *bd = to_backlight_device(dev);
228
Uwe Kleine-Königd1d73572010-11-24 12:57:14 -0800229 mutex_lock(&bd->ops_lock);
230 if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) {
Richard Purdiec835ee72009-01-06 21:00:19 +0000231 bd->props.state &= ~BL_CORE_SUSPENDED;
232 backlight_update_status(bd);
Richard Purdiec835ee72009-01-06 21:00:19 +0000233 }
Uwe Kleine-Königd1d73572010-11-24 12:57:14 -0800234 mutex_unlock(&bd->ops_lock);
Richard Purdiec835ee72009-01-06 21:00:19 +0000235
236 return 0;
237}
238
Richard Purdie655bfd72007-07-09 12:17:24 +0100239static void bl_device_release(struct device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240{
241 struct backlight_device *bd = to_backlight_device(dev);
242 kfree(bd);
243}
244
Richard Purdie655bfd72007-07-09 12:17:24 +0100245static struct device_attribute bl_device_attributes[] = {
246 __ATTR(bl_power, 0644, backlight_show_power, backlight_store_power),
247 __ATTR(brightness, 0644, backlight_show_brightness,
Richard Purdie6ca01762006-03-31 02:31:49 -0800248 backlight_store_brightness),
Richard Purdie655bfd72007-07-09 12:17:24 +0100249 __ATTR(actual_brightness, 0444, backlight_show_actual_brightness,
Richard Purdie6ca01762006-03-31 02:31:49 -0800250 NULL),
Richard Purdie655bfd72007-07-09 12:17:24 +0100251 __ATTR(max_brightness, 0444, backlight_show_max_brightness, NULL),
Matthew Garrettbb7ca742011-03-22 16:30:21 -0700252 __ATTR(type, 0444, backlight_show_type, NULL),
Richard Purdie655bfd72007-07-09 12:17:24 +0100253 __ATTR_NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254};
255
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256/**
Matthew Garrett325253a2009-07-14 17:06:02 +0100257 * backlight_force_update - tell the backlight subsystem that hardware state
258 * has changed
259 * @bd: the backlight device to update
260 *
261 * Updates the internal state of the backlight in response to a hardware event,
262 * and generate a uevent to notify userspace
263 */
264void backlight_force_update(struct backlight_device *bd,
265 enum backlight_update_reason reason)
266{
267 mutex_lock(&bd->ops_lock);
268 if (bd->ops && bd->ops->get_brightness)
269 bd->props.brightness = bd->ops->get_brightness(bd);
270 mutex_unlock(&bd->ops_lock);
271 backlight_generate_event(bd, reason);
272}
273EXPORT_SYMBOL(backlight_force_update);
274
275/**
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 * backlight_device_register - create and register a new object of
277 * backlight_device class.
278 * @name: the name of the new object(must be the same as the name of the
279 * respective framebuffer device).
Sebastian Siewiorf6ec2d92008-07-16 23:05:49 +0100280 * @parent: a pointer to the parent device
Richard Purdie655bfd72007-07-09 12:17:24 +0100281 * @devdata: an optional pointer to be stored for private driver use. The
282 * methods may retrieve it by using bl_get_data(bd).
Richard Purdie599a52d2007-02-10 23:07:48 +0000283 * @ops: the backlight operations structure.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 *
Richard Purdie655bfd72007-07-09 12:17:24 +0100285 * Creates and registers new backlight device. Returns either an
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 * ERR_PTR() or a pointer to the newly allocated device.
287 */
Yu Luming519ab5f2006-12-19 12:56:15 -0800288struct backlight_device *backlight_device_register(const char *name,
Matthew Garretta19a6ee2010-02-17 16:39:44 -0500289 struct device *parent, void *devdata, const struct backlight_ops *ops,
290 const struct backlight_properties *props)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 struct backlight_device *new_bd;
Richard Purdie655bfd72007-07-09 12:17:24 +0100293 int rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294
Richard Purdie655bfd72007-07-09 12:17:24 +0100295 pr_debug("backlight_device_register: name=%s\n", name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
Richard Purdie599a52d2007-02-10 23:07:48 +0000297 new_bd = kzalloc(sizeof(struct backlight_device), GFP_KERNEL);
Dmitry Torokhov90968e82007-02-08 00:12:28 +0000298 if (!new_bd)
Jean Delvare10ad1b72006-03-09 17:33:36 -0800299 return ERR_PTR(-ENOMEM);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
Richard Purdie28ee0862007-02-08 22:25:09 +0000301 mutex_init(&new_bd->update_lock);
Richard Purdie599a52d2007-02-10 23:07:48 +0000302 mutex_init(&new_bd->ops_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303
Richard Purdie655bfd72007-07-09 12:17:24 +0100304 new_bd->dev.class = backlight_class;
305 new_bd->dev.parent = parent;
306 new_bd->dev.release = bl_device_release;
Kay Sievers64dba9a2009-01-06 10:44:35 -0800307 dev_set_name(&new_bd->dev, name);
Richard Purdie655bfd72007-07-09 12:17:24 +0100308 dev_set_drvdata(&new_bd->dev, devdata);
309
Matthew Garretta19a6ee2010-02-17 16:39:44 -0500310 /* Set default properties */
Matthew Garrettbb7ca742011-03-22 16:30:21 -0700311 if (props) {
Matthew Garretta19a6ee2010-02-17 16:39:44 -0500312 memcpy(&new_bd->props, props,
313 sizeof(struct backlight_properties));
Matthew Garrettbb7ca742011-03-22 16:30:21 -0700314 if (props->type <= 0 || props->type >= BACKLIGHT_TYPE_MAX) {
315 WARN(1, "%s: invalid backlight type", name);
316 new_bd->props.type = BACKLIGHT_RAW;
317 }
318 } else {
319 new_bd->props.type = BACKLIGHT_RAW;
320 }
Matthew Garretta19a6ee2010-02-17 16:39:44 -0500321
Richard Purdie655bfd72007-07-09 12:17:24 +0100322 rc = device_register(&new_bd->dev);
Dmitry Torokhov90968e82007-02-08 00:12:28 +0000323 if (rc) {
Dmitry Torokhov2fd5a152007-02-07 22:25:50 +0000324 kfree(new_bd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 return ERR_PTR(rc);
326 }
327
James Simmons3d5eead2006-12-08 02:40:47 -0800328 rc = backlight_register_fb(new_bd);
Dmitry Torokhov2fd5a152007-02-07 22:25:50 +0000329 if (rc) {
Richard Purdie655bfd72007-07-09 12:17:24 +0100330 device_unregister(&new_bd->dev);
Dmitry Torokhov2fd5a152007-02-07 22:25:50 +0000331 return ERR_PTR(rc);
332 }
333
Richard Purdie655bfd72007-07-09 12:17:24 +0100334 new_bd->ops = ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335
Richard Purdie321709c2007-02-10 15:04:08 +0000336#ifdef CONFIG_PMAC_BACKLIGHT
337 mutex_lock(&pmac_backlight_mutex);
338 if (!pmac_backlight)
339 pmac_backlight = new_bd;
340 mutex_unlock(&pmac_backlight_mutex);
341#endif
342
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 return new_bd;
344}
345EXPORT_SYMBOL(backlight_device_register);
346
347/**
348 * backlight_device_unregister - unregisters a backlight device object.
349 * @bd: the backlight device object to be unregistered and freed.
350 *
351 * Unregisters a previously registered via backlight_device_register object.
352 */
353void backlight_device_unregister(struct backlight_device *bd)
354{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 if (!bd)
356 return;
357
Richard Purdie321709c2007-02-10 15:04:08 +0000358#ifdef CONFIG_PMAC_BACKLIGHT
359 mutex_lock(&pmac_backlight_mutex);
360 if (pmac_backlight == bd)
361 pmac_backlight = NULL;
362 mutex_unlock(&pmac_backlight_mutex);
363#endif
Richard Purdie599a52d2007-02-10 23:07:48 +0000364 mutex_lock(&bd->ops_lock);
365 bd->ops = NULL;
366 mutex_unlock(&bd->ops_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367
James Simmons3d5eead2006-12-08 02:40:47 -0800368 backlight_unregister_fb(bd);
Richard Purdie655bfd72007-07-09 12:17:24 +0100369 device_unregister(&bd->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370}
371EXPORT_SYMBOL(backlight_device_unregister);
372
Thierry Reding762a9362012-12-17 16:01:06 -0800373#ifdef CONFIG_OF
374static int of_parent_match(struct device *dev, void *data)
375{
376 return dev->parent && dev->parent->of_node == data;
377}
378
379/**
380 * of_find_backlight_by_node() - find backlight device by device-tree node
381 * @node: device-tree node of the backlight device
382 *
383 * Returns a pointer to the backlight device corresponding to the given DT
384 * node or NULL if no such backlight device exists or if the device hasn't
385 * been probed yet.
386 *
387 * This function obtains a reference on the backlight device and it is the
388 * caller's responsibility to drop the reference by calling put_device() on
389 * the backlight device's .dev field.
390 */
391struct backlight_device *of_find_backlight_by_node(struct device_node *node)
392{
393 struct device *dev;
394
395 dev = class_find_device(backlight_class, NULL, node, of_parent_match);
396
397 return dev ? to_backlight_device(dev) : NULL;
398}
399EXPORT_SYMBOL(of_find_backlight_by_node);
400#endif
401
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402static void __exit backlight_class_exit(void)
403{
Richard Purdie655bfd72007-07-09 12:17:24 +0100404 class_destroy(backlight_class);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405}
406
407static int __init backlight_class_init(void)
408{
Richard Purdie655bfd72007-07-09 12:17:24 +0100409 backlight_class = class_create(THIS_MODULE, "backlight");
410 if (IS_ERR(backlight_class)) {
Jingoo Han35f96162012-05-29 15:07:16 -0700411 pr_warn("Unable to create backlight class; errno = %ld\n",
412 PTR_ERR(backlight_class));
Richard Purdie655bfd72007-07-09 12:17:24 +0100413 return PTR_ERR(backlight_class);
414 }
415
416 backlight_class->dev_attrs = bl_device_attributes;
Richard Purdiec835ee72009-01-06 21:00:19 +0000417 backlight_class->suspend = backlight_suspend;
418 backlight_class->resume = backlight_resume;
Richard Purdie655bfd72007-07-09 12:17:24 +0100419 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420}
421
422/*
423 * if this is compiled into the kernel, we need to ensure that the
424 * class is registered before users of the class try to register lcd's
425 */
426postcore_initcall(backlight_class_init);
427module_exit(backlight_class_exit);
428
429MODULE_LICENSE("GPL");
430MODULE_AUTHOR("Jamey Hicks <jamey.hicks@hp.com>, Andrew Zabolotny <zap@homelink.ru>");
431MODULE_DESCRIPTION("Backlight Lowlevel Control Abstraction");