hc
2024-03-25 edb30157bad0c0001c32b854271ace01d3b9a16a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
 ******************************************************************************
 *
 * @file rwnx_fw_trace.c
 *
 * Copyright (C) RivieraWaves 2017-2019
 *
 ******************************************************************************
 */
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/sched.h>
#include <linux/fs.h>
#include <linux/delay.h>
#include "rwnx_fw_trace.h"
#include "aicwf_debug.h"
 
int rwnx_fw_log_init(struct rwnx_fw_log *fw_log)
{
   u8 *buf = kmalloc(FW_LOG_SIZE, GFP_KERNEL);
   if (!buf)
       return -ENOMEM;
 
   fw_log->buf.data = buf;
   fw_log->buf.start = fw_log->buf.data;
   fw_log->buf.size  = 0;
   fw_log->buf.end   = fw_log->buf.data;
   fw_log->buf.dataend = fw_log->buf.data + FW_LOG_SIZE;
   spin_lock_init(&fw_log->lock);
 
   AICWFDBG(LOGINFO, "fw_log_init: %lx, %lx\n", (unsigned long)fw_log->buf.start, (unsigned long)(fw_log->buf.dataend));
   return 0;
}
 
void rwnx_fw_log_deinit(struct rwnx_fw_log *fw_log)
{
   if (!fw_log)
       return;
 
   if (fw_log->buf.data)
       kfree(fw_log->buf.data);
   fw_log->buf.start = NULL;
   fw_log->buf.end   = NULL;
   fw_log->buf.size = 0;
}