@@ -416,55 +416,64 @@ static ssize_t show_bl_curve(struct device *device,
416416/* When cmap is added back in it should be a binary attribute
417417 * not a text one. Consideration should also be given to converting
418418 * fbdev to use configfs instead of sysfs */
419- static struct device_attribute device_attrs [] = {
420- __ATTR (bits_per_pixel , S_IRUGO |S_IWUSR , show_bpp , store_bpp ),
421- __ATTR (blank , S_IRUGO |S_IWUSR , show_blank , store_blank ),
422- __ATTR (console , S_IRUGO |S_IWUSR , show_console , store_console ),
423- __ATTR (cursor , S_IRUGO |S_IWUSR , show_cursor , store_cursor ),
424- __ATTR (mode , S_IRUGO |S_IWUSR , show_mode , store_mode ),
425- __ATTR (modes , S_IRUGO |S_IWUSR , show_modes , store_modes ),
426- __ATTR (pan , S_IRUGO |S_IWUSR , show_pan , store_pan ),
427- __ATTR (virtual_size , S_IRUGO |S_IWUSR , show_virtual , store_virtual ),
428- __ATTR (name , S_IRUGO , show_name , NULL ),
429- __ATTR (stride , S_IRUGO , show_stride , NULL ),
430- __ATTR (rotate , S_IRUGO |S_IWUSR , show_rotate , store_rotate ),
431- __ATTR (state , S_IRUGO |S_IWUSR , show_fbstate , store_fbstate ),
419+ static DEVICE_ATTR (bits_per_pixel , 0644 , show_bpp , store_bpp ) ;
420+ static DEVICE_ATTR (blank , 0644 , show_blank , store_blank ) ;
421+ static DEVICE_ATTR (console , 0644 , show_console , store_console ) ;
422+ static DEVICE_ATTR (cursor , 0644 , show_cursor , store_cursor ) ;
423+ static DEVICE_ATTR (mode , 0644 , show_mode , store_mode ) ;
424+ static DEVICE_ATTR (modes , 0644 , show_modes , store_modes ) ;
425+ static DEVICE_ATTR (pan , 0644 , show_pan , store_pan ) ;
426+ static DEVICE_ATTR (virtual_size , 0644 , show_virtual , store_virtual ) ;
427+ static DEVICE_ATTR (name , 0444 , show_name , NULL) ;
428+ static DEVICE_ATTR (stride , 0444 , show_stride , NULL) ;
429+ static DEVICE_ATTR (rotate , 0644 , show_rotate , store_rotate ) ;
430+ static DEVICE_ATTR (state , 0644 , show_fbstate , store_fbstate ) ;
432431#if IS_ENABLED (CONFIG_FB_BACKLIGHT )
433- __ATTR (bl_curve , S_IRUGO | S_IWUSR , show_bl_curve , store_bl_curve ),
432+ static DEVICE_ATTR (bl_curve , 0644 , show_bl_curve , store_bl_curve );
434433#endif
434+
435+ static struct attribute * fb_device_attrs [] = {
436+ & dev_attr_bits_per_pixel .attr ,
437+ & dev_attr_blank .attr ,
438+ & dev_attr_console .attr ,
439+ & dev_attr_cursor .attr ,
440+ & dev_attr_mode .attr ,
441+ & dev_attr_modes .attr ,
442+ & dev_attr_pan .attr ,
443+ & dev_attr_virtual_size .attr ,
444+ & dev_attr_name .attr ,
445+ & dev_attr_stride .attr ,
446+ & dev_attr_rotate .attr ,
447+ & dev_attr_state .attr ,
448+ #if IS_ENABLED (CONFIG_FB_BACKLIGHT )
449+ & dev_attr_bl_curve .attr ,
450+ #endif
451+ NULL ,
452+ };
453+
454+ static const struct attribute_group fb_device_attr_group = {
455+ .attrs = fb_device_attrs ,
435456};
436457
437458static int fb_init_device (struct fb_info * fb_info )
438459{
439- int i , error = 0 ;
460+ int ret ;
440461
441462 dev_set_drvdata (fb_info -> dev , fb_info );
442463
443464 fb_info -> class_flag |= FB_SYSFS_FLAG_ATTR ;
444465
445- for (i = 0 ; i < ARRAY_SIZE (device_attrs ); i ++ ) {
446- error = device_create_file (fb_info -> dev , & device_attrs [i ]);
447-
448- if (error )
449- break ;
450- }
451-
452- if (error ) {
453- while (-- i >= 0 )
454- device_remove_file (fb_info -> dev , & device_attrs [i ]);
466+ ret = device_add_group (fb_info -> dev , & fb_device_attr_group );
467+ if (ret )
455468 fb_info -> class_flag &= ~FB_SYSFS_FLAG_ATTR ;
456- }
457469
458470 return 0 ;
459471}
460472
461473static void fb_cleanup_device (struct fb_info * fb_info )
462474{
463- unsigned int i ;
464-
465475 if (fb_info -> class_flag & FB_SYSFS_FLAG_ATTR ) {
466- for (i = 0 ; i < ARRAY_SIZE (device_attrs ); i ++ )
467- device_remove_file (fb_info -> dev , & device_attrs [i ]);
476+ device_remove_group (fb_info -> dev , & fb_device_attr_group );
468477
469478 fb_info -> class_flag &= ~FB_SYSFS_FLAG_ATTR ;
470479 }
0 commit comments