mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
drivers/: Within the OS, nxisg_usleep() should be used instead of usleep(). usleep() is a cancellation point and sets the errno value. Neither of which should be done inside the OS.
This commit is contained in:
@@ -43,7 +43,9 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
#include <nuttx/modem/altmdm.h>
|
#include <nuttx/modem/altmdm.h>
|
||||||
|
|
||||||
#include "altmdm_sys.h"
|
#include "altmdm_sys.h"
|
||||||
#include "altmdm_pm.h"
|
#include "altmdm_pm.h"
|
||||||
#include "altmdm_pm_state.h"
|
#include "altmdm_pm_state.h"
|
||||||
@@ -1277,7 +1279,8 @@ int altmdm_pm_uninit(FAR struct altmdm_dev_s *priv)
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
usleep(10);
|
|
||||||
|
nxsig_usleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete event flags. */
|
/* Delete event flags. */
|
||||||
|
|||||||
@@ -41,8 +41,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
#include <nuttx/spi/spi.h>
|
#include <nuttx/spi/spi.h>
|
||||||
#include <nuttx/modem/altmdm.h>
|
#include <nuttx/modem/altmdm.h>
|
||||||
|
|
||||||
#include "altmdm_sys.h"
|
#include "altmdm_sys.h"
|
||||||
#include "altmdm_pm.h"
|
#include "altmdm_pm.h"
|
||||||
#include "altmdm_pm_state.h"
|
#include "altmdm_pm_state.h"
|
||||||
@@ -1943,7 +1945,7 @@ int altmdm_spi_uninit(FAR struct altmdm_dev_s *priv)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(10);
|
nxsig_usleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
altmdm_sys_deletelock(&priv->spidev.tx_param.lock);
|
altmdm_sys_deletelock(&priv->spidev.tx_param.lock);
|
||||||
@@ -2153,7 +2155,7 @@ again:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TRANS_OK_RCVBUFFUL:
|
case TRANS_OK_RCVBUFFUL:
|
||||||
usleep(100);
|
nxsig_usleep(100);
|
||||||
goto again;
|
goto again;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -411,7 +411,7 @@ static uint8_t gd25_waitwritecomplete(FAR struct gd25_dev_s *priv)
|
|||||||
if (priv->prev_instr != GD25_PP && (status & GD25_SR_WIP) != 0)
|
if (priv->prev_instr != GD25_PP && (status & GD25_SR_WIP) != 0)
|
||||||
{
|
{
|
||||||
gd25_unlock(priv->spi);
|
gd25_unlock(priv->spi);
|
||||||
usleep(1000);
|
nxsig_usleep(1000);
|
||||||
gd25_lock(priv->spi);
|
gd25_lock(priv->spi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -49,6 +49,7 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
#include <nuttx/spi/spi.h>
|
#include <nuttx/spi/spi.h>
|
||||||
#include <nuttx/mtd/mtd.h>
|
#include <nuttx/mtd/mtd.h>
|
||||||
@@ -327,7 +328,7 @@ static bool gd5f_waitstatus(FAR struct gd5f_dev_s *priv, uint8_t mask, bool succ
|
|||||||
/* Deselect the FLASH */
|
/* Deselect the FLASH */
|
||||||
|
|
||||||
SPI_SELECT(priv->dev, SPIDEV_FLASH(priv->spi_devid), false);
|
SPI_SELECT(priv->dev, SPIDEV_FLASH(priv->spi_devid), false);
|
||||||
usleep(1000);
|
nxsig_usleep(1000);
|
||||||
}
|
}
|
||||||
while ((status & GD5F_SR_OIP) != 0);
|
while ((status & GD5F_SR_OIP) != 0);
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -2,7 +2,7 @@
|
|||||||
* drivers/mtd/mx35.c
|
* drivers/mtd/mx35.c
|
||||||
* Driver for SPI-based MX35LFxGE4AB parts of 1 or 2GBit.
|
* Driver for SPI-based MX35LFxGE4AB parts of 1 or 2GBit.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2016, 2019 Gregory Nutt. All rights reserved.
|
||||||
* Author: Ekaterina Kovylova <fomalhaut.hm@gmail.com>
|
* Author: Ekaterina Kovylova <fomalhaut.hm@gmail.com>
|
||||||
*
|
*
|
||||||
* Copied from / based on mx25lx.c driver written by
|
* Copied from / based on mx25lx.c driver written by
|
||||||
@@ -52,6 +52,7 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
#include <nuttx/spi/spi.h>
|
#include <nuttx/spi/spi.h>
|
||||||
#include <nuttx/mtd/mtd.h>
|
#include <nuttx/mtd/mtd.h>
|
||||||
@@ -379,7 +380,7 @@ static bool mx35_waitstatus(FAR struct mx35_dev_s *priv, uint8_t mask, bool succ
|
|||||||
* other peripherals to access the SPI bus.
|
* other peripherals to access the SPI bus.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
while (((status & MX35_SR_OIP) != 0) && (!usleep(1000)));
|
while (((status & MX35_SR_OIP) != 0) && (!nxsig_usleep(1000)));
|
||||||
|
|
||||||
mx35info("Complete\n");
|
mx35info("Complete\n");
|
||||||
return successif ? ((status & mask) != 0) : ((status & mask) == 0);
|
return successif ? ((status & mask) != 0) : ((status & mask) == 0);
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ static uint8_t as726x_read8(FAR struct as726x_dev_s *priv, uint8_t regaddr)
|
|||||||
break; /* If TX bit is clear, it is ok to write */
|
break; /* If TX bit is clear, it is ok to write */
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(AS726X_POLLING_DELAY);
|
nxsig_usleep(AS726X_POLLING_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send the virtual register address (bit 7 should be 0 to indicate we are
|
/* Send the virtual register address (bit 7 should be 0 to indicate we are
|
||||||
@@ -245,7 +245,7 @@ static uint8_t as726x_read8(FAR struct as726x_dev_s *priv, uint8_t regaddr)
|
|||||||
break; /* Read data is ready. */
|
break; /* Read data is ready. */
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(AS726X_POLLING_DELAY);
|
nxsig_usleep(AS726X_POLLING_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t incoming = read_register(priv, AS72XX_SLAVE_READ_REG);
|
uint8_t incoming = read_register(priv, AS72XX_SLAVE_READ_REG);
|
||||||
@@ -300,7 +300,7 @@ static void as726x_write8(FAR struct as726x_dev_s *priv, uint8_t regaddr,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(AS726X_POLLING_DELAY);
|
nxsig_usleep(AS726X_POLLING_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send the virtual register address (setting bit 7 to indicate we are
|
/* Send the virtual register address (setting bit 7 to indicate we are
|
||||||
@@ -321,7 +321,7 @@ static void as726x_write8(FAR struct as726x_dev_s *priv, uint8_t regaddr,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(AS726X_POLLING_DELAY);
|
nxsig_usleep(AS726X_POLLING_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send the data to complete the operation. */
|
/* Send the data to complete the operation. */
|
||||||
|
|||||||
@@ -37,16 +37,19 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/i2c/i2c_master.h>
|
#include <nuttx/i2c/i2c_master.h>
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
#include <nuttx/random.h>
|
#include <nuttx/random.h>
|
||||||
|
|
||||||
#include <nuttx/sensors/hts221.h>
|
#include <nuttx/sensors/hts221.h>
|
||||||
@@ -400,7 +403,7 @@ static int hts221_config_ctrl_reg2(FAR struct hts221_dev_s *priv,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(10 * 1000);
|
nxsig_usleep(10 * 1000);
|
||||||
retries--;
|
retries--;
|
||||||
}
|
}
|
||||||
while (retries);
|
while (retries);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbdev/usbmsc_scsi.c
|
* drivers/usbdev/usbmsc_scsi.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2010, 2012, 2016-2017 Gregory Nutt. All rights
|
* Copyright (C) 2008-2010, 2012, 2016-2017, 2019 Gregory Nutt. All rights
|
||||||
* reserved.
|
* reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
@@ -71,6 +71,7 @@
|
|||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kthread.h>
|
#include <nuttx/kthread.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
#include <nuttx/scsi.h>
|
#include <nuttx/scsi.h>
|
||||||
#include <nuttx/usb/storage.h>
|
#include <nuttx/usb/storage.h>
|
||||||
#include <nuttx/usb/usbdev.h>
|
#include <nuttx/usb/usbdev.h>
|
||||||
@@ -2467,12 +2468,12 @@ static int usbmsc_cmdfinishstate(FAR struct usbmsc_dev_s *priv)
|
|||||||
* First, wait for the transfer to complete, then stall the endpoint
|
* First, wait for the transfer to complete, then stall the endpoint
|
||||||
*/
|
*/
|
||||||
|
|
||||||
usleep (100000);
|
nxsig_usleep (100000);
|
||||||
(void)EP_STALL(priv->epbulkin);
|
(void)EP_STALL(priv->epbulkin);
|
||||||
|
|
||||||
/* now wait for stall to go away .... */
|
/* now wait for stall to go away .... */
|
||||||
|
|
||||||
usleep (100000);
|
nxsig_usleep (100000);
|
||||||
#else
|
#else
|
||||||
(void)EP_STALL(priv->epbulkin);
|
(void)EP_STALL(priv->epbulkin);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbhost/usbhost_max3421e.c
|
* drivers/usbhost/usbhost_max3421e.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2018, 2019 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* References:
|
* References:
|
||||||
@@ -3295,7 +3295,7 @@ static void max3421e_int_wait(FAR struct max3421e_usbhost_s *priv,
|
|||||||
|
|
||||||
if (regval == 0 && usec > 0)
|
if (regval == 0 && usec > 0)
|
||||||
{
|
{
|
||||||
usleep(usec);
|
nxsig_usleep(usec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (regval == 0);
|
while (regval == 0);
|
||||||
@@ -4510,7 +4510,7 @@ static int max3421e_startsof(FAR struct max3421e_usbhost_s *priv)
|
|||||||
while ((max3421e_getreg(priv, MAX3421E_USBHOST_HCTL) &
|
while ((max3421e_getreg(priv, MAX3421E_USBHOST_HCTL) &
|
||||||
USBHOST_HCTL_BUSSAMPLE) == 0)
|
USBHOST_HCTL_BUSSAMPLE) == 0)
|
||||||
{
|
{
|
||||||
usleep(5);
|
nxsig_usleep(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for low- or full-speed and start SOF (actually already started
|
/* Check for low- or full-speed and start SOF (actually already started
|
||||||
@@ -4579,7 +4579,7 @@ static int max3421e_startsof(FAR struct max3421e_usbhost_s *priv)
|
|||||||
/* Wait for the first SOF received and 20ms has passed */
|
/* Wait for the first SOF received and 20ms has passed */
|
||||||
|
|
||||||
max3421e_int_wait(priv, USBHOST_HIRQ_FRAMEIRQ, 0);
|
max3421e_int_wait(priv, USBHOST_HIRQ_FRAMEIRQ, 0);
|
||||||
usleep(20*1000);
|
nxsig_usleep(20*1000);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/i2c/i2c_master.h>
|
#include <nuttx/i2c/i2c_master.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
@@ -741,7 +742,7 @@ static int isx012_chk_int_state(isx012_dev_t *priv,
|
|||||||
volatile uint8_t data;
|
volatile uint8_t data;
|
||||||
uint32_t time = 0;
|
uint32_t time = 0;
|
||||||
|
|
||||||
usleep(delay_time * 1000);
|
nxsig_usleep(delay_time * 1000);
|
||||||
while (time < timeout)
|
while (time < timeout)
|
||||||
{
|
{
|
||||||
data = isx012_getreg(priv, INTSTS0, sizeof(data));
|
data = isx012_getreg(priv, INTSTS0, sizeof(data));
|
||||||
@@ -752,7 +753,7 @@ static int isx012_chk_int_state(isx012_dev_t *priv,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(wait_time * 1000);
|
nxsig_usleep(wait_time * 1000);
|
||||||
time += wait_time;
|
time += wait_time;
|
||||||
}
|
}
|
||||||
return ERROR;
|
return ERROR;
|
||||||
@@ -1107,10 +1108,10 @@ int init_isx012(FAR struct isx012_dev_s *priv)
|
|||||||
#ifdef ISX012_NOT_USE_NSTBY
|
#ifdef ISX012_NOT_USE_NSTBY
|
||||||
board_isx012_release_sleep();
|
board_isx012_release_sleep();
|
||||||
board_isx012_release_reset();
|
board_isx012_release_reset();
|
||||||
usleep(6000);
|
nxsig_usleep(6000);
|
||||||
#else
|
#else
|
||||||
board_isx012_release_reset();
|
board_isx012_release_reset();
|
||||||
usleep(6000);
|
nxsig_usleep(6000);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ISX012_CHECK_IN_DETAIL
|
#ifdef ISX012_CHECK_IN_DETAIL
|
||||||
|
|||||||
@@ -111,6 +111,7 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/wireless/cc1101.h>
|
#include <nuttx/wireless/cc1101.h>
|
||||||
|
|
||||||
@@ -720,7 +721,7 @@ void cc1101_access_begin(FAR struct cc1101_dev_s *dev)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
usleep(150 * 1000);
|
nxsig_usleep(150 * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/wqueue.h>
|
#include <nuttx/wqueue.h>
|
||||||
#include <nuttx/semaphore.h>
|
#include <nuttx/semaphore.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
#include <nuttx/wireless/gs2200m.h>
|
#include <nuttx/wireless/gs2200m.h>
|
||||||
#include <nuttx/net/netdev.h>
|
#include <nuttx/net/netdev.h>
|
||||||
|
|
||||||
@@ -878,14 +879,14 @@ retry:
|
|||||||
{
|
{
|
||||||
/* TODO: timeout */
|
/* TODO: timeout */
|
||||||
|
|
||||||
usleep(10);
|
nxsig_usleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NOTE: wait 100us
|
/* NOTE: wait 100us
|
||||||
* workaround to avoid realy receiving an invalid frame response
|
* workaround to avoid really receiving an invalid frame response
|
||||||
*/
|
*/
|
||||||
|
|
||||||
up_udelay(100);
|
nxsig_usleep(100);
|
||||||
|
|
||||||
/* Read frame response */
|
/* Read frame response */
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
#include <net/ethernet.h>
|
#include <net/ethernet.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
#include <nuttx/wdog.h>
|
#include <nuttx/wdog.h>
|
||||||
#include <nuttx/sdio.h>
|
#include <nuttx/sdio.h>
|
||||||
#include <nuttx/net/arp.h>
|
#include <nuttx/net/arp.h>
|
||||||
@@ -995,7 +996,7 @@ int bcmf_wl_enable(FAR struct bcmf_dev_s *priv, bool enable)
|
|||||||
|
|
||||||
/* TODO wait for WLC_E_RADIO event */
|
/* TODO wait for WLC_E_RADIO event */
|
||||||
|
|
||||||
usleep(3000);
|
nxsig_usleep(3000);
|
||||||
|
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2977,7 +2977,7 @@ static int sx127x_lora_opmode_set(FAR struct sx127x_dev_s *dev,
|
|||||||
|
|
||||||
/* Wait for mode ready. REVISIT: do we need this ? */
|
/* Wait for mode ready. REVISIT: do we need this ? */
|
||||||
|
|
||||||
usleep(250);
|
nxsig_usleep(250);
|
||||||
|
|
||||||
errout:
|
errout:
|
||||||
return ret;
|
return ret;
|
||||||
@@ -3805,7 +3805,7 @@ static bool sx127x_channel_scan(FAR struct sx127x_dev_s *dev,
|
|||||||
|
|
||||||
/* Wait some time */
|
/* Wait some time */
|
||||||
|
|
||||||
usleep(1000);
|
nxsig_usleep(1000);
|
||||||
}
|
}
|
||||||
while (tstart.tv_sec + chanscan->stime > tnow.tv_sec);
|
while (tstart.tv_sec + chanscan->stime > tnow.tv_sec);
|
||||||
|
|
||||||
@@ -4160,7 +4160,7 @@ static int sx127x_calibration(FAR struct sx127x_dev_s *dev, uint32_t freq)
|
|||||||
{
|
{
|
||||||
/* Wait 10ms */
|
/* Wait 10ms */
|
||||||
|
|
||||||
usleep(10000);
|
nxsig_usleep(10000);
|
||||||
|
|
||||||
/* Get register */
|
/* Get register */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user