1 From 1ca9b0e3d8f11b5fd0ce99511b44b8be2c89d3ba Mon Sep 17 00:00:00 2001
2 From: David Herrmann <dh.herrmann@googlemail.com>
3 Date: Sat, 16 Jun 2012 23:28:18 +0200
4 Subject: [PATCH 09/10] fblog: register all handlers on module-init
6 We now create a new "fblog" device when initializing the fblog module. We
7 register the "active" sysfs-file with it so user-space can now access
8 fblog. We also register the framebuffer-notifier and console-handler so
11 Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
13 drivers/video/console/fblog.c | 59 +++++++++++++++++++++++++++++++++++++++++
14 1 file changed, 59 insertions(+)
16 diff --git a/drivers/video/console/fblog.c b/drivers/video/console/fblog.c
17 index 79bfbcc..9d3b072 100644
18 --- a/drivers/video/console/fblog.c
19 +++ b/drivers/video/console/fblog.c
20 @@ -92,6 +92,7 @@ struct fblog_fb {
23 static struct fblog_fb *fblog_fbs[FB_MAX];
24 +static struct device *fblog_device;
25 static atomic_t fblog_active;
27 static void fblog_buf_resize(struct fblog_buf *buf, size_t width,
28 @@ -609,13 +610,71 @@ static ssize_t fblog_dev_active_store(struct device *dev,
29 static DEVICE_ATTR(active, S_IRUGO | S_IWUSR | S_IWGRP, fblog_dev_active_show,
30 fblog_dev_active_store);
32 +static void fblog_dev_release(struct device *dev)
35 + module_put(THIS_MODULE);
38 static int __init fblog_init(void)
42 + fblog_device = kzalloc(sizeof(*fblog_device), GFP_KERNEL);
43 + if (!fblog_device) {
44 + pr_err("fblog: cannot allocate device\n");
49 + __module_get(THIS_MODULE);
50 + device_initialize(fblog_device);
51 + fblog_device->class = fb_class;
52 + fblog_device->release = fblog_dev_release;
53 + dev_set_name(fblog_device, "fblog");
55 + ret = device_add(fblog_device);
57 + pr_err("fblog: cannot add device\n");
61 + ret = fb_register_client(&fblog_notifier);
63 + pr_err("fblog: cannot register framebuffer notifier\n");
67 + ret = device_create_file(fblog_device, &dev_attr_active);
69 + pr_err("fblog: cannot create sysfs entry\n");
73 + register_console(&fblog_con_driver);
78 + fb_unregister_client(&fblog_notifier);
80 + device_del(fblog_device);
82 + put_device(fblog_device);
87 static void __exit fblog_exit(void)
89 + unregister_console(&fblog_con_driver);
90 + device_remove_file(fblog_device, &dev_attr_active);
91 + device_del(fblog_device);
92 + fb_unregister_client(&fblog_notifier);
96 + put_device(fblog_device);
99 module_init(fblog_init);