Skip to contentSkip to conversation

tty: Use static attribute groups for sysfs entries

PATCH Superseded Takashi Iwai 1 participant 1 message Feb 5, 2015 TTY layer and serial drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty: Use static attribute groups for sysfs entries

Instead of manual calls of device_create_file() and device_remove_file(), pass the static attribute groups using device_create_with_groups().

---
 drivers/tty/tty_io.c | 14 ++++++++---
 drivers/tty/vt/vt.c  | 70 +++++++++++++++++++++++-----------------------------
 2 files changed, 41 insertions(+), 43 deletions(-)
drivers/tty/tty_io.c +10 -4
index 51f066aa375e..42d4153ad262 100644
@@ -3593,6 +3593,13 @@ static ssize_t show_cons_active(struct device *dev,
 }
 static DEVICE_ATTR(active, S_IRUGO, show_cons_active, NULL);
 
+static struct attribute *cons_dev_attrs[] = {
+	&dev_attr_active.attr,
+	NULL
+};
+
+ATTRIBUTE_GROUPS(cons_dev);
+
 static struct device *consdev;
 
 void console_sysfs_notify(void)
@@ -3617,12 +3624,11 @@ int __init tty_init(void)
 	if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
 	    register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
 		panic("Couldn't register /dev/console driver\n");
-	consdev = device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL,
-			      "console");
+	consdev = device_create_with_groups(tty_class, NULL,
+					    MKDEV(TTYAUX_MAJOR, 1), NULL,
+					    cons_dev_groups, "console");
 	if (IS_ERR(consdev))
 		consdev = NULL;
-	else
-		WARN_ON(device_create_file(consdev, &dev_attr_active) < 0);
 
 #ifdef CONFIG_VT
 	vty_init(&console_fops);
drivers/tty/vt/vt.c +31 -39

111 lines not on this page · raw message

Signature · 1 line
2.2.2