Squashed commit of the following:

This commit backs out most of commit b4747286b1.  That change was added because sem_wait() would sometimes cause cancellation points inappropriated.  But with these recent changes, nxsem_wait() is used instead and it is not a cancellation point.

    In the OS, all calls to sem_wait() changed to nxsem_wait().  nxsem_wait() does not return errors via errno so each place where nxsem_wait() is now called must not examine the errno variable.

    In all OS functions (not libraries), change sem_wait() to nxsem_wait().  This will prevent the OS from creating bogus cancellation points and from modifying the per-task errno variable.

    sched/semaphore:  Add the function nxsem_wait().  This is a new internal OS interface.  It is functionally equivalent to sem_wait() except that (1) it is not a cancellation point, and (2) it does not set the per-thread errno value on return.
This commit is contained in:
Gregory Nutt 2017-10-04 15:22:27 -06:00
parent 42a0796615
commit 9568600ab1
307 changed files with 3421 additions and 2423 deletions

27
TODO
View file

@ -202,11 +202,7 @@ o Task/Scheduler (sched/)
For example, having cancellation points hidden inside of the
OS can cause non-cancellation point interfaces to behave
strangely. There was a change recently in pthread_cond_wait()
and pthread_cond_timedwait() recently to effectively disable
the cancellation point behavior of sem_wait(). This was
accomplished with two functions: pthread_disable_cancel()
and pthread_enable_cancel()
strangely.
Here is another issue:  Internal OS functions should not set
errno and should never have to look at the errno value to
@ -217,7 +213,7 @@ o Task/Scheduler (sched/)
Both of these could be fixed if there were special internal
versions these functions.  For example, there could be a an
nx_sem_wait() that does all of the same things as sem_wait()
nxsem_wait() that does all of the same things as sem_wait()
was does not create a cancellation point and does not set
the errno value on failures.
@ -227,20 +223,13 @@ o Task/Scheduler (sched/)
and that sets the errno value on failures.
Changes like that could clean up some of this internal
craziness.  The condition variable change described above is
really a "bandaid" to handle the case that sem_wait() is a
cancellation point. Also will need to revisit previous changes
like:
craziness.
commit b4747286b19d3b15193b2a5e8a0fe48fa0a8638c
Author: Juha Niskanen (Haltian) <juha.niskanen@haltian.com>
Date: Tue Apr 11 11:03:25 2017 -0600
Add logic to disable cancellation points within the OS.
This is useful when an internal OS function that is NOT
a cancellation point calls an OS function which is a
cancellation point. In that case, irrecoverable states
may occur if the cancellation is within the OS.
UPDATE:
2017-1003: This change has been completed for the case of
semaphores used int he OS. Still need to checkout signals
and messages queues that are also used in the OS. Also
backed out commit b4747286b19d3b15193b2a5e8a0fe48fa0a8638c.
Status: Open
Priority: Low. Things are working OK the way they are. But the design

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/efm32/efm32_dma.c
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -336,6 +336,7 @@ DMA_HANDLE efm32_dmachannel(void)
struct dma_channel_s *dmach;
unsigned int chndx;
uint32_t bit;
int ret;
/* Take a count from from the channel counting semaphore. We may block
* if there are no free channels. When we get the count, then we can
@ -343,21 +344,35 @@ DMA_HANDLE efm32_dmachannel(void)
* reserved for us.
*/
while (sem_wait(&g_dmac.chansem) < 0)
do
{
/* sem_wait should fail only if it is awakened by a a signal */
/* Take the semaphore (perhaps waiting) */
DEBUGASSERT(errno == EINTR);
ret = nxsem_wait(&g_dmac.chansem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
/* Get exclusive access to the DMA channel list */
while (sem_wait(&g_dmac.exclsem) < 0)
do
{
/* sem_wait should fail only if it is awakened by a a signal */
/* Take the semaphore (perhaps waiting) */
DEBUGASSERT(errno == EINTR);
ret = nxsem_wait(&g_dmac.exclsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
/* Search for an available DMA channel */

View file

@ -5,7 +5,7 @@
* Copyright (C) 2015 Pierre-noel Bouteville . All rights reserved.
* Authors: Pierre-noel Bouteville <pnb990@gmail.com>
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -480,10 +480,21 @@ static const char *efm32_i2c_state_str(int i2c_state)
static inline void efm32_i2c_sem_wait(FAR struct efm32_i2c_priv_s *priv)
{
while (sem_wait(&priv->sem_excl) != OK)
int ret;
do
{
ASSERT(errno == EINTR);
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&priv->sem_excl);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arm/arm/src/efm32/efm32_spi.c
*
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2014, 2016-2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2014 Bouteville Pierre-Noel. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
* Bouteville Pierre-Noel <pnb990@gmail.com>
@ -437,18 +437,24 @@ static void spi_dma_timeout(int argc, uint32_t arg1, ...)
static void spi_dmarxwait(struct efm32_spidev_s *priv)
{
irqstate_t flags;
int ret;
/* Take the semaphore (perhaps waiting). */
flags = enter_critical_section();
while (sem_wait(&priv->rxdmasem) != 0)
do
{
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&priv->rxdmasem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
/* Cancel the timeout only if both the RX and TX transfers have completed */
@ -474,18 +480,24 @@ static void spi_dmarxwait(struct efm32_spidev_s *priv)
static void spi_dmatxwait(struct efm32_spidev_s *priv)
{
irqstate_t flags;
int ret;
/* Take the semaphore (perhaps waiting). */
flags = enter_critical_section();
while (sem_wait(&priv->txdmasem) != 0)
do
{
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&priv->txdmasem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
/* Cancel the timeout only if both the RX and TX transfers have completed */
@ -748,21 +760,25 @@ static int spi_lock(struct spi_dev_s *dev, bool lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&priv->exclsem) != 0)
do
{
ret = nxsem_wait(&priv->exclsem);
/* The only case that an error should occur here is if the wait
* was awakened by a signal.
*/
DEBUGASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&priv->exclsem);
ret = OK;
}
return OK;
return ret;
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/efm32/efm32_usbhost.c
*
* Copyright (C) 2014-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -718,16 +718,21 @@ static inline void efm32_modifyreg(uint32_t addr, uint32_t clrbits, uint32_t set
static void efm32_takesem(sem_t *sem)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(sem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************
@ -1181,13 +1186,13 @@ static int efm32_chan_wait(FAR struct efm32_usbhost_s *priv,
* wait here.
*/
ret = sem_wait(&chan->waitsem);
ret = nxsem_wait(&chan->waitsem);
/* sem_wait should succeed. But it is possible that we could be
/* nxsem_wait should succeed. But it is possible that we could be
* awakened by a signal too.
*/
DEBUGASSERT(ret == OK || get_errno() == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (chan->waiter);

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/imx1/imx_spi.c
*
* Copyright (C) 2009-2010, 2013, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2009-2010, 2013, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -562,9 +562,9 @@ static int spi_transfer(struct imx_spidev_s *priv, const void *txbuffer,
{
/* Wait to be signaled from the interrupt handler */
ret = sem_wait(&priv->waitsem);
ret = nxsem_wait(&priv->waitsem);
}
while (ret < 0 && errno == EINTR);
while (ret < 0 && ret == -EINTR);
#else
/* Perform the transfer using polling logic. This will totally
@ -709,26 +709,26 @@ static int spi_interrupt(int irq, void *context, FAR void *arg, FAR void *arg)
static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
{
struct imx_spidev_s *priv = (struct imx_spidev_s *)dev;
int ret;
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&priv->exclsem) != 0)
do
{
/* The only case that an error should occur here is if the wait
* was awakened by a signal.
*/
/* Take the semaphore (perhaps waiting) */
DEBUGASSERT(errno == EINTR);
ret = nxsem_wait(&priv->exclsem);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&priv->exclsem);
ret = OK;
}
return OK;
return ret;
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/imx6/imx_ecspi.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Derives from the i.MX1 CSPI driver:
@ -687,9 +687,9 @@ static int spi_transfer(struct imx_spidev_s *priv, const void *txbuffer,
{
/* Wait to be signaled from the interrupt handler */
ret = sem_wait(&priv->waitsem);
ret = nxsem_wait(&priv->waitsem);
}
while (ret < 0 && errno == EINTR);
while (ret < 0 && ret == -EINTR);
#else
/* Perform the transfer using polling logic. This will totally
@ -794,26 +794,26 @@ static int spi_interrupt(int irq, void *context, FAR void *arg)
static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
{
struct imx_spidev_s *priv = (struct imx_spidev_s *)dev;
int ret;
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&priv->exclsem) != 0)
do
{
/* The only case that an error should occur here is if the wait
* was awakened by a signal.
*/
/* Take the semaphore (perhaps waiting) */
DEBUGASSERT(errno == EINTR);
ret = nxsem_wait(&priv->exclsem);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&priv->exclsem);
ret = OK;
}
return OK;
return ret;
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/imx6/imx_serial.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -963,10 +963,10 @@ int up_putc(int ch)
if (!up_interrupt_context() && g_os_initstate >= OSINIT_HARDWARE)
{
ret = sem_wait(&g_putc_lock);
ret = nxsem_wait(&g_putc_lock);
if (ret < 0)
{
return ERROR;
return ret;
}
locked = true;

View file

@ -350,10 +350,21 @@ static inline void kinetis_i2c_sem_destroy(FAR struct kinetis_i2cdev_s *priv)
static inline void kinetis_i2c_sem_wait(FAR struct kinetis_i2cdev_s *priv)
{
while (sem_wait(&priv->mutex) != 0)
int ret;
do
{
DEBUGASSERT(errno == EINTR);
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&priv->mutex);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/************************************************************************************
@ -379,7 +390,7 @@ static inline void kinetis_i2c_sem_post(struct kinetis_i2cdev_s *priv)
static inline void kinetis_i2c_wait(struct kinetis_i2cdev_s *priv)
{
sem_wait(&priv->wait);
(void)nxsem_wait(&priv->wait);
}
/************************************************************************************

View file

@ -432,16 +432,21 @@ static struct kinetis_sdhcregs_s g_sampleregs[DEBUG_NSAMPLES];
static void kinetis_takesem(struct kinetis_dev_s *priv)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&priv->waitsem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&priv->waitsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -583,26 +583,31 @@ void inline spi_run(FAR struct kinetis_spidev_s *priv, bool enable)
static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
{
FAR struct kinetis_spidev_s *priv = (FAR struct kinetis_spidev_s *)dev;
int ret;
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&priv->exclsem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
ret = nxsem_wait(&priv->exclsem);
/* The only case that an error should occur here is if the wait
* was awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&priv->exclsem);
ret = OK;
}
return OK;
return ret;
}
/************************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/kl/kl_spi.c
*
* Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -235,25 +235,31 @@ static inline void spi_putreg(FAR struct kl_spidev_s *priv, uint8_t offset,
static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
{
FAR struct kl_spidev_s *priv = (FAR struct kl_spidev_s *)dev;
int ret;
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&priv->exclsem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
ret = nxsem_wait(&priv->exclsem);
/* The only case that an error should occur here is if the wait
* was awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&priv->exclsem);
ret = OK;
}
return OK;
return ret;
}
/************************************************************************************

View file

@ -226,7 +226,9 @@ static void lc823450_adc_start(FAR struct lc823450_adc_inst_s *inst)
uint8_t i;
uint32_t div;
#ifdef CONFIG_ADC_POLLED
#ifndef CONFIG_ADC_POLLED
int ret;
#else
irqstate_t flags;
flags = enter_critical_section();
@ -261,10 +263,19 @@ static void lc823450_adc_start(FAR struct lc823450_adc_inst_s *inst)
while ((getreg32(rADCSTS) & rADCSTS_fADCMPL) == 0)
;
#else
while (sem_wait(&inst->sem_isr) != 0)
do
{
ASSERT(errno == EINTR);
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&inst->sem_isr);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
#endif
#ifdef CONFIG_ADC_POLLED
@ -282,10 +293,21 @@ static void lc823450_adc_start(FAR struct lc823450_adc_inst_s *inst)
static inline void lc823450_adc_sem_wait(FAR struct lc823450_adc_inst_s *inst)
{
while (sem_wait(&inst->sem_excl) != 0)
int ret;
do
{
ASSERT(errno == EINTR);
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&inst->sem_excl);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -260,10 +260,21 @@ static struct lc823450_i2c_priv_s lc823450_i2c1_priv =
static inline void lc823450_i2c_sem_wait(FAR struct lc823450_i2c_priv_s *priv)
{
while (sem_wait(&priv->sem_excl) != 0)
int ret;
do
{
ASSERT(errno == EINTR);
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&priv->sem_excl);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -142,10 +142,21 @@ static struct lc823450_partinfo_s partinfo[LC823450_NPARTS] =
static void mtd_semtake(FAR sem_t *sem)
{
while (sem_wait(sem) != 0)
int ret;
do
{
ASSERT(errno == EINTR);
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -138,10 +138,21 @@ extern SINT_T sddep_write(void *src, void *dst, UI_32 size, SINT_T type,
static void _sdc_semtake(FAR sem_t *sem)
{
while (sem_wait(sem) != 0)
int ret;
do
{
ASSERT(errno == EINTR);
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -131,10 +131,21 @@ static void dma_callback(DMA_HANDLE hdma, void *arg, int result)
static void _sddep_semtake(FAR sem_t *sem)
{
while (sem_wait(sem) != 0)
int ret;
do
{
ASSERT(errno == EINTR);
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1204,7 +1204,7 @@ static int up_hs_send(struct uart_dev_s *dev, const char *buf, int buflen)
retry:
sem_wait(&priv->txdma_wait);
nxsem_wait(&priv->txdma_wait);
/* If buflen <= FIFO space, write it by PIO. */

View file

@ -149,26 +149,31 @@ static struct lc823450_spidev_s g_spidev =
static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
{
FAR struct lc823450_spidev_s *priv = (FAR struct lc823450_spidev_s *)dev;
int ret;
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&priv->exclsem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
ret = nxsem_wait(&priv->exclsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&priv->exclsem);
ret = OK;
}
return OK;
return ret;
}
#endif
@ -409,7 +414,7 @@ static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer,
modifyreg32(LC823450_SPI_SMD, 0, SPI_SMD_WTR);
while (sem_wait(&priv->dma_wait) != 0);
while (nxsem_wait(&priv->dma_wait) < 0);
nwords -= len;
buffer += len;
}

View file

@ -391,7 +391,7 @@ int up_hrttimer_usleep(unsigned int usec)
hrt.usec = usec;
hrt_usleep_add(&hrt);
sem_wait(&hrt.sem);
nxsem_wait(&hrt.sem);
return 0;
}

View file

@ -1780,7 +1780,7 @@ int usbdev_msc_epwrite(void *buf, int len)
USB_DMAC_START,
USB_DMAC1);
(void)sem_wait(&dma_wait);
(void)nxsem_wait(&dma_wait);
return 0;
}
@ -1884,7 +1884,7 @@ int usbdev_msc_epread(void *buf, int len)
CONFIG_USBMSC_EPBULKOUT << USB_DMAC_DMAEP_SHIFT |
USB_DMAC_START,
USB_DMAC1);
(void)sem_wait(&dma_wait);
(void)nxsem_wait(&dma_wait);
return 0;
}

View file

@ -216,7 +216,7 @@ static int lpc11_i2c_start(struct lpc11_i2cdev_s *priv)
putreg32(I2C_CONSET_STA, priv->base + LPC11_I2C_CONSET_OFFSET);
wd_start(priv->timeout, I2C_TIMEOUT, lpc11_i2c_timeout, 1, (uint32_t)priv);
sem_wait(&priv->wait);
nxsem_wait(&priv->wait);
wd_cancel(priv->timeout);
@ -278,7 +278,7 @@ static int lpc11_i2c_transfer(FAR struct i2c_master_s *dev,
/* Get exclusive access to the I2C bus */
sem_wait(&priv->mutex);
nxsem_wait(&priv->mutex);
/* Set up for the transfer */

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc11xx/lpc11_spi.c
*
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2015-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -186,25 +186,31 @@ static struct lpc11_spidev_s g_spidev =
static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
{
FAR struct lpc11_spidev_s *priv = (FAR struct lpc11_spidev_s *)dev;
int ret;
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&priv->exclsem) != 0)
do
{
ret = nxsem_wait(&priv->exclsem);
/* The only case that an error should occur here is if the wait
* was awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&priv->exclsem);
ret = 0
}
return OK;
return ret;
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc11xx/lpc11_ssp.c
*
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2015-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -334,25 +334,31 @@ static inline void ssp_putreg(FAR struct lpc11_sspdev_s *priv,
static int ssp_lock(FAR struct spi_dev_s *dev, bool lock)
{
FAR struct lpc11_sspdev_s *priv = (FAR struct lpc11_sspdev_s *)dev;
int ret
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&priv->exclsem) != 0)
do
{
ret = nxsem_wait(&priv->exclsem);
/* The only case that an error should occur here is if the wait
* was awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&priv->exclsem);
ret = OK;
}
return OK;
return ret;
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc17xx/lpc17_gpdma.c
*
* Copyright (C) 2010, 2014, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2010, 2014, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -395,10 +395,10 @@ DMA_HANDLE lpc17_dmachannel(void)
do
{
ret = sem_wait(&g_gpdma.exclsem);
DEBUGASSERT(ret == 0 || errno == EINTR);
ret = nxsem_wait(&g_gpdma.exclsem);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret < 0);
while (ret == -EINTR);
/* Find an available DMA channel */

View file

@ -216,7 +216,7 @@ static int lpc17_i2c_start(struct lpc17_i2cdev_s *priv)
putreg32(I2C_CONSET_STA, priv->base + LPC17_I2C_CONSET_OFFSET);
wd_start(priv->timeout, I2C_TIMEOUT, lpc17_i2c_timeout, 1, (uint32_t)priv);
sem_wait(&priv->wait);
nxsem_wait(&priv->wait);
wd_cancel(priv->timeout);
@ -278,7 +278,7 @@ static int lpc17_i2c_transfer(FAR struct i2c_master_s *dev,
/* Get exclusive access to the I2C bus */
sem_wait(&priv->mutex);
nxsem_wait(&priv->mutex);
/* Set up for the transfer */

View file

@ -485,16 +485,21 @@ static struct lpc17_sampleregs_s g_sampleregs[DEBUG_NSAMPLES];
static void lpc17_takesem(struct lpc17_dev_s *priv)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&priv->waitsem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&priv->waitsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1,7 +1,8 @@
/****************************************************************************
* arch/arm/src/lpc17xx/lpc17_spi.c
*
* Copyright (C) 2010, 2012-2013, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2010, 2012-2013, 2016-2017 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -182,25 +183,31 @@ static struct lpc17_spidev_s g_spidev =
static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
{
FAR struct lpc17_spidev_s *priv = (FAR struct lpc17_spidev_s *)dev;
int ret;
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&priv->exclsem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
ret = nxsem_wait(&priv->exclsem);
/* The only case that an error should occur here is if the wait
* was awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&priv->exclsem);
ret = OK;
}
return OK;
return ret;
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc17xx/lpc17_ssp.c
*
* Copyright (C) 2010-2013, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2010-2013, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -330,25 +330,31 @@ static inline void ssp_putreg(FAR struct lpc17_sspdev_s *priv, uint8_t offset, u
static int ssp_lock(FAR struct spi_dev_s *dev, bool lock)
{
FAR struct lpc17_sspdev_s *priv = (FAR struct lpc17_sspdev_s *)dev;
int ret;
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&priv->exclsem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
ret = nxsem_wait(&priv->exclsem);
/* The only case that an error should occur here is if the wait
* was awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&priv->exclsem);
ret = OK;
}
return OK;
return ret;
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc17xx/lpc17_usbhost.c
*
* Copyright (C) 2010-2012, 2014-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2010-2012, 2014-2017 Gregory Nutt. All rights reserved.
* Authors: Rafael Noronha <rafael@pdsolucoes.com.br>
* Gregory Nutt <gnutt@nuttx.org>
*
@ -583,16 +583,21 @@ static void lpc17_putreg(uint32_t val, uint32_t addr)
static void lpc17_takesem(sem_t *sem)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(sem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -221,7 +221,7 @@ static int lpc2378_i2c_start(struct lpc2378_i2cdev_s *priv)
putreg32(I2C_CONSET_STA, priv->base + I2C_CONSET_OFFSET);
wd_start(priv->timeout, I2C_TIMEOUT, lpc2378_i2c_timeout, 1, (uint32_t)priv);
sem_wait(&priv->wait);
nxsem_wait(&priv->wait);
wd_cancel(priv->timeout);
@ -404,7 +404,7 @@ static int lpc2378_i2c_transfer(FAR struct i2c_master_s *dev,
/* Get exclusive access to the I2C bus */
sem_wait(&priv->mutex);
nxsem_wait(&priv->mutex);
/* Set up for the transfer */

View file

@ -6,7 +6,7 @@
*
* Derived from arch/arm/src/lpc17xx/lpc17_spi.c
*
* Copyright (C) 2010, 2012, 2014, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2010, 2012, 2014, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -189,26 +189,31 @@ static struct lpc23xx_spidev_s g_spidev =
static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
{
FAR struct lpc23xx_spidev_s *priv = (FAR struct lpc23xx_spidev_s *)dev;
int ret;
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&priv->exclsem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
ret = nxsem_wait(&priv->exclsem);
/* The only case that an error should occur here is if the wait
* was awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&priv->exclsem);
ret = OK;
}
return OK;
return ret;
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc31xx/lpc31_ehci.c
*
* Copyright (C) 2013-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2013-2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -1013,16 +1013,21 @@ static int ehci_wait_usbsts(uint32_t maskbits, uint32_t donebits,
static void lpc31_takesem(sem_t *sem)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(sem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -467,7 +467,7 @@ static int i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs
/* Get exclusive access to the I2C bus */
sem_wait(&priv->mutex);
nxsem_wait(&priv->mutex);
flags = enter_critical_section();
/* Set up for the transfer */
@ -496,7 +496,7 @@ static int i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs
while (priv->state != I2C_STATE_DONE)
{
sem_wait(&priv->wait);
nxsem_wait(&priv->wait);
}
wd_cancel(priv->timeout);

View file

@ -1,7 +1,7 @@
/************************************************************************************
* arm/arm/src/lpc31xx/lpc31_spi.c
*
* Copyright (C) 2009-2010, 2012, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2009-2010, 2012, 2016-2017 Gregory Nutt. All rights reserved.
* Author: David Hewson, deriving in part from other SPI drivers originally by
* Gregory Nutt <gnutt@nuttx.org>
*
@ -443,25 +443,31 @@ static inline void spi_writeword(FAR struct lpc31_spidev_s *priv, uint16_t word)
static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
{
FAR struct lpc31_spidev_s *priv = (FAR struct lpc31_spidev_s *)dev;
int ret;
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&priv->exclsem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
ret = nxsem_wait(&priv->exclsem);
/* The only case that an error should occur here is if the wait
* was awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&priv->exclsem);
ret = OK;
}
return OK;
return ret;
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc43xx/lpc43_ehci.c
*
* Copyright (C) 2013-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2013-2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -1004,16 +1004,21 @@ static int ehci_wait_usbsts(uint32_t maskbits, uint32_t donebits,
static void lpc43_takesem(sem_t *sem)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(sem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc43xx/lpc43_gpdma.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -396,8 +396,8 @@ DMA_HANDLE lpc43_dmachannel(void)
do
{
ret = sem_wait(&g_gpdma.exclsem);
DEBUGASSERT(ret == 0 || errno == EINTR);
ret = nxsem_wait(&g_gpdma.exclsem);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret < 0);

View file

@ -203,7 +203,7 @@ static int lpc43_i2c_start(struct lpc43_i2cdev_s *priv)
putreg32(I2C_CONSET_STA, priv->base + LPC43_I2C_CONSET_OFFSET);
wd_start(priv->timeout, I2C_TIMEOUT, lpc43_i2c_timeout, 1, (uint32_t)priv);
sem_wait(&priv->wait);
nxsem_wait(&priv->wait);
wd_cancel(priv->timeout);
return priv->nmsg;
@ -385,7 +385,7 @@ static int lpc43_i2c_transfer(FAR struct i2c_master_s *dev,
/* Get exclusive access to the I2C bus */
sem_wait(&priv->mutex);
nxsem_wait(&priv->mutex);
/* Set up for the transfer */

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc43xx/lpc43_spi.c
*
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2015-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -176,25 +176,31 @@ static struct lpc43_spidev_s g_spidev =
static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
{
FAR struct lpc43_spidev_s *priv = (FAR struct lpc43_spidev_s *)dev;
int ret;
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&priv->exclsem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
ret = nxsem_wait(&priv->exclsem);
/* The only case that an error should occur here is if the wait
* was awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&priv->exclsem);
ret = OK;
}
return OK;
return ret;
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc43xx/lpc43_ssp.c
*
* Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -272,26 +272,31 @@ static inline void ssp_putreg(FAR struct lpc43_sspdev_s *priv, uint8_t offset, u
static int ssp_lock(FAR struct spi_dev_s *dev, bool lock)
{
FAR struct lpc43_sspdev_s *priv = (FAR struct lpc43_sspdev_s *)dev;
int ret;
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&priv->exclsem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
ret = nxsem_wait(&priv->exclsem);
/* The only case that an error should occur here is if the wait
* was awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&priv->exclsem);
ret = OK;
}
return OK;
return ret;
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/sam34/sam_tc.c
*
* Copyright (C) 2013-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2013-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* References:
@ -360,16 +360,21 @@ static const uint8_t g_regoffset[TC_NREGISTERS] =
static void sam_takesem(struct sam_chan_s *chan)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&chan->exclsem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&chan->exclsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -88,7 +88,7 @@ static sem_t lock;
static void aes_lock(void)
{
sem_wait(&lock);
nxsem_wait(&lock);
}
static void aes_unlock(void)

View file

@ -1,7 +1,8 @@
/****************************************************************************
* arch/arm/src/sam34/sam_dmac.c
*
* Copyright (C) 2010, 2013-2014, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2010, 2013-2014, 2016-2017 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -274,16 +275,21 @@ static struct sam_dma_s g_dma[SAM34_NDMACHAN] =
static void sam_takechsem(void)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&g_chsem) != 0)
do
{
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&g_chsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
static inline void sam_givechsem(void)
@ -301,16 +307,21 @@ static inline void sam_givechsem(void)
static void sam_takedsem(void)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&g_dsem) != 0)
do
{
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&g_dsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
static inline void sam_givedsem(void)

View file

@ -591,16 +591,21 @@ static bool g_cmdinitialized;
static void sam_takesem(struct sam_dev_s *priv)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&priv->waitsem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&priv->waitsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1,7 +1,8 @@
/****************************************************************************
* arch/arm/src/sam34/sam_spi.c
*
* Copyright (C) 2011, 2013-2014, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2013-2014, 2016-2017 Gregory Nutt. All rights
* reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
* Diego Sanchez <dsanchez@nx-engineering.com>
*
@ -876,27 +877,34 @@ static int spi_lock(struct spi_dev_s *dev, bool lock)
{
struct sam_spics_s *spics = (struct sam_spics_s *)dev;
struct sam_spidev_s *spi = spi_device(spics);
int ret;
spiinfo("lock=%d\n", lock);
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&spi->spisem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&spi->spisem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&spi->spisem);
ret = OK;
}
return OK;
return ret;
}
/****************************************************************************
@ -1589,26 +1597,20 @@ static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer,
/* Wait for the DMA complete */
ret = sem_wait(&spics->dmawait);
ret = nxsem_wait(&spics->dmawait);
/* Cancel the watchdog timeout */
(void)wd_cancel(spics->dmadog);
/* Check if we were awakened by an error of some kind */
/* Check if we were awakened by an error of some kind. EINTR is not a
* failure. It simply means that the wait was awakened by a signal.
*/
if (ret < 0)
if (ret < 0 && ret != -EINTR)
{
/* EINTR is not a failure. That simply means that the wait
* was awakened by a signal.
*/
int errorcode = errno;
if (errorcode != EINTR)
{
DEBUGPANIC();
return;
}
DEBUGPANIC();
return;
}
/* Not that we might be awakened before the wait is over due to

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/sam34/sam_twi.c
*
* Copyright (C) 2013, 2015-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2015-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* References:
@ -225,16 +225,21 @@ static const struct i2c_ops_s g_twiops =
static void twi_takesem(sem_t *sem)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(sem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -2152,15 +2152,15 @@ void sam_adc_lock(FAR struct sam_adc_s *priv)
do
{
ret = sem_wait(&priv->exclsem);
ret = nxsem_wait(&priv->exclsem);
/* This should only fail if the wait was canceled by an signal
* (and the worker thread will receive a lot of signals).
*/
DEBUGASSERT(ret == OK || errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret < 0);
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/sama5/sam_can.c
*
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2013-2014, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* References:
@ -567,10 +567,10 @@ static void can_semtake(FAR struct sam_can_s *priv)
do
{
ret = sem_wait(&priv->exclsem);
DEBUGASSERT(ret == 0 || errno == EINTR);
ret = nxsem_wait(&priv->exclsem);
DEBUGASSERT(ret == 0 || ret == -EINTR);
}
while (ret < 0);
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/sama5/sam3u_dmac.c
*
* Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -487,16 +487,21 @@ static struct sam_dmac_s g_dmac1 =
static void sam_takechsem(struct sam_dmac_s *dmac)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&dmac->chsem) != 0)
do
{
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&dmac->chsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
static inline void sam_givechsem(struct sam_dmac_s *dmac)
@ -514,16 +519,21 @@ static inline void sam_givechsem(struct sam_dmac_s *dmac)
static void sam_takedsem(struct sam_dmac_s *dmac)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&dmac->dsem) != 0)
do
{
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&dmac->dsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
static inline void sam_givedsem(struct sam_dmac_s *dmac)

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/sama5/sam_ehci.c
*
* Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2016-2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -815,16 +815,21 @@ static int ehci_wait_usbsts(uint32_t maskbits, uint32_t donebits,
static void sam_takesem(sem_t *sem)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(sem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -678,16 +678,21 @@ static struct sam_dev_s g_hsmci2;
static void sam_takesem(struct sam_dev_s *priv)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&priv->waitsem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&priv->waitsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/sama5/sam_nand.c
*
* Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* References:
@ -318,10 +318,10 @@ void nand_lock(void)
do
{
ret = sem_wait(&g_nand.exclsem);
DEBUGASSERT(ret == OK || errno == EINTR);
ret = nxsem_wait(&g_nand.exclsem);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret != OK);
while (ret == -EINTR);
}
#endif
@ -689,11 +689,8 @@ static void nand_wait_cmddone(struct sam_nandcs_s *priv)
flags = enter_critical_section();
do
{
ret = sem_wait(&g_nand.waitsem);
if (ret < 0)
{
DEBUGASSERT(errno == EINTR);
}
ret = nxsem_wait(&g_nand.waitsem);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (!g_nand.cmddone);
@ -780,11 +777,8 @@ static void nand_wait_xfrdone(struct sam_nandcs_s *priv)
flags = enter_critical_section();
do
{
ret = sem_wait(&g_nand.waitsem);
if (ret < 0)
{
DEBUGASSERT(errno == EINTR);
}
ret = nxsem_wait(&g_nand.waitsem);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (!g_nand.xfrdone);
@ -871,11 +865,8 @@ static void nand_wait_rbedge(struct sam_nandcs_s *priv)
flags = enter_critical_section();
do
{
ret = sem_wait(&g_nand.waitsem);
if (ret < 0)
{
DEBUGASSERT(errno == EINTR);
}
ret = nxsem_wait(&g_nand.waitsem);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (!g_nand.rbedge);
@ -1227,11 +1218,8 @@ static int nand_wait_dma(struct sam_nandcs_s *priv)
while (!priv->dmadone)
{
ret = sem_wait(&priv->waitsem);
if (ret < 0)
{
DEBUGASSERT(errno == EINTR);
}
ret = nxsem_wait(&priv->waitsem);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
finfo("Awakened: result=%d\n", priv->result);

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/sama5/sam_ohci.c
*
* Copyright (C) 2013, 2015-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2015-2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -643,16 +643,21 @@ static void sam_putreg(uint32_t val, uint32_t addr)
static void sam_takesem(sem_t *sem)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(sem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/sama5/sam_pmecc.c
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* References:
@ -1240,10 +1240,10 @@ void pmecc_lock(void)
do
{
ret = sem_wait(&g_pmecc.exclsem);
DEBUGASSERT(ret == OK || errno == EINTR);
ret = nxsem_wait(&g_pmecc.exclsem);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret != OK);
while (ret == -EINTR);
}
#endif

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/sama5/sam_spi.c
*
* Copyright (C) 2013-2014, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2013-2014, 2016-2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
*
* This derives from SAM3/4 SPI driver:
@ -865,27 +865,34 @@ static int spi_lock(struct spi_dev_s *dev, bool lock)
{
struct sam_spics_s *spics = (struct sam_spics_s *)dev;
struct sam_spidev_s *spi = spi_device(spics);
int ret;
spiinfo("lock=%d\n", lock);
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&spi->spisem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&spi->spisem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&spi->spisem);
ret = OK;
}
return OK;
return ret;
}
/****************************************************************************
@ -1520,26 +1527,20 @@ static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer,
/* Wait for the DMA complete */
ret = sem_wait(&spics->dmawait);
ret = nxsem_wait(&spics->dmawait);
/* Cancel the watchdog timeout */
(void)wd_cancel(spics->dmadog);
/* Check if we were awakened by an error of some kind */
/* Check if we were awakened by an error of some kind. EINTR is not a
* failure. It simply means that the wait was awakened by a signal.
*/
if (ret < 0)
if (ret < 0 && ret != -EINTR)
{
/* EINTR is not a failure. That simply means that the wait
* was awakened by a signel.
*/
int errorcode = errno;
if (errorcode != EINTR)
{
DEBUGPANIC();
return;
}
DEBUGPANIC();
return;
}
/* Not that we might be awkened before the wait is over due to

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/sama5/sam_ssc.c
*
* Copyright (C) 2013-2014, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2013-2014, 2016-2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -898,10 +898,10 @@ static void ssc_exclsem_take(struct sam_ssc_s *priv)
do
{
ret = sem_wait(&priv->exclsem);
DEBUGASSERT(ret == 0 || errno == EINTR);
ret = nxsem_wait(&priv->exclsem);
DEBUGASSERT(ret == 0 || ret == -EINTR);
}
while (ret < 0);
while (ret == -EINTR);
}
/****************************************************************************
@ -929,10 +929,10 @@ static void ssc_bufsem_take(struct sam_ssc_s *priv)
do
{
ret = sem_wait(&priv->bufsem);
DEBUGASSERT(ret == 0 || errno == EINTR);
ret = nxsem_wait(&priv->bufsem);
DEBUGASSERT(ret == 0 || ret == -EINTR);
}
while (ret < 0);
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/sama5/sam_tc.c
*
* Copyright (C) 2013-2014, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2013-2014, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* References:
@ -471,16 +471,21 @@ static const uint8_t g_regoffset[TC_NREGISTERS] =
static void sam_takesem(struct sam_tc_s *tc)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&tc->exclsem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&tc->exclsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/sama5/sam_trng.c
*
* Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Derives, in part, from Max Holtzberg's STM32 RNG Nuttx driver:
@ -253,11 +253,12 @@ static ssize_t sam_read(struct file *filep, char *buffer, size_t buflen)
/* Get exclusive access to the TRNG harware */
if (sem_wait(&g_trngdev.exclsem) != OK)
ret = nxsem_wait(&g_trngdev.exclsem);
if (ret < 0)
{
/* This is probably -EINTR meaning that we were awakened by a signal */
return -errno;
return ret;
}
/* Save the buffer information. */
@ -287,7 +288,7 @@ static ssize_t sam_read(struct file *filep, char *buffer, size_t buflen)
while (g_trngdev.nsamples < g_trngdev.maxsamples)
{
ret = sem_wait(&g_trngdev.waitsem);
ret = nxsem_wait(&g_trngdev.waitsem);
finfo("Awakened: nsamples=%d maxsamples=%d ret=%d\n",
g_trngdev.nsamples, g_trngdev.maxsamples, ret);
@ -302,7 +303,7 @@ static ssize_t sam_read(struct file *filep, char *buffer, size_t buflen)
}
else
{
retval = -errno;
retval = ret;
goto errout;
}
}

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/sama5/sam_tsd.c
*
* Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2016-2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
*
* References:
@ -383,7 +383,7 @@ static int sam_tsd_waitsample(struct sam_tsd_s *priv, struct sam_sample_s *sampl
iinfo("Waiting..\n");
priv->nwaiters++;
ret = sem_wait(&priv->waitsem);
ret = nxsem_wait(&priv->waitsem);
priv->nwaiters--;
if (ret < 0)
@ -392,9 +392,8 @@ static int sam_tsd_waitsample(struct sam_tsd_s *priv, struct sam_sample_s *sampl
* the failure now.
*/
ierr("ERROR: sem_wait: %d\n", errno);
DEBUGASSERT(errno == EINTR);
ret = -EINTR;
ierr("ERROR: nxsem_wait: %d\n", ret);
DEBUGASSERT(ret == -EINTR);
goto errout;
}
}

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/sama5/sam_twi.c
*
* Copyright (C) 2013-2014, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2013-2014, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* References:
@ -309,16 +309,21 @@ static const struct i2c_ops_s g_twiops =
static void twi_takesem(sem_t *sem)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(sem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/sama5/sam_xdmac.c
*
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2014, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -645,16 +645,21 @@ static struct sam_xdmac_s g_xdmac1 =
static void sam_takechsem(struct sam_xdmac_s *xdmac)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&xdmac->chsem) != 0)
do
{
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&xdmac->chsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
static inline void sam_givechsem(struct sam_xdmac_s *xdmac)
@ -672,16 +677,21 @@ static inline void sam_givechsem(struct sam_xdmac_s *xdmac)
static void sam_takedsem(struct sam_xdmac_s *xdmac)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&xdmac->dsem) != 0)
do
{
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&xdmac->dsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
static inline void sam_givedsem(struct sam_xdmac_s *xdmac)

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/samdl/sam_dmac.c
*
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2015-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -178,16 +178,21 @@ static struct dma_desc_s g_dma_desc[CONFIG_SAMDL_DMAC_NDESC]
static void sam_takechsem(void)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&g_chsem) != 0)
do
{
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&g_chsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
static inline void sam_givechsem(void)
@ -206,16 +211,21 @@ static inline void sam_givechsem(void)
#if CONFIG_SAMDL_DMAC_NDESC > 0
static void sam_takedsem(void)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&g_dsem) != 0)
do
{
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&g_dsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
static inline void sam_givedsem(void)

View file

@ -1,7 +1,7 @@
/*******************************************************************************
* arch/arm/src/samdl/sam_i2c_master.c
*
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2013-2014, 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Filament - www.filament.com
* Author: Matt Thompson <mthompson@hexwave.com>
* Author: Alan Carvalho de Assis <acassis@gmail.com>
@ -460,18 +460,23 @@ static void i2c_putreg32(struct sam_i2c_dev_s *priv, uint32_t regval,
*
*******************************************************************************/
static void i2c_takesem(sem_t * sem)
static void i2c_takesem(sem_t *sem)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(sem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/*******************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/samdl/sam_spi.c
*
* Copyright (C) 2014-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
*
* References:
@ -780,27 +780,32 @@ static int spi_interrupt(int irq, void *context, FAR void *arg)
static int spi_lock(struct spi_dev_s *dev, bool lock)
{
struct sam_spidev_s *priv = (struct sam_spidev_s *)dev;
int ret;
spiinfo("lock=%d\n", lock);
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&priv->spilock) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
ret = nxsem_wait(&priv->spilock);
/* The only case that an error should occur here is if the wait
* was awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&priv->spilock);
ret = OK;
}
return OK;
return ret;
}
/****************************************************************************

View file

@ -610,16 +610,21 @@ static struct sam_dev_s g_hsmci1;
static void sam_takesem(struct sam_dev_s *priv)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&priv->waitsem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&priv->waitsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/samv7/sam_mcan.c
*
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2015-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* References:
@ -1381,10 +1381,10 @@ static void mcan_dev_lock(FAR struct sam_mcan_s *priv)
do
{
ret = sem_wait(&priv->locksem);
DEBUGASSERT(ret == 0 || errno == EINTR);
ret = nxsem_wait(&priv->locksem);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret < 0);
while (ret == -EINTR);
}
/****************************************************************************
@ -1548,9 +1548,9 @@ static void mcan_buffer_reserve(FAR struct sam_mcan_s *priv)
/* The semaphore value is reasonable. Wait for the next TC interrupt. */
ret = sem_wait(&priv->txfsem);
ret = nxsem_wait(&priv->txfsem);
leave_critical_section(flags);
DEBUGASSERT(ret == 0 || errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret < 0);
}

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/samv7/sam_progmem.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -186,18 +186,21 @@ static sem_t g_page_sem;
static void page_buffer_lock(void)
{
while (sem_wait(&g_page_sem) < 0)
int ret;
do
{
int errcode = errno;
/* Take the semaphore (perhaps waiting) */
/* sem_wait should only fail if it was awakened by a signal */
ret = nxsem_wait(&g_page_sem);
DEBUGASSERT(errcode == EINTR);
if (errcode != EINTR)
{
break;
}
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
#define page_buffer_unlock() nxsem_post(&g_page_sem)

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/samv7/sam_qspi.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -892,26 +892,20 @@ static int qspi_memory_dma(struct sam_qspidev_s *priv,
/* Wait for the DMA complete */
ret = sem_wait(&priv->dmawait);
ret = nxsem_wait(&priv->dmawait);
/* Cancel the watchdog timeout */
(void)wd_cancel(priv->dmadog);
/* Check if we were awakened by an error of some kind */
/* Check if we were awakened by an error of some kind. EINTR is not a
* failure. That simply means that the wait was awakened by a signal.
*/
if (ret < 0)
if (ret < 0 && ret != -EINTR)
{
/* EINTR is not a failure. That simply means that the wait
* was awakened by a signal.
*/
int errorcode = errno;
if (errorcode != EINTR)
{
DEBUGPANIC();
return -errorcode;
}
DEBUGPANIC();
return ret;
}
/* Not that we might be awakened before the wait is over due to
@ -1061,27 +1055,32 @@ static void qspi_memcpy(uint8_t *dest, const uint8_t *src, size_t buflen)
static int qspi_lock(struct qspi_dev_s *dev, bool lock)
{
struct sam_qspidev_s *priv = (struct sam_qspidev_s *)dev;
int ret;
spiinfo("lock=%d\n", lock);
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&priv->exclsem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
ret = nxsem_wait(&priv->exclsem);
/* The only case that an error should occur here is if the wait
* was awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&priv->exclsem);
ret = OK;
}
return OK;
return ret;
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/samv7/sam_spi.c
*
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2015-2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
* Diego Sanchez <dsanchez@nx-engineering.com>
*
@ -903,27 +903,34 @@ static int spi_lock(struct spi_dev_s *dev, bool lock)
{
struct sam_spics_s *spics = (struct sam_spics_s *)dev;
struct sam_spidev_s *spi = spi_device(spics);
int ret;
spiinfo("lock=%d\n", lock);
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&spi->spisem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&spi->spisem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&spi->spisem);
ret = OK;
}
return OK;
return ret;
}
/****************************************************************************
@ -1864,26 +1871,20 @@ static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer,
/* Wait for the DMA complete */
ret = sem_wait(&spics->dmawait);
ret = nxsem_wait(&spics->dmawait);
/* Cancel the watchdog timeout */
(void)wd_cancel(spics->dmadog);
/* Check if we were awakened by an error of some kind */
/* Check if we were awakened by an error of some kind. EINTR is not a
* failure. It simply means that the wait was awakened by a signal.
*/
if (ret < 0)
if (ret < 0 && ret != -EINTR)
{
/* EINTR is not a failure. That simply means that the wait
* was awakened by a signal.
*/
int errorcode = errno;
if (errorcode != EINTR)
{
DEBUGPANIC();
return;
}
DEBUGPANIC();
return;
}
/* Not that we might be awakened before the wait is over due to

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/samv7/sam_spi_slave.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -369,10 +369,10 @@ static void spi_semtake(struct sam_spidev_s *priv)
do
{
ret = sem_wait(&priv->spisem);
DEBUGASSERT(ret == 0 || errno == EINTR);
ret = nxsem_wait(&priv->spisem);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret < 0);
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/samv7/sam_ssc.c
*
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2015-2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -872,10 +872,10 @@ static void ssc_exclsem_take(struct sam_ssc_s *priv)
do
{
ret = sem_wait(&priv->exclsem);
DEBUGASSERT(ret == 0 || errno == EINTR);
ret = nxsem_wait(&priv->exclsem);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret < 0);
while (ret == -EINTR);
}
/****************************************************************************
@ -903,10 +903,10 @@ static void ssc_bufsem_take(struct sam_ssc_s *priv)
do
{
ret = sem_wait(&priv->bufsem);
DEBUGASSERT(ret == 0 || errno == EINTR);
ret = nxsem_wait(&priv->bufsem);
DEBUGASSERT(ret == 0 || ret == -EINTR);
}
while (ret < 0);
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/SAMV7/sam_tc.c
*
* Copyright (C) 2015=2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2015-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* References:
@ -610,16 +610,21 @@ static const uint8_t g_regoffset[TC_NREGISTERS] =
static void sam_takesem(struct sam_tc_s *tc)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&tc->exclsem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&tc->exclsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -254,11 +254,12 @@ static ssize_t sam_read(struct file *filep, char *buffer, size_t buflen)
/* Get exclusive access to the TRNG harware */
if (sem_wait(&g_trngdev.exclsem) != OK)
ret = nxsem_wait(&g_trngdev.exclsem);
if (ret < 0)
{
/* This is probably -EINTR meaning that we were awakened by a signal */
return -errno;
return ret;
}
/* Save the buffer information. */
@ -288,7 +289,7 @@ static ssize_t sam_read(struct file *filep, char *buffer, size_t buflen)
while (g_trngdev.nsamples < g_trngdev.maxsamples)
{
ret = sem_wait(&g_trngdev.waitsem);
ret = nxsem_wait(&g_trngdev.waitsem);
finfo("Awakened: nsamples=%d maxsamples=%d ret=%d\n",
g_trngdev.nsamples, g_trngdev.maxsamples, ret);
@ -303,7 +304,7 @@ static ssize_t sam_read(struct file *filep, char *buffer, size_t buflen)
}
else
{
retval = -errno;
retval = ret;
goto errout;
}
}

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/samv7/sam_twihs.c
*
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2015-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* This driver derives from the SAMA5Dx TWIHS driver. References:
@ -313,16 +313,21 @@ static const struct i2c_ops_s g_twiops =
static void twi_takesem(sem_t *sem)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(sem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/samv7/sam_xdmac.c
*
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2015-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -370,16 +370,21 @@ static struct sam_xdmac_s g_xdmac;
static void sam_takechsem(struct sam_xdmac_s *xdmac)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&xdmac->chsem) != 0)
do
{
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&xdmac->chsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
static inline void sam_givechsem(struct sam_xdmac_s *xdmac)
@ -397,16 +402,21 @@ static inline void sam_givechsem(struct sam_xdmac_s *xdmac)
static void sam_takedsem(struct sam_xdmac_s *xdmac)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&xdmac->dsem) != 0)
do
{
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&xdmac->dsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
static inline void sam_givedsem(struct sam_xdmac_s *xdmac)

View file

@ -742,10 +742,21 @@ static inline void stm32_1wire_sem_destroy(FAR struct stm32_1wire_priv_s *priv)
static inline void stm32_1wire_sem_wait(FAR struct stm32_1wire_priv_s *priv)
{
while (sem_wait(&priv->sem_excl) != 0)
int ret;
do
{
ASSERT(errno == EINTR);
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&priv->sem_excl);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -234,7 +234,7 @@ int aes_cypher(void *out, const void *in, uint32_t size, const void *iv,
return -EINVAL;
}
ret = sem_wait(&aes_lock);
ret = nxsem_wait(&aes_lock);
if (ret < 0)
{
return ret;

View file

@ -233,10 +233,10 @@ static void stm32_bbsram_semtake(FAR struct stm32_bbsram_s *priv)
do
{
ret = sem_wait(&priv->exclsem);
DEBUGASSERT(ret == 0 || errno == EINTR);
ret = nxsem_wait(&priv->exclsem);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret < 0);
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -506,15 +506,15 @@ static int stm32_dma2d_waitforirq(void)
priv->wait = true;
ret = sem_wait(priv->sem);
ret = nxsem_wait(priv->sem);
/* irq or an error occurs, reset the wait flag */
priv->wait = false;
if (ret != OK)
if (ret < 0)
{
lcderr("ERROR: sem_wait() failed\n");
lcderr("ERROR: nxsem_wait() failed\n");
return ret;
}
}
@ -1178,7 +1178,7 @@ static int stm32_dma2dgetvideoinfo(FAR struct dma2d_layer_s *layer,
if (stm32_dma2d_lvalidate(priv) && vinfo)
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
memcpy(vinfo, &priv->vinfo, sizeof(struct fb_videoinfo_s));
nxsem_post(priv->lock);
@ -1215,7 +1215,7 @@ static int stm32_dma2dgetplaneinfo(FAR struct dma2d_layer_s *layer, int planeno,
if (stm32_dma2d_lvalidate(priv) && pinfo && planeno == 0)
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
memcpy(pinfo, &priv->pinfo, sizeof(struct fb_planeinfo_s));
nxsem_post(priv->lock);
@ -1250,7 +1250,7 @@ static int stm32_dma2dgetlid(FAR struct dma2d_layer_s *layer, int *lid)
if (stm32_dma2d_lvalidate(priv) && lid)
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
*lid = priv->lid;
nxsem_post(priv->lock);
return OK;
@ -1288,7 +1288,7 @@ static int stm32_dma2dsetclut(FAR struct dma2d_layer_s *layer,
if (stm32_dma2d_lvalidate(priv) && cmap)
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
#ifdef CONFIG_STM32_LTDC_INTERFACE
if (priv->lid < DMA2D_SHADOW_LAYER)
@ -1407,7 +1407,7 @@ static int stm32_dma2dgetclut(FAR struct dma2d_layer_s *layer,
if (stm32_dma2d_lvalidate(priv) && cmap)
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
if (priv->fmt != DMA2D_PF_L8)
{
@ -1497,7 +1497,7 @@ static int stm32_dma2dsetalpha(FAR struct dma2d_layer_s *layer, uint8_t alpha)
if (stm32_dma2d_lvalidate(priv))
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
priv->alpha = alpha;
nxsem_post(priv->lock);
@ -1532,7 +1532,7 @@ static int stm32_dma2dgetalpha(FAR struct dma2d_layer_s *layer, uint8_t *alpha)
if (stm32_dma2d_lvalidate(priv))
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
*alpha = priv->alpha;
nxsem_post(priv->lock);
@ -1583,7 +1583,7 @@ static int stm32_dma2dsetblendmode(FAR struct dma2d_layer_s *layer,
if (stm32_dma2d_lvalidate(priv))
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
priv->blendmode = mode;
nxsem_post(priv->lock);
@ -1619,7 +1619,7 @@ static int stm32_dma2dgetblendmode(FAR struct dma2d_layer_s *layer,
if (stm32_dma2d_lvalidate(priv) && mode)
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
*mode = priv->blendmode;
nxsem_post(priv->lock);
@ -1670,7 +1670,7 @@ static int stm32_dma2dblit(FAR struct dma2d_layer_s *dest,
stm32_dma2d_lvalidatesize(srclayer, srcarea->xpos,
srcarea->ypos, srcarea))
{
sem_wait(destlayer->lock);
nxsem_wait(destlayer->lock);
/* Set output pfc */
@ -1784,8 +1784,7 @@ static int stm32_dma2dblend(FAR struct dma2d_layer_s *dest,
stm32_dma2d_lvalidatesize(backlayer, backarea->xpos,
backarea->ypos, backarea))
{
sem_wait(destlayer->lock);
nxsem_wait(destlayer->lock);
/* Set output pfc */
@ -1880,8 +1879,7 @@ static int stm32_dma2dfillarea(FAR struct dma2d_layer_s *layer,
if (stm32_dma2d_lvalidatesize(priv, area->xpos, area->ypos, area))
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
/* Set output pfc */
@ -1949,7 +1947,7 @@ FAR struct dma2d_layer_s *up_dma2dgetlayer(int lid)
if (lid < DMA2D_LAYER_NSIZE)
{
FAR struct stm32_dma2d_s *priv;
sem_wait(&g_lock);
nxsem_wait(&g_lock);
priv = g_layers[lid];
nxsem_post(&g_lock);
@ -2000,7 +1998,7 @@ FAR struct dma2d_layer_s *up_dma2dcreatelayer(fb_coord_t width,
ret = stm32_dma2d_bpp(fmt, &bpp);
sem_wait(&g_lock);
nxsem_wait(&g_lock);
/* Get a free layer identifier */
@ -2108,7 +2106,7 @@ int up_dma2dremovelayer(FAR struct dma2d_layer_s *layer)
if (stm32_dma2d_lvalidate(priv) && priv->lid >= DMA2D_SHADOW_LAYER)
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
/* Check also if the layer id is valid to the layer reference */

View file

@ -108,10 +108,21 @@ static sem_t g_sem = SEM_INITIALIZER(1);
static void sem_lock(void)
{
while (sem_wait(&g_sem) < 0)
int ret;
do
{
DEBUGASSERT(errno == EINTR);
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&g_sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
static inline void sem_unlock(void)

View file

@ -505,10 +505,21 @@ static inline void stm32_i2c_modifyreg(FAR struct stm32_i2c_priv_s *priv,
static inline void stm32_i2c_sem_wait(FAR struct stm32_i2c_priv_s *priv)
{
while (sem_wait(&priv->sem_excl) != 0)
int ret;
do
{
ASSERT(errno == EINTR);
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&priv->sem_excl);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/************************************************************************************

View file

@ -513,10 +513,21 @@ static inline void stm32_i2c_modifyreg(FAR struct stm32_i2c_priv_s *priv,
static inline void stm32_i2c_sem_wait(FAR struct stm32_i2c_priv_s *priv)
{
while (sem_wait(&priv->sem_excl) != 0)
int ret;
do
{
ASSERT(errno == EINTR);
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&priv->sem_excl);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/************************************************************************************

View file

@ -634,10 +634,10 @@ static void i2s_exclsem_take(struct stm32_i2s_s *priv)
do
{
ret = sem_wait(&priv->exclsem);
DEBUGASSERT(ret == 0 || errno == EINTR);
ret = nxsem_wait(&priv->exclsem);
DEBUGASSERT(ret == 0 || ret == -EINTR);
}
while (ret < 0);
while (ret == -EINTR);
}
/****************************************************************************
@ -665,10 +665,10 @@ static void i2s_bufsem_take(struct stm32_i2s_s *priv)
do
{
ret = sem_wait(&priv->bufsem);
DEBUGASSERT(ret == 0 || errno == EINTR);
ret = nxsem_wait(&priv->bufsem);
DEBUGASSERT(ret == 0 || ret == -EINTR);
}
while (ret < 0);
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1194,15 +1194,15 @@ static int stm32_ltdc_waitforirq(void)
priv->wait = true;
ret = sem_wait(priv->sem);
ret = nxsem_wait(priv->sem);
/* irq or an error occurs, reset the wait flag */
priv->wait = false;
if (ret != OK)
if (ret < 0)
{
lcderr("ERROR: sem_wait() failed\n");
lcderr("ERROR: nxsem_wait() failed\n");
}
}
@ -2395,7 +2395,7 @@ static int stm32_setclut(struct ltdc_layer_s *layer,
if (stm32_ltdc_lvalidate(priv) && cmap)
{
sem_wait(priv->state.lock);
nxsem_wait(priv->state.lock);
if (priv->state.vinfo.fmt != FB_FMT_RGB8)
{
@ -2454,7 +2454,7 @@ static int stm32_getclut(struct ltdc_layer_s *layer,
if (priv == &LAYER_L1 || priv == &LAYER_L2)
{
sem_wait(priv->state.lock);
nxsem_wait(priv->state.lock);
#ifdef CONFIG_STM32_DMA2D
/* Note! We share the same color lookup table with the dma2d driver and
* the getclut implementation works in the same way.
@ -2554,7 +2554,7 @@ static int stm32_getlid(FAR struct ltdc_layer_s *layer, int *lid,
{
int ret = OK;
sem_wait(priv->state.lock);
nxsem_wait(priv->state.lock);
switch (flag)
{
@ -2628,7 +2628,7 @@ static int stm32_setcolor(FAR struct ltdc_layer_s *layer, uint32_t argb)
if (stm32_ltdc_lvalidate(priv))
{
sem_wait(priv->state.lock);
nxsem_wait(priv->state.lock);
priv->state.color = argb;
priv->operation |= LTDC_LAYER_SETCOLOR;
nxsem_post(priv->state.lock);
@ -2664,7 +2664,7 @@ static int stm32_getcolor(FAR struct ltdc_layer_s *layer, uint32_t *argb)
if (stm32_ltdc_lvalidate(priv))
{
sem_wait(priv->state.lock);
nxsem_wait(priv->state.lock);
*argb = priv->state.color;
nxsem_post(priv->state.lock);
@ -2701,7 +2701,7 @@ static int stm32_setcolorkey(FAR struct ltdc_layer_s *layer, uint32_t rgb)
if (stm32_ltdc_lvalidate(priv))
{
sem_wait(priv->state.lock);
nxsem_wait(priv->state.lock);
priv->state.colorkey = rgb;
priv->operation |= LTDC_LAYER_SETCOLORKEY;
nxsem_post(priv->state.lock);
@ -2737,7 +2737,7 @@ static int stm32_getcolorkey(FAR struct ltdc_layer_s *layer, uint32_t *rgb)
if (stm32_ltdc_lvalidate(priv))
{
sem_wait(priv->state.lock);
nxsem_wait(priv->state.lock);
*rgb = priv->state.colorkey;
nxsem_post(priv->state.lock);
@ -2778,7 +2778,7 @@ static int stm32_setalpha(FAR struct ltdc_layer_s *layer, uint8_t alpha)
if (stm32_ltdc_lvalidate(priv))
{
sem_wait(priv->state.lock);
nxsem_wait(priv->state.lock);
priv->state.alpha = alpha;
priv->operation |= LTDC_LAYER_SETALPHAVALUE;
nxsem_post(priv->state.lock);
@ -2814,7 +2814,7 @@ static int stm32_getalpha(FAR struct ltdc_layer_s *layer, uint8_t *alpha)
if (stm32_ltdc_lvalidate(priv))
{
sem_wait(priv->state.lock);
nxsem_wait(priv->state.lock);
*alpha = priv->state.alpha;
nxsem_post(priv->state.lock);
@ -2876,7 +2876,7 @@ static int stm32_setblendmode(FAR struct ltdc_layer_s *layer, uint32_t mode)
{
int ret = OK;
sem_wait(priv->state.lock);
nxsem_wait(priv->state.lock);
/* Disable colorkeying by default */
@ -2982,7 +2982,7 @@ static int stm32_getblendmode(FAR struct ltdc_layer_s *layer, uint32_t *mode)
if (stm32_ltdc_lvalidate(priv))
{
sem_wait(priv->state.lock);
nxsem_wait(priv->state.lock);
*mode = priv->state.blendmode;
nxsem_post(priv->state.lock);
@ -3033,7 +3033,7 @@ static int stm32_setarea(FAR struct ltdc_layer_s *layer,
{
int ret;
sem_wait(priv->state.lock);
nxsem_wait(priv->state.lock);
ret = stm32_ltdc_lvalidatearea(priv, area->xpos, area->ypos, area->xres,
area->yres, srcxpos, srcypos);
@ -3087,7 +3087,7 @@ static int stm32_getarea(FAR struct ltdc_layer_s *layer,
if (stm32_ltdc_lvalidate(priv))
{
sem_wait(priv->state.lock);
nxsem_wait(priv->state.lock);
*srcxpos = priv->state.xpos;
*srcypos = priv->state.ypos;
memcpy(area, &priv->state.area, sizeof(struct ltdc_area_s));
@ -3156,7 +3156,7 @@ static int stm32_update(FAR struct ltdc_layer_s *layer, uint32_t mode)
bool waitvblank = false;
uint8_t reload = LTDC_SRCR_IMR;
sem_wait(priv->state.lock);
nxsem_wait(priv->state.lock);
if (mode & LTDC_SYNC_VBLANK)
{
@ -3295,7 +3295,7 @@ static int stm32_blit(FAR struct ltdc_layer_s *dest,
{
int ret;
sem_wait(priv->state.lock);
nxsem_wait(priv->state.lock);
priv->dma2d->blit(priv->dma2d, destxpos, destypos, src, srcarea);
nxsem_post(priv->state.lock);
@ -3350,7 +3350,7 @@ static int stm32_blend(FAR struct ltdc_layer_s *dest,
{
int ret;
sem_wait(priv->state.lock);
nxsem_wait(priv->state.lock);
priv->dma2d->blend(priv->dma2d, destxpos, destypos,
fore, forexpos, foreypos, back, backarea);
nxsem_post(priv->state.lock);
@ -3393,7 +3393,7 @@ static int stm32_fillarea(FAR struct ltdc_layer_s *layer,
{
int ret;
sem_wait(priv->state.lock);
nxsem_wait(priv->state.lock);
priv->dma2d->fillarea(priv->dma2d, area, color);
nxsem_post(priv->state.lock);

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32_otgfshost.c
*
* Copyright (C) 2012-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2012-2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -643,16 +643,21 @@ static inline void stm32_modifyreg(uint32_t addr, uint32_t clrbits, uint32_t set
static void stm32_takesem(sem_t *sem)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(sem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************
@ -1104,13 +1109,13 @@ static int stm32_chan_wait(FAR struct stm32_usbhost_s *priv,
* wait here.
*/
ret = sem_wait(&chan->waitsem);
ret = nxsem_wait(&chan->waitsem);
/* sem_wait should succeed. But it is possible that we could be
/* nxsem_wait should succeed. But it is possible that we could be
* awakened by a signal too.
*/
DEBUGASSERT(ret == OK || get_errno() == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (chan->waiter);

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32_otghshost.c
*
* Copyright (C) 2012-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2012-2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -648,16 +648,21 @@ static inline void stm32_modifyreg(uint32_t addr, uint32_t clrbits, uint32_t set
static void stm32_takesem(sem_t *sem)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(sem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************
@ -1109,9 +1114,9 @@ static int stm32_chan_wait(FAR struct stm32_usbhost_s *priv,
* wait here.
*/
ret = sem_wait(&chan->waitsem);
ret = nxsem_wait(&chan->waitsem);
/* sem_wait should succeed. But it is possible that we could be
/* nxsem_wait should succeed. But it is possible that we could be
* awakened by a signal too.
*/

View file

@ -248,44 +248,38 @@ static ssize_t stm32_read(struct file *filep, char *buffer, size_t buflen)
{
int ret;
if (sem_wait(&g_rngdev.rd_devsem) < 0)
ret = nxsem_wait(&g_rngdev.rd_devsem);
if (ret < 0)
{
return -get_errno();
return ret;
}
else
{
/* We've got the semaphore. */
/* Initialize the operation semaphore with 0 for blocking until the
* buffer is filled from interrupts. The readsem semaphore is used
* for signaling and, hence, should not have priority inheritance
* enabled.
*/
/* We've got the semaphore. */
nxsem_init(&g_rngdev.rd_readsem, 0, 0);
nxsem_setprotocol(&g_rngdev.rd_readsem, SEM_PRIO_NONE);
/* Initialize the operation semaphore with 0 for blocking until the
* buffer is filled from interrupts. The readsem semaphore is used
* for signaling and, hence, should not have priority inheritance
* enabled.
*/
g_rngdev.rd_buflen = buflen;
g_rngdev.rd_buf = buffer;
nxsem_init(&g_rngdev.rd_readsem, 0, 0);
nxsem_setprotocol(&g_rngdev.rd_readsem, SEM_PRIO_NONE);
/* Enable RNG with interrupts */
g_rngdev.rd_buflen = buflen;
g_rngdev.rd_buf = buffer;
stm32_enable();
/* Enable RNG with interrupts */
/* Wait until the buffer is filled */
stm32_enable();
ret = sem_wait(&g_rngdev.rd_readsem);
if (ret < 0)
{
ret = -get_errno();
}
/* Wait until the buffer is filled */
/* Free RNG for next use */
ret = nxsem_wait(&g_rngdev.rd_readsem);
nxsem_post(&g_rngdev.rd_devsem);
/* Free RNG for next use */
return ret < 0 ? ret : buflen;
}
nxsem_post(&g_rngdev.rd_devsem);
return ret < 0 ? ret : buflen;
}
/****************************************************************************

View file

@ -582,16 +582,21 @@ static struct stm32_sampleregs_s g_sampleregs[DEBUG_NSAMPLES];
static void stm32_takesem(struct stm32_dev_s *priv)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&priv->waitsem) != 0)
do
{
/* The only case that an error should occr here is if the wait was
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&priv->waitsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/src/stm32/stm32_spi.c
*
* Copyright (C) 2009-2013, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2009-2013, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -742,18 +742,23 @@ static inline bool spi_16bitmode(FAR struct stm32_spidev_s *priv)
#ifdef CONFIG_STM32_SPI_DMA
static void spi_dmarxwait(FAR struct stm32_spidev_s *priv)
{
int ret;
/* Take the semaphore (perhaps waiting). If the result is zero, then the DMA
* must not really have completed???
*/
while (sem_wait(&priv->rxsem) != 0 || priv->rxresult == 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
ret = nxsem_wait(&priv->rxsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR || priv->rxresult == 0);
}
#endif
@ -768,18 +773,23 @@ static void spi_dmarxwait(FAR struct stm32_spidev_s *priv)
#ifdef CONFIG_STM32_SPI_DMA
static void spi_dmatxwait(FAR struct stm32_spidev_s *priv)
{
int ret;
/* Take the semaphore (perhaps waiting). If the result is zero, then the DMA
* must not really have completed???
*/
while (sem_wait(&priv->txsem) != 0 || priv->txresult == 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
ret = nxsem_wait(&priv->txsem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR || priv->txresult == 0);
}
#endif
@ -1064,25 +1074,31 @@ static void spi_modifycr2(FAR struct stm32_spidev_s *priv, uint16_t setbits,
static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
{
FAR struct stm32_spidev_s *priv = (FAR struct stm32_spidev_s *)dev;
int ret;
if (lock)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&priv->exclsem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
ret = nxsem_wait(&priv->exclsem);
/* The only case that an error should occur here is if the wait
* was awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
else
{
(void)nxsem_post(&priv->exclsem);
ret = OK;
}
return OK;
return ret;
}
/************************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32f10xxx_dma.c
*
* Copyright (C) 2009, 2011-2013, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2009, 2011-2013, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -224,16 +224,21 @@ static inline void dmachan_putreg(struct stm32_dma_s *dmach, uint32_t offset, ui
static void stm32_dmatake(FAR struct stm32_dma_s *dmach)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&dmach->sem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&dmach->sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
static inline void stm32_dmagive(FAR struct stm32_dma_s *dmach)

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32f20xxx_dma.c
*
* Copyright (C) 2012-2013, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2012-2013, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -253,16 +253,21 @@ static inline void dmast_putreg(struct stm32_dma_s *dmast, uint32_t offset, uint
static void stm32_dmatake(FAR struct stm32_dma_s *dmast)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&dmast->sem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&dmast->sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
static inline void stm32_dmagive(FAR struct stm32_dma_s *dmast)

View file

@ -513,10 +513,21 @@ static inline void stm32_i2c_modifyreg32(FAR struct stm32_i2c_priv_s *priv,
static inline void stm32_i2c_sem_wait(FAR struct stm32_i2c_priv_s *priv)
{
while (sem_wait(&priv->sem_excl) != 0)
int ret;
do
{
ASSERT(errno == EINTR);
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&priv->sem_excl);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/************************************************************************************

View file

@ -184,16 +184,21 @@ static inline void dmachan_putreg(struct stm32_dma_s *dmach, uint32_t offset, ui
static void stm32_dmatake(FAR struct stm32_dma_s *dmach)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&dmach->sem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&dmach->sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
static inline void stm32_dmagive(FAR struct stm32_dma_s *dmach)

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32f40xxx_dma.c
*
* Copyright (C) 2011-2013, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2011-2013, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -252,16 +252,21 @@ static inline void dmast_putreg(struct stm32_dma_s *dmast, uint32_t offset, uint
static void stm32_dmatake(FAR struct stm32_dma_s *dmast)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&dmast->sem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&dmast->sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
static inline void stm32_dmagive(FAR struct stm32_dma_s *dmast)

View file

@ -561,10 +561,21 @@ static inline void stm32_i2c_modifyreg(FAR struct stm32_i2c_priv_s *priv,
static inline void stm32_i2c_sem_wait(FAR struct stm32_i2c_priv_s *priv)
{
while (sem_wait(&priv->sem_excl) != 0)
int ret;
do
{
DEBUGASSERT(errno == EINTR);
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&priv->sem_excl);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/************************************************************************************

View file

@ -456,10 +456,21 @@ static inline void stm32f0_i2c_modifyreg32(FAR struct stm32f0_i2c_priv_s *priv,
static inline void stm32f0_i2c_sem_wait(FAR struct stm32f0_i2c_priv_s *priv)
{
while (sem_wait(&priv->sem_excl) != 0)
int ret;
do
{
ASSERT(errno == EINTR);
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&priv->sem_excl);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/************************************************************************************

View file

@ -234,10 +234,10 @@ static void stm32_bbsram_semtake(FAR struct stm32_bbsram_s *priv)
do
{
ret = sem_wait(&priv->exclsem);
DEBUGASSERT(ret == 0 || errno == EINTR);
ret = nxsem_wait(&priv->exclsem);
DEBUGASSERT(ret == 0 || ret == -EINTR);
}
while (ret < 0);
while (ret == -EINTR);
}
/****************************************************************************

View file

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32f7/stm32_dma.c
*
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2015-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -252,16 +252,21 @@ static inline void dmast_putreg(struct stm32_dma_s *dmast, uint32_t offset, uint
static void stm32_dmatake(FAR struct stm32_dma_s *dmast)
{
/* Take the semaphore (perhaps waiting) */
int ret;
while (sem_wait(&dmast->sem) != 0)
do
{
/* The only case that an error should occur here is if the wait was awakened
* by a signal.
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&dmast->sem);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
ASSERT(errno == EINTR);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
static inline void stm32_dmagive(FAR struct stm32_dma_s *dmast)

View file

@ -501,15 +501,15 @@ static int stm32_dma2d_waitforirq(void)
priv->wait = true;
ret = sem_wait(priv->sem);
ret = nxsem_wait(priv->sem);
/* irq or an error occurs, reset the wait flag */
priv->wait = false;
if (ret != OK)
if (ret < 0)
{
lcderr("ERROR: sem_wait() failed\n");
lcderr("ERROR: nxsem_wait() failed\n");
return ret;
}
}
@ -1172,7 +1172,7 @@ static int stm32_dma2dgetvideoinfo(FAR struct dma2d_layer_s *layer,
if (stm32_dma2d_lvalidate(priv) && vinfo)
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
memcpy(vinfo, &priv->vinfo, sizeof(struct fb_videoinfo_s));
nxsem_post(priv->lock);
@ -1209,7 +1209,7 @@ static int stm32_dma2dgetplaneinfo(FAR struct dma2d_layer_s *layer, int planeno,
if (stm32_dma2d_lvalidate(priv) && pinfo && planeno == 0)
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
memcpy(pinfo, &priv->pinfo, sizeof(struct fb_planeinfo_s));
nxsem_post(priv->lock);
@ -1244,7 +1244,7 @@ static int stm32_dma2dgetlid(FAR struct dma2d_layer_s *layer, int *lid)
if (stm32_dma2d_lvalidate(priv) && lid)
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
*lid = priv->lid;
nxsem_post(priv->lock);
return OK;
@ -1282,7 +1282,7 @@ static int stm32_dma2dsetclut(FAR struct dma2d_layer_s *layer,
if (stm32_dma2d_lvalidate(priv) && cmap)
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
#ifdef CONFIG_STM32F7_LTDC_INTERFACE
if (priv->lid < DMA2D_SHADOW_LAYER)
@ -1401,7 +1401,7 @@ static int stm32_dma2dgetclut(FAR struct dma2d_layer_s *layer,
if (stm32_dma2d_lvalidate(priv) && cmap)
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
if (priv->fmt != DMA2D_PF_L8)
{
@ -1491,7 +1491,7 @@ static int stm32_dma2dsetalpha(FAR struct dma2d_layer_s *layer, uint8_t alpha)
if (stm32_dma2d_lvalidate(priv))
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
priv->alpha = alpha;
nxsem_post(priv->lock);
@ -1526,7 +1526,7 @@ static int stm32_dma2dgetalpha(FAR struct dma2d_layer_s *layer, uint8_t *alpha)
if (stm32_dma2d_lvalidate(priv))
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
*alpha = priv->alpha;
nxsem_post(priv->lock);
@ -1577,7 +1577,7 @@ static int stm32_dma2dsetblendmode(FAR struct dma2d_layer_s *layer,
if (stm32_dma2d_lvalidate(priv))
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
priv->blendmode = mode;
nxsem_post(priv->lock);
@ -1613,7 +1613,7 @@ static int stm32_dma2dgetblendmode(FAR struct dma2d_layer_s *layer,
if (stm32_dma2d_lvalidate(priv) && mode)
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
*mode = priv->blendmode;
nxsem_post(priv->lock);
@ -1664,7 +1664,7 @@ static int stm32_dma2dblit(FAR struct dma2d_layer_s *dest,
stm32_dma2d_lvalidatesize(srclayer, srcarea->xpos,
srcarea->ypos, srcarea))
{
sem_wait(destlayer->lock);
nxsem_wait(destlayer->lock);
/* Set output pfc */
@ -1778,8 +1778,7 @@ static int stm32_dma2dblend(FAR struct dma2d_layer_s *dest,
stm32_dma2d_lvalidatesize(backlayer, backarea->xpos,
backarea->ypos, backarea))
{
sem_wait(destlayer->lock);
nxsem_wait(destlayer->lock);
/* Set output pfc */
@ -1874,8 +1873,7 @@ static int stm32_dma2dfillarea(FAR struct dma2d_layer_s *layer,
if (stm32_dma2d_lvalidatesize(priv, area->xpos, area->ypos, area))
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
/* Set output pfc */
@ -1943,7 +1941,7 @@ FAR struct dma2d_layer_s *up_dma2dgetlayer(int lid)
if (lid < DMA2D_LAYER_NSIZE)
{
FAR struct stm32_dma2d_s *priv;
sem_wait(&g_lock);
nxsem_wait(&g_lock);
priv = g_layers[lid];
nxsem_post(&g_lock);
@ -1994,7 +1992,7 @@ FAR struct dma2d_layer_s *up_dma2dcreatelayer(fb_coord_t width,
ret = stm32_dma2d_bpp(fmt, &bpp);
sem_wait(&g_lock);
nxsem_wait(&g_lock);
/* Get a free layer identifier */
@ -2100,7 +2098,7 @@ int up_dma2dremovelayer(FAR struct dma2d_layer_s *layer)
if (stm32_dma2d_lvalidate(priv) && priv->lid >= DMA2D_SHADOW_LAYER)
{
sem_wait(priv->lock);
nxsem_wait(priv->lock);
/* Check also if the layer id is valid to the layer reference */

View file

@ -714,10 +714,21 @@ static inline void stm32_i2c_modifyreg32(FAR struct stm32_i2c_priv_s *priv,
static inline void stm32_i2c_sem_wait(FAR struct i2c_master_s *dev)
{
while (sem_wait(&((struct stm32_i2c_inst_s *)dev)->priv->sem_excl) != 0)
int ret;
do
{
ASSERT(errno == EINTR);
/* Take the semaphore (perhaps waiting) */
ret = nxsem_wait(&((struct stm32_i2c_inst_s *)dev)->priv->sem_excl);
/* The only case that an error should occur here is if the wait was
* awakened by a signal.
*/
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
}
/************************************************************************************

Some files were not shown because too many files have changed in this diff Show more