Commit f511a004 authored by Ramesh Gupta's avatar Ramesh Gupta Committed by Hari Kanigeri

OMAP4 Syslink Notify driver fix format

This Patch fixes coding format in notify
driver.
Signed-off-by: default avatarRamesh Gupta G <grgupta@ti.com>
parent e5f5316e
...@@ -81,19 +81,18 @@ struct notifydrv_moduleobject{ ...@@ -81,19 +81,18 @@ struct notifydrv_moduleobject{
struct list_head evt_cbck_list; struct list_head evt_cbck_list;
/*List containg callback arguments for all registered handlers from /*List containg callback arguments for all registered handlers from
user mode. */ user mode. */
struct notifydrv_event_state event_state [MAX_PROCESSES]; struct notifydrv_event_state event_state[MAX_PROCESSES];
/* List for all user processes registered. */ /* List for all user processes registered. */
}; };
struct notifydrv_moduleobject notifydrv_state = struct notifydrv_moduleobject notifydrv_state = {
{
.is_setup = false, .is_setup = false,
.open_refcount = 0, .open_refcount = 0,
.gatehandle = NULL, .gatehandle = NULL,
}; };
/*Major number of driver.*/ /*Major number of driver.*/
int major = 232 ; int major = 232;
static void notify_drv_setup(void); static void notify_drv_setup(void);
...@@ -110,10 +109,11 @@ static int notify_drv_open(struct inode *inode, struct file *filp) ; ...@@ -110,10 +109,11 @@ static int notify_drv_open(struct inode *inode, struct file *filp) ;
static int notify_drv_close(struct inode *inode, struct file *filp); static int notify_drv_close(struct inode *inode, struct file *filp);
/* Linux driver function to map memory regions to user space. */ /* Linux driver function to map memory regions to user space. */
static int notify_drv_mmap(struct file * filp, struct vm_area_struct * vma); static int notify_drv_mmap(struct file *filp, struct vm_area_struct *vma);
/* read function for of Notify driver.*/ /* read function for of Notify driver.*/
static int notify_drv_read(struct file *filp, char *dst, size_t size, loff_t *offset); static int notify_drv_read(struct file *filp, char *dst,
size_t size, loff_t *offset);
/* ioctl function for of Linux Notify driver.*/ /* ioctl function for of Linux Notify driver.*/
static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd, static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
...@@ -127,12 +127,12 @@ static void __exit notify_drv_finalize_module(void) ; ...@@ -127,12 +127,12 @@ static void __exit notify_drv_finalize_module(void) ;
static void notify_drv_destroy(void); static void notify_drv_destroy(void);
int notify_drv_register_driver(void); static int notify_drv_register_driver(void);
int notify_drv_unregister_driver(void); static int notify_drv_unregister_driver(void);
/* Function to invoke the APIs through ioctl.*/ /* Function to invoke the APIs through ioctl.*/
static struct file_operations driver_ops = { static const struct file_operations driver_ops = {
.open = notify_drv_open, .open = notify_drv_open,
.ioctl = notify_drv_ioctl, .ioctl = notify_drv_ioctl,
.release = notify_drv_close, .release = notify_drv_close,
...@@ -140,22 +140,20 @@ static struct file_operations driver_ops = { ...@@ -140,22 +140,20 @@ static struct file_operations driver_ops = {
.mmap = notify_drv_mmap, .mmap = notify_drv_mmap,
}; };
int notify_drv_register_driver(void) static int notify_drv_register_driver(void)
{ {
notify_drv_setup(); notify_drv_setup();
return 0; return 0;
} }
EXPORT_SYMBOL(notify_drv_register_driver);
int notify_drv_unregister_driver(void) static int notify_drv_unregister_driver(void)
{ {
notify_drv_destroy(); notify_drv_destroy();
return 0; return 0;
} }
EXPORT_SYMBOL(notify_drv_unregister_driver);
/*============================== /*
* This function implements the callback registered with IPS. Here * This function implements the callback registered with IPS. Here
* to pass event no. back to user function(so that it can do another * to pass event no. back to user function(so that it can do another
* level of demultiplexing of callbacks) * level of demultiplexing of callbacks)
...@@ -175,7 +173,7 @@ func_end: ...@@ -175,7 +173,7 @@ func_end:
return; return;
} }
/*============================== /*
* Linux specific function to open the driver. * Linux specific function to open the driver.
*/ */
static int notify_drv_open(struct inode *inode, struct file *filp) static int notify_drv_open(struct inode *inode, struct file *filp)
...@@ -200,10 +198,10 @@ static int notify_drv_open(struct inode *inode, struct file *filp) ...@@ -200,10 +198,10 @@ static int notify_drv_open(struct inode *inode, struct file *filp)
} }
} }
mutex_unlock(notifydrv_state.gatehandle); mutex_unlock(notifydrv_state.gatehandle);
if ( isinit == true) if (isinit == true)
goto func_end; goto func_end;
sem_handle = kmalloc(sizeof (struct semaphore), GFP_ATOMIC); sem_handle = kmalloc(sizeof(struct semaphore), GFP_ATOMIC);
ter_sem_handle = kmalloc(sizeof (struct semaphore), GFP_ATOMIC); ter_sem_handle = kmalloc(sizeof(struct semaphore), GFP_ATOMIC);
sema_init(sem_handle, 0); sema_init(sem_handle, 0);
/* Create the termination semaphore */ /* Create the termination semaphore */
sema_init(ter_sem_handle, 0); sema_init(ter_sem_handle, 0);
...@@ -225,16 +223,16 @@ static int notify_drv_open(struct inode *inode, struct file *filp) ...@@ -225,16 +223,16 @@ static int notify_drv_open(struct inode *inode, struct file *filp)
} }
} }
mutex_unlock(notifydrv_state.gatehandle); mutex_unlock(notifydrv_state.gatehandle);
/* No free slots found. Let this check remain at /* No free slots found. Let this check remain at
* run-time, since it is dependent on user environment. * run-time, since it is dependent on user environment.
*/ */
if (WARN_ON(flag != true)) { if (WARN_ON(flag != true)) {
/*! @retval -1 Maximum number of supported user clients /*! @retval -1 Maximum number of supported user
have already been registered. */ clients have already been registered. */
status = NOTIFY_E_MAXCLIENTS; status = NOTIFY_E_MAXCLIENTS;
} }
} }
if(status == NOTIFY_SUCCESS) if (status == NOTIFY_SUCCESS)
ret_val = 0; ret_val = 0;
else else
ret_val = -EINVAL; ret_val = -EINVAL;
...@@ -242,7 +240,7 @@ func_end: ...@@ -242,7 +240,7 @@ func_end:
return ret_val; return ret_val;
} }
/*============== /*
* close the driver * close the driver
*/ */
static int notify_drv_close(struct inode *inode, struct file *filp) static int notify_drv_close(struct inode *inode, struct file *filp)
...@@ -254,11 +252,12 @@ static int notify_drv_close(struct inode *inode, struct file *filp) ...@@ -254,11 +252,12 @@ static int notify_drv_close(struct inode *inode, struct file *filp)
/* /*
* read data from the driver * read data from the driver
*/ */
static int notify_drv_read(struct file *filp, char *dst, size_t size, loff_t *offset) static int notify_drv_read(struct file *filp, char *dst, size_t size,
loff_t *offset)
{ {
bool flag = false; bool flag = false;
struct notify_drv_event_packet * u_buf= NULL; struct notify_drv_event_packet *u_buf = NULL;
u32 pid = (u32) current->mm; u32 pid = (u32) current->mm;
int ret_val = 0; int ret_val = 0;
u32 i; u32 i;
...@@ -282,7 +281,7 @@ static int notify_drv_read(struct file *filp, char *dst, size_t size, loff_t *of ...@@ -282,7 +281,7 @@ static int notify_drv_read(struct file *filp, char *dst, size_t size, loff_t *of
/* Wait for the event */ /* Wait for the event */
ret_val = down_interruptible( ret_val = down_interruptible(
notifydrv_state.event_state[i].semhandle); notifydrv_state.event_state[i].semhandle);
if (ret_val <0) { if (ret_val < 0) {
ret_val = -ERESTARTSYS; ret_val = -ERESTARTSYS;
goto func_end; goto func_end;
} }
...@@ -295,7 +294,7 @@ static int notify_drv_read(struct file *filp, char *dst, size_t size, loff_t *of ...@@ -295,7 +294,7 @@ static int notify_drv_read(struct file *filp, char *dst, size_t size, loff_t *of
goto func_end; goto func_end;
} }
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));
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)
...@@ -305,18 +304,18 @@ func_end: ...@@ -305,18 +304,18 @@ func_end:
return ret_val ; return ret_val ;
} }
static int notify_drv_mmap (struct file * filp, struct vm_area_struct * vma) static int notify_drv_mmap(struct file *filp, struct vm_area_struct *vma)
{ {
vma->vm_page_prot = pgprot_noncached (vma->vm_page_prot); vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
if (remap_pfn_range (vma,vma->vm_start,vma->vm_pgoff, if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
vma->vm_end - vma->vm_start,vma->vm_page_prot)) { vma->vm_end - vma->vm_start, vma->vm_page_prot)) {
return -EAGAIN; return -EAGAIN;
} }
return 0; return 0;
} }
/*===================== /*
* name notify_drv_ioctl * name notify_drv_ioctl
* *
* ioctl function for of Linux Notify driver. * ioctl function for of Linux Notify driver.
...@@ -329,32 +328,31 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd, ...@@ -329,32 +328,31 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
int status = NOTIFY_SUCCESS; int status = NOTIFY_SUCCESS;
struct notify_cmd_args *cmdArgs = (struct notify_cmd_args *)args; struct notify_cmd_args *cmdArgs = (struct notify_cmd_args *)args;
struct notify_cmd_args commonArgs; struct notify_cmd_args commonArgs;
switch (cmd) { switch (cmd) {
case CMD_NOTIFY_GETCONFIG: case CMD_NOTIFY_GETCONFIG:
{ {
struct notify_cmd_args_get_config * src_args = struct notify_cmd_args_get_config *src_args =
(struct notify_cmd_args_get_config *)args; (struct notify_cmd_args_get_config *)args;
struct notify_config cfg; struct notify_config cfg;
notify_get_config(&cfg);
notify_get_config (&cfg); retval = copy_to_user((void *) (src_args->cfg),
retval = copy_to_user ((void*) (src_args->cfg), (const void *) &cfg, sizeof(struct notify_config));
(const void *) &cfg, sizeof (struct notify_config));
} }
break; break;
case CMD_NOTIFY_SETUP: case CMD_NOTIFY_SETUP:
{ {
struct notify_cmd_args_setup * src_args = struct notify_cmd_args_setup *src_args =
(struct notify_cmd_args_setup *) args; (struct notify_cmd_args_setup *) args;
struct notify_config cfg; struct notify_config cfg;
retval = copy_from_user ((void *) &cfg, retval = copy_from_user((void *) &cfg,
(const void *) (src_args->cfg), (const void *) (src_args->cfg),
sizeof (struct notify_config)); sizeof(struct notify_config));
if (WARN_ON(retval != 0)) if (WARN_ON(retval != 0))
goto func_end; goto func_end;
notify_setup (&cfg); notify_setup(&cfg);
} }
break; break;
...@@ -363,7 +361,7 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd, ...@@ -363,7 +361,7 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
/* copy_from_user is not needed for Notify_getConfig, since the /* copy_from_user is not needed for Notify_getConfig, since the
* user's config is not used. * user's config is not used.
*/ */
status = notify_destroy (); status = notify_destroy();
} }
break; break;
...@@ -373,27 +371,26 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd, ...@@ -373,27 +371,26 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
struct notify_drv_event_cbck *cbck = NULL; struct notify_drv_event_cbck *cbck = NULL;
/* Copy the full args from user-side. */ /* Copy the full args from user-side. */
retval = copy_from_user ((void *) &src_args, (const void *) (args), retval = copy_from_user((void *) &src_args,
sizeof (struct notify_cmd_args_register_event)); (const void *) (args),
sizeof(struct notify_cmd_args_register_event));
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 = vmalloc(sizeof (struct notify_drv_event_cbck));
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;
cbck->param = src_args.cbckArg; cbck->param = src_args.cbckArg;
cbck->pid = (u32) current->mm; cbck->pid = (u32) current->mm;
status = notify_register_event (src_args.handle, src_args.procId, status = notify_register_event(src_args.handle, src_args.procId,
src_args.eventNo, notify_drv_cbck, (void *)cbck); src_args.eventNo, notify_drv_cbck, (void *)cbck);
if (status < 0) { if (status < 0) {
/* This does not impact return status of this function, /* This does not impact return status of this function,
* so retval comment is not used. * so retval comment is not used.
*/ */
kfree (cbck); kfree(cbck);
} } else {
else {
WARN_ON(mutex_lock_interruptible WARN_ON(mutex_lock_interruptible
(notifydrv_state.gatehandle)); (notifydrv_state.gatehandle));
INIT_LIST_HEAD((struct list_head *)&(cbck->element)); INIT_LIST_HEAD((struct list_head *)&(cbck->element));
...@@ -408,13 +405,13 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd, ...@@ -408,13 +405,13 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
{ {
bool found = false; bool found = false;
u32 pid = (u32) current->mm; u32 pid = (u32) current->mm;
struct notify_drv_event_cbck * cbck = NULL; struct notify_drv_event_cbck *cbck = NULL;
struct list_head *entry = NULL; struct list_head *entry = NULL;
struct notify_cmd_args_unregister_event src_args; struct notify_cmd_args_unregister_event src_args;
/* Copy the full args from user-side. */ /* Copy the full args from user-side. */
retval = copy_from_user ((void *)&src_args, (const void *)(args), retval = copy_from_user((void *)&src_args, (const void *)(args),
sizeof (struct notify_cmd_args_unregister_event)); sizeof(struct notify_cmd_args_unregister_event));
if (WARN_ON(retval != 0)) if (WARN_ON(retval != 0))
goto func_end; goto func_end;
...@@ -435,19 +432,21 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd, ...@@ -435,19 +432,21 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
status = NOTIFY_E_NOTFOUND; status = NOTIFY_E_NOTFOUND;
goto func_end; goto func_end;
} }
status = notify_unregister_event(src_args.handle, src_args.procId, status = notify_unregister_event(src_args.handle,
src_args.eventNo, notify_drv_cbck, (void *) cbck); src_args.procId,
src_args.eventNo,
notify_drv_cbck, (void *) cbck);
/* This check is needed at run-time also to propagate the /* This check is needed at run-time also to propagate the
* status to user-side. This must not be optimized out. * status to user-side. This must not be optimized out.
*/ */
if (status < 0) if (status < 0)
printk(" notify_unregister_event failed \n"); printk(KERN_ERR " notify_unregister_event failed \n");
else { else {
WARN_ON(mutex_lock_interruptible WARN_ON(mutex_lock_interruptible
(notifydrv_state.gatehandle)); (notifydrv_state.gatehandle));
list_del((struct list_head *)cbck); list_del((struct list_head *)cbck);
mutex_unlock(notifydrv_state.gatehandle); mutex_unlock(notifydrv_state.gatehandle);
kfree (cbck); kfree(cbck);
} }
} }
break; break;
...@@ -457,14 +456,14 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd, ...@@ -457,14 +456,14 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
struct notify_cmd_args_send_event src_args; struct notify_cmd_args_send_event src_args;
/* Copy the full args from user-side. */ /* Copy the full args from user-side. */
retval = copy_from_user ((void *) &src_args, retval = copy_from_user((void *) &src_args,
(const void *) (args), (const void *) (args),
sizeof (struct notify_cmd_args_send_event)); sizeof(struct notify_cmd_args_send_event));
if (WARN_ON(retval != 0)) { if (WARN_ON(retval != 0)) {
retval = -EFAULT; retval = -EFAULT;
goto func_end; goto func_end;
} }
status = notify_sendevent (src_args.handle, src_args.procId, status = notify_sendevent(src_args.handle, src_args.procId,
src_args.eventNo, src_args.payload, src_args.eventNo, src_args.payload,
src_args.waitClear); src_args.waitClear);
} }
...@@ -475,9 +474,9 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd, ...@@ -475,9 +474,9 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
struct notify_cmd_args_disable src_args; struct notify_cmd_args_disable src_args;
/* Copy the full args from user-side. */ /* Copy the full args from user-side. */
retval = copy_from_user ((void *) &src_args, retval = copy_from_user((void *) &src_args,
(const void *) (args), (const void *) (args),
sizeof (struct notify_cmd_args_disable)); sizeof(struct notify_cmd_args_disable));
/* This check is needed at run-time also since it depends on /* This check is needed at run-time also since it depends on
* run environment. It must not be optimized out. * run environment. It must not be optimized out.
...@@ -489,9 +488,9 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd, ...@@ -489,9 +488,9 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
src_args.flags = notify_disable(src_args.procId); src_args.flags = notify_disable(src_args.procId);
/* Copy the full args to user-side */ /* Copy the full args to user-side */
retval = copy_to_user ((void *) (args), retval = copy_to_user((void *) (args),
(const void *) &src_args, (const void *) &src_args,
sizeof (struct notify_cmd_args_disable)); sizeof(struct notify_cmd_args_disable));
/* This check is needed at run-time also since it depends on /* This check is needed at run-time also since it depends on
* run environment. It must not be optimized out. * run environment. It must not be optimized out.
*/ */
...@@ -505,8 +504,9 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd, ...@@ -505,8 +504,9 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
struct notify_cmd_args_restore src_args; struct notify_cmd_args_restore src_args;
/* Copy the full args from user-side. */ /* Copy the full args from user-side. */
retval = copy_from_user((void *) &src_args,(const void *)(args), retval = copy_from_user((void *) &src_args,
sizeof (struct notify_cmd_args_restore)); (const void *)(args),
sizeof(struct notify_cmd_args_restore));
if (WARN_ON(retval != 0)) { if (WARN_ON(retval != 0)) {
retval = -EFAULT; retval = -EFAULT;
goto func_end; goto func_end;
...@@ -520,8 +520,9 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd, ...@@ -520,8 +520,9 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
struct notify_cmd_args_disable_event src_args; struct notify_cmd_args_disable_event src_args;
/* Copy the full args from user-side. */ /* Copy the full args from user-side. */
retval = copy_from_user((void *) &src_args, (const void *)(args), retval = copy_from_user((void *) &src_args,
sizeof (struct notify_cmd_args_disable_event)); (const void *)(args),
sizeof(struct notify_cmd_args_disable_event));
/* This check is needed at run-time also since it depends on /* This check is needed at run-time also since it depends on
* run environment. It must not be optimized out. * run environment. It must not be optimized out.
...@@ -540,8 +541,9 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd, ...@@ -540,8 +541,9 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
struct notify_cmd_args_enable_event src_args; struct notify_cmd_args_enable_event src_args;
/* Copy the full args from user-side. */ /* Copy the full args from user-side. */
retval = copy_from_user ((void *)&src_args, (const void *)(args), retval = copy_from_user((void *)&src_args,
sizeof (struct notify_cmd_args_enable_event)); (const void *)(args),
sizeof(struct notify_cmd_args_enable_event));
if (WARN_ON(retval != 0)) { if (WARN_ON(retval != 0)) {
retval = -EFAULT; retval = -EFAULT;
goto func_end; goto func_end;
...@@ -556,26 +558,26 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd, ...@@ -556,26 +558,26 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
/* No args to be copied from user-side. */ /* No args to be copied from user-side. */
status = notify_drv_exit(); status = notify_drv_exit();
if (status < 0) if (status < 0)
printk("notify_driver_exit FAILED\n"); printk(KERN_ERR "notify_driver_exit FAILED\n");
} }
break; break;
default: default:
{ {
/* This does not impact return status of this function, so retval /* This does not impact return status of this function,so retval
* comment is not used. * comment is not used.
*/ */
status = NOTIFY_E_INVALIDARG; status = NOTIFY_E_INVALIDARG;
printk("not valid command\n"); printk(KERN_ERR "not valid command\n");
} }
break; break;
} }
func_end: func_end:
/* Set the status and copy the common args to user-side. */ /* Set the status and copy the common args to user-side. */
commonArgs.apiStatus = status; commonArgs.apiStatus = status;
status = copy_to_user ((void *) cmdArgs, status = copy_to_user((void *) cmdArgs,
(const void *) &commonArgs, (const void *) &commonArgs,
sizeof (struct notify_cmd_args)); sizeof(struct notify_cmd_args));
if (status < 0) if (status < 0)
retval = -EFAULT; retval = -EFAULT;
return retval; return retval;
...@@ -591,7 +593,7 @@ static int notify_drv_add_buf_by_pid(u16 proc_id, u32 pid, ...@@ -591,7 +593,7 @@ static int notify_drv_add_buf_by_pid(u16 proc_id, u32 pid,
s32 status = 0; s32 status = 0;
bool flag = false; bool flag = false;
bool is_exit = false; bool is_exit = false;
struct notify_drv_event_packet * u_buf = NULL; struct notify_drv_event_packet *u_buf = NULL;
u32 i; u32 i;
for (i = 0 ; (i < MAX_PROCESSES) && (flag != true) ; i++) { for (i = 0 ; (i < MAX_PROCESSES) && (flag != true) ; i++) {
...@@ -604,8 +606,7 @@ static int notify_drv_add_buf_by_pid(u16 proc_id, u32 pid, ...@@ -604,8 +606,7 @@ static int notify_drv_add_buf_by_pid(u16 proc_id, u32 pid,
status = -EFAULT; status = -EFAULT;
goto func_end; goto func_end;
} }
u_buf = (struct notify_drv_event_packet *)kmalloc u_buf = kmalloc(sizeof(struct notify_drv_event_packet), GFP_ATOMIC);
(sizeof (struct notify_drv_event_packet), GFP_ATOMIC);
if (u_buf != NULL) { if (u_buf != NULL) {
INIT_LIST_HEAD((struct list_head *)&u_buf->element); INIT_LIST_HEAD((struct list_head *)&u_buf->element);
u_buf->proc_id = proc_id; u_buf->proc_id = proc_id;
...@@ -636,7 +637,7 @@ func_end: ...@@ -636,7 +637,7 @@ func_end:
return status; return status;
} }
/*==================== /*
* notify_drv_exit * notify_drv_exit
* *
*/ */
...@@ -655,16 +656,16 @@ int notify_drv_exit(void) ...@@ -655,16 +656,16 @@ int notify_drv_exit(void)
status = NOTIFY_E_FAIL; status = NOTIFY_E_FAIL;
goto func_end; goto func_end;
} }
if (WARN_ON(notifydrv_state.is_setup == false)){ if (WARN_ON(notifydrv_state.is_setup == false)) {
/* The Notify OS driver was not setup */ /* The Notify OS driver was not setup */
status = NOTIFY_E_SETUP; status = NOTIFY_E_SETUP;
goto func_end; goto func_end;
} }
/* Send the termination packet to notify thread */ /* Send the termination packet to notify thread */
status = notify_drv_add_buf_by_pid (0, /* Ignored. */ status = notify_drv_add_buf_by_pid(0, /* Ignored. */
(u32) current->mm, (u32) -1, (u32)0, NULL, NULL); (u32) current->mm, (u32) -1, (u32)0, NULL, NULL);
if (status < 0) { if (status < 0) {
printk ("notify_drv_exit failed to send" printk(KERN_ERR "notify_drv_exit failed to send"
"termination packet\n."); "termination packet\n.");
goto func_end; goto func_end;
} }
...@@ -691,8 +692,7 @@ int notify_drv_exit(void) ...@@ -691,8 +692,7 @@ int notify_drv_exit(void)
NULL; NULL;
flag = true; flag = true;
break; break;
} } else
else
notifydrv_state.event_state[i].ref_count--; notifydrv_state.event_state[i].ref_count--;
} }
} }
...@@ -710,7 +710,7 @@ func_end: ...@@ -710,7 +710,7 @@ func_end:
return status; return status;
} }
/*==================== /*
* Module setup function. * Module setup function.
* *
*/ */
...@@ -719,7 +719,7 @@ static void notify_drv_setup(void) ...@@ -719,7 +719,7 @@ static void notify_drv_setup(void)
int i; int i;
INIT_LIST_HEAD((struct list_head *)&(notifydrv_state.evt_cbck_list)); INIT_LIST_HEAD((struct list_head *)&(notifydrv_state.evt_cbck_list));
notifydrv_state.gatehandle = kmalloc(sizeof (struct mutex), notifydrv_state.gatehandle = kmalloc(sizeof(struct mutex),
GFP_KERNEL); GFP_KERNEL);
mutex_init(notifydrv_state.gatehandle); mutex_init(notifydrv_state.gatehandle);
for (i = 0; i < MAX_PROCESSES ; i++) { for (i = 0; i < MAX_PROCESSES ; i++) {
...@@ -732,7 +732,7 @@ static void notify_drv_setup(void) ...@@ -732,7 +732,7 @@ static void notify_drv_setup(void)
} }
/*===================== /*
* brief Module destroy function. * brief Module destroy function.
*/ */
static void notify_drv_destroy(void) static void notify_drv_destroy(void)
...@@ -748,7 +748,6 @@ static void notify_drv_destroy(void) ...@@ -748,7 +748,6 @@ static void notify_drv_destroy(void)
packet = (struct notify_drv_event_packet *)entry; packet = (struct notify_drv_event_packet *)entry;
if (packet != NULL) if (packet != NULL)
kfree(packet); kfree(packet);
} }
INIT_LIST_HEAD(&notifydrv_state.event_state[i].buf_list); INIT_LIST_HEAD(&notifydrv_state.event_state[i].buf_list);
} }
...@@ -774,7 +773,7 @@ static int __init notify_drv_init_module(void) ...@@ -774,7 +773,7 @@ static int __init notify_drv_init_module(void)
result = register_chrdev(major, "ipcnotify", &driver_ops); result = register_chrdev(major, "ipcnotify", &driver_ops);
if (result < 0) { if (result < 0) {
printk("Notify driver initialization failure - 1\n"); printk(KERN_ERR "Notify driver initialization failure - 1\n");
goto func_end; goto func_end;
} }
result = notify_drv_register_driver(); result = notify_drv_register_driver();
...@@ -797,7 +796,6 @@ static void __exit notify_drv_finalize_module(void) ...@@ -797,7 +796,6 @@ static void __exit notify_drv_finalize_module(void)
packet = (struct notify_drv_event_packet *)entry; packet = (struct notify_drv_event_packet *)entry;
if (packet != NULL) if (packet != NULL)
kfree(packet); kfree(packet);
} }
} }
list_for_each(entry, list_for_each(entry,
......
...@@ -34,11 +34,10 @@ ...@@ -34,11 +34,10 @@
*desc Check if specified processor ID is supported by the Notify driver. *desc Check if specified processor ID is supported by the Notify driver.
* *
*/ */
bool _notify_is_support_proc(struct notify_driver_object *drv_handle, static bool _notify_is_support_proc(struct notify_driver_object *drv_handle,
int proc_id); int proc_id);
struct notify_module_object notify_state = struct notify_module_object notify_state = {
{
.is_setup = false, .is_setup = false,
.def_cfg.gate_handle = NULL, .def_cfg.gate_handle = NULL,
.def_cfg.maxDrivers = 2, .def_cfg.maxDrivers = 2,
...@@ -46,7 +45,7 @@ struct notify_module_object notify_state = ...@@ -46,7 +45,7 @@ struct notify_module_object notify_state =
EXPORT_SYMBOL(notify_state); EXPORT_SYMBOL(notify_state);
/*================================== /*
* Get the default configuration for the Notify module. * Get the default configuration for the Notify module.
* *
* This function can be called by the application to get their * This function can be called by the application to get their
...@@ -58,18 +57,19 @@ EXPORT_SYMBOL(notify_state); ...@@ -58,18 +57,19 @@ EXPORT_SYMBOL(notify_state);
* param-cfg :Pointer to the Notify module configuration * param-cfg :Pointer to the Notify module configuration
* structure in which the default config is to be returned. * structure in which the default config is to be returned.
*/ */
void notify_get_config (struct notify_config * cfg) void notify_get_config(struct notify_config *cfg)
{ {
BUG_ON(cfg == NULL); BUG_ON(cfg == NULL);
if (notify_state.is_setup == false) if (notify_state.is_setup == false)
memcpy(cfg, &notify_state.def_cfg, sizeof(struct notify_config)); memcpy(cfg, &notify_state.def_cfg,
sizeof(struct notify_config));
else else
memcpy(cfg, &notify_state.cfg, sizeof(struct notify_config)); memcpy(cfg, &notify_state.cfg, sizeof(struct notify_config));
} }
EXPORT_SYMBOL(notify_get_config); EXPORT_SYMBOL(notify_get_config);
/*================================ /*
* Setup the Notify module. * Setup the Notify module.
* *
* This function sets up the Notify module. This function * This function sets up the Notify module. This function
...@@ -87,32 +87,32 @@ EXPORT_SYMBOL(notify_get_config); ...@@ -87,32 +87,32 @@ EXPORT_SYMBOL(notify_get_config);
* param -cfg Optional Notify module configuration. If provided as * param -cfg Optional Notify module configuration. If provided as
* NULL, default configuration is used. * NULL, default configuration is used.
*/ */
int notify_setup (struct notify_config * cfg) int notify_setup(struct notify_config *cfg)
{ {
int status = NOTIFY_SUCCESS; int status = NOTIFY_SUCCESS;
struct notify_config tmpCfg; struct notify_config tmpCfg;
if (cfg == NULL) { if (cfg == NULL) {
notify_get_config (&tmpCfg); notify_get_config(&tmpCfg);
cfg = &tmpCfg; cfg = &tmpCfg;
} }
if (cfg->gate_handle != NULL) { if (cfg->gate_handle != NULL) {
notify_state.gate_handle = cfg->gate_handle; notify_state.gate_handle = cfg->gate_handle;
} } else {
else {
notify_state.gate_handle = kmalloc(sizeof(struct mutex), notify_state.gate_handle = kmalloc(sizeof(struct mutex),
GFP_ATOMIC); GFP_ATOMIC);
/* User has not provided any gate handle, so create a default handle. */ /*User has not provided any gate handle,
mutex_init (notify_state.gate_handle); so create a default handle.*/
mutex_init(notify_state.gate_handle);
} }
if (WARN_ON(cfg->maxDrivers > NOTIFY_MAX_DRIVERS)) { if (WARN_ON(cfg->maxDrivers > NOTIFY_MAX_DRIVERS)) {
status = NOTIFY_E_CONFIG; status = NOTIFY_E_CONFIG;
goto func_end; goto func_end;
} }
memcpy(&notify_state.cfg, cfg, sizeof (struct notify_config)); memcpy(&notify_state.cfg, cfg, sizeof(struct notify_config));
memset(&notify_state.drivers, 0, memset(&notify_state.drivers, 0,
(sizeof (struct notify_driver_object) * NOTIFY_MAX_DRIVERS)); (sizeof(struct notify_driver_object) * NOTIFY_MAX_DRIVERS));
notify_state.disable_depth = 0; notify_state.disable_depth = 0;
notify_state.is_setup = true; notify_state.is_setup = true;
func_end: func_end:
...@@ -120,7 +120,7 @@ func_end: ...@@ -120,7 +120,7 @@ func_end:
} }
EXPORT_SYMBOL(notify_setup); EXPORT_SYMBOL(notify_setup);
/*====================================== /*
* Destroy the Notify module. * Destroy the Notify module.
* *
* Once this function is called, other Notify module APIs, * Once this function is called, other Notify module APIs,
...@@ -134,9 +134,9 @@ int notify_destroy(void) ...@@ -134,9 +134,9 @@ int notify_destroy(void)
/* Check if any Notify driver instances have not been deleted so far. /* Check if any Notify driver instances have not been deleted so far.
* 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)
kfree(notify_state.gate_handle); kfree(notify_state.gate_handle);
...@@ -146,7 +146,7 @@ int notify_destroy(void) ...@@ -146,7 +146,7 @@ int notify_destroy(void)
} }
EXPORT_SYMBOL(notify_destroy); EXPORT_SYMBOL(notify_destroy);
/*==================================== /*
* func notify_register_event * func notify_register_event
* *
* desc This function registers a callback for a specific event with the * desc This function registers a callback for a specific event with the
...@@ -159,7 +159,7 @@ int notify_register_event(void *notify_driver_handle, u16 proc_id, ...@@ -159,7 +159,7 @@ int notify_register_event(void *notify_driver_handle, u16 proc_id,
struct notify_driver_object *drv_handle = struct notify_driver_object *drv_handle =
(struct notify_driver_object *)notify_driver_handle; (struct notify_driver_object *)notify_driver_handle;
BUG_ON(drv_handle == NULL); BUG_ON(drv_handle == NULL);
if (WARN_ON(drv_handle->is_init == false)) { if (WARN_ON(drv_handle->is_init == false)) {
status = NOTIFY_E_SETUP; status = NOTIFY_E_SETUP;
...@@ -174,14 +174,14 @@ int notify_register_event(void *notify_driver_handle, u16 proc_id, ...@@ -174,14 +174,14 @@ int notify_register_event(void *notify_driver_handle, u16 proc_id,
status = NOTIFY_E_INVALIDEVENT; status = NOTIFY_E_INVALIDEVENT;
goto func_end; goto func_end;
} }
if (WARN_ON(((event_no & NOTIFY_EVENT_MASK) < if (WARN_ON(((event_no & NOTIFY_EVENT_MASK) <
drv_handle->attrs.proc_info [proc_id].reserved_events) && drv_handle->attrs.proc_info[proc_id].reserved_events) &&
((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof (u16)) != ((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof(u16)) !=
NOTIFY_SYSTEM_KEY)) { NOTIFY_SYSTEM_KEY)) {
status = NOTIFY_E_RESERVEDEVENT; status = NOTIFY_E_RESERVEDEVENT;
goto func_end; goto func_end;
} }
if (mutex_lock_interruptible (notify_state.gate_handle) != 0) if (mutex_lock_interruptible(notify_state.gate_handle) != 0)
WARN_ON(1); WARN_ON(1);
status = drv_handle->fn_table.register_event(drv_handle, proc_id, status = drv_handle->fn_table.register_event(drv_handle, proc_id,
...@@ -204,15 +204,12 @@ EXPORT_SYMBOL(notify_register_event); ...@@ -204,15 +204,12 @@ EXPORT_SYMBOL(notify_register_event);
* the Notify module. * the Notify module.
*/ */
int notify_unregister_event (void *notify_driver_handle, u16 proc_id, int notify_unregister_event(void *notify_driver_handle, u16 proc_id,
u32 event_no, notify_callback_fxn notify_callback_fxn, void *cbck_arg) u32 event_no, notify_callback_fxn notify_callback_fxn, void *cbck_arg)
{ {
int status = NOTIFY_SUCCESS; int status = NOTIFY_SUCCESS;
struct notify_driver_object *drv_handle = struct notify_driver_object *drv_handle =
(struct notify_driver_object *)notify_driver_handle; (struct notify_driver_object *)notify_driver_handle;
BUG_ON(drv_handle == NULL); BUG_ON(drv_handle == NULL);
if (WARN_ON(drv_handle->is_init == false)) { if (WARN_ON(drv_handle->is_init == false)) {
status = NOTIFY_E_SETUP; status = NOTIFY_E_SETUP;
...@@ -227,25 +224,24 @@ int notify_unregister_event (void *notify_driver_handle, u16 proc_id, ...@@ -227,25 +224,24 @@ int notify_unregister_event (void *notify_driver_handle, u16 proc_id,
status = NOTIFY_E_INVALIDEVENT; status = NOTIFY_E_INVALIDEVENT;
goto func_end; goto func_end;
} }
if (WARN_ON(((event_no & NOTIFY_EVENT_MASK) < if (WARN_ON(((event_no & NOTIFY_EVENT_MASK) <
drv_handle->attrs.proc_info [proc_id].reserved_events) && drv_handle->attrs.proc_info[proc_id].reserved_events) &&
((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof (u16)) != ((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof(u16)) !=
NOTIFY_SYSTEM_KEY)) { NOTIFY_SYSTEM_KEY)) {
status = NOTIFY_E_RESERVEDEVENT; status = NOTIFY_E_RESERVEDEVENT;
goto func_end; goto func_end;
} }
if (mutex_lock_interruptible (notify_state.gate_handle) != 0) if (mutex_lock_interruptible(notify_state.gate_handle) != 0)
WARN_ON(1); WARN_ON(1);
status = drv_handle->fn_table.unregister_event(drv_handle, status = drv_handle->fn_table.unregister_event(drv_handle,
proc_id, (event_no & NOTIFY_EVENT_MASK), proc_id, (event_no & NOTIFY_EVENT_MASK),
notify_callback_fxn, cbck_arg); notify_callback_fxn, cbck_arg);
mutex_unlock(notify_state.gate_handle); mutex_unlock(notify_state.gate_handle);
if (WARN_ON(status < 0)) { if (WARN_ON(status < 0))
status = NOTIFY_E_FAIL; status = NOTIFY_E_FAIL;
}else else
status = NOTIFY_SUCCESS; status = NOTIFY_SUCCESS;
func_end: func_end:
return status; return status;
} }
...@@ -262,10 +258,8 @@ int notify_sendevent(void *notify_driver_handle, u16 proc_id, ...@@ -262,10 +258,8 @@ int notify_sendevent(void *notify_driver_handle, u16 proc_id,
u32 event_no, u32 payload, bool wait_clear) u32 event_no, u32 payload, bool wait_clear)
{ {
int status = NOTIFY_SUCCESS; int status = NOTIFY_SUCCESS;
struct notify_driver_object *drv_handle = struct notify_driver_object *drv_handle =
(struct notify_driver_object *)notify_driver_handle; (struct notify_driver_object *)notify_driver_handle;
BUG_ON(drv_handle == NULL); BUG_ON(drv_handle == NULL);
if (WARN_ON(drv_handle->is_init == false)) { if (WARN_ON(drv_handle->is_init == false)) {
status = NOTIFY_E_SETUP; status = NOTIFY_E_SETUP;
...@@ -280,14 +274,14 @@ int notify_sendevent(void *notify_driver_handle, u16 proc_id, ...@@ -280,14 +274,14 @@ int notify_sendevent(void *notify_driver_handle, u16 proc_id,
status = NOTIFY_E_INVALIDEVENT; status = NOTIFY_E_INVALIDEVENT;
goto func_end; goto func_end;
} }
if (WARN_ON(((event_no & NOTIFY_EVENT_MASK) < if (WARN_ON(((event_no & NOTIFY_EVENT_MASK) <
drv_handle->attrs.proc_info [proc_id].reserved_events) && drv_handle->attrs.proc_info[proc_id].reserved_events) &&
((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof (u16)) != ((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof(u16)) !=
NOTIFY_SYSTEM_KEY)) { NOTIFY_SYSTEM_KEY)) {
status = NOTIFY_E_RESERVEDEVENT; status = NOTIFY_E_RESERVEDEVENT;
goto func_end; goto func_end;
} }
if (mutex_lock_interruptible (notify_state.gate_handle) != 0) if (mutex_lock_interruptible(notify_state.gate_handle) != 0)
WARN_ON(1); WARN_ON(1);
status = drv_handle->fn_table.send_event status = drv_handle->fn_table.send_event
(drv_handle, proc_id, (event_no & NOTIFY_EVENT_MASK), (drv_handle, proc_id, (event_no & NOTIFY_EVENT_MASK),
...@@ -319,7 +313,7 @@ u32 notify_disable(u16 proc_id) ...@@ -319,7 +313,7 @@ u32 notify_disable(u16 proc_id)
BUG_ON(notify_state.is_setup != true); BUG_ON(notify_state.is_setup != true);
if (mutex_lock_interruptible (notify_state.gate_handle) != 0) if (mutex_lock_interruptible(notify_state.gate_handle) != 0)
WARN_ON(1); WARN_ON(1);
for (i = 0; i < notify_state.cfg.maxDrivers; i++) { for (i = 0; i < notify_state.cfg.maxDrivers; i++) {
drv_handle = &(notify_state.drivers[i]); drv_handle = &(notify_state.drivers[i]);
...@@ -328,9 +322,11 @@ u32 notify_disable(u16 proc_id) ...@@ -328,9 +322,11 @@ u32 notify_disable(u16 proc_id)
if (drv_handle->is_init == if (drv_handle->is_init ==
NOTIFY_DRIVERINITSTATUS_NOTDONE) { NOTIFY_DRIVERINITSTATUS_NOTDONE) {
if (drv_handle->fn_table.disable) { if (drv_handle->fn_table.disable) {
drv_handle->disable_flag[notify_state.disable_depth] = drv_handle->disable_flag[notify_state.
(u32 *)drv_handle->fn_table.disable disable_depth] =
(drv_handle, proc_id); (u32 *)drv_handle->fn_table.
disable(drv_handle,
proc_id);
} }
} }
} }
...@@ -341,7 +337,7 @@ u32 notify_disable(u16 proc_id) ...@@ -341,7 +337,7 @@ u32 notify_disable(u16 proc_id)
} }
EXPORT_SYMBOL(notify_disable); EXPORT_SYMBOL(notify_disable);
/*============================== /*
* notify_restore * notify_restore
* *
* desc This function restores the Notify module to the state before the * desc This function restores the Notify module to the state before the
...@@ -350,29 +346,30 @@ EXPORT_SYMBOL(notify_disable); ...@@ -350,29 +346,30 @@ EXPORT_SYMBOL(notify_disable);
* the Notify module. All callbacks registered for all events as * the Notify module. All callbacks registered for all events as
* specified in the flags are enabled with this API. It is not possible * specified in the flags are enabled with this API. It is not possible
* to enable a specific callback. * to enable a specific callback.
* *
* *
*/ */
void notify_restore (u32 key, u16 proc_id) void notify_restore(u32 key, u16 proc_id)
{ {
struct notify_driver_object *drv_handle; struct notify_driver_object *drv_handle;
int i; int i;
BUG_ON(notify_state.is_setup != true); BUG_ON(notify_state.is_setup != true);
if (mutex_lock_interruptible (notify_state.gate_handle) != 0) if (mutex_lock_interruptible(notify_state.gate_handle) != 0)
WARN_ON(1); WARN_ON(1);
notify_state.disable_depth--; notify_state.disable_depth--;
for (i = 0; i < notify_state.cfg.maxDrivers; i++) { for (i = 0; i < notify_state.cfg.maxDrivers; i++) {
drv_handle = &(notify_state.drivers[i]); drv_handle = &(notify_state.drivers[i]);
if (drv_handle->fn_table.restore) if (drv_handle->fn_table.restore)
drv_handle->fn_table.restore(drv_handle, key, proc_id); drv_handle->fn_table.restore(drv_handle,
key, proc_id);
} }
mutex_unlock(notify_state.gate_handle); mutex_unlock(notify_state.gate_handle);
return; return;
} }
EXPORT_SYMBOL(notify_restore); EXPORT_SYMBOL(notify_restore);
/*================================= /*
*func notify_disable_event *func notify_disable_event
* *
* desc This function disables a specific event. All callbacks registered * desc This function disables a specific event. All callbacks registered
...@@ -386,7 +383,6 @@ void notify_disable_event(void *notify_driver_handle, u16 proc_id, u32 event_no) ...@@ -386,7 +383,6 @@ void notify_disable_event(void *notify_driver_handle, u16 proc_id, u32 event_no)
int status = 0; int status = 0;
struct notify_driver_object *drv_handle = struct notify_driver_object *drv_handle =
(struct notify_driver_object *)notify_driver_handle; (struct notify_driver_object *)notify_driver_handle;
BUG_ON(drv_handle == NULL); BUG_ON(drv_handle == NULL);
if (WARN_ON(drv_handle->is_init == false)) { if (WARN_ON(drv_handle->is_init == false)) {
status = NOTIFY_E_SETUP; status = NOTIFY_E_SETUP;
...@@ -401,14 +397,14 @@ void notify_disable_event(void *notify_driver_handle, u16 proc_id, u32 event_no) ...@@ -401,14 +397,14 @@ void notify_disable_event(void *notify_driver_handle, u16 proc_id, u32 event_no)
status = NOTIFY_E_INVALIDEVENT; status = NOTIFY_E_INVALIDEVENT;
goto func_end; goto func_end;
} }
if (WARN_ON(((event_no & NOTIFY_EVENT_MASK) < if (WARN_ON(((event_no & NOTIFY_EVENT_MASK) <
drv_handle->attrs.proc_info [proc_id].reserved_events) && drv_handle->attrs.proc_info[proc_id].reserved_events) &&
((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof (u16)) != ((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof(u16)) !=
NOTIFY_SYSTEM_KEY)) { NOTIFY_SYSTEM_KEY)) {
status = NOTIFY_E_RESERVEDEVENT; status = NOTIFY_E_RESERVEDEVENT;
goto func_end; goto func_end;
} }
if (mutex_lock_interruptible (notify_state.gate_handle) != 0) if (mutex_lock_interruptible(notify_state.gate_handle) != 0)
WARN_ON(1); WARN_ON(1);
drv_handle->fn_table.disable_event(drv_handle, drv_handle->fn_table.disable_event(drv_handle,
proc_id, (event_no & NOTIFY_EVENT_MASK)); proc_id, (event_no & NOTIFY_EVENT_MASK));
...@@ -418,13 +414,13 @@ func_end: ...@@ -418,13 +414,13 @@ func_end:
} }
EXPORT_SYMBOL(notify_disable_event); EXPORT_SYMBOL(notify_disable_event);
/*================================= /*
* notify_enable_event * notify_enable_event
* *
* This function enables a specific event. All callbacks registered for * This function enables a specific event. All callbacks registered for
* this specific event are enabled with this API. It is not possible to * this specific event are enabled with this API. It is not possible to
* enable a specific callback. * enable a specific callback.
* *
*/ */
void notify_enable_event(void *notify_driver_handle, u16 proc_id, u32 event_no) void notify_enable_event(void *notify_driver_handle, u16 proc_id, u32 event_no)
{ {
...@@ -440,15 +436,15 @@ void notify_enable_event(void *notify_driver_handle, u16 proc_id, u32 event_no) ...@@ -440,15 +436,15 @@ void notify_enable_event(void *notify_driver_handle, u16 proc_id, u32 event_no)
if (WARN_ON(((event_no & NOTIFY_EVENT_MASK) if (WARN_ON(((event_no & NOTIFY_EVENT_MASK)
>= drv_handle->attrs.proc_info[proc_id].max_events))) >= drv_handle->attrs.proc_info[proc_id].max_events)))
goto func_end; goto func_end;
if (WARN_ON(((event_no & NOTIFY_EVENT_MASK) < if (WARN_ON(((event_no & NOTIFY_EVENT_MASK) <
drv_handle->attrs.proc_info [proc_id].reserved_events) && drv_handle->attrs.proc_info[proc_id].reserved_events) &&
((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof (u16)) != ((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof(u16)) !=
NOTIFY_SYSTEM_KEY)) NOTIFY_SYSTEM_KEY))
goto func_end; goto func_end;
if (mutex_lock_interruptible (notify_state.gate_handle) != 0) if (mutex_lock_interruptible(notify_state.gate_handle) != 0)
WARN_ON(1); WARN_ON(1);
if(drv_handle->fn_table.enable_event) { if (drv_handle->fn_table.enable_event) {
drv_handle->fn_table.enable_event(drv_handle, drv_handle->fn_table.enable_event(drv_handle,
proc_id, (event_no & NOTIFY_EVENT_MASK)); proc_id, (event_no & NOTIFY_EVENT_MASK));
} }
...@@ -458,13 +454,13 @@ func_end: ...@@ -458,13 +454,13 @@ func_end:
} }
EXPORT_SYMBOL(notify_enable_event); EXPORT_SYMBOL(notify_enable_event);
/*=============================== /*
*_notify_is_support_proc *_notify_is_support_proc
* *
* Check if specified processor ID is supported by the Notify driver. * Check if specified processor ID is supported by the Notify driver.
* *
*/ */
bool _notify_is_support_proc(struct notify_driver_object *drv_handle, static bool _notify_is_support_proc(struct notify_driver_object *drv_handle,
int proc_id) int proc_id)
{ {
bool found = false; bool found = false;
......
...@@ -67,7 +67,8 @@ int notify_register_driver(char *driver_name, ...@@ -67,7 +67,8 @@ int notify_register_driver(char *driver_name,
} }
if (drv_handle->is_init == NOTIFY_DRIVERINITSTATUS_NOTDONE) { if (drv_handle->is_init == NOTIFY_DRIVERINITSTATUS_NOTDONE) {
/* Found an empty slot, so block it. */ /* Found an empty slot, so block it. */
drv_handle->is_init = NOTIFY_DRIVERINITSTATUS_INPROGRESS; drv_handle->is_init =
NOTIFY_DRIVERINITSTATUS_INPROGRESS;
status = NOTIFY_SUCCESS; status = NOTIFY_SUCCESS;
break; break;
} }
...@@ -79,13 +80,11 @@ int notify_register_driver(char *driver_name, ...@@ -79,13 +80,11 @@ int notify_register_driver(char *driver_name,
driver_name, NOTIFY_MAX_NAMELEN); driver_name, NOTIFY_MAX_NAMELEN);
memcpy(&(drv_handle->attrs), drv_attrs, memcpy(&(drv_handle->attrs), drv_attrs,
sizeof(struct notify_driver_attrs)); sizeof(struct notify_driver_attrs));
memcpy(&(drv_handle->fn_table), fn_table, sizeof(struct notify_interface)); memcpy(&(drv_handle->fn_table), fn_table,
sizeof(struct notify_interface));
drv_handle->driver_object = NULL; drv_handle->driver_object = NULL;
/*is_setup is set when driverInit is called. */ /*is_setup is set when driverInit is called. */
*driver_handle = drv_handle; *driver_handle = drv_handle;
return status; return status;
} }
EXPORT_SYMBOL(notify_register_driver); EXPORT_SYMBOL(notify_register_driver);
...@@ -132,7 +131,7 @@ int notify_get_driver_handle(char *driver_name, ...@@ -132,7 +131,7 @@ int notify_get_driver_handle(char *driver_name,
if (WARN_ON(notify_state.is_setup == false)) { if (WARN_ON(notify_state.is_setup == false)) {
status = NOTIFY_E_SETUP; status = NOTIFY_E_SETUP;
} else if (WARN_ON(driver_name = NULL)) } else if (WARN_ON(driver_name == NULL))
status = NOTIFY_E_INVALIDARG; status = NOTIFY_E_INVALIDARG;
else { else {
if (mutex_lock_interruptible(notify_state.gate_handle) != 0) if (mutex_lock_interruptible(notify_state.gate_handle) != 0)
......
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