aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/video/backlight/backlight.c40
-rw-r--r--include/linux/backlight.h7
2 files changed, 47 insertions, 0 deletions
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index bd2172c2d650..428089009cd5 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -23,6 +23,7 @@
23 23
24static struct list_head backlight_dev_list; 24static struct list_head backlight_dev_list;
25static struct mutex backlight_dev_list_mutex; 25static struct mutex backlight_dev_list_mutex;
26static struct blocking_notifier_head backlight_notifier;
26 27
27static const char *const backlight_types[] = { 28static const char *const backlight_types[] = {
28 [BACKLIGHT_RAW] = "raw", 29 [BACKLIGHT_RAW] = "raw",
@@ -370,6 +371,9 @@ struct backlight_device *backlight_device_register(const char *name,
370 list_add(&new_bd->entry, &backlight_dev_list); 371 list_add(&new_bd->entry, &backlight_dev_list);
371 mutex_unlock(&backlight_dev_list_mutex); 372 mutex_unlock(&backlight_dev_list_mutex);
372 373
374 blocking_notifier_call_chain(&backlight_notifier,
375 BACKLIGHT_REGISTERED, new_bd);
376
373 return new_bd; 377 return new_bd;
374} 378}
375EXPORT_SYMBOL(backlight_device_register); 379EXPORT_SYMBOL(backlight_device_register);
@@ -413,6 +417,10 @@ void backlight_device_unregister(struct backlight_device *bd)
413 pmac_backlight = NULL; 417 pmac_backlight = NULL;
414 mutex_unlock(&pmac_backlight_mutex); 418 mutex_unlock(&pmac_backlight_mutex);
415#endif 419#endif
420
421 blocking_notifier_call_chain(&backlight_notifier,
422 BACKLIGHT_UNREGISTERED, bd);
423
416 mutex_lock(&bd->ops_lock); 424 mutex_lock(&bd->ops_lock);
417 bd->ops = NULL; 425 bd->ops = NULL;
418 mutex_unlock(&bd->ops_lock); 426 mutex_unlock(&bd->ops_lock);
@@ -438,6 +446,36 @@ static int devm_backlight_device_match(struct device *dev, void *res,
438} 446}
439 447
440/** 448/**
449 * backlight_register_notifier - get notified of backlight (un)registration
450 * @nb: notifier block with the notifier to call on backlight (un)registration
451 *
452 * @return 0 on success, otherwise a negative error code
453 *
454 * Register a notifier to get notified when backlight devices get registered
455 * or unregistered.
456 */
457int backlight_register_notifier(struct notifier_block *nb)
458{
459 return blocking_notifier_chain_register(&backlight_notifier, nb);
460}
461EXPORT_SYMBOL(backlight_register_notifier);
462
463/**
464 * backlight_unregister_notifier - unregister a backlight notifier
465 * @nb: notifier block to unregister
466 *
467 * @return 0 on success, otherwise a negative error code
468 *
469 * Register a notifier to get notified when backlight devices get registered
470 * or unregistered.
471 */
472int backlight_unregister_notifier(struct notifier_block *nb)
473{
474 return blocking_notifier_chain_unregister(&backlight_notifier, nb);
475}
476EXPORT_SYMBOL(backlight_unregister_notifier);
477
478/**
441 * devm_backlight_device_register - resource managed backlight_device_register() 479 * devm_backlight_device_register - resource managed backlight_device_register()
442 * @dev: the device to register 480 * @dev: the device to register
443 * @name: the name of the device 481 * @name: the name of the device
@@ -544,6 +582,8 @@ static int __init backlight_class_init(void)
544 backlight_class->pm = &backlight_class_dev_pm_ops; 582 backlight_class->pm = &backlight_class_dev_pm_ops;
545 INIT_LIST_HEAD(&backlight_dev_list); 583 INIT_LIST_HEAD(&backlight_dev_list);
546 mutex_init(&backlight_dev_list_mutex); 584 mutex_init(&backlight_dev_list_mutex);
585 BLOCKING_INIT_NOTIFIER_HEAD(&backlight_notifier);
586
547 return 0; 587 return 0;
548} 588}
549 589
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 72647429adf6..adb14a8616df 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -40,6 +40,11 @@ enum backlight_type {
40 BACKLIGHT_TYPE_MAX, 40 BACKLIGHT_TYPE_MAX,
41}; 41};
42 42
43enum backlight_notification {
44 BACKLIGHT_REGISTERED,
45 BACKLIGHT_UNREGISTERED,
46};
47
43struct backlight_device; 48struct backlight_device;
44struct fb_info; 49struct fb_info;
45 50
@@ -133,6 +138,8 @@ extern void devm_backlight_device_unregister(struct device *dev,
133extern void backlight_force_update(struct backlight_device *bd, 138extern void backlight_force_update(struct backlight_device *bd,
134 enum backlight_update_reason reason); 139 enum backlight_update_reason reason);
135extern bool backlight_device_registered(enum backlight_type type); 140extern bool backlight_device_registered(enum backlight_type type);
141extern int backlight_register_notifier(struct notifier_block *nb);
142extern int backlight_unregister_notifier(struct notifier_block *nb);
136 143
137#define to_backlight_device(obj) container_of(obj, struct backlight_device, dev) 144#define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
138 145