* [PATCH 1/2] tty: vt: make vtconsole_class constant @ 2023-10-05 13:33 Greg Kroah-Hartman 2023-10-05 13:33 ` [PATCH 2/2] tty: vc_screen: make vc_class constant Greg Kroah-Hartman 0 siblings, 1 reply; 3+ messages in thread From: Greg Kroah-Hartman @ 2023-10-05 13:33 UTC (permalink / raw) To: linux-serial; +Cc: linux-kernel, Greg Kroah-Hartman, Jiri Slaby Now that the driver core allows for struct class to be in read-only memory, making all 'class' structures to be declared at build time placing them into read-only memory, instead of having to be dynamically allocated at load time. Cc: Jiri Slaby <jirislaby@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- drivers/tty/vt/vt.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 5c47f77804f0..7659b92db631 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -3565,7 +3565,9 @@ int __init vty_init(const struct file_operations *console_fops) return 0; } -static struct class *vtconsole_class; +static const struct class vtconsole_class = { + .name = "vtconsole", +}; static int do_bind_con_driver(const struct consw *csw, int first, int last, int deflt) @@ -4092,7 +4094,7 @@ static int do_register_con_driver(const struct consw *csw, int first, int last) goto err; con_driver->dev = - device_create_with_groups(vtconsole_class, NULL, + device_create_with_groups(&vtconsole_class, NULL, MKDEV(0, con_driver->node), con_driver, con_dev_groups, "vtcon%i", con_driver->node); @@ -4173,7 +4175,7 @@ static void con_driver_unregister_callback(struct work_struct *ignored) console_unlock(); vtconsole_deinit_device(con_driver); - device_destroy(vtconsole_class, MKDEV(0, con_driver->node)); + device_destroy(&vtconsole_class, MKDEV(0, con_driver->node)); console_lock(); @@ -4234,12 +4236,9 @@ static int __init vtconsole_class_init(void) { int i; - vtconsole_class = class_create("vtconsole"); - if (IS_ERR(vtconsole_class)) { - pr_warn("Unable to create vt console class; errno = %ld\n", - PTR_ERR(vtconsole_class)); - vtconsole_class = NULL; - } + i = class_register(&vtconsole_class); + if (i) + pr_warn("Unable to create vt console class; errno = %d\n", i); /* Add system drivers to sysfs */ for (i = 0; i < MAX_NR_CON_DRIVER; i++) { @@ -4247,7 +4246,7 @@ static int __init vtconsole_class_init(void) if (con->con && !con->dev) { con->dev = - device_create_with_groups(vtconsole_class, NULL, + device_create_with_groups(&vtconsole_class, NULL, MKDEV(0, con->node), con, con_dev_groups, "vtcon%i", con->node); -- 2.42.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] tty: vc_screen: make vc_class constant 2023-10-05 13:33 [PATCH 1/2] tty: vt: make vtconsole_class constant Greg Kroah-Hartman @ 2023-10-05 13:33 ` Greg Kroah-Hartman 2023-10-09 5:28 ` Jiri Slaby 0 siblings, 1 reply; 3+ messages in thread From: Greg Kroah-Hartman @ 2023-10-05 13:33 UTC (permalink / raw) To: linux-serial; +Cc: linux-kernel, Greg Kroah-Hartman, Jiri Slaby Now that the driver core allows for struct class to be in read-only memory, making all 'class' structures to be declared at build time placing them into read-only memory, instead of having to be dynamically allocated at load time. Cc: Jiri Slaby <jirislaby@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- drivers/tty/vt/vc_screen.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c index 829c4be66f3b..b16ea517bb17 100644 --- a/drivers/tty/vt/vc_screen.c +++ b/drivers/tty/vt/vc_screen.c @@ -786,23 +786,22 @@ static const struct file_operations vcs_fops = { .release = vcs_release, }; -static struct class *vc_class; +static const struct class vc_class = { + .name = "vc", +}; void vcs_make_sysfs(int index) { - device_create(vc_class, NULL, MKDEV(VCS_MAJOR, index + 1), NULL, - "vcs%u", index + 1); - device_create(vc_class, NULL, MKDEV(VCS_MAJOR, index + 65), NULL, - "vcsu%u", index + 1); - device_create(vc_class, NULL, MKDEV(VCS_MAJOR, index + 129), NULL, - "vcsa%u", index + 1); + device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, index + 1), NULL, "vcs%u", index + 1); + device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, index + 65), NULL, "vcsu%u", index + 1); + device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, index + 129), NULL, "vcsa%u", index + 1); } void vcs_remove_sysfs(int index) { - device_destroy(vc_class, MKDEV(VCS_MAJOR, index + 1)); - device_destroy(vc_class, MKDEV(VCS_MAJOR, index + 65)); - device_destroy(vc_class, MKDEV(VCS_MAJOR, index + 129)); + device_destroy(&vc_class, MKDEV(VCS_MAJOR, index + 1)); + device_destroy(&vc_class, MKDEV(VCS_MAJOR, index + 65)); + device_destroy(&vc_class, MKDEV(VCS_MAJOR, index + 129)); } int __init vcs_init(void) @@ -811,11 +810,12 @@ int __init vcs_init(void) if (register_chrdev(VCS_MAJOR, "vcs", &vcs_fops)) panic("unable to get major %d for vcs device", VCS_MAJOR); - vc_class = class_create("vc"); + if (class_register(&vc_class)) + panic("unable to create vc_class"); - device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs"); - device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 64), NULL, "vcsu"); - device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa"); + device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs"); + device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, 64), NULL, "vcsu"); + device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa"); for (i = 0; i < MIN_NR_CONSOLES; i++) vcs_make_sysfs(i); return 0; -- 2.42.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] tty: vc_screen: make vc_class constant 2023-10-05 13:33 ` [PATCH 2/2] tty: vc_screen: make vc_class constant Greg Kroah-Hartman @ 2023-10-09 5:28 ` Jiri Slaby 0 siblings, 0 replies; 3+ messages in thread From: Jiri Slaby @ 2023-10-09 5:28 UTC (permalink / raw) To: Greg Kroah-Hartman, linux-serial; +Cc: linux-kernel On 05. 10. 23, 15:33, Greg Kroah-Hartman wrote: > Now that the driver core allows for struct class to be in read-only > memory, making all 'class' structures to be declared at build time > placing them into read-only memory, instead of having to be dynamically > allocated at load time. > > Cc: Jiri Slaby <jirislaby@kernel.org> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > --- > drivers/tty/vt/vc_screen.c | 28 ++++++++++++++-------------- > 1 file changed, 14 insertions(+), 14 deletions(-) > > diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c > index 829c4be66f3b..b16ea517bb17 100644 > --- a/drivers/tty/vt/vc_screen.c > +++ b/drivers/tty/vt/vc_screen.c ... > @@ -811,11 +810,12 @@ int __init vcs_init(void) > > if (register_chrdev(VCS_MAJOR, "vcs", &vcs_fops)) > panic("unable to get major %d for vcs device", VCS_MAJOR); > - vc_class = class_create("vc"); > + if (class_register(&vc_class)) > + panic("unable to create vc_class"); FWIW it's no longer "create". Now it's "register". Anyway, for the sake of archives: Reviewed-by: Jiri Slaby <jirislaby@kernel.org> regards, -- js suse labs ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-09 5:28 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-10-05 13:33 [PATCH 1/2] tty: vt: make vtconsole_class constant Greg Kroah-Hartman 2023-10-05 13:33 ` [PATCH 2/2] tty: vc_screen: make vc_class constant Greg Kroah-Hartman 2023-10-09 5:28 ` Jiri Slaby
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).