aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Lu <aaron.lu@intel.com>2013-10-11 09:27:43 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-10-15 19:16:04 -0400
commit5915a3db0c3983f1cd5e046bf70086c7d0c686d2 (patch)
treed3f56cdf916f71ac50789abf511ee16b6bc55fe6
parent068aab7766cf968a8ddb86a6d7c6bbed9d61e353 (diff)
backlight: introduce backlight_device_registered
Introduce a new API for modules to query if a specific type of backlight device has been registered. This is useful for some backlight device provider module (e.g. ACPI video) to know if a native control interface(e.g. the interface created by i915) is available and then do things accordingly (e.g. avoid registering its own on Win8 systems). Signed-off-by: Aaron Lu <aaron.lu@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/video/backlight/backlight.c31
-rw-r--r--include/linux/backlight.h4
2 files changed, 35 insertions, 0 deletions
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 94a403a9717a..5d05555fe841 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -21,6 +21,9 @@
21#include <asm/backlight.h> 21#include <asm/backlight.h>
22#endif 22#endif
23 23
24static struct list_head backlight_dev_list;
25static struct mutex backlight_dev_list_mutex;
26
24static const char *const backlight_types[] = { 27static const char *const backlight_types[] = {
25 [BACKLIGHT_RAW] = "raw", 28 [BACKLIGHT_RAW] = "raw",
26 [BACKLIGHT_PLATFORM] = "platform", 29 [BACKLIGHT_PLATFORM] = "platform",
@@ -349,10 +352,32 @@ struct backlight_device *backlight_device_register(const char *name,
349 mutex_unlock(&pmac_backlight_mutex); 352 mutex_unlock(&pmac_backlight_mutex);
350#endif 353#endif
351 354
355 mutex_lock(&backlight_dev_list_mutex);
356 list_add(&new_bd->entry, &backlight_dev_list);
357 mutex_unlock(&backlight_dev_list_mutex);
358
352 return new_bd; 359 return new_bd;
353} 360}
354EXPORT_SYMBOL(backlight_device_register); 361EXPORT_SYMBOL(backlight_device_register);
355 362
363bool backlight_device_registered(enum backlight_type type)
364{
365 bool found = false;
366 struct backlight_device *bd;
367
368 mutex_lock(&backlight_dev_list_mutex);
369 list_for_each_entry(bd, &backlight_dev_list, entry) {
370 if (bd->props.type == type) {
371 found = true;
372 break;
373 }
374 }
375 mutex_unlock(&backlight_dev_list_mutex);
376
377 return found;
378}
379EXPORT_SYMBOL(backlight_device_registered);
380
356/** 381/**
357 * backlight_device_unregister - unregisters a backlight device object. 382 * backlight_device_unregister - unregisters a backlight device object.
358 * @bd: the backlight device object to be unregistered and freed. 383 * @bd: the backlight device object to be unregistered and freed.
@@ -364,6 +389,10 @@ void backlight_device_unregister(struct backlight_device *bd)
364 if (!bd) 389 if (!bd)
365 return; 390 return;
366 391
392 mutex_lock(&backlight_dev_list_mutex);
393 list_del(&bd->entry);
394 mutex_unlock(&backlight_dev_list_mutex);
395
367#ifdef CONFIG_PMAC_BACKLIGHT 396#ifdef CONFIG_PMAC_BACKLIGHT
368 mutex_lock(&pmac_backlight_mutex); 397 mutex_lock(&pmac_backlight_mutex);
369 if (pmac_backlight == bd) 398 if (pmac_backlight == bd)
@@ -499,6 +528,8 @@ static int __init backlight_class_init(void)
499 528
500 backlight_class->dev_groups = bl_device_groups; 529 backlight_class->dev_groups = bl_device_groups;
501 backlight_class->pm = &backlight_class_dev_pm_ops; 530 backlight_class->pm = &backlight_class_dev_pm_ops;
531 INIT_LIST_HEAD(&backlight_dev_list);
532 mutex_init(&backlight_dev_list_mutex);
502 return 0; 533 return 0;
503} 534}
504 535
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 53b77949c79d..5f9cd963213d 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -100,6 +100,9 @@ struct backlight_device {
100 /* The framebuffer notifier block */ 100 /* The framebuffer notifier block */
101 struct notifier_block fb_notif; 101 struct notifier_block fb_notif;
102 102
103 /* list entry of all registered backlight devices */
104 struct list_head entry;
105
103 struct device dev; 106 struct device dev;
104}; 107};
105 108
@@ -123,6 +126,7 @@ extern void devm_backlight_device_unregister(struct device *dev,
123 struct backlight_device *bd); 126 struct backlight_device *bd);
124extern void backlight_force_update(struct backlight_device *bd, 127extern void backlight_force_update(struct backlight_device *bd,
125 enum backlight_update_reason reason); 128 enum backlight_update_reason reason);
129extern bool backlight_device_registered(enum backlight_type type);
126 130
127#define to_backlight_device(obj) container_of(obj, struct backlight_device, dev) 131#define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
128 132