Skip to content

Commit

Permalink
Fix some compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyVR1 committed Sep 28, 2016
1 parent 2444b90 commit 6ed6d0a
Show file tree
Hide file tree
Showing 12 changed files with 1,131 additions and 6 deletions.
543 changes: 543 additions & 0 deletions drivers/misc/mediatek/conn_md/conn_md.c

Large diffs are not rendered by default.

157 changes: 157 additions & 0 deletions drivers/misc/mediatek/conn_md/conn_md_dbg.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@

#define DFT_TAG "[CONN_MD_DMP]"
#include "conn_md_log.h"

#include "conn_md_dbg.h"
#include "conn_md.h"
#include <linux/version.h>


#define USE_NEW_PROC_FS_FLAG 1
#define CONN_MD_DBG_PROCNAME "driver/conn_md_dbg"

static struct proc_dir_entry *gConnMdDbgEntry;

#if USE_NEW_PROC_FS_FLAG
static const struct file_operations conn_md_dbg_fops = {
.read = conn_md_dbg_read,
.write = conn_md_dbg_write,
};
#endif

static int conn_md_test_dbg(int par1, int par2, int par3);
static int conn_md_dbg_set_log_lvl(int par1, int par2, int par3);
static int conn_md_dbg_dmp_msg_log(int par1, int par2, int par3);

static const CONN_MD_DEV_DBG_FUNC conn_md_dbg_func[] = {
conn_md_test_dbg,
conn_md_dbg_set_log_lvl,
conn_md_dbg_dmp_msg_log,
NULL,
};

int conn_md_dbg_dmp_msg_log(int par1, int par2, int par3)
{
return conn_md_dmp_msg_logged(par2, par3);
}

int conn_md_dbg_set_log_lvl(int par1, int par2, int par3)
{
return conn_md_log_set_lvl(par2);
}

#if USE_NEW_PROC_FS_FLAG
ssize_t conn_md_dbg_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
{
return 0;
}
#else
static int conn_md_dbg_read(char *page, char **start, off_t off, int count, int *eof, void *data)
{
int len = 0;

return len;
}
#endif

#if USE_NEW_PROC_FS_FLAG
ssize_t conn_md_dbg_write(struct file *filp, const char __user *buffer, size_t count, loff_t *f_pos)
#else
static int conn_md_dbg_write(struct file *file, const char *buffer, unsigned long count, void *data)
#endif
{

char buf[256];
char *pBuf;
unsigned long len = count;
long x = 0;
long y = 0;
long z = 0;
long i;
char *pToken = NULL;
char *pDelimiter = " \t";

CONN_MD_INFO_FUNC("write parameter len = %d\n\r", (int)len);
if (len >= sizeof(buf)) {
CONN_MD_ERR_FUNC("input handling fail!\n");
len = sizeof(buf) - 1;
return -1;
}

if (copy_from_user(buf, buffer, len))
return -EFAULT;
buf[len] = '\0';
CONN_MD_INFO_FUNC("write parameter data = %s\n\r", buf);

pBuf = buf;
pToken = strsep(&pBuf, pDelimiter);
if (NULL != pToken)
i = kstrtol(pToken, 16, &x);
else
x = 0;

pToken = strsep(&pBuf, "\t\n ");
if (NULL != pToken)
i = kstrtol(pToken, 16, &y);
else
y = 0;

pToken = strsep(&pBuf, "\t\n ");
if (NULL != pToken)
i = kstrtol(pToken, 16, &z);
else
z = 0;

CONN_MD_INFO_FUNC("x(0x%08x), y(0x%08x), z(0x%08x)\n\r", x, y, z);

if (ARRAY_SIZE(conn_md_dbg_func) > x && NULL != conn_md_dbg_func[x])
(*conn_md_dbg_func[x]) (x, y, z);
else
CONN_MD_WARN_FUNC("no handler defined for command id(0x%08x)\n\r", x);
return len;
}

int conn_md_test_dbg(int par1, int par2, int par3)
{
return conn_md_test();
}

int conn_md_dbg_init(void)
{
#if USE_NEW_PROC_FS_FLAG
gConnMdDbgEntry = proc_create(CONN_MD_DBG_PROCNAME, 0664, NULL, &conn_md_dbg_fops);
if (gConnMdDbgEntry == NULL) {
CONN_MD_ERR_FUNC("Unable to create /proc entry\n\r");
return -1;
}
#else
gConnMdDbgEntry = create_proc_entry(CONN_MD_DBG_PROCNAME, 0664, NULL);
if (gConnMdDbgEntry == NULL) {
CONN_MD_ERR_FUNC("Unable to create /proc entry\n\r");
return -1;
}

gConnMdDbgEntry->read_proc = conn_md_dbg_read;
gConnMdDbgEntry->write_proc = conn_md_dbg_write;
#endif
return 0;

}

int conn_md_dbg_deinit(void)
{

#if USE_NEW_PROC_FS_FLAG
if (NULL != gConnMdDbgEntry)
proc_remove(gConnMdDbgEntry);
#else

if (gConnMdDbgEntry != NULL) {
remove_proc_entry(CONN_MD_DBG_PROCNAME, NULL);
return -1;
}
#endif

return 0;

}
Empty file.
153 changes: 153 additions & 0 deletions drivers/misc/mediatek/conn_md/conn_md_dump.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@

#define DFT_TAG "[CONN_MD_DMP]"

#include "conn_md_log.h"
#include "conn_md_dump.h"

P_CONN_MD_DMP_MSG_LOG conn_md_dmp_init(void)
{
uint32 msg_log_size = sizeof(CONN_MD_DMP_MSG_LOG);
P_CONN_MD_DMP_MSG_LOG p_msg_log = vmalloc(msg_log_size);

if (NULL != p_msg_log) {
CONN_MD_INFO_FUNC("alloc memory for msg log system done, size:0x%08x\n", msg_log_size);
memset(p_msg_log, 0, msg_log_size);

mutex_init(&p_msg_log->lock);

} else {
CONN_MD_ERR_FUNC("alloc memory for msg log system failed\n");
}
return p_msg_log;
}

int conn_md_dmp_deinit(P_CONN_MD_DMP_MSG_LOG p_log)
{
int i_ret = -1;

if (NULL != p_log) {
CONN_MD_INFO_FUNC("valid log buffer pointer:0x%08x, free it.\n", p_log);
mutex_destroy(&p_log->lock);
vfree(p_log);
i_ret = 0;
} else {
CONN_MD_WARN_FUNC("invalid log buffer pointer\n");
i_ret = CONN_MD_ERR_INVALID_PARAM;
}
return 0;
}

int __conn_md_dmp_in(ipc_ilm_t *p_ilm, CONN_MD_MSG_TYPE msg_type, P_CONN_MD_DMP_MSG_LOG p_msg_log)
{
struct timeval now;
P_CONN_MD_DMP_MSG_STR p_msg = NULL;

/*get current time */
do_gettimeofday(&now);

mutex_lock(&p_msg_log->lock);

p_msg = &p_msg_log->msg[p_msg_log->in];

/*Log timestamp */
p_msg->sec = now.tv_sec;
p_msg->usec = now.tv_usec;
p_msg->type = msg_type;

/*Log p_ilm */
memcpy(&p_msg->ilm, p_ilm, sizeof(ipc_ilm_t));

/*Log msg length */
p_msg->msg_len = p_ilm->local_para_ptr->msg_len;

/*Log msg content */
memcpy(&p_msg->data, p_ilm->local_para_ptr->data,
p_msg->msg_len > LENGTH_PER_PACKAGE ? LENGTH_PER_PACKAGE : p_msg->msg_len);

/*update in size and index */

if (NUMBER_OF_MSG_LOGGED <= p_msg_log->size)
p_msg_log->size = NUMBER_OF_MSG_LOGGED;
else
p_msg_log->size++;

p_msg_log->in++;
p_msg_log->in %= NUMBER_OF_MSG_LOGGED;

mutex_unlock(&p_msg_log->lock);
CONN_MD_DBG_FUNC("msg type:%d enqueued succeed\n", msg_type);
return 0;
}

int conn_md_dmp_in(ipc_ilm_t *p_ilm, CONN_MD_MSG_TYPE msg_type, P_CONN_MD_DMP_MSG_LOG p_msg_log)
{
int i_ret = -1;

if (NULL == p_ilm ||
NULL == p_ilm->local_para_ptr ||
0 == p_ilm->local_para_ptr->msg_len || (msg_type != MSG_ENQUEUE && msg_type != MSG_DEQUEUE)) {
CONN_MD_WARN_FUNC("invalid parameter\n");
i_ret = CONN_MD_ERR_INVALID_PARAM;
} else {
i_ret = __conn_md_dmp_in(p_ilm, msg_type, p_msg_log);
}
return i_ret;
}

int __conn_md_dmp_msg_filter(P_CONN_MD_DMP_MSG_STR p_msg, uint32 src_id, uint32 dst_id)
{
ipc_ilm_t *p_ilm = &p_msg->ilm;
int i = 0;

if (((0 == src_id) || (src_id == p_ilm->src_mod_id)) && ((0 == dst_id) || (dst_id == p_ilm->dest_mod_id))) {
__conn_md_log_print(DFT_TAG
"%d.%d s, <%s> src_id:0x%08x, dst_id:0x%08x, msg_len:%d, dump_len:%d:\n",
p_msg->sec, p_msg->usec,
(MSG_ENQUEUE == p_msg->type ? "enqueue" : "dequeue"),
p_msg->ilm.src_mod_id, p_msg->ilm.dest_mod_id, p_msg->msg_len,
(LENGTH_PER_PACKAGE >= p_msg->msg_len ? p_msg->msg_len : LENGTH_PER_PACKAGE));

for (i = 0; (i < p_msg->msg_len) && (i < LENGTH_PER_PACKAGE); i++) {
__conn_md_log_print("%02x ", p_msg->data[i]);
if (7 == (i % 8))
__conn_md_log_print("\n");
}
__conn_md_log_print("\n");
}
return 0;
}

int conn_md_dmp_out(P_CONN_MD_DMP_MSG_LOG p_msg_log, uint32 src_id, uint32 dst_id)
{
int i_ret = 0;
int size = 0;
int in = 0;
int out = 0;
P_CONN_MD_DMP_MSG_STR p_msg = NULL;


if (NULL == p_msg_log) {
CONN_MD_WARN_FUNC("invalid parameter, p_msg_log:0x%08x\n", p_msg_log);
return CONN_MD_ERR_INVALID_PARAM;
}
mutex_lock(&p_msg_log->lock);
size = p_msg_log->size;
mutex_unlock(&p_msg_log->lock);
CONN_MD_INFO_FUNC("dump msg for <src_id:0x%08x, dst_id:0x%08x> start\n", src_id, dst_id);
if (NUMBER_OF_MSG_LOGGED == size)
out = in;
else
out = 0;

while (size--) {
p_msg = &p_msg_log->msg[out];

__conn_md_dmp_msg_filter(p_msg, src_id, dst_id);

out++;
out %= NUMBER_OF_MSG_LOGGED;
}
mutex_unlock(&p_msg_log->lock);
CONN_MD_INFO_FUNC("dump msg for <src_id:0x%08x, dst_id:0x%08x> finished\n", src_id, dst_id);
return i_ret;
}
52 changes: 52 additions & 0 deletions drivers/misc/mediatek/conn_md/conn_md_exp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

#define DFT_TAG "[CONN_MD_EXP]"

#include "conn_md_exp.h"
#include "conn_md_log.h"

#include "conn_md.h"

int mtk_conn_md_bridge_reg(uint32 u_id, CONN_MD_BRIDGE_OPS *p_ops)
{

int i_ret = -1;
/*sanity check */
if (NULL != p_ops && NULL != p_ops->rx_cb) {
/*add user */
i_ret = conn_md_add_user(u_id, p_ops);
} else {
CONN_MD_ERR_FUNC("invalid parameter, u_id (0x%08x), p_ops(0x08x), rx_cb(0x%08x)\n",
u_id, p_ops, NULL == p_ops ? NULL : p_ops->rx_cb);
i_ret = CONN_MD_ERR_INVALID_PARAM;
}

return i_ret;
}
EXPORT_SYMBOL(mtk_conn_md_bridge_reg);

int mtk_conn_md_bridge_unreg(uint32 u_id)
{

int i_ret = -1;

/*delete user */
i_ret = conn_md_del_user(u_id);
return 0;
}
EXPORT_SYMBOL(mtk_conn_md_bridge_unreg);
int mtk_conn_md_bridge_send_msg(ipc_ilm_t *ilm)
{
int i_ret = -1;
/*sanity check */
if (NULL != ilm && NULL != ilm->local_para_ptr) {
/*send data */
i_ret = conn_md_send_msg(ilm);
} else {
CONN_MD_ERR_FUNC("invalid parameter, ilm(0x08x), ilm local_para_ptr(0x%08x)\n", ilm,
NULL == ilm ? NULL : ilm->local_para_ptr);
i_ret = CONN_MD_ERR_INVALID_PARAM;
}

return 0;
}
EXPORT_SYMBOL(mtk_conn_md_bridge_send_msg);
Loading

0 comments on commit 6ed6d0a

Please sign in to comment.