Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fbdev: Register sysfs groups through device_add_group

Use device_add_group() to simplify creation.

Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
Signed-off-by: Helge Deller <deller@gmx.de>

authored by

Shixiong Ou and committed by
Helge Deller
5fc830d6 a979182a

+39 -30
+39 -30
drivers/video/fbdev/core/fbsysfs.c
··· 416 416 /* When cmap is added back in it should be a binary attribute 417 417 * not a text one. Consideration should also be given to converting 418 418 * 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); 432 431 #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); 434 433 #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, 435 456 }; 436 457 437 458 static int fb_init_device(struct fb_info *fb_info) 438 459 { 439 - int i, error = 0; 460 + int ret; 440 461 441 462 dev_set_drvdata(fb_info->dev, fb_info); 442 463 443 464 fb_info->class_flag |= FB_SYSFS_FLAG_ATTR; 444 465 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) 455 468 fb_info->class_flag &= ~FB_SYSFS_FLAG_ATTR; 456 - } 457 469 458 470 return 0; 459 471 } 460 472 461 473 static void fb_cleanup_device(struct fb_info *fb_info) 462 474 { 463 - unsigned int i; 464 - 465 475 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); 468 477 469 478 fb_info->class_flag &= ~FB_SYSFS_FLAG_ATTR; 470 479 }