mirror of
https://github.com/apache/nuttx.git
synced 2026-08-14 00:43:13 +00:00
Replace nxsem API when used as a lock with nxmutex API
Signed-off-by: anjiahao <anjiahao@xiaomi.com> Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
0dfd1f004d
commit
d1d46335df
710 changed files with 7503 additions and 14852 deletions
|
|
@ -32,6 +32,7 @@
|
|||
#include <fcntl.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/mutex.h>
|
||||
#include <nuttx/mm/circbuf.h>
|
||||
#include <nuttx/rc/lirc_dev.h>
|
||||
|
||||
|
|
@ -53,7 +54,7 @@ struct lirc_upperhalf_s
|
|||
{
|
||||
struct list_node fh; /* list of struct lirc_fh_s object */
|
||||
FAR struct lirc_lowerhalf_s *lower; /* the handle of lower half driver */
|
||||
sem_t exclsem; /* Manages exclusive access to lowerhalf */
|
||||
mutex_t lock; /* Manages exclusive access to lowerhalf */
|
||||
bool gap; /* true if we're in a gap */
|
||||
uint64_t gap_start; /* time when gap starts */
|
||||
uint64_t gap_duration; /* duration of initial gap */
|
||||
|
|
@ -260,7 +261,7 @@ static int lirc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
FAR unsigned int *val = (unsigned int *)(uintptr_t)arg;
|
||||
int ret;
|
||||
|
||||
ret = nxsem_wait(&upper->exclsem);
|
||||
ret = nxmutex_lock(&upper->lock);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
|
|
@ -575,7 +576,7 @@ static int lirc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
ret = -ENOTTY;
|
||||
}
|
||||
|
||||
nxsem_post(&upper->exclsem);
|
||||
nxmutex_unlock(&upper->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -631,7 +632,7 @@ static ssize_t lirc_write(FAR struct file *filep, FAR const char *buffer,
|
|||
FAR struct lirc_fh_s *fh = filep->f_priv;
|
||||
ssize_t ret;
|
||||
|
||||
ret = nxsem_wait(&upper->exclsem);
|
||||
ret = nxmutex_lock(&upper->lock);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
|
|
@ -646,7 +647,7 @@ static ssize_t lirc_write(FAR struct file *filep, FAR const char *buffer,
|
|||
ret = lirc_write_pulse(filep, buffer, buflen);
|
||||
}
|
||||
|
||||
nxsem_post(&upper->exclsem);
|
||||
nxmutex_unlock(&upper->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -788,7 +789,7 @@ int lirc_register(FAR struct lirc_lowerhalf_s *lower, int devno)
|
|||
|
||||
upper->lower = lower;
|
||||
list_initialize(&upper->fh);
|
||||
nxsem_init(&upper->exclsem, 0, 1);
|
||||
nxmutex_init(&upper->lock);
|
||||
lower->priv = upper;
|
||||
|
||||
/* Register remote control character device */
|
||||
|
|
@ -803,7 +804,7 @@ int lirc_register(FAR struct lirc_lowerhalf_s *lower, int devno)
|
|||
return ret;
|
||||
|
||||
drv_err:
|
||||
nxsem_destroy(&upper->exclsem);
|
||||
nxmutex_destroy(&upper->lock);
|
||||
kmm_free(upper);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -825,7 +826,7 @@ void lirc_unregister(FAR struct lirc_lowerhalf_s *lower, int devno)
|
|||
FAR struct lirc_upperhalf_s *upper = lower->priv;
|
||||
char path[DEVNAME_MAX];
|
||||
|
||||
nxsem_destroy(&upper->exclsem);
|
||||
nxmutex_destroy(&upper->lock);
|
||||
snprintf(path, DEVNAME_MAX, DEVNAME_FMT, devno);
|
||||
rcinfo("UnRegistering %s\n", path);
|
||||
unregister_driver(path);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue