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{
struct list_head evt_cbck_list;
/*List containg callback arguments for all registered handlers from
user mode. */
struct notifydrv_event_state event_state [MAX_PROCESSES];
struct notifydrv_event_state event_state[MAX_PROCESSES];
/* List for all user processes registered. */
};
struct notifydrv_moduleobject notifydrv_state =
{
struct notifydrv_moduleobject notifydrv_state = {
.is_setup = false,
.open_refcount = 0,
.gatehandle = NULL,
};
/*Major number of driver.*/
int major = 232 ;
int major = 232;
static void notify_drv_setup(void);
......@@ -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);
/* 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.*/
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.*/
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) ;
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.*/
static struct file_operations driver_ops = {
static const struct file_operations driver_ops = {
.open = notify_drv_open,
.ioctl = notify_drv_ioctl,
.release = notify_drv_close,
......@@ -140,22 +140,20 @@ static struct file_operations driver_ops = {
.mmap = notify_drv_mmap,
};
int notify_drv_register_driver(void)
static int notify_drv_register_driver(void)
{
notify_drv_setup();
return 0;
}
EXPORT_SYMBOL(notify_drv_register_driver);
int notify_drv_unregister_driver(void)
static int notify_drv_unregister_driver(void)
{
notify_drv_destroy();
return 0;
}
EXPORT_SYMBOL(notify_drv_unregister_driver);
/*==============================
/*
* This function implements the callback registered with IPS. Here
* to pass event no. back to user function(so that it can do another
* level of demultiplexing of callbacks)
......@@ -175,7 +173,7 @@ func_end:
return;
}
/*==============================
/*
* Linux specific function to open the driver.
*/
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);
if ( isinit == true)
if (isinit == true)
goto func_end;
sem_handle = kmalloc(sizeof (struct semaphore), GFP_ATOMIC);
ter_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);
sema_init(sem_handle, 0);
/* Create the termination semaphore */
sema_init(ter_sem_handle, 0);
......@@ -229,12 +227,12 @@ static int notify_drv_open(struct inode *inode, struct file *filp)
* run-time, since it is dependent on user environment.
*/
if (WARN_ON(flag != true)) {
/*! @retval -1 Maximum number of supported user clients
have already been registered. */
/*! @retval -1 Maximum number of supported user
clients have already been registered. */
status = NOTIFY_E_MAXCLIENTS;
}
}
if(status == NOTIFY_SUCCESS)
if (status == NOTIFY_SUCCESS)
ret_val = 0;
else
ret_val = -EINVAL;
......@@ -242,7 +240,7 @@ func_end:
return ret_val;
}
/*==============
/*
* close the driver
*/
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
*/
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;
struct notify_drv_event_packet * u_buf= NULL;
struct notify_drv_event_packet *u_buf = NULL;
u32 pid = (u32) current->mm;
int ret_val = 0;
u32 i;
......@@ -282,7 +281,7 @@ static int notify_drv_read(struct file *filp, char *dst, size_t size, loff_t *of
/* Wait for the event */
ret_val = down_interruptible(
notifydrv_state.event_state[i].semhandle);
if (ret_val <0) {
if (ret_val < 0) {
ret_val = -ERESTARTSYS;
goto func_end;
}
......@@ -295,7 +294,7 @@ static int notify_drv_read(struct file *filp, char *dst, size_t size, loff_t *of
goto func_end;
}
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))
ret_val = -EFAULT;
if (u_buf->is_exit == true)
......@@ -305,18 +304,18 @@ func_end:
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,
vma->vm_end - vma->vm_start,vma->vm_page_prot)) {
if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
vma->vm_end - vma->vm_start, vma->vm_page_prot)) {
return -EAGAIN;
}
return 0;
}
/*=====================
/*
* name notify_drv_ioctl
*
* ioctl function for of Linux Notify driver.
......@@ -333,28 +332,27 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
switch (cmd) {
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_config cfg;
notify_get_config (&cfg);
retval = copy_to_user ((void*) (src_args->cfg),
(const void *) &cfg, sizeof (struct notify_config));
notify_get_config(&cfg);
retval = copy_to_user((void *) (src_args->cfg),
(const void *) &cfg, sizeof(struct notify_config));
}
break;
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_config cfg;
retval = copy_from_user ((void *) &cfg,
retval = copy_from_user((void *) &cfg,
(const void *) (src_args->cfg),
sizeof (struct notify_config));
sizeof(struct notify_config));
if (WARN_ON(retval != 0))
goto func_end;
notify_setup (&cfg);
notify_setup(&cfg);
}
break;
......@@ -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
* user's config is not used.
*/
status = notify_destroy ();
status = notify_destroy();
}
break;
......@@ -373,27 +371,26 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
struct notify_drv_event_cbck *cbck = NULL;
/* Copy the full args from user-side. */
retval = copy_from_user ((void *) &src_args, (const void *) (args),
sizeof (struct notify_cmd_args_register_event));
retval = copy_from_user((void *) &src_args,
(const void *) (args),
sizeof(struct notify_cmd_args_register_event));
if (WARN_ON(retval != 0))
goto func_end;
cbck = vmalloc(sizeof (struct notify_drv_event_cbck));
cbck = vmalloc(sizeof(struct notify_drv_event_cbck));
WARN_ON(cbck == NULL);
cbck->proc_id = src_args.procId;
cbck->func = src_args.fnNotifyCbck;
cbck->param = src_args.cbckArg;
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);
if (status < 0) {
/* This does not impact return status of this function,
* so retval comment is not used.
*/
kfree (cbck);
}
else {
kfree(cbck);
} else {
WARN_ON(mutex_lock_interruptible
(notifydrv_state.gatehandle));
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,
{
bool found = false;
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 notify_cmd_args_unregister_event src_args;
/* Copy the full args from user-side. */
retval = copy_from_user ((void *)&src_args, (const void *)(args),
sizeof (struct notify_cmd_args_unregister_event));
retval = copy_from_user((void *)&src_args, (const void *)(args),
sizeof(struct notify_cmd_args_unregister_event));
if (WARN_ON(retval != 0))
goto func_end;
......@@ -435,19 +432,21 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
status = NOTIFY_E_NOTFOUND;
goto func_end;
}
status = notify_unregister_event(src_args.handle, src_args.procId,
src_args.eventNo, notify_drv_cbck, (void *) cbck);
status = notify_unregister_event(src_args.handle,
src_args.procId,
src_args.eventNo,
notify_drv_cbck, (void *) cbck);
/* This check is needed at run-time also to propagate the
* status to user-side. This must not be optimized out.
*/
if (status < 0)
printk(" notify_unregister_event failed \n");
printk(KERN_ERR " notify_unregister_event failed \n");
else {
WARN_ON(mutex_lock_interruptible
(notifydrv_state.gatehandle));
list_del((struct list_head *)cbck);
mutex_unlock(notifydrv_state.gatehandle);
kfree (cbck);
kfree(cbck);
}
}
break;
......@@ -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;
/* Copy the full args from user-side. */
retval = copy_from_user ((void *) &src_args,
retval = copy_from_user((void *) &src_args,
(const void *) (args),
sizeof (struct notify_cmd_args_send_event));
sizeof(struct notify_cmd_args_send_event));
if (WARN_ON(retval != 0)) {
retval = -EFAULT;
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.waitClear);
}
......@@ -475,9 +474,9 @@ static int notify_drv_ioctl(struct inode *inode, struct file *filp, u32 cmd,
struct notify_cmd_args_disable src_args;
/* Copy the full args from user-side. */
retval = copy_from_user ((void *) &src_args,
retval = copy_from_user((void *) &src_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
* 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,
src_args.flags = notify_disable(src_args.procId);
/* Copy the full args to user-side */
retval = copy_to_user ((void *) (args),
retval = copy_to_user((void *) (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
* 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,
struct notify_cmd_args_restore src_args;
/* Copy the full args from user-side. */
retval = copy_from_user((void *) &src_args,(const void *)(args),
sizeof (struct notify_cmd_args_restore));
retval = copy_from_user((void *) &src_args,
(const void *)(args),
sizeof(struct notify_cmd_args_restore));
if (WARN_ON(retval != 0)) {
retval = -EFAULT;
goto func_end;
......@@ -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;
/* Copy the full args from user-side. */
retval = copy_from_user((void *) &src_args, (const void *)(args),
sizeof (struct notify_cmd_args_disable_event));
retval = copy_from_user((void *) &src_args,
(const void *)(args),
sizeof(struct notify_cmd_args_disable_event));
/* This check is needed at run-time also since it depends on
* 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,
struct notify_cmd_args_enable_event src_args;
/* Copy the full args from user-side. */
retval = copy_from_user ((void *)&src_args, (const void *)(args),
sizeof (struct notify_cmd_args_enable_event));
retval = copy_from_user((void *)&src_args,
(const void *)(args),
sizeof(struct notify_cmd_args_enable_event));
if (WARN_ON(retval != 0)) {
retval = -EFAULT;
goto func_end;
......@@ -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. */
status = notify_drv_exit();
if (status < 0)
printk("notify_driver_exit FAILED\n");
printk(KERN_ERR "notify_driver_exit FAILED\n");
}
break;
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.
*/
status = NOTIFY_E_INVALIDARG;
printk("not valid command\n");
printk(KERN_ERR "not valid command\n");
}
break;
}
func_end:
/* Set the status and copy the common args to user-side. */
commonArgs.apiStatus = status;
status = copy_to_user ((void *) cmdArgs,
status = copy_to_user((void *) cmdArgs,
(const void *) &commonArgs,
sizeof (struct notify_cmd_args));
sizeof(struct notify_cmd_args));
if (status < 0)
retval = -EFAULT;
return retval;
......@@ -591,7 +593,7 @@ static int notify_drv_add_buf_by_pid(u16 proc_id, u32 pid,
s32 status = 0;
bool flag = false;
bool is_exit = false;
struct notify_drv_event_packet * u_buf = NULL;
struct notify_drv_event_packet *u_buf = NULL;
u32 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,
status = -EFAULT;
goto func_end;
}
u_buf = (struct notify_drv_event_packet *)kmalloc
(sizeof (struct notify_drv_event_packet), GFP_ATOMIC);
u_buf = kmalloc(sizeof(struct notify_drv_event_packet), GFP_ATOMIC);
if (u_buf != NULL) {
INIT_LIST_HEAD((struct list_head *)&u_buf->element);
u_buf->proc_id = proc_id;
......@@ -636,7 +637,7 @@ func_end:
return status;
}
/*====================
/*
* notify_drv_exit
*
*/
......@@ -655,16 +656,16 @@ int notify_drv_exit(void)
status = NOTIFY_E_FAIL;
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 */
status = NOTIFY_E_SETUP;
goto func_end;
}
/* 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);
if (status < 0) {
printk ("notify_drv_exit failed to send"
printk(KERN_ERR "notify_drv_exit failed to send"
"termination packet\n.");
goto func_end;
}
......@@ -691,8 +692,7 @@ int notify_drv_exit(void)
NULL;
flag = true;
break;
}
else
} else
notifydrv_state.event_state[i].ref_count--;
}
}
......@@ -710,7 +710,7 @@ func_end:
return status;
}
/*====================
/*
* Module setup function.
*
*/
......@@ -719,7 +719,7 @@ static void notify_drv_setup(void)
int i;
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);
mutex_init(notifydrv_state.gatehandle);
for (i = 0; i < MAX_PROCESSES ; i++) {
......@@ -732,7 +732,7 @@ static void notify_drv_setup(void)
}
/*=====================
/*
* brief Module destroy function.
*/
static void notify_drv_destroy(void)
......@@ -748,7 +748,6 @@ static void notify_drv_destroy(void)
packet = (struct notify_drv_event_packet *)entry;
if (packet != NULL)
kfree(packet);
}
INIT_LIST_HEAD(&notifydrv_state.event_state[i].buf_list);
}
......@@ -774,7 +773,7 @@ static int __init notify_drv_init_module(void)
result = register_chrdev(major, "ipcnotify", &driver_ops);
if (result < 0) {
printk("Notify driver initialization failure - 1\n");
printk(KERN_ERR "Notify driver initialization failure - 1\n");
goto func_end;
}
result = notify_drv_register_driver();
......@@ -797,7 +796,6 @@ static void __exit notify_drv_finalize_module(void)
packet = (struct notify_drv_event_packet *)entry;
if (packet != NULL)
kfree(packet);
}
}
list_for_each(entry,
......
......@@ -34,11 +34,10 @@
*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);
struct notify_module_object notify_state =
{
struct notify_module_object notify_state = {
.is_setup = false,
.def_cfg.gate_handle = NULL,
.def_cfg.maxDrivers = 2,
......@@ -46,7 +45,7 @@ struct notify_module_object notify_state =
EXPORT_SYMBOL(notify_state);
/*==================================
/*
* Get the default configuration for the Notify module.
*
* This function can be called by the application to get their
......@@ -58,18 +57,19 @@ EXPORT_SYMBOL(notify_state);
* param-cfg :Pointer to the Notify module configuration
* 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);
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
memcpy(cfg, &notify_state.cfg, sizeof(struct notify_config));
}
EXPORT_SYMBOL(notify_get_config);
/*================================
/*
* Setup the Notify module.
*
* This function sets up the Notify module. This function
......@@ -87,32 +87,32 @@ EXPORT_SYMBOL(notify_get_config);
* param -cfg Optional Notify module configuration. If provided as
* NULL, default configuration is used.
*/
int notify_setup (struct notify_config * cfg)
int notify_setup(struct notify_config *cfg)
{
int status = NOTIFY_SUCCESS;
struct notify_config tmpCfg;
if (cfg == NULL) {
notify_get_config (&tmpCfg);
notify_get_config(&tmpCfg);
cfg = &tmpCfg;
}
if (cfg->gate_handle != NULL) {
notify_state.gate_handle = cfg->gate_handle;
}
else {
} else {
notify_state.gate_handle = kmalloc(sizeof(struct mutex),
GFP_ATOMIC);
/* User has not provided any gate handle, so create a default handle. */
mutex_init (notify_state.gate_handle);
/*User has not provided any gate handle,
so create a default handle.*/
mutex_init(notify_state.gate_handle);
}
if (WARN_ON(cfg->maxDrivers > NOTIFY_MAX_DRIVERS)) {
status = NOTIFY_E_CONFIG;
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,
(sizeof (struct notify_driver_object) * NOTIFY_MAX_DRIVERS));
(sizeof(struct notify_driver_object) * NOTIFY_MAX_DRIVERS));
notify_state.disable_depth = 0;
notify_state.is_setup = true;
func_end:
......@@ -120,7 +120,7 @@ func_end:
}
EXPORT_SYMBOL(notify_setup);
/*======================================
/*
* Destroy the Notify module.
*
* Once this function is called, other Notify module APIs,
......@@ -134,9 +134,9 @@ int notify_destroy(void)
/* Check if any Notify driver instances have not been deleted so far.
* 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);
}
if (notify_state.cfg.gate_handle == NULL) {
if (notify_state.gate_handle != NULL)
kfree(notify_state.gate_handle);
......@@ -146,7 +146,7 @@ int notify_destroy(void)
}
EXPORT_SYMBOL(notify_destroy);
/*====================================
/*
* func notify_register_event
*
* desc This function registers a callback for a specific event with the
......@@ -175,13 +175,13 @@ int notify_register_event(void *notify_driver_handle, u16 proc_id,
goto func_end;
}
if (WARN_ON(((event_no & NOTIFY_EVENT_MASK) <
drv_handle->attrs.proc_info [proc_id].reserved_events) &&
((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof (u16)) !=
drv_handle->attrs.proc_info[proc_id].reserved_events) &&
((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof(u16)) !=
NOTIFY_SYSTEM_KEY)) {
status = NOTIFY_E_RESERVEDEVENT;
goto func_end;
}
if (mutex_lock_interruptible (notify_state.gate_handle) != 0)
if (mutex_lock_interruptible(notify_state.gate_handle) != 0)
WARN_ON(1);
status = drv_handle->fn_table.register_event(drv_handle, proc_id,
......@@ -204,15 +204,12 @@ EXPORT_SYMBOL(notify_register_event);
* 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)
{
int status = NOTIFY_SUCCESS;
struct notify_driver_object *drv_handle =
(struct notify_driver_object *)notify_driver_handle;
BUG_ON(drv_handle == NULL);
if (WARN_ON(drv_handle->is_init == false)) {
status = NOTIFY_E_SETUP;
......@@ -228,24 +225,23 @@ int notify_unregister_event (void *notify_driver_handle, u16 proc_id,
goto func_end;
}
if (WARN_ON(((event_no & NOTIFY_EVENT_MASK) <
drv_handle->attrs.proc_info [proc_id].reserved_events) &&
((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof (u16)) !=
drv_handle->attrs.proc_info[proc_id].reserved_events) &&
((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof(u16)) !=
NOTIFY_SYSTEM_KEY)) {
status = NOTIFY_E_RESERVEDEVENT;
goto func_end;
}
if (mutex_lock_interruptible (notify_state.gate_handle) != 0)
if (mutex_lock_interruptible(notify_state.gate_handle) != 0)
WARN_ON(1);
status = drv_handle->fn_table.unregister_event(drv_handle,
proc_id, (event_no & NOTIFY_EVENT_MASK),
notify_callback_fxn, cbck_arg);
mutex_unlock(notify_state.gate_handle);
if (WARN_ON(status < 0)) {
if (WARN_ON(status < 0))
status = NOTIFY_E_FAIL;
}else
else
status = NOTIFY_SUCCESS;
func_end:
return status;
}
......@@ -262,10 +258,8 @@ int notify_sendevent(void *notify_driver_handle, u16 proc_id,
u32 event_no, u32 payload, bool wait_clear)
{
int status = NOTIFY_SUCCESS;
struct notify_driver_object *drv_handle =
(struct notify_driver_object *)notify_driver_handle;
BUG_ON(drv_handle == NULL);
if (WARN_ON(drv_handle->is_init == false)) {
status = NOTIFY_E_SETUP;
......@@ -281,13 +275,13 @@ int notify_sendevent(void *notify_driver_handle, u16 proc_id,
goto func_end;
}
if (WARN_ON(((event_no & NOTIFY_EVENT_MASK) <
drv_handle->attrs.proc_info [proc_id].reserved_events) &&
((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof (u16)) !=
drv_handle->attrs.proc_info[proc_id].reserved_events) &&
((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof(u16)) !=
NOTIFY_SYSTEM_KEY)) {
status = NOTIFY_E_RESERVEDEVENT;
goto func_end;
}
if (mutex_lock_interruptible (notify_state.gate_handle) != 0)
if (mutex_lock_interruptible(notify_state.gate_handle) != 0)
WARN_ON(1);
status = drv_handle->fn_table.send_event
(drv_handle, proc_id, (event_no & NOTIFY_EVENT_MASK),
......@@ -319,7 +313,7 @@ u32 notify_disable(u16 proc_id)
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);
for (i = 0; i < notify_state.cfg.maxDrivers; i++) {
drv_handle = &(notify_state.drivers[i]);
......@@ -328,9 +322,11 @@ u32 notify_disable(u16 proc_id)
if (drv_handle->is_init ==
NOTIFY_DRIVERINITSTATUS_NOTDONE) {
if (drv_handle->fn_table.disable) {
drv_handle->disable_flag[notify_state.disable_depth] =
(u32 *)drv_handle->fn_table.disable
(drv_handle, proc_id);
drv_handle->disable_flag[notify_state.
disable_depth] =
(u32 *)drv_handle->fn_table.
disable(drv_handle,
proc_id);
}
}
}
......@@ -341,7 +337,7 @@ u32 notify_disable(u16 proc_id)
}
EXPORT_SYMBOL(notify_disable);
/*==============================
/*
* notify_restore
*
* desc This function restores the Notify module to the state before the
......@@ -353,26 +349,27 @@ EXPORT_SYMBOL(notify_disable);
*
*
*/
void notify_restore (u32 key, u16 proc_id)
void notify_restore(u32 key, u16 proc_id)
{
struct notify_driver_object *drv_handle;
int i;
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);
notify_state.disable_depth--;
for (i = 0; i < notify_state.cfg.maxDrivers; i++) {
drv_handle = &(notify_state.drivers[i]);
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);
return;
}
EXPORT_SYMBOL(notify_restore);
/*=================================
/*
*func notify_disable_event
*
* 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)
int status = 0;
struct notify_driver_object *drv_handle =
(struct notify_driver_object *)notify_driver_handle;
BUG_ON(drv_handle == NULL);
if (WARN_ON(drv_handle->is_init == false)) {
status = NOTIFY_E_SETUP;
......@@ -402,13 +398,13 @@ void notify_disable_event(void *notify_driver_handle, u16 proc_id, u32 event_no)
goto func_end;
}
if (WARN_ON(((event_no & NOTIFY_EVENT_MASK) <
drv_handle->attrs.proc_info [proc_id].reserved_events) &&
((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof (u16)) !=
drv_handle->attrs.proc_info[proc_id].reserved_events) &&
((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof(u16)) !=
NOTIFY_SYSTEM_KEY)) {
status = NOTIFY_E_RESERVEDEVENT;
goto func_end;
}
if (mutex_lock_interruptible (notify_state.gate_handle) != 0)
if (mutex_lock_interruptible(notify_state.gate_handle) != 0)
WARN_ON(1);
drv_handle->fn_table.disable_event(drv_handle,
proc_id, (event_no & NOTIFY_EVENT_MASK));
......@@ -418,7 +414,7 @@ func_end:
}
EXPORT_SYMBOL(notify_disable_event);
/*=================================
/*
* notify_enable_event
*
* This function enables a specific event. All callbacks registered for
......@@ -441,14 +437,14 @@ void notify_enable_event(void *notify_driver_handle, u16 proc_id, u32 event_no)
>= drv_handle->attrs.proc_info[proc_id].max_events)))
goto func_end;
if (WARN_ON(((event_no & NOTIFY_EVENT_MASK) <
drv_handle->attrs.proc_info [proc_id].reserved_events) &&
((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof (u16)) !=
drv_handle->attrs.proc_info[proc_id].reserved_events) &&
((event_no & NOTIFY_SYSTEM_KEY_MASK) >> sizeof(u16)) !=
NOTIFY_SYSTEM_KEY))
goto func_end;
if (mutex_lock_interruptible (notify_state.gate_handle) != 0)
if (mutex_lock_interruptible(notify_state.gate_handle) != 0)
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,
proc_id, (event_no & NOTIFY_EVENT_MASK));
}
......@@ -458,13 +454,13 @@ func_end:
}
EXPORT_SYMBOL(notify_enable_event);
/*===============================
/*
*_notify_is_support_proc
*
* 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)
{
bool found = false;
......
......@@ -67,7 +67,8 @@ int notify_register_driver(char *driver_name,
}
if (drv_handle->is_init == NOTIFY_DRIVERINITSTATUS_NOTDONE) {
/* Found an empty slot, so block it. */
drv_handle->is_init = NOTIFY_DRIVERINITSTATUS_INPROGRESS;
drv_handle->is_init =
NOTIFY_DRIVERINITSTATUS_INPROGRESS;
status = NOTIFY_SUCCESS;
break;
}
......@@ -79,13 +80,11 @@ int notify_register_driver(char *driver_name,
driver_name, NOTIFY_MAX_NAMELEN);
memcpy(&(drv_handle->attrs), drv_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;
/*is_setup is set when driverInit is called. */
*driver_handle = drv_handle;
return status;
}
EXPORT_SYMBOL(notify_register_driver);
......@@ -132,7 +131,7 @@ int notify_get_driver_handle(char *driver_name,
if (WARN_ON(notify_state.is_setup == false)) {
status = NOTIFY_E_SETUP;
} else if (WARN_ON(driver_name = NULL))
} else if (WARN_ON(driver_name == NULL))
status = NOTIFY_E_INVALIDARG;
else {
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