Commit 6e74797e authored by Subramaniam C.A's avatar Subramaniam C.A Committed by Hari Kanigeri

Syslink: Notify,various fixes on Notify driver to support notify functionality...

Syslink: Notify,various fixes on Notify driver to support notify functionality on the kernel/user side

This patch contains various fixes on the notify module.These
include:
	- Memory allocation and freeing as required.
	- Remove/modify conditions in functions
	  notify_destroy()
	  notify_ducatidrv_qsearch_elem(), etc.
	- Remove compile time warning for
	  notify_drv_unregister_driver()
Signed-off-by: default avatarC A Subramaniam <subramaniam.ca@ti.com>
parent 106ae103
...@@ -489,8 +489,7 @@ int notify_ducatidrv_delete(struct notify_driver_object **handle_ptr) ...@@ -489,8 +489,7 @@ int notify_ducatidrv_delete(struct notify_driver_object **handle_ptr)
if (event_list != NULL) { if (event_list != NULL) {
/* Check if lists were created. */ /* Check if lists were created. */
for (i = 0 ; i < driver_obj->params.num_events ; i++) { for (i = 0 ; i < driver_obj->params.num_events ; i++) {
WARN_ON(event_list[i]. WARN_ON(event_list[i].event_handler_count != 0);
event_handler_count != 0);
event_list[i].event_handler_count = 0; event_list[i].event_handler_count = 0;
list_del((struct list_head *) list_del((struct list_head *)
&event_list[i].listeners); &event_list[i].listeners);
...@@ -1116,10 +1115,8 @@ static void notify_ducatidrv_qsearch_elem(struct list_head *list, ...@@ -1116,10 +1115,8 @@ static void notify_ducatidrv_qsearch_elem(struct list_head *list,
BUG_ON(list == NULL); BUG_ON(list == NULL);
BUG_ON(check_obj == NULL); BUG_ON(check_obj == NULL);
WARN_ON(listener == NULL); BUG_ON(listener == NULL);
if (listener != NULL)
return;
*listener = NULL; *listener = NULL;
if ((list != NULL) && (check_obj != NULL)) { if ((list != NULL) && (check_obj != NULL)) {
if (list_empty((struct list_head *)list) == false) { if (list_empty((struct list_head *)list) == false) {
......
...@@ -261,6 +261,7 @@ static int notify_drv_read(struct file *filp, char *dst, size_t size, ...@@ -261,6 +261,7 @@ static int notify_drv_read(struct file *filp, char *dst, size_t size,
u32 pid = (u32) current->mm; u32 pid = (u32) current->mm;
int ret_val = 0; int ret_val = 0;
u32 i; u32 i;
struct list_head *elem;
if (WARN_ON(notifydrv_state.is_setup == false)) { if (WARN_ON(notifydrv_state.is_setup == false)) {
ret_val = -EFAULT; ret_val = -EFAULT;
...@@ -286,8 +287,11 @@ static int notify_drv_read(struct file *filp, char *dst, size_t size, ...@@ -286,8 +287,11 @@ static int notify_drv_read(struct file *filp, char *dst, size_t size,
goto func_end; goto func_end;
} }
WARN_ON(mutex_lock_interruptible(notifydrv_state.gatehandle)); WARN_ON(mutex_lock_interruptible(notifydrv_state.gatehandle));
u_buf = (struct notify_drv_event_packet *) elem = ((struct list_head *)&(notifydrv_state.event_state[i]. \
&(notifydrv_state.event_state[i].buf_list); buf_list))->next;
u_buf = container_of(elem, struct notify_drv_event_packet,
element);
list_del(elem);
mutex_unlock(notifydrv_state.gatehandle); mutex_unlock(notifydrv_state.gatehandle);
if (u_buf == NULL) { if (u_buf == NULL) {
ret_val = -EFAULT; ret_val = -EFAULT;
...@@ -295,6 +299,8 @@ static int notify_drv_read(struct file *filp, char *dst, size_t size, ...@@ -295,6 +299,8 @@ static int notify_drv_read(struct file *filp, char *dst, size_t size,
} }
ret_val = copy_to_user((void *)dst, u_buf, ret_val = copy_to_user((void *)dst, u_buf,
sizeof(struct notify_drv_event_packet)); sizeof(struct notify_drv_event_packet));
kfree(u_buf);
if (WARN_ON(ret_val != 0)) if (WARN_ON(ret_val != 0))
ret_val = -EFAULT; ret_val = -EFAULT;
if (u_buf->is_exit == true) if (u_buf->is_exit == true)
...@@ -377,7 +383,8 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd, ...@@ -377,7 +383,8 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
if (WARN_ON(retval != 0)) if (WARN_ON(retval != 0))
goto func_end; goto func_end;
cbck = vmalloc(sizeof(struct notify_drv_event_cbck)); cbck = kmalloc(sizeof(struct notify_drv_event_cbck),
GFP_ATOMIC);
WARN_ON(cbck == NULL); WARN_ON(cbck == NULL);
cbck->proc_id = src_args.procId; cbck->proc_id = src_args.procId;
cbck->func = src_args.fnNotifyCbck; cbck->func = src_args.fnNotifyCbck;
...@@ -784,29 +791,9 @@ func_end: ...@@ -784,29 +791,9 @@ func_end:
/* Module finalization function for Notify driver.*/ /* Module finalization function for Notify driver.*/
static void __exit notify_drv_finalize_module(void) static void __exit notify_drv_finalize_module(void)
{ {
struct notify_drv_event_packet *packet;
struct notify_drv_event_cbck *cbck;
u32 i ;
struct list_head *entry;
unregister_chrdev(major, "ipcnotify") ; unregister_chrdev(major, "ipcnotify") ;
notify_drv_unregister_driver();
for (i = 0 ; i < MAX_PROCESSES ; i++) {
list_for_each(entry, (struct list_head *)
&notifydrv_state.event_state[i].buf_list) {
packet = (struct notify_drv_event_packet *)entry;
if (packet != NULL)
kfree(packet);
}
}
list_for_each(entry,
(struct list_head *)&(notifydrv_state.evt_cbck_list)) {
cbck = (struct notify_drv_event_cbck *)(entry);
if (cbck != NULL)
kfree(cbck) ;
}
mutex_destroy(notifydrv_state.gatehandle);
kfree(notifydrv_state.gatehandle);
notifydrv_state.is_setup = false;
return; return;
} }
......
...@@ -135,7 +135,7 @@ int notify_destroy(void) ...@@ -135,7 +135,7 @@ int notify_destroy(void)
* If not, assert. * If not, assert.
*/ */
for (i = 0; i < NOTIFY_MAX_DRIVERS; i++) for (i = 0; i < NOTIFY_MAX_DRIVERS; i++)
WARN_ON(notify_state.drivers[i].is_init == false); WARN_ON(notify_state.drivers[i].is_init != false);
if (notify_state.cfg.gate_handle == NULL) { if (notify_state.cfg.gate_handle == NULL) {
if (notify_state.gate_handle != NULL) if (notify_state.gate_handle != NULL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment