[9610] wlbt: Create and register logring sable file client
authorAlbert Cano <a.canocamps@samsung.com>
Thu, 12 Jul 2018 18:22:08 +0000 (19:22 +0100)
committerhskang <hs1218.kang@samsung.com>
Fri, 17 Aug 2018 00:32:55 +0000 (20:32 -0400)
Create and register logring sable file client to collect logring in the
sbl file.

Change-Id: I98cc68afb49d26644879193b45a2735fce681fca
SCSC-Bug-Id: SSB-41875
Signed-off-by: Cristian Marussi <c.marussi@samsung.com>
Signed-off-by: Albert Cano <a.canocamps@samsung.com>
drivers/misc/samsung/scsc/scsc_logring_debugfs.c
drivers/misc/samsung/scsc/scsc_logring_main.c

index 97a9f8a11868176e62c2c1cc86f6de63ca850014..66967948288ce774e51242949ae674177d532ab7 100644 (file)
@@ -4,6 +4,7 @@
  *
  ******************************************************************************/
 
+#include <scsc/scsc_mx.h>
 #include "scsc_logring_main.h"
 #include "scsc_logring_debugfs.h"
 
@@ -308,11 +309,32 @@ loff_t debugfile_llseek(struct file *filp, loff_t off, int whence)
        return newpos;
 }
 
+static int samsg_open(struct inode *ino, struct file *filp)
+{
+       int ret;
+
+       ret = debugfile_open(ino, filp);
+#ifdef CONFIG_SCSC_MXLOGGER
+       if (!ret)
+               scsc_service_register_observer(NULL, "LOGRING");
+#endif
+       return ret;
+}
+
+static int samsg_release(struct inode *ino, struct file *filp)
+{
+#ifdef CONFIG_SCSC_MXLOGGER
+       scsc_service_unregister_observer(NULL, "LOGRING");
+#endif
+
+       return debugfile_release(ino, filp);
+}
+
 const struct file_operations samsg_fops = {
        .owner = THIS_MODULE,
-       .open = debugfile_open,
+       .open = samsg_open,
        .read = samsg_read,
-       .release = debugfile_release,
+       .release = samsg_release,
 };
 
 /**
index 6ae198b02cad23d47d040e69411c8a447fcfdf42..7f5eda49d4c8b8c5401521b3ff94dbe8aa7b99d9 100644 (file)
@@ -3,10 +3,12 @@
  *   Copyright (c) 2016 - 2018 Samsung Electronics Co., Ltd. All rights reserved.
  *
  ********************************************************************************/
-
 #include "scsc_logring_main.h"
 #include "scsc_logring_ring.h"
 #include "scsc_logring_debugfs.h"
+#ifdef CONFIG_SCSC_LOG_COLLECTION
+#include <scsc/scsc_log_collector.h>
+#endif
 
 /* Global module parameters */
 static int              enable = DEFAULT_ENABLE_LOGRING;
@@ -26,6 +28,19 @@ static int              scsc_reset_all_droplevels_to;
 
 struct scsc_ring_buffer *the_ringbuf;
 
+#ifdef CONFIG_SCSC_LOG_COLLECTION
+static int logring_collect(struct scsc_log_collector_client *collect_client, size_t size);
+
+struct scsc_log_collector_client logring_collect_client = {
+       .name = "Logring",
+       .type = SCSC_LOG_CHUNK_LOGRING,
+       .collect_init = NULL,
+       .collect = logring_collect,
+       .collect_end = NULL,
+       .prv = NULL,
+};
+#endif
+
 /* Module init and ring buffer allocation */
 int __init samlog_init(void)
 {
@@ -70,6 +85,10 @@ int __init samlog_init(void)
                        rb->bsz);
        scsc_printk_tag(NO_ECHO_PRK, NO_TAG,
                        "Using THROWAWAY DYNAMIC per-reader buffer.\n");
+
+#ifdef CONFIG_SCSC_LOG_COLLECTION
+       scsc_log_collector_register_client(&logring_collect_client);
+#endif
        return 0;
 
 tfail:
@@ -88,6 +107,9 @@ void __exit samlog_exit(void)
        initialized = false;
        free_ring_buffer(the_ringbuf);
        the_ringbuf = NULL;
+#ifdef CONFIG_SCSC_LOG_COLLECTION
+       scsc_log_collector_unregister_client(&logring_collect_client);
+#endif
        pr_info("Samlog Unloaded\n");
 }
 
@@ -300,6 +322,29 @@ int *scsc_droplevels[] = {
        &scsc_droplevel_test_me,
 };
 
+#ifdef CONFIG_SCSC_LOG_COLLECTION
+static int logring_collect(struct scsc_log_collector_client *collect_client, size_t size)
+{
+       int ret = 0, saved_droplevel;
+
+       if (!the_ringbuf)
+               return 0;
+
+       /**
+        * Inhibit logring during collection overriding with scsc_droplevel_all
+        */
+       saved_droplevel = scsc_droplevel_all;
+       scsc_droplevel_all = DEFAULT_DROP_ALL;
+
+       /* Write buffer */
+       ret = scsc_log_collector_write(the_ringbuf->buf, the_ringbuf->bsz, 1);
+
+       scsc_droplevel_all = saved_droplevel;
+
+       return ret;
+}
+#endif
+
 static int scsc_reset_all_droplevels_to_set_param_cb(const char *val,
                                                     const struct kernel_param *kp)
 {