[PATCH RESEND drm-misc 3/4] drm/fbdev/core: make fb_class constant

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since commit 43a7206b0963 ("driver core: class: make class_register() take
a const *"), the driver core allows for struct class to be in read-only
memory, so move the fb_class structure to be declared at build time placing
it into read-only memory, instead of having to be dynamically allocated at
boot time.

Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Suggested-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Ricardo B. Marliere <ricardo@xxxxxxxxxxxx>
---
 drivers/video/fbdev/core/fb_internal.h |  2 +-
 drivers/video/fbdev/core/fbcon.c       |  4 ++--
 drivers/video/fbdev/core/fbmem.c       | 17 ++++++++---------
 drivers/video/fbdev/core/fbsysfs.c     |  4 ++--
 4 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/video/fbdev/core/fb_internal.h b/drivers/video/fbdev/core/fb_internal.h
index 613832d335fe..f1c0f1386675 100644
--- a/drivers/video/fbdev/core/fb_internal.h
+++ b/drivers/video/fbdev/core/fb_internal.h
@@ -38,7 +38,7 @@ static inline int fb_show_logo(struct fb_info *info, int rotate)
 #endif /* CONFIG_LOGO */
 
 /* fbmem.c */
-extern struct class *fb_class;
+extern const struct class fb_class;
 extern struct mutex registration_lock;
 extern struct fb_info *registered_fb[FB_MAX];
 extern int num_registered_fb;
diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index 1183e7a871f8..4d87a6ebdbdf 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -3380,7 +3380,7 @@ void __init fb_console_init(void)
 	int i;
 
 	console_lock();
-	fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL,
+	fbcon_device = device_create(&fb_class, NULL, MKDEV(0, 0), NULL,
 				     "fbcon");
 
 	if (IS_ERR(fbcon_device)) {
@@ -3425,7 +3425,7 @@ void __exit fb_console_exit(void)
 
 	console_lock();
 	fbcon_deinit_device();
-	device_destroy(fb_class, MKDEV(0, 0));
+	device_destroy(&fb_class, MKDEV(0, 0));
 
 	do_unregister_con_driver(&fb_con);
 	console_unlock();
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 48287366e0d4..d868194499fb 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -26,7 +26,9 @@
 
 #define FBPIXMAPSIZE	(1024 * 8)
 
-struct class *fb_class;
+const struct class fb_class = {
+	.name = "graphics",
+};
 
 DEFINE_MUTEX(registration_lock);
 struct fb_info *registered_fb[FB_MAX] __read_mostly;
@@ -571,11 +573,10 @@ static int __init fbmem_init(void)
 {
 	int ret;
 
-	fb_class = class_create("graphics");
-	if (IS_ERR(fb_class)) {
-		ret = PTR_ERR(fb_class);
+	ret = class_register(&fb_class);
+	if (ret) {
 		pr_err("Unable to create fb class; errno = %d\n", ret);
-		goto err_fb_class;
+		return ret;
 	}
 
 	ret = fb_init_procfs();
@@ -593,9 +594,7 @@ static int __init fbmem_init(void)
 err_fb_cleanup_procfs:
 	fb_cleanup_procfs();
 err_class_destroy:
-	class_destroy(fb_class);
-err_fb_class:
-	fb_class = NULL;
+	class_unregister(&fb_class);
 	return ret;
 }
 
@@ -605,7 +604,7 @@ static void __exit fbmem_exit(void)
 	fb_console_exit();
 	fb_unregister_chrdev();
 	fb_cleanup_procfs();
-	class_destroy(fb_class);
+	class_unregister(&fb_class);
 }
 
 module_init(fbmem_init);
diff --git a/drivers/video/fbdev/core/fbsysfs.c b/drivers/video/fbdev/core/fbsysfs.c
index 1b3c9958ef5c..aac013dfe06a 100644
--- a/drivers/video/fbdev/core/fbsysfs.c
+++ b/drivers/video/fbdev/core/fbsysfs.c
@@ -476,7 +476,7 @@ int fb_device_create(struct fb_info *fb_info)
 	dev_t devt = MKDEV(FB_MAJOR, node);
 	int ret;
 
-	fb_info->dev = device_create(fb_class, fb_info->device, devt, NULL, "fb%d", node);
+	fb_info->dev = device_create(&fb_class, fb_info->device, devt, NULL, "fb%d", node);
 	if (IS_ERR(fb_info->dev)) {
 		/* Not fatal */
 		ret = PTR_ERR(fb_info->dev);
@@ -497,6 +497,6 @@ void fb_device_destroy(struct fb_info *fb_info)
 		return;
 
 	fb_cleanup_device(fb_info);
-	device_destroy(fb_class, devt);
+	device_destroy(&fb_class, devt);
 	fb_info->dev = NULL;
 }

-- 
2.43.0





[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux