1 /******************************************************************************
3 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
5 *****************************************************************************/
7 #include "scsc_wifilogger_ring_wakelock.h"
10 #include "scsc_wifilogger_ring_wakelock_api.h"
11 #include "scsc_wifilogger_internal.h"
13 static struct scsc_wlog_ring
*the_ring
;
16 #ifdef CONFIG_SCSC_WIFILOGGER_DEBUGFS
17 #include "scsc_wifilogger_debugfs.h"
19 static struct scsc_wlog_debugfs_info di
;
21 #endif /* CONFIG_SCSC_WIFILOGGER_DEBUGFS */
23 bool scsc_wifilogger_ring_wakelock_init(void)
25 struct scsc_wlog_ring
*r
= NULL
;
26 #ifdef CONFIG_SCSC_WIFILOGGER_DEBUGFS
27 struct scsc_ring_test_object
*rto
= NULL
;
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
,
37 SCSC_TAG_ERR(WLOG
, "Failed to CREATE WiFiLogger ring: %s\n",
38 WLOGGER_RWAKELOCK_NAME
);
41 scsc_wlog_register_verbosity_reference(r
, &wring_lev
);
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
);
51 #ifdef CONFIG_SCSC_WIFILOGGER_DEBUGFS
52 rto
= init_ring_test_object(the_ring
);
54 scsc_register_common_debugfs_entries(the_ring
->st
.name
, rto
, &di
);
60 /**** Producer API ******/
62 int scsc_wifilogger_ring_wakelock_action(u32 verbose_level
, int status
,
63 char *wl_name
, int reason
)
66 struct scsc_wake_lock_event wl_event
;
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
);
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
);
80 EXPORT_SYMBOL(scsc_wifilogger_ring_wakelock_action
);