Within the OS, nxisg_sleep() should be used instead of sleep(). sleep() is a cancellation point and sets the errno value. Neither of which should be done inside the OS.

This commit is contained in:
Gregory Nutt 2019-11-29 19:03:24 -06:00
parent 4f1d891067
commit 108ffe7044
9 changed files with 25 additions and 23 deletions

View File

@ -44,6 +44,8 @@
#include <unistd.h> #include <unistd.h>
#include <debug.h> #include <debug.h>
#include <nuttx/signal.h>
#include "stm32_dfumode.h" #include "stm32_dfumode.h"
/**************************************************************************** /****************************************************************************
@ -73,7 +75,7 @@ void stm32_dfumode(void)
{ {
#ifdef CONFIG_DEBUG_WARN #ifdef CONFIG_DEBUG_WARN
_warn("Entering DFU mode...\n"); _warn("Entering DFU mode...\n");
sleep(1); nxsig_sleep(1);
#endif #endif
asm("ldr r0, =0x40023844\n\t" /* RCC_APB2ENR */ asm("ldr r0, =0x40023844\n\t" /* RCC_APB2ENR */

View File

@ -504,7 +504,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_REG, 0); adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_REG, 0);
nxsig_usleep(100); usleep(100);
#endif #endif
#ifdef HIGHPRI_HAVE_INJECTED #ifdef HIGHPRI_HAVE_INJECTED
@ -512,7 +512,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_INJ, 0); adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_INJ, 0);
nxsig_usleep(100); usleep(100);
#endif #endif
/* Lock global data */ /* Lock global data */
@ -548,7 +548,7 @@ int highpri_main(int argc, char *argv[])
g_highpri.lock = false; g_highpri.lock = false;
sleep(1); nxsig_sleep(1);
} }
errout: errout:

View File

@ -546,7 +546,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_REG, 0); adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_REG, 0);
nxsig_usleep(100); usleep(100);
#endif #endif
#ifdef HIGHPRI_HAVE_INJECTED #ifdef HIGHPRI_HAVE_INJECTED
@ -554,7 +554,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_INJ, 0); adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_INJ, 0);
nxsig_usleep(100); usleep(100);
#endif #endif
/* Lock global data */ /* Lock global data */
@ -590,7 +590,7 @@ int highpri_main(int argc, char *argv[])
g_highpri.lock = false; g_highpri.lock = false;
sleep(1); nxsig_sleep(1);
} }
errout: errout:

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* boards/arm/stm32/nucleo-f334r8/src/stm32_spwm.c * boards/arm/stm32/nucleo-f334r8/src/stm32_spwm.c
* *
* Copyright (C) 2018 Gregory Nutt. All rights reserved. * Copyright (C) 2018, 2019 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me> * Author: Mateusz Szafoni <raiden00@railab.me>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -1047,7 +1047,7 @@ int spwm_main(int argc, char *argv[])
/* Sleep */ /* Sleep */
sleep(1); nxsig_sleep(1);
} }
errout: errout:

View File

@ -495,7 +495,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_REG, 0); adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_REG, 0);
nxsig_usleep(100); usleep(100);
#endif #endif
#ifdef HIGHPRI_HAVE_INJECTED #ifdef HIGHPRI_HAVE_INJECTED
@ -503,7 +503,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_INJ, 0); adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_INJ, 0);
nxsig_usleep(100); usleep(100);
#endif #endif
/* Lock global data */ /* Lock global data */
@ -539,7 +539,7 @@ int highpri_main(int argc, char *argv[])
g_highpri.lock = false; g_highpri.lock = false;
sleep(1); nxsig_sleep(1);
} }
errout: errout:

View File

@ -10,7 +10,7 @@
* Copyright (C) 2016 Omni Hoverboards Inc. All rights reserved. * Copyright (C) 2016 Omni Hoverboards Inc. All rights reserved.
* Author: Paul Alexander Patience <paul-a.patience@polymtl.ca> * Author: Paul Alexander Patience <paul-a.patience@polymtl.ca>
* *
* Copyright (C) 2016 Gregory Nutt. All rights reserved. * Copyright (C) 2016, 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -53,11 +53,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <nuttx/kmalloc.h> #include <nuttx/kmalloc.h>
#include <nuttx/random.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 <nuttx/sensors/lsm303agr.h> #include <nuttx/sensors/lsm303agr.h>
#include <nuttx/random.h>
#include <nuttx/signal.h>
#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_LSM303AGR) #if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_LSM303AGR)
@ -834,7 +834,7 @@ static int lsm303agr_selftest(FAR struct lsm303agr_dev_s *priv, uint32_t mode)
sninfo("\n"); sninfo("\n");
} }
sleep(2); nxsig_sleep(2);
/* Disable test */ /* Disable test */

View File

@ -10,7 +10,7 @@
* Copyright (C) 2016 Omni Hoverboards Inc. All rights reserved. * Copyright (C) 2016 Omni Hoverboards Inc. All rights reserved.
* Author: Paul Alexander Patience <paul-a.patience@polymtl.ca> * Author: Paul Alexander Patience <paul-a.patience@polymtl.ca>
* *
* Copyright (C) 2016 Gregory Nutt. All rights reserved. * Copyright (C) 2016, 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -53,11 +53,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <nuttx/kmalloc.h> #include <nuttx/kmalloc.h>
#include <nuttx/random.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 <nuttx/sensors/lsm6dsl.h> #include <nuttx/sensors/lsm6dsl.h>
#include <nuttx/random.h>
#include <nuttx/signal.h>
#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_LSM6DSL) #if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_LSM6DSL)
@ -855,7 +855,7 @@ static int lsm6dsl_selftest(FAR struct lsm6dsl_dev_s *priv, uint32_t mode)
sninfo("\n"); sninfo("\n");
} }
sleep(2); nxsig_sleep(2);
/* Disable test */ /* Disable test */

View File

@ -47,10 +47,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <nuttx/kmalloc.h> #include <nuttx/kmalloc.h>
#include <nuttx/random.h>
#include <nuttx/fs/fs.h> #include <nuttx/fs/fs.h>
#include <nuttx/i2c/i2c_master.h> #include <nuttx/i2c/i2c_master.h>
#include <nuttx/sensors/lsm9ds1.h> #include <nuttx/sensors/lsm9ds1.h>
#include <nuttx/random.h>
#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_LSM9DS1) #if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_LSM9DS1)

View File

@ -3001,7 +3001,7 @@ static int max3421e_connected(FAR struct max3421e_usbhost_s *priv)
/* Stop SOF generation and reset the bus */ /* Stop SOF generation and reset the bus */
max3421e_busreset(priv); max3421e_busreset(priv);
sleep(1); nxsig_sleep(1);
/* Check for low- or full-speed and restart SOF generation. */ /* Check for low- or full-speed and restart SOF generation. */
@ -3460,7 +3460,7 @@ static int max3421e_getspeed(FAR struct max3421e_usbhost_s *priv,
/* Stop SOF generation and reset the host port */ /* Stop SOF generation and reset the host port */
max3421e_busreset(priv); max3421e_busreset(priv);
sleep(1); nxsig_sleep(1);
/* Get the current device speed */ /* Get the current device speed */