Modify it to adjust Tizen IVI enviroment
[platform/upstream/kmscon.git] / fblog / 0009-fblog-register-all-handlers-on-module-init.patch
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
5
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
9 fblog is ready to go.
10
11 Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 ---
13  drivers/video/console/fblog.c |   59 +++++++++++++++++++++++++++++++++++++++++
14  1 file changed, 59 insertions(+)
15
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 {
21  };
22  
23  static struct fblog_fb *fblog_fbs[FB_MAX];
24 +static struct device *fblog_device;
25  static atomic_t fblog_active;
26  
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);
31  
32 +static void fblog_dev_release(struct device *dev)
33 +{
34 +       kfree(dev);
35 +       module_put(THIS_MODULE);
36 +}
37 +
38  static int __init fblog_init(void)
39  {
40 +       int ret;
41 +
42 +       fblog_device = kzalloc(sizeof(*fblog_device), GFP_KERNEL);
43 +       if (!fblog_device) {
44 +               pr_err("fblog: cannot allocate device\n");
45 +               ret = -ENOMEM;
46 +               goto err_out;
47 +       }
48 +
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");
54 +
55 +       ret = device_add(fblog_device);
56 +       if (ret) {
57 +               pr_err("fblog: cannot add device\n");
58 +               goto err_dev;
59 +       }
60 +
61 +       ret = fb_register_client(&fblog_notifier);
62 +       if (ret) {
63 +               pr_err("fblog: cannot register framebuffer notifier\n");
64 +               goto err_dev_rm;
65 +       }
66 +
67 +       ret = device_create_file(fblog_device, &dev_attr_active);
68 +       if (ret) {
69 +               pr_err("fblog: cannot create sysfs entry\n");
70 +               goto err_fb;
71 +       }
72 +
73 +       register_console(&fblog_con_driver);
74 +
75         return 0;
76 +
77 +err_fb:
78 +       fb_unregister_client(&fblog_notifier);
79 +err_dev_rm:
80 +       device_del(fblog_device);
81 +err_dev:
82 +       put_device(fblog_device);
83 +err_out:
84 +       return ret;
85  }
86  
87  static void __exit fblog_exit(void)
88  {
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);
93 +       console_lock();
94 +       fblog_deactivate();
95 +       console_unlock();
96 +       put_device(fblog_device);
97  }
98  
99  module_init(fblog_init);
100 -- 
101 1.7.10.4
102