Don't check nxsem_init and nxmutex_init

since both never fail

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-10-30 21:23:09 +08:00 committed by Masayuki Ishikawa
parent e244720aa4
commit 148c544759
2 changed files with 15 additions and 47 deletions

View File

@ -2711,11 +2711,7 @@ static int cxd56_gnss_open(struct file *filep)
if (priv->num_open == 0)
{
ret = nxsem_init(&priv->syncsem, 0, 0);
if (ret < 0)
{
goto err0;
}
nxsem_init(&priv->syncsem, 0, 0);
/* Prohibit the clock change during loading image */
@ -2729,13 +2725,13 @@ static int cxd56_gnss_open(struct file *filep)
if (ret < 0)
{
goto err1;
goto err0;
}
ret = fw_pm_startcpu(CXD56_GNSS_GPS_CPUID, 1);
if (ret < 0)
{
goto err2;
goto err1;
}
#ifndef CONFIG_CXD56_GNSS_HOT_SLEEP
@ -2750,14 +2746,14 @@ static int cxd56_gnss_open(struct file *filep)
ret = cxd56_gnss_wait_notify(&priv->syncsem, 5);
if (ret < 0)
{
goto err2;
goto err1;
}
ret = fw_gd_writebuffer(CXD56_CPU1_DATA_TYPE_INFO, 0,
&priv->shared_info, sizeof(priv->shared_info));
if (ret < 0)
{
goto err2;
goto err1;
}
nxsem_destroy(&priv->syncsem);
@ -2766,14 +2762,13 @@ static int cxd56_gnss_open(struct file *filep)
priv->num_open++;
goto success;
err2:
err1:
#ifndef CONFIG_CXD56_GNSS_HOT_SLEEP
fw_pm_sleepcpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_HOT_ENABLE);
#endif
fw_pm_sleepcpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_COLD);
err1:
nxsem_destroy(&priv->syncsem);
err0:
nxsem_destroy(&priv->syncsem);
success:
nxmutex_unlock(&priv->devlock);
return ret;
@ -3119,26 +3114,9 @@ static int cxd56_gnss_register(const char *devpath)
return -ENOMEM;
}
ret = nxmutex_init(&priv->devlock);
if (ret < 0)
{
gnsserr("Failed to initialize gnss devlock!\n");
goto err0;
}
ret = nxsem_init(&priv->apiwait, 0, 0);
if (ret < 0)
{
gnsserr("Failed to initialize gnss apiwait!\n");
goto err0;
}
ret = nxmutex_init(&priv->ioctllock);
if (ret < 0)
{
gnsserr("Failed to initialize gnss ioctllock!\n");
goto err0;
}
nxmutex_init(&priv->devlock);
nxsem_init(&priv->apiwait, 0, 0);
nxmutex_init(&priv->ioctllock);
ret = cxd56_gnss_initialize(priv);
if (ret < 0)

View File

@ -110,15 +110,10 @@ static void amebaz_state_deinit(struct amebaz_state_s *state)
wd_cancel(&state->timeout);
}
static int amebaz_state_init(struct amebaz_state_s *state)
static void amebaz_state_init(struct amebaz_state_s *state)
{
if (nxsem_init(&state->sem, 0, 0) != OK)
{
return -ENOMEM;
}
state->status = AMEBAZ_STATUS_DISABLED;
return 0;
nxsem_init(&state->sem, 0, 0);
}
void amebaz_wl_scan_handler(int index, union iwreq_data *wrqu, char *extra)
@ -1083,20 +1078,15 @@ int amebaz_wl_get_freq(struct amebaz_dev_s *priv, struct iwreq *iwr)
static struct amebaz_dev_s *amebaz_allocate_device(int devnum)
{
struct amebaz_dev_s *priv;
int ret;
priv = (struct amebaz_dev_s *)kmm_zalloc(sizeof(*priv));
if (!priv)
{
return NULL;
}
ret = amebaz_state_init(&priv->scan);
ret |= amebaz_state_init(&priv->conn);
if (ret)
{
kmm_free(priv);
return NULL;
}
amebaz_state_init(&priv->scan);
amebaz_state_init(&priv->conn);
memcpy(priv->country, AMEBAZ_DEFAULT_COUNTRY, 2);
priv->devnum = devnum;