diff options
Diffstat (limited to 'drivers/video/backlight/backlight.c')
-rw-r--r-- | drivers/video/backlight/backlight.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 86e1cdc8e3..a82934694d 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -98,7 +98,9 @@ static int fb_notifier_callback(struct notifier_block *self, { struct backlight_device *bd; struct fb_event *evdata = data; - int node = evdata->info->node; + struct fb_info *info = evdata->info; + struct backlight_device *fb_bd = fb_bl_device(info); + int node = info->node; int fb_blank = 0; /* If we aren't interested in this event, skip it immediately ... */ @@ -110,7 +112,9 @@ static int fb_notifier_callback(struct notifier_block *self, if (!bd->ops) goto out; - if (bd->ops->check_fb && !bd->ops->check_fb(bd, evdata->info)) + if (bd->ops->controls_device && !bd->ops->controls_device(bd, info->device)) + goto out; + if (fb_bd && fb_bd != bd) goto out; fb_blank = *(int *)evdata->data; @@ -118,14 +122,12 @@ static int fb_notifier_callback(struct notifier_block *self, bd->fb_bl_on[node] = true; if (!bd->use_count++) { bd->props.state &= ~BL_CORE_FBBLANK; - bd->props.fb_blank = FB_BLANK_UNBLANK; backlight_update_status(bd); } } else if (fb_blank != FB_BLANK_UNBLANK && bd->fb_bl_on[node]) { bd->fb_bl_on[node] = false; if (!(--bd->use_count)) { bd->props.state |= BL_CORE_FBBLANK; - bd->props.fb_blank = fb_blank; backlight_update_status(bd); } } @@ -317,8 +319,6 @@ static ssize_t scale_show(struct device *dev, } static DEVICE_ATTR_RO(scale); -static struct class *backlight_class; - #ifdef CONFIG_PM_SLEEP static int backlight_suspend(struct device *dev) { @@ -369,6 +369,12 @@ static struct attribute *bl_device_attrs[] = { }; ATTRIBUTE_GROUPS(bl_device); +static const struct class backlight_class = { + .name = "backlight", + .dev_groups = bl_device_groups, + .pm = &backlight_class_dev_pm_ops, +}; + /** * backlight_force_update - tell the backlight subsystem that hardware state * has changed @@ -418,7 +424,7 @@ struct backlight_device *backlight_device_register(const char *name, mutex_init(&new_bd->update_lock); mutex_init(&new_bd->ops_lock); - new_bd->dev.class = backlight_class; + new_bd->dev.class = &backlight_class; new_bd->dev.parent = parent; new_bd->dev.release = bl_device_release; dev_set_name(&new_bd->dev, "%s", name); @@ -510,7 +516,7 @@ struct backlight_device *backlight_device_get_by_name(const char *name) { struct device *dev; - dev = class_find_device_by_name(backlight_class, name); + dev = class_find_device_by_name(&backlight_class, name); return dev ? to_backlight_device(dev) : NULL; } @@ -678,7 +684,7 @@ struct backlight_device *of_find_backlight_by_node(struct device_node *node) { struct device *dev; - dev = class_find_device(backlight_class, NULL, node, of_parent_match); + dev = class_find_device(&backlight_class, NULL, node, of_parent_match); return dev ? to_backlight_device(dev) : NULL; } @@ -746,20 +752,19 @@ EXPORT_SYMBOL(devm_of_find_backlight); static void __exit backlight_class_exit(void) { - class_destroy(backlight_class); + class_unregister(&backlight_class); } static int __init backlight_class_init(void) { - backlight_class = class_create("backlight"); - if (IS_ERR(backlight_class)) { - pr_warn("Unable to create backlight class; errno = %ld\n", - PTR_ERR(backlight_class)); - return PTR_ERR(backlight_class); + int ret; + + ret = class_register(&backlight_class); + if (ret) { + pr_warn("Unable to create backlight class; errno = %d\n", ret); + return ret; } - backlight_class->dev_groups = bl_device_groups; - backlight_class->pm = &backlight_class_dev_pm_ops; INIT_LIST_HEAD(&backlight_dev_list); mutex_init(&backlight_dev_list_mutex); BLOCKING_INIT_NOTIFIER_HEAD(&backlight_notifier); |