mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
OS internal function should indicate the error by return negative value
instead to change errno value by calling set_errno Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
committed by
Abdelatif Guettouche
parent
c8db3293bb
commit
0defe43282
@@ -625,8 +625,7 @@ static int charger_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
set_errno(EINVAL);
|
ret = -EINVAL;
|
||||||
ret = -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -641,8 +640,7 @@ static int charger_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
set_errno(EINVAL);
|
ret = -EINVAL;
|
||||||
ret = -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -154,8 +154,7 @@ static ssize_t ge2d_write(FAR struct file *filep,
|
|||||||
|
|
||||||
if (((uintptr_t)buffer & 0xf) != 0)
|
if (((uintptr_t)buffer & 0xf) != 0)
|
||||||
{
|
{
|
||||||
set_errno(EINVAL);
|
return -EINVAL;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get exclusive access */
|
/* Get exclusive access */
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ static int cxd56_rdtime(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
ret = up_rtc_gettime(&ts);
|
ret = up_rtc_gettime(&ts);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
goto errout_with_errno;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the one second epoch time to a struct tm. This operation
|
/* Convert the one second epoch time to a struct tm. This operation
|
||||||
@@ -229,15 +229,15 @@ static int cxd56_rdtime(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
|
|
||||||
if (!gmtime_r(&ts.tv_sec, (FAR struct tm *)rtctime))
|
if (!gmtime_r(&ts.tv_sec, (FAR struct tm *)rtctime))
|
||||||
{
|
{
|
||||||
goto errout_with_errno;
|
ret = -get_errno();
|
||||||
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
errout_with_errno:
|
errout:
|
||||||
ret = get_errno();
|
DEBUGASSERT(ret < 0);
|
||||||
DEBUGASSERT(ret > 0);
|
return ret;
|
||||||
return -ret;
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
time_t timer;
|
time_t timer;
|
||||||
|
|||||||
@@ -3159,8 +3159,7 @@ int seq_ioctl(FAR struct seq_s *seq, int fifoid, int cmd, unsigned long arg)
|
|||||||
|
|
||||||
if (fifoid < 0 || fifoid > 2)
|
if (fifoid < 0 || fifoid > 2)
|
||||||
{
|
{
|
||||||
set_errno(-EINVAL);
|
return -EINVAL;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scuinfo("cmd = %04x, arg = %08x\n", cmd, arg);
|
scuinfo("cmd = %04x, arg = %08x\n", cmd, arg);
|
||||||
@@ -3406,11 +3405,6 @@ int seq_ioctl(FAR struct seq_s *seq, int fifoid, int cmd, unsigned long arg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
set_errno(-ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,8 +103,7 @@ static int cxd56_erase(FAR struct mtd_dev_s *dev, off_t startblock,
|
|||||||
ret = fw_fm_rawerasesector(startblock + i);
|
ret = fw_fm_rawerasesector(startblock + i);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
set_errno(-ret);
|
return ret;
|
||||||
return ERROR;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,8 +121,7 @@ static ssize_t cxd56_bread(FAR struct mtd_dev_s *dev, off_t startblock,
|
|||||||
nblocks << PAGE_SHIFT);
|
nblocks << PAGE_SHIFT);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
set_errno(-ret);
|
return ret;
|
||||||
return ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nblocks;
|
return nblocks;
|
||||||
@@ -145,8 +143,7 @@ static ssize_t cxd56_bwrite(FAR struct mtd_dev_s *dev, off_t startblock,
|
|||||||
#endif
|
#endif
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
set_errno(-ret);
|
return ret;
|
||||||
return ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nblocks;
|
return nblocks;
|
||||||
@@ -162,8 +159,7 @@ static ssize_t cxd56_read(FAR struct mtd_dev_s *dev, off_t offset,
|
|||||||
ret = fw_fm_rawread(offset, buffer, nbytes);
|
ret = fw_fm_rawread(offset, buffer, nbytes);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
set_errno(-ret);
|
return ret;
|
||||||
return ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nbytes;
|
return nbytes;
|
||||||
@@ -184,8 +180,7 @@ static ssize_t cxd56_write(FAR struct mtd_dev_s *dev, off_t offset,
|
|||||||
#endif
|
#endif
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
set_errno(-ret);
|
return ret;
|
||||||
return ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nbytes;
|
return nbytes;
|
||||||
|
|||||||
@@ -104,10 +104,6 @@ static int sysctl_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
{
|
{
|
||||||
_err("cmd %x(%lx)\n", cmd, arg);
|
_err("cmd %x(%lx)\n", cmd, arg);
|
||||||
ret = cxd56_sysctlcmd(cmd & 0xff, arg);
|
ret = cxd56_sysctlcmd(cmd & 0xff, arg);
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
set_errno(ret);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -162,8 +162,7 @@ static int uart0_open(FAR struct file *filep)
|
|||||||
ret = fw_pd_uartinit(0);
|
ret = fw_pd_uartinit(0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
set_errno(EFAULT);
|
return -EFAULT;
|
||||||
return ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 0 = 5bit, 1 = 6bit, 2 = 7bit, 3 = 8bit */
|
/* 0 = 5bit, 1 = 6bit, 2 = 7bit, 3 = 8bit */
|
||||||
@@ -191,16 +190,14 @@ static int uart0_open(FAR struct file *filep)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
fw_pd_uartuninit(0);
|
fw_pd_uartuninit(0);
|
||||||
set_errno(EINVAL);
|
return -EINVAL;
|
||||||
return ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = fw_pd_uartenable(0);
|
ret = fw_pd_uartenable(0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
fw_pd_uartuninit(0);
|
fw_pd_uartuninit(0);
|
||||||
set_errno(EFAULT);
|
return -EFAULT;
|
||||||
return ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -247,12 +244,6 @@ static ssize_t uart0_read(FAR struct file *filep,
|
|||||||
|
|
||||||
uart0_semgive(&g_lock);
|
uart0_semgive(&g_lock);
|
||||||
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
set_errno(-ret);
|
|
||||||
ret = 0; /* Receive no data */
|
|
||||||
}
|
|
||||||
|
|
||||||
return (ssize_t)ret;
|
return (ssize_t)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,12 +263,6 @@ static ssize_t uart0_write(FAR struct file *filep,
|
|||||||
|
|
||||||
uart0_semgive(&g_lock);
|
uart0_semgive(&g_lock);
|
||||||
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
set_errno(-ret);
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (ssize_t)ret;
|
return (ssize_t)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ static int kinetis_rdtime(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
ret = up_rtc_gettime(&ts);
|
ret = up_rtc_gettime(&ts);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
goto errout_with_errno;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the one second epoch time to a struct tm. This operation
|
/* Convert the one second epoch time to a struct tm. This operation
|
||||||
@@ -234,15 +234,15 @@ static int kinetis_rdtime(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
|
|
||||||
if (!gmtime_r(&ts.tv_sec, (FAR struct tm *)rtctime))
|
if (!gmtime_r(&ts.tv_sec, (FAR struct tm *)rtctime))
|
||||||
{
|
{
|
||||||
goto errout_with_errno;
|
ret = -get_errno();
|
||||||
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
errout_with_errno:
|
errout:
|
||||||
ret = get_errno();
|
DEBUGASSERT(ret < 0);
|
||||||
DEBUGASSERT(ret > 0);
|
return ret;
|
||||||
return -ret;
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
time_t timer;
|
time_t timer;
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ static int max326_rdtime(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
ret = up_rtc_gettime(&ts);
|
ret = up_rtc_gettime(&ts);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
goto errout_with_errno;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the one second epoch time to a struct tm. This operation
|
/* Convert the one second epoch time to a struct tm. This operation
|
||||||
@@ -265,15 +265,15 @@ static int max326_rdtime(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
|
|
||||||
if (!gmtime_r(&ts.tv_sec, (FAR struct tm *)rtctime))
|
if (!gmtime_r(&ts.tv_sec, (FAR struct tm *)rtctime))
|
||||||
{
|
{
|
||||||
goto errout_with_errno;
|
ret = -get_errno();
|
||||||
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
errout_with_errno:
|
errout:
|
||||||
ret = get_errno();
|
DEBUGASSERT(ret < 0);
|
||||||
DEBUGASSERT(ret > 0);
|
return ret;
|
||||||
return -ret;
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
time_t timer;
|
time_t timer;
|
||||||
|
|||||||
@@ -926,7 +926,6 @@ struct adc_dev_s *nrf52_adcinitialize(
|
|||||||
if (channels > 1)
|
if (channels > 1)
|
||||||
{
|
{
|
||||||
aerr("ERORR: timer trigger works only for 1 channel!\n");
|
aerr("ERORR: timer trigger works only for 1 channel!\n");
|
||||||
set_errno(-EINVAL);
|
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ static int stm32_rdtime(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
ret = up_rtc_gettime(&ts);
|
ret = up_rtc_gettime(&ts);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
goto errout_with_errno;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the one second epoch time to a struct tm. This operation
|
/* Convert the one second epoch time to a struct tm. This operation
|
||||||
@@ -296,15 +296,15 @@ static int stm32_rdtime(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
|
|
||||||
if (!gmtime_r(&ts.tv_sec, (FAR struct tm *)rtctime))
|
if (!gmtime_r(&ts.tv_sec, (FAR struct tm *)rtctime))
|
||||||
{
|
{
|
||||||
goto errout_with_errno;
|
ret = -get_errno();
|
||||||
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
errout_with_errno:
|
errout:
|
||||||
ret = get_errno();
|
DEBUGASSERT(ret < 0);
|
||||||
DEBUGASSERT(ret > 0);
|
return ret;
|
||||||
return -ret;
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
time_t timer;
|
time_t timer;
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ static int rx65n_rdtime(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
ret = up_rtc_gettime(&ts);
|
ret = up_rtc_gettime(&ts);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
goto errout_with_errno;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the one second epoch time to a struct tm. This operation
|
/* Convert the one second epoch time to a struct tm. This operation
|
||||||
@@ -257,16 +257,16 @@ static int rx65n_rdtime(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
|
|
||||||
if (!gmtime_r(&ts.tv_sec, (FAR struct tm *)rtctime))
|
if (!gmtime_r(&ts.tv_sec, (FAR struct tm *)rtctime))
|
||||||
{
|
{
|
||||||
goto errout_with_errno;
|
ret = -get_errno();
|
||||||
|
goto errout;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
errout_with_errno:
|
errout:
|
||||||
ret = get_errno();
|
DEBUGASSERT(ret < 0);
|
||||||
DEBUGASSERT(ret > 0);
|
return ret;
|
||||||
return -ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ static int ez80_rdtime(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
ret = up_rtc_gettime(&ts);
|
ret = up_rtc_gettime(&ts);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
goto errout_with_errno;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the one second epoch time to a struct tm. This operation
|
/* Convert the one second epoch time to a struct tm. This operation
|
||||||
@@ -233,15 +233,15 @@ static int ez80_rdtime(FAR struct rtc_lowerhalf_s *lower,
|
|||||||
|
|
||||||
if (!gmtime_r(&ts.tv_sec, (FAR struct tm *)rtctime))
|
if (!gmtime_r(&ts.tv_sec, (FAR struct tm *)rtctime))
|
||||||
{
|
{
|
||||||
goto errout_with_errno;
|
ret = -get_errno();
|
||||||
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
errout_with_errno:
|
errout:
|
||||||
ret = get_errno();
|
DEBUGASSERT(ret < 0);
|
||||||
DEBUGASSERT(ret > 0);
|
return ret;
|
||||||
return -ret;
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
time_t timer;
|
time_t timer;
|
||||||
|
|||||||
@@ -267,8 +267,7 @@ static ssize_t ws2812_write(FAR struct file *filep, FAR const char *buffer,
|
|||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
{
|
{
|
||||||
lederr("ERROR: Buffer is null\n");
|
lederr("ERROR: Buffer is null\n");
|
||||||
set_errno(EINVAL);
|
return -EINVAL;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We need at least one LED, so 1 byte */
|
/* We need at least one LED, so 1 byte */
|
||||||
@@ -276,15 +275,13 @@ static ssize_t ws2812_write(FAR struct file *filep, FAR const char *buffer,
|
|||||||
if (buflen < 1)
|
if (buflen < 1)
|
||||||
{
|
{
|
||||||
lederr("ERROR: You need to control at least 1 LED!\n");
|
lederr("ERROR: You need to control at least 1 LED!\n");
|
||||||
set_errno(EINVAL);
|
return -EINVAL;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((buflen % WS2812_RW_PIXEL_SIZE) != 0)
|
if ((buflen % WS2812_RW_PIXEL_SIZE) != 0)
|
||||||
{
|
{
|
||||||
lederr("ERROR: LED values must be 24bit packed in 32bit\n");
|
lederr("ERROR: LED values must be 24bit packed in 32bit\n");
|
||||||
set_errno(EINVAL);
|
return -EINVAL;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nxsem_wait(&priv->exclsem);
|
nxsem_wait(&priv->exclsem);
|
||||||
|
|||||||
@@ -344,7 +344,6 @@ static int adt7320_open(FAR struct file *filep)
|
|||||||
|
|
||||||
if (adt7320_read_reg8(priv, ADT7320_ID_REG) != ADT7320_ID)
|
if (adt7320_read_reg8(priv, ADT7320_ID_REG) != ADT7320_ID)
|
||||||
{
|
{
|
||||||
set_errno(ENODEV);
|
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -487,7 +487,6 @@ static int adxl372_dvr_open(FAR void *instance_handle, int32_t arg)
|
|||||||
snwarn("ERROR: Invalid ADXL372_ID = 0x%08x\n", pnpid);
|
snwarn("ERROR: Invalid ADXL372_ID = 0x%08x\n", pnpid);
|
||||||
|
|
||||||
priv->readonly = true;
|
priv->readonly = true;
|
||||||
set_errno(ENODEV);
|
|
||||||
}
|
}
|
||||||
else /* ID matches */
|
else /* ID matches */
|
||||||
{
|
{
|
||||||
@@ -612,8 +611,7 @@ static ssize_t adxl372_dvr_write(FAR void *instance_handle,
|
|||||||
|
|
||||||
if (priv->readonly)
|
if (priv->readonly)
|
||||||
{
|
{
|
||||||
set_errno(EROFS);
|
return -EROFS;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
adxl372_write_registerblk(priv, priv->seek_address, (uint8_t *)buffer,
|
adxl372_write_registerblk(priv, priv->seek_address, (uint8_t *)buffer,
|
||||||
@@ -640,8 +638,7 @@ static off_t adxl372_dvr_seek(FAR void *instance_handle, off_t offset,
|
|||||||
reg = priv->seek_address + offset;
|
reg = priv->seek_address + offset;
|
||||||
if (0 > reg || reg > ADXL372_LAST)
|
if (0 > reg || reg > ADXL372_LAST)
|
||||||
{
|
{
|
||||||
set_errno(-EINVAL);
|
return -EINVAL;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->seek_address = reg;
|
priv->seek_address = reg;
|
||||||
@@ -654,16 +651,14 @@ static off_t adxl372_dvr_seek(FAR void *instance_handle, off_t offset,
|
|||||||
case SEEK_SET: /* Seek to designated address */
|
case SEEK_SET: /* Seek to designated address */
|
||||||
if (0 > offset || offset > ADXL372_LAST)
|
if (0 > offset || offset > ADXL372_LAST)
|
||||||
{
|
{
|
||||||
set_errno(-EINVAL);
|
return -EINVAL;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->seek_address = offset;
|
priv->seek_address = offset;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* invalid whence */
|
default: /* invalid whence */
|
||||||
set_errno(-EINVAL);
|
return -EINVAL;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return priv->seek_address;
|
return priv->seek_address;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/sensors/lsm330.c
|
* drivers/sensors/lsm330_spi.c
|
||||||
* Character driver for the ST LSM330 Tri-axis accelerometer and gyroscope.
|
* Character driver for the ST LSM330 Tri-axis accelerometer and gyroscope.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017-2018 RAF Research LLC. All rights reserved.
|
* Copyright (C) 2017-2018 RAF Research LLC. All rights reserved.
|
||||||
@@ -671,8 +671,7 @@ static int lsm330acl_dvr_open(FAR void *instance_handle, int32_t arg)
|
|||||||
{
|
{
|
||||||
sninfo("INFO: LSM330 Accelerometer is already open.\n");
|
sninfo("INFO: LSM330 Accelerometer is already open.\n");
|
||||||
|
|
||||||
set_errno(-EBUSY);
|
return -EBUSY;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the ID Register */
|
/* Read the ID Register */
|
||||||
@@ -690,7 +689,6 @@ static int lsm330acl_dvr_open(FAR void *instance_handle, int32_t arg)
|
|||||||
"Device ID (0x%02X) does not match expected LSM330 Acl ID (0x%02).\n",
|
"Device ID (0x%02X) does not match expected LSM330 Acl ID (0x%02).\n",
|
||||||
reg_content, LSM330_ACL_IDREG_VALUE);
|
reg_content, LSM330_ACL_IDREG_VALUE);
|
||||||
|
|
||||||
set_errno(ENODEV);
|
|
||||||
priv->readonly = true;
|
priv->readonly = true;
|
||||||
}
|
}
|
||||||
else /* ID matches */
|
else /* ID matches */
|
||||||
@@ -765,8 +763,7 @@ static int lsm330gyro_dvr_open(FAR void *instance_handle, int32_t arg)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
sninfo("INFO: LSM330 Gyroscope is already open.\n");
|
sninfo("INFO: LSM330 Gyroscope is already open.\n");
|
||||||
set_errno(-EBUSY);
|
return -EBUSY;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the ID Register */
|
/* Read the ID Register */
|
||||||
@@ -784,7 +781,6 @@ static int lsm330gyro_dvr_open(FAR void *instance_handle, int32_t arg)
|
|||||||
"Device ID (0x%02X) does not match expected LSM330 Gyro ID (0x%02).\n",
|
"Device ID (0x%02X) does not match expected LSM330 Gyro ID (0x%02).\n",
|
||||||
reg_content, LSM330_GYRO_IDREG_VALUE);
|
reg_content, LSM330_GYRO_IDREG_VALUE);
|
||||||
|
|
||||||
set_errno(ENODEV);
|
|
||||||
priv->readonly = true;
|
priv->readonly = true;
|
||||||
}
|
}
|
||||||
else /* ID matches */
|
else /* ID matches */
|
||||||
@@ -925,8 +921,7 @@ static ssize_t lsm330acl_dvr_write(FAR void *instance_handle,
|
|||||||
|
|
||||||
if (priv->readonly)
|
if (priv->readonly)
|
||||||
{
|
{
|
||||||
set_errno(-EROFS);
|
return -EROFS;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lsm330_write_acl_registerblk(priv, priv->seek_address, (uint8_t *)buffer,
|
lsm330_write_acl_registerblk(priv, priv->seek_address, (uint8_t *)buffer,
|
||||||
@@ -947,8 +942,7 @@ static ssize_t lsm330gyro_dvr_write(FAR void *instance_handle,
|
|||||||
|
|
||||||
if (priv->readonly)
|
if (priv->readonly)
|
||||||
{
|
{
|
||||||
set_errno(-EROFS);
|
return -EROFS;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lsm330_write_gyro_registerblk(priv, priv->seek_address,
|
lsm330_write_gyro_registerblk(priv, priv->seek_address,
|
||||||
@@ -973,8 +967,7 @@ static off_t lsm330acl_dvr_seek(FAR void *instance_handle, off_t offset, int whe
|
|||||||
reg = priv->seek_address + offset;
|
reg = priv->seek_address + offset;
|
||||||
if (0 > reg || reg > LSM330_ACL_LAST)
|
if (0 > reg || reg > LSM330_ACL_LAST)
|
||||||
{
|
{
|
||||||
set_errno(-EINVAL);
|
return -EINVAL;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->seek_address = reg;
|
priv->seek_address = reg;
|
||||||
@@ -987,16 +980,14 @@ static off_t lsm330acl_dvr_seek(FAR void *instance_handle, off_t offset, int whe
|
|||||||
case SEEK_SET: /* seek to designated address */
|
case SEEK_SET: /* seek to designated address */
|
||||||
if (0 > offset || offset > LSM330_ACL_LAST)
|
if (0 > offset || offset > LSM330_ACL_LAST)
|
||||||
{
|
{
|
||||||
set_errno(-EINVAL);
|
return -EINVAL;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->seek_address = offset;
|
priv->seek_address = offset;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* Invalid whence */
|
default: /* Invalid whence */
|
||||||
set_errno(-EINVAL);
|
return -EINVAL;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return priv->seek_address;
|
return priv->seek_address;
|
||||||
@@ -1020,8 +1011,7 @@ static off_t lsm330gyro_dvr_seek(FAR void *instance_handle, off_t offset,
|
|||||||
reg = priv->seek_address + offset;
|
reg = priv->seek_address + offset;
|
||||||
if (0 > reg || reg > LSM330_GYRO_LAST)
|
if (0 > reg || reg > LSM330_GYRO_LAST)
|
||||||
{
|
{
|
||||||
set_errno(-EINVAL);
|
return -EINVAL;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->seek_address = reg;
|
priv->seek_address = reg;
|
||||||
@@ -1034,16 +1024,14 @@ static off_t lsm330gyro_dvr_seek(FAR void *instance_handle, off_t offset,
|
|||||||
case SEEK_SET: /* seek to designated address */
|
case SEEK_SET: /* seek to designated address */
|
||||||
if (0 > offset || offset > LSM330_GYRO_LAST)
|
if (0 > offset || offset > LSM330_GYRO_LAST)
|
||||||
{
|
{
|
||||||
set_errno(-EINVAL);
|
return -EINVAL;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->seek_address = offset;
|
priv->seek_address = offset;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* Invalid whence */
|
default: /* Invalid whence */
|
||||||
set_errno(-EINVAL);
|
return -EINVAL;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return priv->seek_address;
|
return priv->seek_address;
|
||||||
|
|||||||
@@ -52,19 +52,17 @@ static int fat_attrib(const char *path, fat_attrib_t *retattrib,
|
|||||||
uint8_t *direntry;
|
uint8_t *direntry;
|
||||||
uint8_t oldattributes;
|
uint8_t oldattributes;
|
||||||
uint8_t newattributes;
|
uint8_t newattributes;
|
||||||
int status;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Find the inode for this file */
|
/* Find the inode for this file */
|
||||||
|
|
||||||
SETUP_SEARCH(&desc, path, false);
|
SETUP_SEARCH(&desc, path, false);
|
||||||
|
|
||||||
status = inode_find(&desc);
|
ret = inode_find(&desc);
|
||||||
if (status < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
/* There is no mountpoint that includes in this path */
|
/* There is no mountpoint that includes in this path */
|
||||||
|
|
||||||
ret = -status;
|
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +75,7 @@ static int fat_attrib(const char *path, fat_attrib_t *retattrib,
|
|||||||
|
|
||||||
if (!INODE_IS_MOUNTPT(inode) || !inode->u.i_mops || !inode->i_private)
|
if (!INODE_IS_MOUNTPT(inode) || !inode->u.i_mops || !inode->i_private)
|
||||||
{
|
{
|
||||||
ret = ENXIO;
|
ret = -ENXIO;
|
||||||
goto errout_with_inode;
|
goto errout_with_inode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +113,7 @@ static int fat_attrib(const char *path, fat_attrib_t *retattrib,
|
|||||||
{
|
{
|
||||||
/* Ooops.. we found the root directory */
|
/* Ooops.. we found the root directory */
|
||||||
|
|
||||||
ret = EACCES;
|
ret = -EACCES;
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +139,6 @@ static int fat_attrib(const char *path, fat_attrib_t *retattrib,
|
|||||||
ret = fat_updatefsinfo(fs);
|
ret = fat_updatefsinfo(fs);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
ret = -ret;
|
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,8 +163,7 @@ errout_with_inode:
|
|||||||
|
|
||||||
errout:
|
errout:
|
||||||
RELEASE_SEARCH(&desc);
|
RELEASE_SEARCH(&desc);
|
||||||
set_errno(ret);
|
return ret;
|
||||||
return ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
+1
-1
@@ -625,7 +625,7 @@ int eventfd(unsigned int count, int flags)
|
|||||||
|
|
||||||
/* Try open new device */
|
/* Try open new device */
|
||||||
|
|
||||||
new_fd = open(devpath, O_RDWR |
|
new_fd = nx_open(devpath, O_RDWR |
|
||||||
(flags & (EFD_NONBLOCK | EFD_SEMAPHORE | EFD_CLOEXEC)));
|
(flags & (EFD_NONBLOCK | EFD_SEMAPHORE | EFD_CLOEXEC)));
|
||||||
|
|
||||||
if (new_fd < 0)
|
if (new_fd < 0)
|
||||||
|
|||||||
+2
-27
@@ -56,26 +56,6 @@
|
|||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Internal nxsem_* interfaces are not available in the user space in
|
|
||||||
* PROTECTED and KERNEL builds. In that context, the application semaphore
|
|
||||||
* interfaces must be used. The differences between the two sets of
|
|
||||||
* interfaces are: (1) the nxsem_* interfaces do not cause cancellation
|
|
||||||
* points and (2) they do not modify the errno variable.
|
|
||||||
*
|
|
||||||
* See additional definitions in include/nuttx/semaphore.h
|
|
||||||
*
|
|
||||||
* REVISIT: The fact that sem_wait() is a cancellation point is an issue
|
|
||||||
* and does cause a violation: It makes all of the memory management
|
|
||||||
* interfaces into cancellation points when used from user space in the
|
|
||||||
* PROTECTED and KERNEL builds.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
|
|
||||||
# define _SEM_GETERROR(r)
|
|
||||||
#else
|
|
||||||
# define _SEM_GETERROR(r) (r) = -errno
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This is a special value that indicates that there is no holder of the
|
/* This is a special value that indicates that there is no holder of the
|
||||||
* semaphore. The valid range of PIDs is 0-32767 and any value outside of
|
* semaphore. The valid range of PIDs is 0-32767 and any value outside of
|
||||||
* that range could be used (except -ESRCH which is a special return value
|
* that range could be used (except -ESRCH which is a special return value
|
||||||
@@ -194,7 +174,7 @@ int mm_trysemaphore(FAR struct mm_heap_s *heap)
|
|||||||
ret = _SEM_TRYWAIT(&heap->mm_semaphore);
|
ret = _SEM_TRYWAIT(&heap->mm_semaphore);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
_SEM_GETERROR(ret);
|
ret = _SEM_ERRVAL(ret);
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,13 +235,8 @@ void mm_takesemaphore(FAR struct mm_heap_s *heap)
|
|||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
|
ret = _SEM_ERRVAL(ret);
|
||||||
DEBUGASSERT(ret == -EINTR || ret == -ECANCELED);
|
DEBUGASSERT(ret == -EINTR || ret == -ECANCELED);
|
||||||
#else
|
|
||||||
int errcode = get_errno();
|
|
||||||
DEBUGASSERT(errcode == EINTR || errcode == ECANCELED);
|
|
||||||
ret = -errcode;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (ret == -EINTR);
|
while (ret == -EINTR);
|
||||||
|
|||||||
Reference in New Issue
Block a user