backlight.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. /*
  2. * Backlight Lowlevel Control Abstraction
  3. *
  4. * Copyright (C) 2003,2004 Hewlett-Packard Company
  5. *
  6. */
  7. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  8. #include <linux/module.h>
  9. #include <linux/init.h>
  10. #include <linux/device.h>
  11. #include <linux/backlight.h>
  12. #include <linux/notifier.h>
  13. #include <linux/ctype.h>
  14. #include <linux/err.h>
  15. #include <linux/fb.h>
  16. #include <linux/slab.h>
  17. #ifdef CONFIG_PMAC_BACKLIGHT
  18. #include <asm/backlight.h>
  19. #endif
  20. static struct list_head backlight_dev_list;
  21. static struct mutex backlight_dev_list_mutex;
  22. static struct blocking_notifier_head backlight_notifier;
  23. static const char *const backlight_types[] = {
  24. [BACKLIGHT_RAW] = "raw",
  25. [BACKLIGHT_PLATFORM] = "platform",
  26. [BACKLIGHT_FIRMWARE] = "firmware",
  27. };
  28. #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
  29. defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE))
  30. /* This callback gets called when something important happens inside a
  31. * framebuffer driver. We're looking if that important event is blanking,
  32. * and if it is and necessary, we're switching backlight power as well ...
  33. */
  34. static int fb_notifier_callback(struct notifier_block *self,
  35. unsigned long event, void *data)
  36. {
  37. struct backlight_device *bd;
  38. struct fb_event *evdata = data;
  39. int node = evdata->info->node;
  40. int fb_blank = 0;
  41. /* If we aren't interested in this event, skip it immediately ... */
  42. if (event != FB_EVENT_BLANK && event != FB_EVENT_CONBLANK)
  43. return 0;
  44. bd = container_of(self, struct backlight_device, fb_notif);
  45. mutex_lock(&bd->ops_lock);
  46. if (bd->ops)
  47. if (!bd->ops->check_fb ||
  48. bd->ops->check_fb(bd, evdata->info)) {
  49. fb_blank = *(int *)evdata->data;
  50. if (fb_blank == FB_BLANK_UNBLANK &&
  51. !bd->fb_bl_on[node]) {
  52. bd->fb_bl_on[node] = true;
  53. if (!bd->use_count++) {
  54. bd->props.state &= ~BL_CORE_FBBLANK;
  55. bd->props.fb_blank = FB_BLANK_UNBLANK;
  56. backlight_update_status(bd);
  57. }
  58. } else if (fb_blank != FB_BLANK_UNBLANK &&
  59. bd->fb_bl_on[node]) {
  60. bd->fb_bl_on[node] = false;
  61. if (!(--bd->use_count)) {
  62. bd->props.state |= BL_CORE_FBBLANK;
  63. bd->props.fb_blank = fb_blank;
  64. backlight_update_status(bd);
  65. }
  66. }
  67. }
  68. mutex_unlock(&bd->ops_lock);
  69. return 0;
  70. }
  71. static int backlight_register_fb(struct backlight_device *bd)
  72. {
  73. memset(&bd->fb_notif, 0, sizeof(bd->fb_notif));
  74. bd->fb_notif.notifier_call = fb_notifier_callback;
  75. return fb_register_client(&bd->fb_notif);
  76. }
  77. static void backlight_unregister_fb(struct backlight_device *bd)
  78. {
  79. fb_unregister_client(&bd->fb_notif);
  80. }
  81. #else
  82. static inline int backlight_register_fb(struct backlight_device *bd)
  83. {
  84. return 0;
  85. }
  86. static inline void backlight_unregister_fb(struct backlight_device *bd)
  87. {
  88. }
  89. #endif /* CONFIG_FB */
  90. static void backlight_generate_event(struct backlight_device *bd,
  91. enum backlight_update_reason reason)
  92. {
  93. char *envp[2];
  94. switch (reason) {
  95. case BACKLIGHT_UPDATE_SYSFS:
  96. envp[0] = "SOURCE=sysfs";
  97. break;
  98. case BACKLIGHT_UPDATE_HOTKEY:
  99. envp[0] = "SOURCE=hotkey";
  100. break;
  101. default:
  102. envp[0] = "SOURCE=unknown";
  103. break;
  104. }
  105. envp[1] = NULL;
  106. kobject_uevent_env(&bd->dev.kobj, KOBJ_CHANGE, envp);
  107. sysfs_notify(&bd->dev.kobj, NULL, "actual_brightness");
  108. }
  109. static ssize_t bl_power_show(struct device *dev, struct device_attribute *attr,
  110. char *buf)
  111. {
  112. struct backlight_device *bd = to_backlight_device(dev);
  113. return sprintf(buf, "%d\n", bd->props.power);
  114. }
  115. static ssize_t bl_power_store(struct device *dev, struct device_attribute *attr,
  116. const char *buf, size_t count)
  117. {
  118. int rc;
  119. struct backlight_device *bd = to_backlight_device(dev);
  120. unsigned long power, old_power;
  121. rc = kstrtoul(buf, 0, &power);
  122. if (rc)
  123. return rc;
  124. rc = -ENXIO;
  125. mutex_lock(&bd->ops_lock);
  126. if (bd->ops) {
  127. pr_debug("set power to %lu\n", power);
  128. if (bd->props.power != power) {
  129. old_power = bd->props.power;
  130. bd->props.power = power;
  131. rc = backlight_update_status(bd);
  132. if (rc)
  133. bd->props.power = old_power;
  134. else
  135. rc = count;
  136. } else {
  137. rc = count;
  138. }
  139. }
  140. mutex_unlock(&bd->ops_lock);
  141. return rc;
  142. }
  143. static DEVICE_ATTR_RW(bl_power);
  144. static ssize_t brightness_show(struct device *dev,
  145. struct device_attribute *attr, char *buf)
  146. {
  147. struct backlight_device *bd = to_backlight_device(dev);
  148. return sprintf(buf, "%d\n", bd->props.brightness);
  149. }
  150. int backlight_device_set_brightness(struct backlight_device *bd,
  151. unsigned long brightness)
  152. {
  153. int rc = -ENXIO;
  154. mutex_lock(&bd->ops_lock);
  155. if (bd->ops) {
  156. if (brightness > bd->props.max_brightness)
  157. rc = -EINVAL;
  158. else {
  159. pr_debug("set brightness to %lu\n", brightness);
  160. bd->props.brightness = brightness;
  161. rc = backlight_update_status(bd);
  162. }
  163. }
  164. mutex_unlock(&bd->ops_lock);
  165. backlight_generate_event(bd, BACKLIGHT_UPDATE_SYSFS);
  166. return rc;
  167. }
  168. EXPORT_SYMBOL(backlight_device_set_brightness);
  169. static ssize_t brightness_store(struct device *dev,
  170. struct device_attribute *attr, const char *buf, size_t count)
  171. {
  172. int rc;
  173. struct backlight_device *bd = to_backlight_device(dev);
  174. unsigned long brightness;
  175. rc = kstrtoul(buf, 0, &brightness);
  176. if (rc)
  177. return rc;
  178. rc = backlight_device_set_brightness(bd, brightness);
  179. return rc ? rc : count;
  180. }
  181. static DEVICE_ATTR_RW(brightness);
  182. static ssize_t type_show(struct device *dev, struct device_attribute *attr,
  183. char *buf)
  184. {
  185. struct backlight_device *bd = to_backlight_device(dev);
  186. return sprintf(buf, "%s\n", backlight_types[bd->props.type]);
  187. }
  188. static DEVICE_ATTR_RO(type);
  189. static ssize_t max_brightness_show(struct device *dev,
  190. struct device_attribute *attr, char *buf)
  191. {
  192. struct backlight_device *bd = to_backlight_device(dev);
  193. return sprintf(buf, "%d\n", bd->props.max_brightness);
  194. }
  195. static DEVICE_ATTR_RO(max_brightness);
  196. static ssize_t actual_brightness_show(struct device *dev,
  197. struct device_attribute *attr, char *buf)
  198. {
  199. int rc = -ENXIO;
  200. struct backlight_device *bd = to_backlight_device(dev);
  201. 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. else
  205. rc = sprintf(buf, "%d\n", bd->props.brightness);
  206. mutex_unlock(&bd->ops_lock);
  207. return rc;
  208. }
  209. static DEVICE_ATTR_RO(actual_brightness);
  210. static struct class *backlight_class;
  211. #ifdef CONFIG_PM_SLEEP
  212. static int backlight_suspend(struct device *dev)
  213. {
  214. struct backlight_device *bd = to_backlight_device(dev);
  215. mutex_lock(&bd->ops_lock);
  216. if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) {
  217. bd->props.state |= BL_CORE_SUSPENDED;
  218. backlight_update_status(bd);
  219. }
  220. mutex_unlock(&bd->ops_lock);
  221. return 0;
  222. }
  223. static int backlight_resume(struct device *dev)
  224. {
  225. struct backlight_device *bd = to_backlight_device(dev);
  226. mutex_lock(&bd->ops_lock);
  227. if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) {
  228. bd->props.state &= ~BL_CORE_SUSPENDED;
  229. backlight_update_status(bd);
  230. }
  231. mutex_unlock(&bd->ops_lock);
  232. return 0;
  233. }
  234. #endif
  235. static SIMPLE_DEV_PM_OPS(backlight_class_dev_pm_ops, backlight_suspend,
  236. backlight_resume);
  237. static void bl_device_release(struct device *dev)
  238. {
  239. struct backlight_device *bd = to_backlight_device(dev);
  240. kfree(bd);
  241. }
  242. static struct attribute *bl_device_attrs[] = {
  243. &dev_attr_bl_power.attr,
  244. &dev_attr_brightness.attr,
  245. &dev_attr_actual_brightness.attr,
  246. &dev_attr_max_brightness.attr,
  247. &dev_attr_type.attr,
  248. NULL,
  249. };
  250. ATTRIBUTE_GROUPS(bl_device);
  251. /**
  252. * backlight_force_update - tell the backlight subsystem that hardware state
  253. * has changed
  254. * @bd: the backlight device to update
  255. *
  256. * Updates the internal state of the backlight in response to a hardware event,
  257. * and generate a uevent to notify userspace
  258. */
  259. void backlight_force_update(struct backlight_device *bd,
  260. enum backlight_update_reason reason)
  261. {
  262. mutex_lock(&bd->ops_lock);
  263. if (bd->ops && bd->ops->get_brightness)
  264. bd->props.brightness = bd->ops->get_brightness(bd);
  265. mutex_unlock(&bd->ops_lock);
  266. backlight_generate_event(bd, reason);
  267. }
  268. EXPORT_SYMBOL(backlight_force_update);
  269. /**
  270. * backlight_device_register - create and register a new object of
  271. * backlight_device class.
  272. * @name: the name of the new object(must be the same as the name of the
  273. * respective framebuffer device).
  274. * @parent: a pointer to the parent device
  275. * @devdata: an optional pointer to be stored for private driver use. The
  276. * methods may retrieve it by using bl_get_data(bd).
  277. * @ops: the backlight operations structure.
  278. *
  279. * Creates and registers new backlight device. Returns either an
  280. * ERR_PTR() or a pointer to the newly allocated device.
  281. */
  282. struct backlight_device *backlight_device_register(const char *name,
  283. struct device *parent, void *devdata, const struct backlight_ops *ops,
  284. const struct backlight_properties *props)
  285. {
  286. struct backlight_device *new_bd;
  287. int rc;
  288. pr_debug("backlight_device_register: name=%s\n", name);
  289. new_bd = kzalloc(sizeof(struct backlight_device), GFP_KERNEL);
  290. if (!new_bd)
  291. return ERR_PTR(-ENOMEM);
  292. mutex_init(&new_bd->update_lock);
  293. mutex_init(&new_bd->ops_lock);
  294. new_bd->dev.class = backlight_class;
  295. new_bd->dev.parent = parent;
  296. new_bd->dev.release = bl_device_release;
  297. dev_set_name(&new_bd->dev, "%s", name);
  298. dev_set_drvdata(&new_bd->dev, devdata);
  299. /* Set default properties */
  300. if (props) {
  301. memcpy(&new_bd->props, props,
  302. sizeof(struct backlight_properties));
  303. if (props->type <= 0 || props->type >= BACKLIGHT_TYPE_MAX) {
  304. WARN(1, "%s: invalid backlight type", name);
  305. new_bd->props.type = BACKLIGHT_RAW;
  306. }
  307. } else {
  308. new_bd->props.type = BACKLIGHT_RAW;
  309. }
  310. rc = device_register(&new_bd->dev);
  311. if (rc) {
  312. put_device(&new_bd->dev);
  313. return ERR_PTR(rc);
  314. }
  315. rc = backlight_register_fb(new_bd);
  316. if (rc) {
  317. device_unregister(&new_bd->dev);
  318. return ERR_PTR(rc);
  319. }
  320. new_bd->ops = ops;
  321. #ifdef CONFIG_PMAC_BACKLIGHT
  322. mutex_lock(&pmac_backlight_mutex);
  323. if (!pmac_backlight)
  324. pmac_backlight = new_bd;
  325. mutex_unlock(&pmac_backlight_mutex);
  326. #endif
  327. mutex_lock(&backlight_dev_list_mutex);
  328. list_add(&new_bd->entry, &backlight_dev_list);
  329. mutex_unlock(&backlight_dev_list_mutex);
  330. blocking_notifier_call_chain(&backlight_notifier,
  331. BACKLIGHT_REGISTERED, new_bd);
  332. return new_bd;
  333. }
  334. EXPORT_SYMBOL(backlight_device_register);
  335. struct backlight_device *backlight_device_get_by_type(enum backlight_type type)
  336. {
  337. bool found = false;
  338. struct backlight_device *bd;
  339. mutex_lock(&backlight_dev_list_mutex);
  340. list_for_each_entry(bd, &backlight_dev_list, entry) {
  341. if (bd->props.type == type) {
  342. found = true;
  343. break;
  344. }
  345. }
  346. mutex_unlock(&backlight_dev_list_mutex);
  347. return found ? bd : NULL;
  348. }
  349. EXPORT_SYMBOL(backlight_device_get_by_type);
  350. /**
  351. * backlight_device_unregister - unregisters a backlight device object.
  352. * @bd: the backlight device object to be unregistered and freed.
  353. *
  354. * Unregisters a previously registered via backlight_device_register object.
  355. */
  356. void backlight_device_unregister(struct backlight_device *bd)
  357. {
  358. if (!bd)
  359. return;
  360. mutex_lock(&backlight_dev_list_mutex);
  361. list_del(&bd->entry);
  362. mutex_unlock(&backlight_dev_list_mutex);
  363. #ifdef CONFIG_PMAC_BACKLIGHT
  364. mutex_lock(&pmac_backlight_mutex);
  365. if (pmac_backlight == bd)
  366. pmac_backlight = NULL;
  367. mutex_unlock(&pmac_backlight_mutex);
  368. #endif
  369. blocking_notifier_call_chain(&backlight_notifier,
  370. BACKLIGHT_UNREGISTERED, bd);
  371. mutex_lock(&bd->ops_lock);
  372. bd->ops = NULL;
  373. mutex_unlock(&bd->ops_lock);
  374. backlight_unregister_fb(bd);
  375. device_unregister(&bd->dev);
  376. }
  377. EXPORT_SYMBOL(backlight_device_unregister);
  378. static void devm_backlight_device_release(struct device *dev, void *res)
  379. {
  380. struct backlight_device *backlight = *(struct backlight_device **)res;
  381. backlight_device_unregister(backlight);
  382. }
  383. static int devm_backlight_device_match(struct device *dev, void *res,
  384. void *data)
  385. {
  386. struct backlight_device **r = res;
  387. return *r == data;
  388. }
  389. /**
  390. * backlight_register_notifier - get notified of backlight (un)registration
  391. * @nb: notifier block with the notifier to call on backlight (un)registration
  392. *
  393. * @return 0 on success, otherwise a negative error code
  394. *
  395. * Register a notifier to get notified when backlight devices get registered
  396. * or unregistered.
  397. */
  398. int backlight_register_notifier(struct notifier_block *nb)
  399. {
  400. return blocking_notifier_chain_register(&backlight_notifier, nb);
  401. }
  402. EXPORT_SYMBOL(backlight_register_notifier);
  403. /**
  404. * backlight_unregister_notifier - unregister a backlight notifier
  405. * @nb: notifier block to unregister
  406. *
  407. * @return 0 on success, otherwise a negative error code
  408. *
  409. * Register a notifier to get notified when backlight devices get registered
  410. * or unregistered.
  411. */
  412. int backlight_unregister_notifier(struct notifier_block *nb)
  413. {
  414. return blocking_notifier_chain_unregister(&backlight_notifier, nb);
  415. }
  416. EXPORT_SYMBOL(backlight_unregister_notifier);
  417. /**
  418. * devm_backlight_device_register - resource managed backlight_device_register()
  419. * @dev: the device to register
  420. * @name: the name of the device
  421. * @parent: a pointer to the parent device
  422. * @devdata: an optional pointer to be stored for private driver use
  423. * @ops: the backlight operations structure
  424. * @props: the backlight properties
  425. *
  426. * @return a struct backlight on success, or an ERR_PTR on error
  427. *
  428. * Managed backlight_device_register(). The backlight_device returned
  429. * from this function are automatically freed on driver detach.
  430. * See backlight_device_register() for more information.
  431. */
  432. struct backlight_device *devm_backlight_device_register(struct device *dev,
  433. const char *name, struct device *parent, void *devdata,
  434. const struct backlight_ops *ops,
  435. const struct backlight_properties *props)
  436. {
  437. struct backlight_device **ptr, *backlight;
  438. ptr = devres_alloc(devm_backlight_device_release, sizeof(*ptr),
  439. GFP_KERNEL);
  440. if (!ptr)
  441. return ERR_PTR(-ENOMEM);
  442. backlight = backlight_device_register(name, parent, devdata, ops,
  443. props);
  444. if (!IS_ERR(backlight)) {
  445. *ptr = backlight;
  446. devres_add(dev, ptr);
  447. } else {
  448. devres_free(ptr);
  449. }
  450. return backlight;
  451. }
  452. EXPORT_SYMBOL(devm_backlight_device_register);
  453. /**
  454. * devm_backlight_device_unregister - resource managed backlight_device_unregister()
  455. * @dev: the device to unregister
  456. * @bd: the backlight device to unregister
  457. *
  458. * Deallocated a backlight allocated with devm_backlight_device_register().
  459. * Normally this function will not need to be called and the resource management
  460. * code will ensure that the resource is freed.
  461. */
  462. void devm_backlight_device_unregister(struct device *dev,
  463. struct backlight_device *bd)
  464. {
  465. int rc;
  466. rc = devres_release(dev, devm_backlight_device_release,
  467. devm_backlight_device_match, bd);
  468. WARN_ON(rc);
  469. }
  470. EXPORT_SYMBOL(devm_backlight_device_unregister);
  471. #ifdef CONFIG_OF
  472. static int of_parent_match(struct device *dev, const void *data)
  473. {
  474. return dev->parent && dev->parent->of_node == data;
  475. }
  476. /**
  477. * of_find_backlight_by_node() - find backlight device by device-tree node
  478. * @node: device-tree node of the backlight device
  479. *
  480. * Returns a pointer to the backlight device corresponding to the given DT
  481. * node or NULL if no such backlight device exists or if the device hasn't
  482. * been probed yet.
  483. *
  484. * This function obtains a reference on the backlight device and it is the
  485. * caller's responsibility to drop the reference by calling put_device() on
  486. * the backlight device's .dev field.
  487. */
  488. struct backlight_device *of_find_backlight_by_node(struct device_node *node)
  489. {
  490. struct device *dev;
  491. dev = class_find_device(backlight_class, NULL, node, of_parent_match);
  492. return dev ? to_backlight_device(dev) : NULL;
  493. }
  494. EXPORT_SYMBOL(of_find_backlight_by_node);
  495. #endif
  496. /**
  497. * of_find_backlight - Get backlight device
  498. * @dev: Device
  499. *
  500. * This function looks for a property named 'backlight' on the DT node
  501. * connected to @dev and looks up the backlight device.
  502. *
  503. * Call backlight_put() to drop the reference on the backlight device.
  504. *
  505. * Returns:
  506. * A pointer to the backlight device if found.
  507. * Error pointer -EPROBE_DEFER if the DT property is set, but no backlight
  508. * device is found.
  509. * NULL if there's no backlight property.
  510. */
  511. struct backlight_device *of_find_backlight(struct device *dev)
  512. {
  513. struct backlight_device *bd = NULL;
  514. struct device_node *np;
  515. if (!dev)
  516. return NULL;
  517. if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
  518. np = of_parse_phandle(dev->of_node, "backlight", 0);
  519. if (np) {
  520. bd = of_find_backlight_by_node(np);
  521. of_node_put(np);
  522. if (!bd)
  523. return ERR_PTR(-EPROBE_DEFER);
  524. /*
  525. * Note: gpio_backlight uses brightness as
  526. * power state during probe
  527. */
  528. if (!bd->props.brightness)
  529. bd->props.brightness = bd->props.max_brightness;
  530. }
  531. }
  532. return bd;
  533. }
  534. EXPORT_SYMBOL(of_find_backlight);
  535. static void devm_backlight_release(void *data)
  536. {
  537. backlight_put(data);
  538. }
  539. /**
  540. * devm_of_find_backlight - Resource-managed of_find_backlight()
  541. * @dev: Device
  542. *
  543. * Device managed version of of_find_backlight().
  544. * The reference on the backlight device is automatically
  545. * dropped on driver detach.
  546. */
  547. struct backlight_device *devm_of_find_backlight(struct device *dev)
  548. {
  549. struct backlight_device *bd;
  550. int ret;
  551. bd = of_find_backlight(dev);
  552. if (IS_ERR_OR_NULL(bd))
  553. return bd;
  554. ret = devm_add_action(dev, devm_backlight_release, bd);
  555. if (ret) {
  556. backlight_put(bd);
  557. return ERR_PTR(ret);
  558. }
  559. return bd;
  560. }
  561. EXPORT_SYMBOL(devm_of_find_backlight);
  562. static void __exit backlight_class_exit(void)
  563. {
  564. class_destroy(backlight_class);
  565. }
  566. static int __init backlight_class_init(void)
  567. {
  568. backlight_class = class_create(THIS_MODULE, "backlight");
  569. if (IS_ERR(backlight_class)) {
  570. pr_warn("Unable to create backlight class; errno = %ld\n",
  571. PTR_ERR(backlight_class));
  572. return PTR_ERR(backlight_class);
  573. }
  574. backlight_class->dev_groups = bl_device_groups;
  575. backlight_class->pm = &backlight_class_dev_pm_ops;
  576. INIT_LIST_HEAD(&backlight_dev_list);
  577. mutex_init(&backlight_dev_list_mutex);
  578. BLOCKING_INIT_NOTIFIER_HEAD(&backlight_notifier);
  579. return 0;
  580. }
  581. /*
  582. * if this is compiled into the kernel, we need to ensure that the
  583. * class is registered before users of the class try to register lcd's
  584. */
  585. postcore_initcall(backlight_class_init);
  586. module_exit(backlight_class_exit);
  587. MODULE_LICENSE("GPL");
  588. MODULE_AUTHOR("Jamey Hicks <jamey.hicks@hp.com>, Andrew Zabolotny <zap@homelink.ru>");
  589. MODULE_DESCRIPTION("Backlight Lowlevel Control Abstraction");