Fix wait loop and void cast (#24)

* Simplify EINTR/ECANCEL error handling

1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx

* Unify the void cast usage

1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
This commit is contained in:
Xiang Xiao
2020-01-02 10:49:34 -06:00
committed by Gregory Nutt
parent 316675f4db
commit 6a3c2aded6
1602 changed files with 6311 additions and 10874 deletions
+9 -10
View File
@@ -103,8 +103,8 @@ static inline void xen1210_configspi(FAR struct spi_dev_s *spi)
SPI_SETMODE(spi, SPIDEV_MODE1);
SPI_SETBITS(spi, 8);
(void)SPI_HWFEATURES(spi, 0);
(void)SPI_SETFREQUENCY(spi, XEN1210_SPI_MAXFREQUENCY);
SPI_HWFEATURES(spi, 0);
SPI_SETFREQUENCY(spi, XEN1210_SPI_MAXFREQUENCY);
}
/****************************************************************************
@@ -177,7 +177,6 @@ static ssize_t xen1210_read(FAR struct file *filep, FAR char *buffer,
/* This should only happen if the wait was canceled by an signal */
snerr("Failed: Cannot get exclusive access to driver structure!\n");
DEBUGASSERT(ret == -EINTR || ret == -ECANCELED);
return ret;
}
@@ -412,7 +411,7 @@ void xen1210_getdata(FAR struct xen1210_dev_s *priv)
/* If SPI bus is shared then lock and configure it */
(void)SPI_LOCK(priv->spi, true);
SPI_LOCK(priv->spi, true);
xen1210_configspi(priv->spi);
/* Select the XEN1210 */
@@ -436,7 +435,7 @@ void xen1210_getdata(FAR struct xen1210_dev_s *priv)
/* Unlock bus */
(void)SPI_LOCK(priv->spi, false);
SPI_LOCK(priv->spi, false);
#ifdef CONFIG_XEN1210_REGDEBUG
_err("%02x->%02x\n", regaddr, regval);
@@ -465,7 +464,7 @@ void xen1210_putdata(FAR struct xen1210_dev_s *priv, uint32_t regval)
/* If SPI bus is shared then lock and configure it */
(void)SPI_LOCK(priv->spi, true);
SPI_LOCK(priv->spi, true);
xen1210_configspi(priv->spi);
/* Select the XEN1210 */
@@ -476,9 +475,9 @@ void xen1210_putdata(FAR struct xen1210_dev_s *priv, uint32_t regval)
/* Write three times 3 bytes */
(void)SPI_SNDBLOCK(priv->spi, &regval, 3);
(void)SPI_SNDBLOCK(priv->spi, &regval, 3);
(void)SPI_SNDBLOCK(priv->spi, &regval, 3);
SPI_SNDBLOCK(priv->spi, &regval, 3);
SPI_SNDBLOCK(priv->spi, &regval, 3);
SPI_SNDBLOCK(priv->spi, &regval, 3);
/* Deselect the XEN1210 */
@@ -486,7 +485,7 @@ void xen1210_putdata(FAR struct xen1210_dev_s *priv, uint32_t regval)
/* Unlock bus */
(void)SPI_LOCK(priv->spi, false);
SPI_LOCK(priv->spi, false);
}
#endif /* CONFIG_SENSORS_XEN1210 */