[RAMEN9610-20413][9610] wlbt: SCSC Driver version 10.6.1.0
[GitHub/MotorolaMobilityLLC/kernel-slsi.git] / drivers / misc / samsung / scsc / scsc_wifilogger_ring_wakelock.c
1 /******************************************************************************
2 *
3 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
4 *
5 *****************************************************************************/
6 /* Implements */
7 #include "scsc_wifilogger_ring_wakelock.h"
8
9 /* Uses */
10 #include "scsc_wifilogger_ring_wakelock_api.h"
11 #include "scsc_wifilogger_internal.h"
12
13 static struct scsc_wlog_ring *the_ring;
14 u32 wring_lev;
15
16 #ifdef CONFIG_SCSC_WIFILOGGER_DEBUGFS
17 #include "scsc_wifilogger_debugfs.h"
18
19 static struct scsc_wlog_debugfs_info di;
20
21 #endif /* CONFIG_SCSC_WIFILOGGER_DEBUGFS */
22
23 bool scsc_wifilogger_ring_wakelock_init(void)
24 {
25 struct scsc_wlog_ring *r = NULL;
26 #ifdef CONFIG_SCSC_WIFILOGGER_DEBUGFS
27 struct scsc_ring_test_object *rto = NULL;
28 #endif
29
30 r = scsc_wlog_ring_create(WLOGGER_RWAKELOCK_NAME,
31 RING_BUFFER_ENTRY_FLAGS_HAS_BINARY,
32 ENTRY_TYPE_WAKE_LOCK, 65536,
33 WIFI_LOGGER_WAKE_LOCK_SUPPORTED,
34 NULL, NULL, NULL);
35
36 if (!r) {
37 SCSC_TAG_ERR(WLOG, "Failed to CREATE WiFiLogger ring: %s\n",
38 WLOGGER_RWAKELOCK_NAME);
39 return false;
40 }
41 scsc_wlog_register_verbosity_reference(r, &wring_lev);
42
43 if (!scsc_wifilogger_register_ring(r)) {
44 SCSC_TAG_ERR(WLOG, "Failed to REGISTER WiFiLogger ring: %s\n",
45 WLOGGER_RWAKELOCK_NAME);
46 scsc_wlog_ring_destroy(r);
47 return false;
48 }
49 the_ring = r;
50
51 #ifdef CONFIG_SCSC_WIFILOGGER_DEBUGFS
52 rto = init_ring_test_object(the_ring);
53 if (rto)
54 scsc_register_common_debugfs_entries(the_ring->st.name, rto, &di);
55 #endif
56
57 return true;
58 }
59
60 /**** Producer API ******/
61
62 int scsc_wifilogger_ring_wakelock_action(u32 verbose_level, int status,
63 char *wl_name, int reason)
64 {
65 u64 timestamp;
66 struct scsc_wake_lock_event wl_event;
67
68 if (!the_ring)
69 return 0;
70
71 timestamp = local_clock();
72 SCSC_TAG_DBG4(WLOG, "EL -- WAKELOCK[%s] - status:%d reason:%d @0x%x\n",
73 wl_name, status, reason, timestamp);
74
75 wl_event.status = status;
76 wl_event.reason = reason;
77 return scsc_wlog_write_record(the_ring, wl_name, strlen(wl_name), &wl_event,
78 sizeof(wl_event), verbose_level, timestamp);
79 }
80 EXPORT_SYMBOL(scsc_wifilogger_ring_wakelock_action);
81