Skip to content

Commit 26c3624

Browse files
Shixiong Ouhdeller
authored andcommitted
fbcon: Use static attribute groups for sysfs entries
Using device_create_with_groups() to simplify creation and removal. Same as commit 1083a7b ("tty: Use static attribute groups for sysfs entries"). Signed-off-by: Shixiong Ou <[email protected]> Acked-by: Thomas Zimmermann <[email protected]> Signed-off-by: Helge Deller <[email protected]>
1 parent aee50bd commit 26c3624

File tree

1 file changed

+19
-50
lines changed

1 file changed

+19
-50
lines changed

drivers/video/fbdev/core/fbcon.c

Lines changed: 19 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ static int info_idx = -1;
160160

161161
/* console rotation */
162162
static int initial_rotation = -1;
163-
static int fbcon_has_sysfs;
164163
static int margin_color;
165164

166165
static const struct consw fb_con;
@@ -3159,7 +3158,7 @@ static const struct consw fb_con = {
31593158
.con_debug_leave = fbcon_debug_leave,
31603159
};
31613160

3162-
static ssize_t store_rotate(struct device *device,
3161+
static ssize_t rotate_store(struct device *device,
31633162
struct device_attribute *attr, const char *buf,
31643163
size_t count)
31653164
{
@@ -3181,7 +3180,7 @@ static ssize_t store_rotate(struct device *device,
31813180
return count;
31823181
}
31833182

3184-
static ssize_t store_rotate_all(struct device *device,
3183+
static ssize_t rotate_all_store(struct device *device,
31853184
struct device_attribute *attr,const char *buf,
31863185
size_t count)
31873186
{
@@ -3203,7 +3202,7 @@ static ssize_t store_rotate_all(struct device *device,
32033202
return count;
32043203
}
32053204

3206-
static ssize_t show_rotate(struct device *device,
3205+
static ssize_t rotate_show(struct device *device,
32073206
struct device_attribute *attr,char *buf)
32083207
{
32093208
struct fb_info *info;
@@ -3222,7 +3221,7 @@ static ssize_t show_rotate(struct device *device,
32223221
return sysfs_emit(buf, "%d\n", rotate);
32233222
}
32243223

3225-
static ssize_t show_cursor_blink(struct device *device,
3224+
static ssize_t cursor_blink_show(struct device *device,
32263225
struct device_attribute *attr, char *buf)
32273226
{
32283227
struct fb_info *info;
@@ -3247,7 +3246,7 @@ static ssize_t show_cursor_blink(struct device *device,
32473246
return sysfs_emit(buf, "%d\n", blink);
32483247
}
32493248

3250-
static ssize_t store_cursor_blink(struct device *device,
3249+
static ssize_t cursor_blink_store(struct device *device,
32513250
struct device_attribute *attr,
32523251
const char *buf, size_t count)
32533252
{
@@ -3281,35 +3280,18 @@ static ssize_t store_cursor_blink(struct device *device,
32813280
return count;
32823281
}
32833282

3284-
static struct device_attribute device_attrs[] = {
3285-
__ATTR(rotate, S_IRUGO|S_IWUSR, show_rotate, store_rotate),
3286-
__ATTR(rotate_all, S_IWUSR, NULL, store_rotate_all),
3287-
__ATTR(cursor_blink, S_IRUGO|S_IWUSR, show_cursor_blink,
3288-
store_cursor_blink),
3289-
};
3290-
3291-
static int fbcon_init_device(void)
3292-
{
3293-
int i, error = 0;
3283+
static DEVICE_ATTR_RW(cursor_blink);
3284+
static DEVICE_ATTR_RW(rotate);
3285+
static DEVICE_ATTR_WO(rotate_all);
32943286

3295-
fbcon_has_sysfs = 1;
3296-
3297-
for (i = 0; i < ARRAY_SIZE(device_attrs); i++) {
3298-
error = device_create_file(fbcon_device, &device_attrs[i]);
3299-
3300-
if (error)
3301-
break;
3302-
}
3303-
3304-
if (error) {
3305-
while (--i >= 0)
3306-
device_remove_file(fbcon_device, &device_attrs[i]);
3307-
3308-
fbcon_has_sysfs = 0;
3309-
}
3287+
static struct attribute *fbcon_device_attrs[] = {
3288+
&dev_attr_cursor_blink.attr,
3289+
&dev_attr_rotate.attr,
3290+
&dev_attr_rotate_all.attr,
3291+
NULL
3292+
};
33103293

3311-
return 0;
3312-
}
3294+
ATTRIBUTE_GROUPS(fbcon_device);
33133295

33143296
#ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER
33153297
static void fbcon_register_existing_fbs(struct work_struct *work)
@@ -3367,16 +3349,16 @@ void __init fb_console_init(void)
33673349
int i;
33683350

33693351
console_lock();
3370-
fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL,
3371-
"fbcon");
3352+
fbcon_device = device_create_with_groups(fb_class, NULL,
3353+
MKDEV(0, 0), NULL,
3354+
fbcon_device_groups, "fbcon");
33723355

33733356
if (IS_ERR(fbcon_device)) {
33743357
printk(KERN_WARNING "Unable to create device "
33753358
"for fbcon; errno = %ld\n",
33763359
PTR_ERR(fbcon_device));
33773360
fbcon_device = NULL;
3378-
} else
3379-
fbcon_init_device();
3361+
}
33803362

33813363
for (i = 0; i < MAX_NR_CONSOLES; i++)
33823364
con2fb_map[i] = -1;
@@ -3387,18 +3369,6 @@ void __init fb_console_init(void)
33873369

33883370
#ifdef MODULE
33893371

3390-
static void __exit fbcon_deinit_device(void)
3391-
{
3392-
int i;
3393-
3394-
if (fbcon_has_sysfs) {
3395-
for (i = 0; i < ARRAY_SIZE(device_attrs); i++)
3396-
device_remove_file(fbcon_device, &device_attrs[i]);
3397-
3398-
fbcon_has_sysfs = 0;
3399-
}
3400-
}
3401-
34023372
void __exit fb_console_exit(void)
34033373
{
34043374
#ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER
@@ -3411,7 +3381,6 @@ void __exit fb_console_exit(void)
34113381
#endif
34123382

34133383
console_lock();
3414-
fbcon_deinit_device();
34153384
device_destroy(fb_class, MKDEV(0, 0));
34163385

34173386
do_unregister_con_driver(&fb_con);

0 commit comments

Comments
 (0)