@@ -98,7 +98,9 @@ static int fb_notifier_callback(struct notifier_block *self,
9898{
9999 struct backlight_device * bd ;
100100 struct fb_event * evdata = data ;
101- int node = evdata -> info -> node ;
101+ struct fb_info * info = evdata -> info ;
102+ struct backlight_device * fb_bd = fb_bl_device (info );
103+ int node = info -> node ;
102104 int fb_blank = 0 ;
103105
104106 /* If we aren't interested in this event, skip it immediately ... */
@@ -110,22 +112,22 @@ static int fb_notifier_callback(struct notifier_block *self,
110112
111113 if (!bd -> ops )
112114 goto out ;
113- if (bd -> ops -> check_fb && !bd -> ops -> check_fb (bd , evdata -> info ))
115+ if (bd -> ops -> controls_device && !bd -> ops -> controls_device (bd , info -> device ))
116+ goto out ;
117+ if (fb_bd && fb_bd != bd )
114118 goto out ;
115119
116120 fb_blank = * (int * )evdata -> data ;
117121 if (fb_blank == FB_BLANK_UNBLANK && !bd -> fb_bl_on [node ]) {
118122 bd -> fb_bl_on [node ] = true;
119123 if (!bd -> use_count ++ ) {
120124 bd -> props .state &= ~BL_CORE_FBBLANK ;
121- bd -> props .fb_blank = FB_BLANK_UNBLANK ;
122125 backlight_update_status (bd );
123126 }
124127 } else if (fb_blank != FB_BLANK_UNBLANK && bd -> fb_bl_on [node ]) {
125128 bd -> fb_bl_on [node ] = false;
126129 if (!(-- bd -> use_count )) {
127130 bd -> props .state |= BL_CORE_FBBLANK ;
128- bd -> props .fb_blank = fb_blank ;
129131 backlight_update_status (bd );
130132 }
131133 }
@@ -317,8 +319,6 @@ static ssize_t scale_show(struct device *dev,
317319}
318320static DEVICE_ATTR_RO (scale );
319321
320- static struct class * backlight_class ;
321-
322322#ifdef CONFIG_PM_SLEEP
323323static int backlight_suspend (struct device * dev )
324324{
@@ -369,6 +369,12 @@ static struct attribute *bl_device_attrs[] = {
369369};
370370ATTRIBUTE_GROUPS (bl_device );
371371
372+ static const struct class backlight_class = {
373+ .name = "backlight" ,
374+ .dev_groups = bl_device_groups ,
375+ .pm = & backlight_class_dev_pm_ops ,
376+ };
377+
372378/**
373379 * backlight_force_update - tell the backlight subsystem that hardware state
374380 * has changed
@@ -418,7 +424,7 @@ struct backlight_device *backlight_device_register(const char *name,
418424 mutex_init (& new_bd -> update_lock );
419425 mutex_init (& new_bd -> ops_lock );
420426
421- new_bd -> dev .class = backlight_class ;
427+ new_bd -> dev .class = & backlight_class ;
422428 new_bd -> dev .parent = parent ;
423429 new_bd -> dev .release = bl_device_release ;
424430 dev_set_name (& new_bd -> dev , "%s" , name );
@@ -510,7 +516,7 @@ struct backlight_device *backlight_device_get_by_name(const char *name)
510516{
511517 struct device * dev ;
512518
513- dev = class_find_device_by_name (backlight_class , name );
519+ dev = class_find_device_by_name (& backlight_class , name );
514520
515521 return dev ? to_backlight_device (dev ) : NULL ;
516522}
@@ -678,7 +684,7 @@ struct backlight_device *of_find_backlight_by_node(struct device_node *node)
678684{
679685 struct device * dev ;
680686
681- dev = class_find_device (backlight_class , NULL , node , of_parent_match );
687+ dev = class_find_device (& backlight_class , NULL , node , of_parent_match );
682688
683689 return dev ? to_backlight_device (dev ) : NULL ;
684690}
@@ -746,20 +752,19 @@ EXPORT_SYMBOL(devm_of_find_backlight);
746752
747753static void __exit backlight_class_exit (void )
748754{
749- class_destroy ( backlight_class );
755+ class_unregister ( & backlight_class );
750756}
751757
752758static int __init backlight_class_init (void )
753759{
754- backlight_class = class_create ("backlight" );
755- if (IS_ERR (backlight_class )) {
756- pr_warn ("Unable to create backlight class; errno = %ld\n" ,
757- PTR_ERR (backlight_class ));
758- return PTR_ERR (backlight_class );
760+ int ret ;
761+
762+ ret = class_register (& backlight_class );
763+ if (ret ) {
764+ pr_warn ("Unable to create backlight class; errno = %d\n" , ret );
765+ return ret ;
759766 }
760767
761- backlight_class -> dev_groups = bl_device_groups ;
762- backlight_class -> pm = & backlight_class_dev_pm_ops ;
763768 INIT_LIST_HEAD (& backlight_dev_list );
764769 mutex_init (& backlight_dev_list_mutex );
765770 BLOCKING_INIT_NOTIFIER_HEAD (& backlight_notifier );
0 commit comments