This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 2d13ea7  drivers/: Check return from nxsem_wait_uninterruptible.
2d13ea7 is described below

commit 2d13ea7477d70e936fb42f3224b5c8942bde3d4d
Author: Ouss4 <[email protected]>
AuthorDate: Mon Mar 30 22:06:15 2020 +0100

    drivers/: Check return from nxsem_wait_uninterruptible.
---
 drivers/analog/comp.c         |  11 ++-
 drivers/ioexpander/pca9538.c  |  68 ++++++++++++++----
 drivers/ioexpander/pca9555.c  | 135 ++++++++++++++++++++++++------------
 drivers/ioexpander/pcf8574.c  | 121 ++++++++++++++++++++++-----------
 drivers/ioexpander/skeleton.c | 118 +++++++++++++++++++++-----------
 drivers/ioexpander/tca64xx.c  | 155 ++++++++++++++++++++++++++----------------
 drivers/sensors/apds9960.c    |  24 +++++--
 drivers/sensors/dhtxx.c       |  61 ++++++++---------
 drivers/sensors/hc_sr04.c     |  47 ++++++++++---
 drivers/sensors/hts221.c      |  59 +++++++++++-----
 drivers/sensors/kxtj9.c       |  71 ++++++++++++-------
 drivers/sensors/lps25h.c      |  24 +++++--
 drivers/sensors/max44009.c    |  41 ++++++++---
 drivers/sensors/scd30.c       |  51 ++++++++++----
 drivers/sensors/sgp30.c       |  86 ++++++++++++++++-------
 drivers/sensors/sht21.c       |  36 ++++++++--
 drivers/sensors/sht3x.c       |  37 +++++++---
 drivers/sensors/sps30.c       |  86 +++++++++++++++--------
 drivers/sensors/t67xx.c       |  15 +++-
 19 files changed, 862 insertions(+), 384 deletions(-)

diff --git a/drivers/analog/comp.c b/drivers/analog/comp.c
index 1cc978d..5d723ed 100644
--- a/drivers/analog/comp.c
+++ b/drivers/analog/comp.c
@@ -140,9 +140,9 @@ static void comp_pollnotify(FAR struct comp_dev_s *dev,
  * Name: comp_semtake
  ****************************************************************************/
 
-static void comp_semtake(FAR sem_t *sem)
+static int comp_semtake(FAR sem_t *sem)
 {
-  nxsem_wait_uninterruptible(sem);
+  return nxsem_wait_uninterruptible(sem);
 }
 
 /****************************************************************************
@@ -161,7 +161,12 @@ static int comp_poll(FAR struct file *filep, FAR struct 
pollfd *fds,
 
   /* Are we setting up the poll?  Or tearing it down? */
 
-  comp_semtake(&dev->ad_sem);
+  ret = comp_semtake(&dev->ad_sem);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
   if (setup)
     {
       /* This is a request to set up the poll.  Find an available
diff --git a/drivers/ioexpander/pca9538.c b/drivers/ioexpander/pca9538.c
index 0442d7d..e6edc7f 100644
--- a/drivers/ioexpander/pca9538.c
+++ b/drivers/ioexpander/pca9538.c
@@ -129,9 +129,9 @@ static const struct ioexpander_ops_s g_pca9538_ops =
  *
  ****************************************************************************/
 
-static void pca9538_lock(FAR struct pca9538_dev_s *pca)
+static int pca9538_lock(FAR struct pca9538_dev_s *pca)
 {
-  nxsem_wait_uninterruptible(&pca->exclsem);
+  return nxsem_wait_uninterruptible(&pca->exclsem);
 }
 
 #define pca9538_unlock(p) nxsem_post(&(p)->exclsem)
@@ -311,7 +311,12 @@ static int pca9538_direction(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
 
   /* Get exclusive access to the PCA555 */
 
-  pca9538_lock(pca);
+  ret = pca9538_lock(pca);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
   ret = pca9538_setbit(pca, PCA9538_REG_CONFIG, pin,
                        (direction == IOEXPANDER_DIRECTION_IN));
   pca9538_unlock(pca);
@@ -349,7 +354,12 @@ static int pca9538_option(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
 
       /* Get exclusive access to the PCA555 */
 
-      pca9538_lock(pca);
+      ret = pca9538_lock(pca);
+      if (ret < 0)
+        {
+          return ret;
+        }
+
       ret = pca9538_setbit(pca, PCA9538_REG_POLINV, pin, ival);
       pca9538_unlock(pca);
     }
@@ -382,7 +392,12 @@ static int pca9538_writepin(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
 
   /* Get exclusive access to the PCA555 */
 
-  pca9538_lock(pca);
+  ret = pca9538_lock(pca);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
   ret = pca9538_setbit(pca, PCA9538_REG_OUTPUT, pin, value);
   pca9538_unlock(pca);
   return ret;
@@ -415,7 +430,12 @@ static int pca9538_readpin(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
 
   /* Get exclusive access to the PCA555 */
 
-  pca9538_lock(pca);
+  ret = pca9538_lock(pca);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
   ret = pca9538_getbit(pca, PCA9538_REG_INPUT, pin, value);
   pca9538_unlock(pca);
   return ret;
@@ -446,7 +466,12 @@ static int pca9538_readbuf(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
 
   /* Get exclusive access to the PCA555 */
 
-  pca9538_lock(pca);
+  ret = pca9538_lock(pca);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
   ret = pca9538_getbit(pca, PCA9538_REG_OUTPUT, pin, value);
   pca9538_unlock(pca);
   return ret;
@@ -533,7 +558,11 @@ static int pca9538_multiwritepin(FAR struct 
ioexpander_dev_s *dev,
 
   /* Get exclusive access to the PCA555 */
 
-  pca9538_lock(pca);
+  ret = pca9538_lock(pca);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Start by reading both registers, whatever the pins to change. We could
    * attempt to read one port only if all pins were on the same port, but
@@ -617,7 +646,12 @@ static int pca9538_multireadpin(FAR struct 
ioexpander_dev_s *dev,
 
   /* Get exclusive access to the PCA555 */
 
-  pca9538_lock(pca);
+  ret = pca9538_lock(pca);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
   ret = pca9538_getmultibits(pca, PCA9538_REG_INPUT,
                              pins, values, count);
   pca9538_unlock(pca);
@@ -650,7 +684,12 @@ static int pca9538_multireadbuf(FAR struct 
ioexpander_dev_s *dev,
 
   /* Get exclusive access to the PCA555 */
 
-  pca9538_lock(pca);
+  ret = pca9538_lock(pca);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
   ret = pca9538_getmultibits(pca, PCA9538_REG_OUTPUT,
                              pins, values, count);
   pca9538_unlock(pca);
@@ -687,10 +726,15 @@ static FAR void *pca9538_attach(FAR struct 
ioexpander_dev_s *dev,
   FAR struct pca9538_dev_s *pca = (FAR struct pca9538_dev_s *)dev;
   FAR void *handle = NULL;
   int i;
+  int ret;
 
   /* Get exclusive access to the PCA555 */
 
-  pca9538_lock(pca);
+  ret = pca9538_lock(pca);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Find and available in entry in the callback table */
 
@@ -822,7 +866,7 @@ static void pca9538_irqworker(void *arg)
 
 static int pca9538_interrupt(int irq, FAR void *context, FAR void *arg)
 {
-  register FAR struct pca9538_dev_s *pca = (FAR struct pca9538_dev_s *)arg;
+  FAR struct pca9538_dev_s *pca = (FAR struct pca9538_dev_s *)arg;
 
   /* In complex environments, we cannot do I2C transfers from the interrupt
    * handler because semaphores are probably used to lock the I2C bus.  In
diff --git a/drivers/ioexpander/pca9555.c b/drivers/ioexpander/pca9555.c
index 177f4e7..07a45d0 100644
--- a/drivers/ioexpander/pca9555.c
+++ b/drivers/ioexpander/pca9555.c
@@ -147,9 +147,9 @@ static const struct ioexpander_ops_s g_pca9555_ops =
  *
  ****************************************************************************/
 
-static void pca9555_lock(FAR struct pca9555_dev_s *pca)
+static int pca9555_lock(FAR struct pca9555_dev_s *pca)
 {
-  nxsem_wait_uninterruptible(&pca->exclsem);
+  return nxsem_wait_uninterruptible(&pca->exclsem);
 }
 
 #define pca9555_unlock(p) nxsem_post(&(p)->exclsem)
@@ -202,7 +202,8 @@ static inline int pca9555_writeread(FAR struct 
pca9555_dev_s *pca,
   config.address   = pca->config->address;
   config.addrlen   = 7;
 
-  return i2c_writeread(pca->i2c, &config, wbuffer, wbuflen, rbuffer, rbuflen);
+  return i2c_writeread(pca->i2c, &config, wbuffer, wbuflen,
+                       rbuffer, rbuflen);
 }
 
 /****************************************************************************
@@ -338,7 +339,12 @@ static int pca9555_direction(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
 
   /* Get exclusive access to the PCA555 */
 
-  pca9555_lock(pca);
+  ret = pca9555_lock(pca);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
   ret = pca9555_setbit(pca, PCA9555_REG_CONFIG, pin,
                        (direction == IOEXPANDER_DIRECTION_IN));
   pca9555_unlock(pca);
@@ -376,7 +382,12 @@ static int pca9555_option(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
 
       /* Get exclusive access to the PCA555 */
 
-      pca9555_lock(pca);
+      ret = pca9555_lock(pca);
+      if (ret < 0)
+        {
+          return ret;
+        }
+
       ret = pca9555_setbit(pca, PCA9555_REG_POLINV, pin, ival);
       pca9555_unlock(pca);
     }
@@ -409,7 +420,12 @@ static int pca9555_writepin(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
 
   /* Get exclusive access to the PCA555 */
 
-  pca9555_lock(pca);
+  ret = pca9555_lock(pca);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
   ret = pca9555_setbit(pca, PCA9555_REG_OUTPUT, pin, value);
   pca9555_unlock(pca);
   return ret;
@@ -419,14 +435,15 @@ static int pca9555_writepin(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
  * Name: pca9555_readpin
  *
  * Description:
- *   Read the actual PIN level. This can be different from the last value 
written
- *      to this pin. Required.
+ *   Read the actual PIN level. This can be different from the last value
+ *      written to this pin. Required.
  *
  * Input Parameters:
  *   dev    - Device-specific state data
  *   pin    - The index of the pin
  *   valptr - Pointer to a buffer where the pin level is stored. Usually TRUE
- *            if the pin is high, except if OPTION_INVERT has been set on this 
pin.
+ *            if the pin is high, except if OPTION_INVERT has been set on
+ *            this pin.
  *
  * Returned Value:
  *   0 on success, else a negative error code
@@ -441,7 +458,12 @@ static int pca9555_readpin(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
 
   /* Get exclusive access to the PCA555 */
 
-  pca9555_lock(pca);
+  ret = pca9555_lock(pca);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
   ret = pca9555_getbit(pca, PCA9555_REG_INPUT, pin, value);
   pca9555_unlock(pca);
   return ret;
@@ -472,7 +494,12 @@ static int pca9555_readbuf(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
 
   /* Get exclusive access to the PCA555 */
 
-  pca9555_lock(pca);
+  ret = pca9555_lock(pca);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
   ret = pca9555_getbit(pca, PCA9555_REG_OUTPUT, pin, value);
   pca9555_unlock(pca);
   return ret;
@@ -507,8 +534,8 @@ static int pca9555_getmultibits(FAR struct pca9555_dev_s 
*pca, uint8_t addr,
 #ifdef CONFIG_PCA9555_SHADOW_MODE
   /* Save the new register value in the shadow register */
 
-  pca->sreg[addr]   = buf[0];
-  pca->sreg[addr+1] = buf[1];
+  pca->sreg[addr]     = buf[0];
+  pca->sreg[addr + 1] = buf[1];
 #endif
 
   /* Read the requested bits */
@@ -564,7 +591,11 @@ static int pca9555_multiwritepin(FAR struct 
ioexpander_dev_s *dev,
 
   /* Get exclusive access to the PCA555 */
 
-  pca9555_lock(pca);
+  ret = pca9555_lock(pca);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Start by reading both registers, whatever the pins to change. We could
    * attempt to read one port only if all pins were on the same port, but
@@ -582,7 +613,7 @@ static int pca9555_multiwritepin(FAR struct 
ioexpander_dev_s *dev,
   /* In Shadow-Mode we "read" the pin status from the shadow registers */
 
   buf[1] = pca->sreg[addr];
-  buf[2] = pca->sreg[addr+1];
+  buf[2] = pca->sreg[addr + 1];
 #endif
 
   /* Apply the user defined changes */
@@ -617,8 +648,9 @@ static int pca9555_multiwritepin(FAR struct 
ioexpander_dev_s *dev,
   buf[0] = addr;
 #ifdef CONFIG_PCA9555_SHADOW_MODE
   /* Save the new register values in the shadow register */
-  pca->sreg[addr] = buf[1];
-  pca->sreg[addr+1] = buf[2];
+
+  pca->sreg[addr]     = buf[1];
+  pca->sreg[addr + 1] = buf[2];
 #endif
   ret = pca9555_write(pca, buf, 3);
 
@@ -652,7 +684,12 @@ static int pca9555_multireadpin(FAR struct 
ioexpander_dev_s *dev,
 
   /* Get exclusive access to the PCA555 */
 
-  pca9555_lock(pca);
+  ret = pca9555_lock(pca);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
   ret = pca9555_getmultibits(pca, PCA9555_REG_INPUT,
                              pins, values, count);
   pca9555_unlock(pca);
@@ -663,8 +700,8 @@ static int pca9555_multireadpin(FAR struct ioexpander_dev_s 
*dev,
  * Name: pca9555_multireadbuf
  *
  * Description:
- *   Read the buffered level of multiple pins. This routine may be faster than
- *   individual pin accesses. Optional.
+ *   Read the buffered level of multiple pins. This routine may be faster
+ *   than individual pin accesses. Optional.
  *
  * Input Parameters:
  *   dev    - Device-specific state data
@@ -685,7 +722,12 @@ static int pca9555_multireadbuf(FAR struct 
ioexpander_dev_s *dev,
 
   /* Get exclusive access to the PCA555 */
 
-  pca9555_lock(pca);
+  ret = pca9555_lock(pca);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
   ret = pca9555_getmultibits(pca, PCA9555_REG_OUTPUT,
                              pins, values, count);
   pca9555_unlock(pca);
@@ -722,27 +764,32 @@ static FAR void *pca9555_attach(FAR struct 
ioexpander_dev_s *dev,
   FAR struct pca9555_dev_s *pca = (FAR struct pca9555_dev_s *)dev;
   FAR void *handle = NULL;
   int i;
+  int ret;
 
   /* Get exclusive access to the PCA555 */
 
-  pca9555_lock(pca);
+  ret = pca9555_lock(pca);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Find and available in entry in the callback table */
 
   for (i = 0; i < CONFIG_PCA9555_INT_NCALLBACKS; i++)
     {
-       /* Is this entry available (i.e., no callback attached) */
-
-       if (pca->cb[i].cbfunc == NULL)
-         {
-           /* Yes.. use this entry */
-
-           pca->cb[i].pinset = pinset;
-           pca->cb[i].cbfunc = callback;
-           pca->cb[i].cbarg  = arg;
-           handle            = &pca->cb[i];
-           break;
-         }
+      /* Is this entry available (i.e., no callback attached) */
+
+      if (pca->cb[i].cbfunc == NULL)
+        {
+          /* Yes.. use this entry */
+
+          pca->cb[i].pinset = pinset;
+          pca->cb[i].cbfunc = callback;
+          pca->cb[i].cbarg  = arg;
+          handle            = &pca->cb[i];
+          break;
+        }
     }
 
   /* Add this callback to the table */
@@ -769,11 +816,13 @@ static FAR void *pca9555_attach(FAR struct 
ioexpander_dev_s *dev,
 static int pca9555_detach(FAR struct ioexpander_dev_s *dev, FAR void *handle)
 {
   FAR struct pca9555_dev_s *pca = (FAR struct pca9555_dev_s *)dev;
-  FAR struct pca9555_callback_s *cb = (FAR struct pca9555_callback_s *)handle;
+  FAR struct pca9555_callback_s *cb =
+    (FAR struct pca9555_callback_s *)handle;
 
   DEBUGASSERT(pca != NULL && cb != NULL);
   DEBUGASSERT((uintptr_t)cb >= (uintptr_t)&pca->cb[0] &&
-              (uintptr_t)cb <= 
(uintptr_t)&pca->cb[CONFIG_TCA64XX_INT_NCALLBACKS-1]);
+              (uintptr_t)cb <=
+              (uintptr_t)&pca->cb[CONFIG_TCA64XX_INT_NCALLBACKS - 1]);
   UNUSED(pca);
 
   cb->pinset = 0;
@@ -808,8 +857,8 @@ static void pca9555_irqworker(void *arg)
 #ifdef CONFIG_PCA9555_SHADOW_MODE
       /* Don't forget to update the shadow registers at this point */
 
-      pca->sreg[addr]   = buf[0];
-      pca->sreg[addr+1] = buf[1];
+      pca->sreg[addr]     = buf[0];
+      pca->sreg[addr + 1] = buf[1];
 #endif
       /* Create a 16-bit pinset */
 
@@ -855,7 +904,7 @@ static void pca9555_irqworker(void *arg)
 
 static int pca9555_interrupt(int irq, FAR void *context, FAR void *arg)
 {
-  register FAR struct pca9555_dev_s *pca = (FAR struct pca9555_dev_s*)arg;
+  FAR struct pca9555_dev_s *pca = (FAR struct pca9555_dev_s *)arg;
 
   /* In complex environments, we cannot do I2C transfers from the interrupt
    * handler because semaphores are probably used to lock the I2C bus.  In
@@ -896,8 +945,9 @@ static int pca9555_interrupt(int irq, FAR void *context, 
FAR void *arg)
  *
  ****************************************************************************/
 
-FAR struct ioexpander_dev_s *pca9555_initialize(FAR struct i2c_master_s 
*i2cdev,
-                                                FAR struct pca9555_config_s 
*config)
+FAR struct ioexpander_dev_s *pca9555_initialize(
+                              FAR struct i2c_master_s *i2cdev,
+                              FAR struct pca9555_config_s *config)
 {
   FAR struct pca9555_dev_s *pcadev;
 
@@ -906,7 +956,8 @@ FAR struct ioexpander_dev_s *pca9555_initialize(FAR struct 
i2c_master_s *i2cdev,
 #ifdef CONFIG_PCA9555_MULTIPLE
   /* Allocate the device state structure */
 
-  pcadev = (FAR struct pca9555_dev_s *)kmm_zalloc(sizeof(struct 
pca9555_dev_s));
+  pcadev = (FAR struct pca9555_dev_s *)
+    kmm_zalloc(sizeof(struct pca9555_dev_s));
   if (!pcadev)
     {
       return NULL;
diff --git a/drivers/ioexpander/pcf8574.c b/drivers/ioexpander/pcf8574.c
index 010ce99..e6bfdd3 100644
--- a/drivers/ioexpander/pcf8574.c
+++ b/drivers/ioexpander/pcf8574.c
@@ -31,8 +31,7 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- 
********************************************************************************************/
-
+ ****************************************************************************/
 
 /****************************************************************************
  * Included Files
@@ -71,8 +70,9 @@
 
 /* PCF8574xx Helpers */
 
-static void pcf8574_lock(FAR struct pcf8574_dev_s *priv);
-static int pcf8574_read(FAR struct pcf8574_dev_s *priv, FAR uint8_t *portval);
+static int pcf8574_lock(FAR struct pcf8574_dev_s *priv);
+static int pcf8574_read(FAR struct pcf8574_dev_s *priv,
+                        FAR uint8_t *portval);
 static int pcf8574_write(struct pcf8574_dev_s *priv, uint8_t portval);
 
 /* I/O Expander Methods */
@@ -94,7 +94,8 @@ static int pcf8574_multireadpin(FAR struct ioexpander_dev_s 
*dev,
 #ifdef CONFIG_IOEXPANDER_INT_ENABLE
 static FAR void *pcf8574_attach(FAR struct ioexpander_dev_s *dev,
              ioe_pinset_t pinset, ioe_callback_t callback, FAR void *arg);
-static int pcf8574_detach(FAR struct ioexpander_dev_s *dev, FAR void *handle);
+static int pcf8574_detach(FAR struct ioexpander_dev_s *dev,
+                          FAR void *handle);
 #endif
 
 #ifdef CONFIG_PCF8574_INT_ENABLE
@@ -151,9 +152,9 @@ static const struct ioexpander_ops_s g_pcf8574_ops =
  *
  ****************************************************************************/
 
-static void pcf8574_lock(FAR struct pcf8574_dev_s *priv)
+static int pcf8574_lock(FAR struct pcf8574_dev_s *priv)
 {
-  nxsem_wait_uninterruptible(&priv->exclsem);
+  return nxsem_wait_uninterruptible(&priv->exclsem);
 }
 
 #define pcf8574_unlock(p) nxsem_post(&(p)->exclsem)
@@ -265,7 +266,11 @@ static int pcf8574_direction(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
 
   /* Get exclusive access to the I/O Expander */
 
-  pcf8574_lock(priv);
+  ret = pcf8574_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Set a bit in inpins if the pin is an input.  Clear the bit in
    * inpins if the pin is an output.
@@ -331,7 +336,12 @@ static int pcf8574_option(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
       ioe_pinset_t bit = ((ioe_pinset_t)1 << pin);
 
       ret = OK;
-      pcf8574_lock(priv);
+      ret = pcf8574_lock(priv);
+      if (ret < 0)
+        {
+          return ret;
+        }
+
       switch (ival)
         {
           case IOEXPANDER_VAL_HIGH:    /* Interrupt on high level */
@@ -408,7 +418,11 @@ static int pcf8574_writepin(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
 
   /* Get exclusive access to the I/O Expander */
 
-  pcf8574_lock(priv);
+  ret = pcf8574_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Make sure that this is an output pin */
 
@@ -444,8 +458,8 @@ static int pcf8574_writepin(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
  * Name: pcf8574_readpin
  *
  * Description:
- *   Read the actual PIN level. This can be different from the last value 
written
- *   to this pin. Required.
+ *   Read the actual PIN level. This can be different from the last value
+ *   written to this pin. Required.
  *
  *   The PCF8574 is 'interesting' in that it doesn't really have a data
  *   direction register, but instead the outputs are current-limited when
@@ -458,7 +472,8 @@ static int pcf8574_writepin(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
  *   dev    - Device-specific state data
  *   pin    - The index of the pin
  *   valptr - Pointer to a buffer where the pin level is stored. Usually TRUE
- *            if the pin is high, except if OPTION_INVERT has been set on this 
pin.
+ *            if the pin is high, except if OPTION_INVERT has been set on
+ *            this pin.
  *
  * Returned Value:
  *   0 on success, else a negative error code
@@ -472,13 +487,18 @@ static int pcf8574_readpin(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
   uint8_t regval;
   int ret;
 
-  DEBUGASSERT(priv != NULL && priv->config != NULL &&  pin < 8 && value != 
NULL);
+  DEBUGASSERT(priv != NULL && priv->config != NULL &&
+              pin < 8 && value != NULL);
 
   gpioinfo("I2C addr=%02x, pin=%u\n", priv->config->address, pin);
 
   /* Get exclusive access to the I/O Expander */
 
-  pcf8574_lock(priv);
+  ret = pcf8574_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Is the pin an output? */
 
@@ -558,7 +578,11 @@ static int pcf8574_multiwritepin(FAR struct 
ioexpander_dev_s *dev,
 
   /* Get exclusive access to the I/O Expander */
 
-  pcf8574_lock(priv);
+  ret = pcf8574_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Process each pin setting */
 
@@ -635,7 +659,11 @@ static int pcf8574_multireadpin(FAR struct 
ioexpander_dev_s *dev,
 
   /* Get exclusive access to the I/O Expander */
 
-  pcf8574_lock(priv);
+  ret = pcf8574_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Read the input register for this pin
    *
@@ -719,27 +747,32 @@ static FAR void *pcf8574_attach(FAR struct 
ioexpander_dev_s *dev,
   FAR struct pcf8574_dev_s *priv = (FAR struct pcf8574_dev_s *)dev;
   FAR void *handle = NULL;
   int i;
+  int ret;
 
   /* Get exclusive access to the I/O Expander */
 
-  pcf8574_lock(priv);
+  ret = pcf8574_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Find and available in entry in the callback table */
 
   for (i = 0; i < CONFIG_PCF8574_INT_NCALLBACKS; i++)
     {
-       /* Is this entry available (i.e., no callback attached) */
-
-       if (priv->cb[i].cbfunc == NULL)
-         {
-           /* Yes.. use this entry */
-
-           priv->cb[i].pinset = pinset;
-           priv->cb[i].cbfunc = callback;
-           priv->cb[i].cbarg  = arg;
-           handle             = &priv->cb[i];
-           break;
-         }
+      /* Is this entry available (i.e., no callback attached) */
+
+      if (priv->cb[i].cbfunc == NULL)
+        {
+          /* Yes.. use this entry */
+
+          priv->cb[i].pinset = pinset;
+          priv->cb[i].cbfunc = callback;
+          priv->cb[i].cbarg  = arg;
+          handle             = &priv->cb[i];
+          break;
+        }
     }
 
   pcf8574_unlock(priv);
@@ -766,11 +799,13 @@ static FAR void *pcf8574_attach(FAR struct 
ioexpander_dev_s *dev,
 static int pcf8574_detach(FAR struct ioexpander_dev_s *dev, FAR void *handle)
 {
   FAR struct pcf8574_dev_s *priv = (FAR struct pcf8574_dev_s *)dev;
-  FAR struct pcf8574_callback_s *cb = (FAR struct pcf8574_callback_s *)handle;
+  FAR struct pcf8574_callback_s *cb =
+    (FAR struct pcf8574_callback_s *)handle;
 
   DEBUGASSERT(priv != NULL && cb != NULL);
   DEBUGASSERT((uintptr_t)cb >= (uintptr_t)&priv->cb[0] &&
-              (uintptr_t)cb <= 
(uintptr_t)&priv->cb[CONFIG_PCF8574_INT_NCALLBACKS-1]);
+              (uintptr_t)cb <=
+              (uintptr_t)&priv->cb[CONFIG_PCF8574_INT_NCALLBACKS - 1]);
   UNUSED(priv);
 
   cb->pinset = 0;
@@ -905,7 +940,12 @@ static void pcf8574_irqworker(void *arg)
 
   /* Check for pending interrupts */
 
-  pcf8574_lock(priv);
+  ret = pcf8574_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
   pcf8574_register_update(priv);
 
   /* Sample and clear the pending interrupts.  */
@@ -943,7 +983,8 @@ static void pcf8574_irqworker(void *arg)
   /* Re-start the poll timer */
 
   sched_lock();
-  ret = wd_start(priv->wdog, PCF8574_POLLDELAY, (wdentry_t)pcf8574_poll_expiry,
+  ret = wd_start(priv->wdog, PCF8574_POLLDELAY,
+                 (wdentry_t)pcf8574_poll_expiry,
                  1, (wdparm_t)priv);
   if (ret < 0)
     {
@@ -1059,8 +1100,8 @@ static void pcf8574_poll_expiry(int argc, wdparm_t arg1, 
...)
  * Name: pcf8574_initialize
  *
  * Description:
- *   Instantiate and configure the PCF8574xx device driver to use the provided
- *   I2C device instance.
+ *   Instantiate and configure the PCF8574xx device driver to use the
+ *   provided I2C device instance.
  *
  * Input Parameters:
  *   i2c     - An I2C driver instance
@@ -1073,7 +1114,7 @@ static void pcf8574_poll_expiry(int argc, wdparm_t arg1, 
...)
  ****************************************************************************/
 
 FAR struct ioexpander_dev_s *pcf8574_initialize(FAR struct i2c_master_s *i2c,
-                                              FAR struct pcf8574_config_s 
*config)
+                              FAR struct pcf8574_config_s *config)
 {
   FAR struct pcf8574_dev_s *priv;
   int ret;
@@ -1081,7 +1122,8 @@ FAR struct ioexpander_dev_s *pcf8574_initialize(FAR 
struct i2c_master_s *i2c,
 #ifdef CONFIG_PCF8574_MULTIPLE
   /* Allocate the device state structure */
 
-  priv = (FAR struct pcf8574_dev_s *)kmm_zalloc(sizeof(struct pcf8574_dev_s));
+  priv = (FAR struct pcf8574_dev_s *)
+    kmm_zalloc(sizeof(struct pcf8574_dev_s));
   if (!priv)
     {
       gpioerr("ERROR: Failed to allocate driver instance\n");
@@ -1112,7 +1154,8 @@ FAR struct ioexpander_dev_s *pcf8574_initialize(FAR 
struct i2c_master_s *i2c,
   priv->wdog    = wd_create();
   DEBUGASSERT(priv->wdog != NULL);
 
-  ret = wd_start(priv->wdog, PCF8574_POLLDELAY, (wdentry_t)pcf8574_poll_expiry,
+  ret = wd_start(priv->wdog, PCF8574_POLLDELAY,
+                 (wdentry_t)pcf8574_poll_expiry,
                  1, (wdparm_t)priv);
   if (ret < 0)
     {
diff --git a/drivers/ioexpander/skeleton.c b/drivers/ioexpander/skeleton.c
index 00dfc4c..7269482 100644
--- a/drivers/ioexpander/skeleton.c
+++ b/drivers/ioexpander/skeleton.c
@@ -65,9 +65,8 @@
 
 struct skel_callback_s
 {
-   ioe_pinset_t pinset;                 /* Set of pin interrupts that will 
generate
-                                         * the callback. */
-   ioe_callback_t cbfunc;               /* The saved callback function pointer 
*/
+  ioe_pinset_t pinset;          /* Set of pin interrupts that will generate 
the callback */
+  ioe_callback_t cbfunc;        /* The saved callback function pointer */
 };
 #endif
 
@@ -75,19 +74,18 @@ struct skel_callback_s
 
 struct skel_dev_s
 {
-  struct ioexpander_dev_s dev;          /* Nested structure to allow casting 
as public gpio
-                                         * expander. */
+  struct ioexpander_dev_s dev;  /* Nested structure to allow casting as public 
gpio expander */
 #ifdef CONFIG_skeleton_MULTIPLE
-  FAR struct skel_dev_s *flink;         /* Supports a singly linked list of 
drivers */
+  FAR struct skel_dev_s *flink; /* Supports a singly linked list of drivers */
 #endif
-  sem_t exclsem;                        /* Mutual exclusion */
+  sem_t exclsem;                /* Mutual exclusion */
 
 #ifdef CONFIG_IOEXPANDER_INT_ENABLE
-  struct work_s work;                   /* Supports the interrupt handling 
"bottom half" */
+  struct work_s work;           /* Supports the interrupt handling "bottom 
half" */
 
   /* Saved callback information for each I/O expander client */
 
-  struct skel_callback_s cb[CONFIG_skeleton_INT_NCALLBACKS];
+  struct skel_callback_s cb[CONFIG_SKELETON_INT_NCALLBACKS];
 #endif
 };
 
@@ -95,7 +93,7 @@ struct skel_dev_s
  * Private Function Prototypes
  ****************************************************************************/
 
-static void skel_lock(FAR struct skel_dev_s *priv);
+static int skel_lock(FAR struct skel_dev_s *priv);
 
 static int skel_direction(FAR struct ioexpander_dev_s *dev, uint8_t pin,
              int dir);
@@ -166,9 +164,9 @@ static const struct ioexpander_ops_s g_skel_ops =
  *
  ****************************************************************************/
 
-static void skel_lock(FAR struct skel_dev_s *priv)
+static int skel_lock(FAR struct skel_dev_s *priv)
 {
-  nxsem_wait_uninterruptible(&priv->exclsem);
+  return nxsem_wait_uninterruptible(&priv->exclsem);
 }
 
 #define skel_unlock(p) nxsem_post(&(p)->exclsem)
@@ -204,7 +202,11 @@ static int skel_direction(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
 
   /* Get exclusive access to the I/O Expander */
 
-  skel_lock(priv);
+  ret = skel_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Set the pin direction in the I/O Expander */
 #warning Missing logic
@@ -248,7 +250,11 @@ static int skel_option(FAR struct ioexpander_dev_s *dev, 
uint8_t pin,
     {
       /* Get exclusive access to the I/O Expander */
 
-      skel_lock(priv);
+      ret = skel_lock(priv);
+      if (ret < 0)
+        {
+          return ret;
+        }
 
       /* Set the pin option */
 #warning Missing logic
@@ -288,7 +294,11 @@ static int skel_writepin(FAR struct ioexpander_dev_s *dev, 
uint8_t pin,
 
   /* Get exclusive access to the I/O Expander */
 
-  skel_lock(priv);
+  ret = skel_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Write the pin value */
 #warning Missing logic
@@ -301,14 +311,15 @@ static int skel_writepin(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
  * Name: skel_readpin
  *
  * Description:
- *   Read the actual PIN level. This can be different from the last value 
written
- *      to this pin. Required.
+ *   Read the actual PIN level. This can be different from the last value
+ *   written to this pin. Required.
  *
  * Input Parameters:
  *   dev    - Device-specific state data
  *   pin    - The index of the pin
  *   valptr - Pointer to a buffer where the pin level is stored. Usually TRUE
- *            if the pin is high, except if OPTION_INVERT has been set on this 
pin.
+ *            if the pin is high, except if OPTION_INVERT has been set on
+ *            this pin.
  *
  * Returned Value:
  *   0 on success, else a negative error code
@@ -323,11 +334,16 @@ static int skel_readpin(FAR struct ioexpander_dev_s *dev, 
uint8_t pin,
 
   gpioinfo("pin=%u\n", priv->addr);
 
-  DEBUGASSERT(priv != NULL && pin < CONFIG_IOEXPANDER_NPINS && value != NULL);
+  DEBUGASSERT(priv != NULL && pin < CONFIG_IOEXPANDER_NPINS &&
+              value != NULL);
 
   /* Get exclusive access to the I/O Expander */
 
-  skel_lock(priv);
+  ret = skel_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Read the pin value */
 #warning Missing logic
@@ -364,7 +380,11 @@ static int skel_readbuf(FAR struct ioexpander_dev_s *dev, 
uint8_t pin,
 
   /* Get exclusive access to the I/O Expander */
 
-  skel_lock(priv);
+  ret = skel_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Read the buffered pin level */
 #warning Missing logic
@@ -440,7 +460,11 @@ static int skel_multiwritepin(FAR struct ioexpander_dev_s 
*dev,
 
   /* Get exclusive access to the I/O Expander */
 
-  skel_lock(priv);
+  ret = skel_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Read the pinset from the IO-Expander hardware */
 #warning Missing logic
@@ -505,7 +529,12 @@ static int skel_multireadpin(FAR struct ioexpander_dev_s 
*dev,
 
   /* Get exclusive access to the I/O Expander */
 
-  skel_lock(priv);
+  ret = skel_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
   ret = skel_getmultibits(priv, pins, values, count);
   skel_unlock(priv);
   return ret;
@@ -516,8 +545,8 @@ static int skel_multireadpin(FAR struct ioexpander_dev_s 
*dev,
  * Name: skel_multireadbuf
  *
  * Description:
- *   Read the buffered level of multiple pins. This routine may be faster than
- *   individual pin accesses. Optional.
+ *   Read the buffered level of multiple pins. This routine may be faster
+ *   than individual pin accesses. Optional.
  *
  * Input Parameters:
  *   dev    - Device-specific state data
@@ -543,7 +572,12 @@ static int skel_multireadbuf(FAR struct ioexpander_dev_s 
*dev,
 
   /* Get exclusive access to the I/O Expander */
 
-  skel_lock(priv);
+  ret = skel_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
   ret = skel_getmultibits(priv, pins, values, count);
   skel_unlock(priv);
   return ret;
@@ -577,23 +611,27 @@ static int skel_attach(FAR struct ioexpander_dev_s *dev, 
ioe_pinset_t pinset,
 
   /* Get exclusive access to the I/O Expander */
 
-  skel_lock(priv);
+  ret = skel_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Find and available in entry in the callback table */
 
   ret = -ENOSPC;
-  for (i = 0; i < CONFIG_skeleton_INT_NCALLBACKS; i++)
+  for (i = 0; i < CONFIG_SKELETON_INT_NCALLBACKS; i++)
     {
-       /* Is this entry available (i.e., no callback attached) */
+      /* Is this entry available (i.e., no callback attached) */
 
-       if (priv->cb[i].cbfunc == NULL)
-         {
-           /* Yes.. use this entry */
+      if (priv->cb[i].cbfunc == NULL)
+        {
+          /* Yes.. use this entry */
 
-           priv->cb[i].pinset = pinset;
-           priv->cb[i].cbfunc = callback;
-           ret = OK;
-         }
+          priv->cb[i].pinset = pinset;
+          priv->cb[i].cbfunc = callback;
+          ret = OK;
+        }
     }
 
   /* Add this callback to the table */
@@ -625,7 +663,7 @@ static void skel_irqworker(void *arg)
 
   /* Perform pin interrupt callbacks */
 
-  for (i = 0; i < CONFIG_skeleton_INT_NCALLBACKS; i++)
+  for (i = 0; i < CONFIG_SKELETON_INT_NCALLBACKS; i++)
     {
       /* Is this entry valid (i.e., callback attached)?  If so, did andy of
        * the requested pin interrupts occur?
@@ -673,7 +711,7 @@ static void skel_irqworker(void *arg)
 #ifdef CONFIG_skeleton_INT_ENABLE
 static void skel_interrupt(FAR void *arg)
 {
-  FAR struct skel_dev_s *priv = (FAR struct skel_dev_s )arg;
+  FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)arg;
 
   DEBUGASSERT(priv != NULL);
 
@@ -742,8 +780,8 @@ FAR struct ioexpander_dev_s *skel_initialize(void)
   priv = &g_skel;
 #endif
 
-  /* Initialize the device state structure */
-  /* NOTE: Normally you would also save the I2C/SPI device interface and
+  /* Initialize the device state structure
+   * NOTE: Normally you would also save the I2C/SPI device interface and
    * any configuration information here as well.
    */
 
diff --git a/drivers/ioexpander/tca64xx.c b/drivers/ioexpander/tca64xx.c
index 82f5531..9f35927 100644
--- a/drivers/ioexpander/tca64xx.c
+++ b/drivers/ioexpander/tca64xx.c
@@ -12,29 +12,28 @@
  *   All rights reserved.
  *   Author:  Patrick Titiano, Jean Pihet
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ *    used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
  *
  ****************************************************************************/
 
@@ -75,8 +74,9 @@
 
 /* TCA64xx Helpers */
 
-static void tca64_lock(FAR struct tca64_dev_s *priv);
-static FAR const struct tca64_part_s *tca64_getpart(FAR struct tca64_dev_s 
*priv);
+static int tca64_lock(FAR struct tca64_dev_s *priv);
+static FAR const struct tca64_part_s *tca64_getpart(
+                          FAR struct tca64_dev_s *priv);
 static uint8_t tca64_ngpios(FAR struct tca64_dev_s *priv);
 static uint8_t tca64_input_reg(FAR struct tca64_dev_s *priv, uint8_t pin);
 static uint8_t tca64_output_reg(FAR struct tca64_dev_s *priv, uint8_t pin);
@@ -194,9 +194,9 @@ static const struct tca64_part_s 
g_tca64_parts[TCA64_NPARTS] =
  *
  ****************************************************************************/
 
-static void tca64_lock(FAR struct tca64_dev_s *priv)
+static int tca64_lock(FAR struct tca64_dev_s *priv)
 {
-  nxsem_wait_uninterruptible(&priv->exclsem);
+  return nxsem_wait_uninterruptible(&priv->exclsem);
 }
 
 #define tca64_unlock(p) nxsem_post(&(p)->exclsem)
@@ -209,7 +209,8 @@ static void tca64_lock(FAR struct tca64_dev_s *priv)
  *
  ****************************************************************************/
 
-static FAR const struct tca64_part_s *tca64_getpart(FAR struct tca64_dev_s 
*priv)
+static FAR const struct tca64_part_s *tca64_getpart(
+                          FAR struct tca64_dev_s *priv)
 {
   DEBUGASSERT(priv != NULL && priv->config != NULL &&
               priv->config->part < TCA64_NPARTS);
@@ -370,7 +371,7 @@ static int tca64_putreg(struct tca64_dev_s *priv, uint8_t 
regaddr,
 
   for (i = 0; i < count; i++)
     {
-      cmd[i+1] = regval[i];
+      cmd[i + 1] = regval[i];
     }
 
   msg[0].frequency = TCA64XX_I2C_MAXFREQUENCY,
@@ -429,7 +430,11 @@ static int tca64_direction(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
 
   /* Get exclusive access to the I/O Expander */
 
-  tca64_lock(priv);
+  ret = tca64_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Read the Configuration Register associated with this pin.  The
    * Configuration Register configures the direction of the I/O pins.
@@ -527,7 +532,11 @@ static int tca64_option(FAR struct ioexpander_dev_s *dev, 
uint8_t pin,
 
       /* Get exclusive access to the I/O Expander */
 
-      tca64_lock(priv);
+      ret = tca64_lock(priv);
+      if (ret < 0)
+        {
+          return ret;
+        }
 
       /* Read the polarity register */
 
@@ -572,8 +581,12 @@ static int tca64_option(FAR struct ioexpander_dev_s *dev, 
uint8_t pin,
       unsigned int ival = (unsigned int)((uintptr_t)value);
       ioe_pinset_t bit = ((ioe_pinset_t)1 << pin);
 
-      ret = OK;
-      tca64_lock(priv);
+      ret = tca64_lock(priv);
+      if (ret < 0)
+        {
+          return ret;
+        }
+
       switch (ival)
         {
           case IOEXPANDER_VAL_HIGH:    /* Interrupt on high level */
@@ -653,7 +666,11 @@ static int tca64_writepin(FAR struct ioexpander_dev_s 
*dev, uint8_t pin,
 
   /* Get exclusive access to the I/O Expander */
 
-  tca64_lock(priv);
+  ret = tca64_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Read the output register. */
 
@@ -698,14 +715,15 @@ errout_with_lock:
  * Name: tca64_readpin
  *
  * Description:
- *   Read the actual PIN level. This can be different from the last value 
written
- *   to this pin. Required.
+ *   Read the actual PIN level. This can be different from the last value
+ *   written to this pin. Required.
  *
  * Input Parameters:
  *   dev    - Device-specific state data
  *   pin    - The index of the pin
  *   valptr - Pointer to a buffer where the pin level is stored. Usually TRUE
- *            if the pin is high, except if OPTION_INVERT has been set on this 
pin.
+ *            if the pin is high, except if OPTION_INVERT has been set on
+ *            this pin.
  *
  * Returned Value:
  *   0 on success, else a negative error code
@@ -727,7 +745,11 @@ static int tca64_readpin(FAR struct ioexpander_dev_s *dev, 
uint8_t pin,
 
   /* Get exclusive access to the I/O Expander */
 
-  tca64_lock(priv);
+  ret = tca64_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Read the input register for this pin
    *
@@ -795,7 +817,11 @@ static int tca64_multiwritepin(FAR struct ioexpander_dev_s 
*dev,
 
   /* Get exclusive access to the I/O Expander */
 
-  tca64_lock(priv);
+  ret = tca64_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Read the output registers for pin 0 through the number of supported
    * pins.
@@ -884,7 +910,11 @@ static int tca64_multireadpin(FAR struct ioexpander_dev_s 
*dev,
 
   /* Get exclusive access to the I/O Expander */
 
-  tca64_lock(priv);
+  ret = tca64_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Read the input register for pin 0 through the number of supported pins.
    *
@@ -955,27 +985,32 @@ static FAR void *tca64_attach(FAR struct ioexpander_dev_s 
*dev,
   FAR struct tca64_dev_s *priv = (FAR struct tca64_dev_s *)dev;
   FAR void *handle = NULL;
   int i;
+  int ret;
 
   /* Get exclusive access to the I/O Expander */
 
-  tca64_lock(priv);
+  ret = tca64_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Find and available in entry in the callback table */
 
   for (i = 0; i < CONFIG_TCA64XX_INT_NCALLBACKS; i++)
     {
-       /* Is this entry available (i.e., no callback attached) */
-
-       if (priv->cb[i].cbfunc == NULL)
-         {
-           /* Yes.. use this entry */
-
-           priv->cb[i].pinset = pinset;
-           priv->cb[i].cbfunc = callback;
-           priv->cb[i].cbarg  = arg;
-           handle             = &priv->cb[i];
-           break;
-         }
+      /* Is this entry available (i.e., no callback attached) */
+
+      if (priv->cb[i].cbfunc == NULL)
+        {
+          /* Yes.. use this entry */
+
+          priv->cb[i].pinset = pinset;
+          priv->cb[i].cbfunc = callback;
+          priv->cb[i].cbarg  = arg;
+          handle             = &priv->cb[i];
+          break;
+        }
     }
 
   tca64_unlock(priv);
@@ -1004,7 +1039,8 @@ static int tca64_detach(FAR struct ioexpander_dev_s *dev, 
FAR void *handle)
 
   DEBUGASSERT(priv != NULL && cb != NULL);
   DEBUGASSERT((uintptr_t)cb >= (uintptr_t)&priv->cb[0] &&
-              (uintptr_t)cb <= 
(uintptr_t)&priv->cb[CONFIG_TCA64XX_INT_NCALLBACKS-1]);
+              (uintptr_t)cb <=
+              (uintptr_t)&priv->cb[CONFIG_TCA64XX_INT_NCALLBACKS - 1]);
   UNUSED(priv);
 
   cb->pinset = 0;
@@ -1023,7 +1059,8 @@ static int tca64_detach(FAR struct ioexpander_dev_s *dev, 
FAR void *handle)
  ****************************************************************************/
 
 #ifdef CONFIG_TCA64XX_INT_ENABLE
-static void tca64_int_update(FAR struct tca64_dev_s *priv, ioe_pinset_t input,
+static void tca64_int_update(FAR struct tca64_dev_s *priv,
+                             ioe_pinset_t input,
                              ioe_pinset_t mask)
 {
   ioe_pinset_t diff;
@@ -1152,7 +1189,11 @@ static void tca64_irqworker(void *arg)
 
   /* Get exclusive access to read inputs and assess pending interrupts. */
 
-  tca64_lock(priv);
+  ret = tca64_lock(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Read the input register for pin 0 through the number of supported pins.
    *
@@ -1346,7 +1387,7 @@ static void tca64_poll_expiry(int argc, wdparm_t arg1, 
...)
  ****************************************************************************/
 
 FAR struct ioexpander_dev_s *tca64_initialize(FAR struct i2c_master_s *i2c,
-                                              FAR struct tca64_config_s 
*config)
+                               FAR struct tca64_config_s *config)
 {
   FAR struct tca64_dev_s *priv;
   int ret;
diff --git a/drivers/sensors/apds9960.c b/drivers/sensors/apds9960.c
index 309e4a7..b12427a 100644
--- a/drivers/sensors/apds9960.c
+++ b/drivers/sensors/apds9960.c
@@ -481,7 +481,8 @@ static int apds9960_probe(FAR struct apds9960_dev_s *priv)
  ****************************************************************************/
 
 static int apds9960_i2c_read(FAR struct apds9960_dev_s *priv,
-                           uint8_t const regaddr, FAR uint8_t *regval, int len)
+                             uint8_t const regaddr,
+                             FAR uint8_t *regval, int len)
 {
   struct i2c_config_s config;
   int ret = -1;
@@ -1063,10 +1064,14 @@ static int apds9960_readgesture(FAR struct 
apds9960_dev_s *priv)
                 {
                   for (i = 0; i < bytes_read; i += 4)
                     {
-                      priv->gesture_data.u_data[priv->gesture_data.index] = 
fifo_data[i + 0];
-                      priv->gesture_data.d_data[priv->gesture_data.index] = 
fifo_data[i + 1];
-                      priv->gesture_data.l_data[priv->gesture_data.index] = 
fifo_data[i + 2];
-                      priv->gesture_data.r_data[priv->gesture_data.index] = 
fifo_data[i + 3];
+                      priv->gesture_data.u_data[priv->gesture_data.index] =
+                        fifo_data[i + 0];
+                      priv->gesture_data.d_data[priv->gesture_data.index] =
+                        fifo_data[i + 1];
+                      priv->gesture_data.l_data[priv->gesture_data.index] =
+                        fifo_data[i + 2];
+                      priv->gesture_data.r_data[priv->gesture_data.index] =
+                        fifo_data[i + 3];
                       priv->gesture_data.index++;
                       priv->gesture_data.total_gestures++;
                     }
@@ -1171,6 +1176,7 @@ static ssize_t apds9960_read(FAR struct file *filep, FAR 
char *buffer,
 {
   FAR struct inode         *inode;
   FAR struct apds9960_dev_s *priv;
+  int ret;
 
   DEBUGASSERT(filep);
   inode = filep->f_inode;
@@ -1188,7 +1194,11 @@ static ssize_t apds9960_read(FAR struct file *filep, FAR 
char *buffer,
 
   /* Wait for data available */
 
-  nxsem_wait_uninterruptible(&priv->sample_sem);
+  ret = nxsem_wait_uninterruptible(&priv->sample_sem);
+  if (ret < 0)
+    {
+      return (ssize_t)ret;
+    }
 
   buffer[0] = (char) priv->gesture_motion;
   buflen    = 1;
@@ -1218,7 +1228,7 @@ static ssize_t apds9960_write(FAR struct file *filep,
  *
  * Input Parameters:
  *   devpath - The full path to the driver to register. E.g., "/dev/gest0"
- *   i2c - An instance of the I2C interface to use to communicate with APDS9960
+ *   i2c - An instance of the I2C interface to communicate with APDS9960
  *   addr - The I2C address of the APDS9960.
  *
  * Returned Value:
diff --git a/drivers/sensors/dhtxx.c b/drivers/sensors/dhtxx.c
index 59908f4..7456533 100644
--- a/drivers/sensors/dhtxx.c
+++ b/drivers/sensors/dhtxx.c
@@ -1,35 +1,20 @@
 /****************************************************************************
- * include/nuttx/sensors/dhtxx.c
+ * drivers/sensors/dhtxx.c
  *
- *   Copyright (C) 2018 Abdelatif GUETTOUCHE. All rights reserved.
- *   Author: Abdelatif GUETTOUCHE <[email protected]>
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- *    used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
  *
  ****************************************************************************/
 
@@ -53,7 +38,7 @@
 #include <nuttx/semaphore.h>
 #include <nuttx/sensors/dhtxx.h>
 
-/*****************************************************************************
+/****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
 
@@ -428,12 +413,17 @@ static int dhtxx_open(FAR struct file *filep)
 {
   FAR struct inode        *inode = filep->f_inode;
   FAR struct dhtxx_dev_s  *priv  = inode->i_private;
+  int ret;
 
   /* Acquire the semaphore, wait the sampling time before sending anything to
    * pass unstable state.
    */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   dht_standby_mode(priv);
 
@@ -479,13 +469,17 @@ static ssize_t dhtxx_read(FAR struct file *filep, FAR 
char *buffer,
 
   if (buflen < sizeof(FAR struct dhtxx_sensor_data_s))
     {
-      snerr("ERROR: Not enough memory for reading out a sensor data 
sample.\n");
+      snerr("ERROR: Not enough memory to read data sample.\n");
       return -ENOSYS;
     }
 
   memset(priv->raw_data, 0u, sizeof(priv->raw_data));
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return (ssize_t)ret;
+    }
 
   dht_send_start_signal(priv);
 
@@ -587,7 +581,8 @@ static int dhtxx_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
  *
  ****************************************************************************/
 
-int dhtxx_register(FAR const char *devpath, FAR struct dhtxx_config_s *config)
+int dhtxx_register(FAR const char *devpath,
+                   FAR struct dhtxx_config_s *config)
 {
   FAR struct dhtxx_dev_s *priv;
   int ret;
diff --git a/drivers/sensors/hc_sr04.c b/drivers/sensors/hc_sr04.c
index 5ea7fb9..d598529 100644
--- a/drivers/sensors/hc_sr04.c
+++ b/drivers/sensors/hc_sr04.c
@@ -63,7 +63,7 @@
 
 /****************************************************************************
  * Private Function Prototypes
- *****************************************************************************/
+ ****************************************************************************/
 
 static int hcsr04_open(FAR struct file *filep);
 static int hcsr04_close(FAR struct file *filep);
@@ -149,8 +149,14 @@ static int hcsr04_open(FAR struct file *filep)
 {
   FAR struct inode *inode = filep->f_inode;
   FAR struct hcsr04_dev_s *priv = inode->i_private;
+  int ret;
+
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
-  nxsem_wait_uninterruptible(&priv->devsem);
   nxsem_post(&priv->devsem);
   hcsr04_dbg("OPENED\n");
   return OK;
@@ -160,8 +166,14 @@ static int hcsr04_close(FAR struct file *filep)
 {
   FAR struct inode *inode = filep->f_inode;
   FAR struct hcsr04_dev_s *priv = inode->i_private;
+  int ret;
+
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
-  nxsem_wait_uninterruptible(&priv->devsem);
   nxsem_post(&priv->devsem);
   hcsr04_dbg("CLOSED\n");
   return OK;
@@ -174,10 +186,15 @@ static ssize_t hcsr04_read(FAR struct file *filep, FAR 
char *buffer,
   FAR struct hcsr04_dev_s *priv = inode->i_private;
   int distance = 0;
   ssize_t length = 0;
+  int ret;
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return (ssize_t)ret;
+    }
 
   /* Setup and send a pulse to start measuring */
 
@@ -187,7 +204,11 @@ static ssize_t hcsr04_read(FAR struct file *filep, FAR 
char *buffer,
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->conv_donesem);
+  ret = nxsem_wait_uninterruptible(&priv->conv_donesem);
+  if (ret < 0)
+    {
+      return (ssize_t)ret;
+    }
 
   distance = hcsr04_read_distance(priv);
   if (distance < 0)
@@ -224,7 +245,11 @@ static int hcsr04_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   switch (cmd)
     {
@@ -267,8 +292,8 @@ static void hcsr04_notify(FAR struct hcsr04_dev_s *priv)
 
   /* If there are threads waiting on poll() for data to become available,
    * then wake them up now.  NOTE: we wake up all waiting threads because we
-   * do not know that they are going to do.  If they all try to read the data,
-   * then some make end up blocking after all.
+   * do not know that they are going to do.  If they all try to read the
+   * data, then some make end up blocking after all.
    */
 
   for (i = 0; i < CONFIG_HCSR04_NPOLLWAITERS; i++)
@@ -300,7 +325,11 @@ static int hcsr04_poll(FAR struct file *filep, FAR struct 
pollfd *fds,
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   if (setup)
     {
diff --git a/drivers/sensors/hts221.c b/drivers/sensors/hts221.c
index 0b2c081..e803150 100644
--- a/drivers/sensors/hts221.c
+++ b/drivers/sensors/hts221.c
@@ -120,7 +120,7 @@
 
 /****************************************************************************
  * Private Function Prototypes
- *****************************************************************************/
+ ****************************************************************************/
 
 static int hts221_open(FAR struct file *filep);
 static int hts221_close(FAR struct file *filep);
@@ -333,7 +333,8 @@ static int hts221_config_ctrl_reg3(FAR struct hts221_dev_s 
*priv,
     }
 
   regval &= ~mask;
-  regval |= (uint8_t)(settings->is_high_edge ? 0 : HTS221_CTRL_REG3_DRDY_L_H);
+  regval |= (uint8_t)(settings->is_high_edge ?
+                      0 : HTS221_CTRL_REG3_DRDY_L_H);
   regval |= (uint8_t)(settings->is_open_drain ? HTS221_CTRL_REG3_PP_OD : 0);
   regval |= (uint8_t)(settings->is_data_rdy ? HTS221_CTRL_REG3_DRDY_EN : 0);
 
@@ -623,7 +624,8 @@ static int hts221_read_raw_data(FAR struct hts221_dev_s 
*priv,
 
   /* Add low-order bytes to entropy pool. */
 
-  add_sensor_randomness(((uint32_t)data->humid_low_bits << 8) | 
data->temp_low_bits);
+  add_sensor_randomness(((uint32_t)data->humid_low_bits << 8) |
+                        data->temp_low_bits);
 
   flags = enter_critical_section();
   priv->int_pending = false;
@@ -803,18 +805,20 @@ static int hts221_calculate_humidity(FAR struct 
hts221_dev_s *priv,
                                      FAR unsigned int *humidity,
                                      FAR hts221_raw_data_t *raw_data)
 {
-  int16_t h_out = (raw_data->humid_high_bits << 8) | raw_data->humid_low_bits;
+  int16_t h_out;
   int x0 = priv->calib.h0_t0_out;
   int x1 = priv->calib.h1_t0_out;
   int y0 = priv->calib.h0_x2;
   int y1 = priv->calib.h1_x2;
-  int x = h_out;
+  int x;
   int64_t y;
   int x1_x0_diff;
 
+  h_out = (raw_data->humid_high_bits << 8) | raw_data->humid_low_bits;
+  x = h_out;
   x1_x0_diff = x1 - x0;
 
-  y = (y0 * x1_x0_diff + (y1 - y0) * (x - x0));
+  y  = (y0 * x1_x0_diff + (y1 - y0) * (x - x0));
   y *= HTS221_HUMIDITY_PRECISION;
   y /= x1_x0_diff * 2;
 
@@ -904,10 +908,15 @@ static int hts221_open(FAR struct file *filep)
 {
   FAR struct inode *inode = filep->f_inode;
   FAR struct hts221_dev_s *priv = inode->i_private;
+  int ret;
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   priv->config->set_power(priv->config, true);
   priv->config->irq_enable(priv->config, true);
@@ -925,7 +934,11 @@ static int hts221_close(FAR struct file *filep)
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   priv->config->irq_enable(priv->config, false);
   ret = hts221_power_on_off(priv, false);
@@ -947,7 +960,11 @@ static ssize_t hts221_read(FAR struct file *filep, FAR 
char *buffer,
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return (ssize_t)ret;
+    }
 
   ret = hts221_read_convert_data(priv, &data);
   if (ret < 0)
@@ -985,7 +1002,11 @@ static int hts221_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   switch (cmd)
     {
@@ -1032,10 +1053,10 @@ static bool hts221_sample(FAR struct hts221_dev_s *priv)
 {
   int ret;
   hts221_status_t status =
-  {
-    .is_humid_ready = false,
-    .is_temp_ready = false
-  };
+    {
+      .is_humid_ready = false,
+      .is_temp_ready = false
+    };
 
   ret = hts221_check_status(priv, &status);
   if (ret < 0)
@@ -1054,8 +1075,8 @@ static void hts221_notify(FAR struct hts221_dev_s *priv)
 
   /* If there are threads waiting on poll() for data to become available,
    * then wake them up now.  NOTE: we wake up all waiting threads because we
-   * do not know that they are going to do.  If they all try to read the data,
-   * then some make end up blocking after all.
+   * do not know that they are going to do.  If they all try to read the
+   * data, then some make end up blocking after all.
    */
 
   for (i = 0; i < CONFIG_HTS221_NPOLLWAITERS; i++)
@@ -1087,7 +1108,11 @@ static int hts221_poll(FAR struct file *filep, FAR 
struct pollfd *fds,
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   if (setup)
     {
diff --git a/drivers/sensors/kxtj9.c b/drivers/sensors/kxtj9.c
index e333c77..c35693d 100644
--- a/drivers/sensors/kxtj9.c
+++ b/drivers/sensors/kxtj9.c
@@ -10,28 +10,31 @@
  *   All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ *    used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
  *
  ****************************************************************************/
 
@@ -341,8 +344,13 @@ static void kxtj9_set_mode_standby(FAR struct kxtj9_dev_s 
*priv)
 static int kxtj9_configure(FAR struct kxtj9_dev_s *priv, uint8_t odr)
 {
   uint8_t wbuf[0];
+  int ret;
 
-  nxsem_wait_uninterruptible(&priv->exclsem);
+  ret = nxsem_wait_uninterruptible(&priv->exclsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   kxtj9_soft_reset(priv);
   kxtj9_set_mode_standby(priv);
@@ -389,8 +397,13 @@ static int kxtj9_configure(FAR struct kxtj9_dev_s *priv, 
uint8_t odr)
 static int kxtj9_enable(FAR struct kxtj9_dev_s *priv, bool on)
 {
   uint8_t wbuf[1];
+  int ret;
 
-  nxsem_wait_uninterruptible(&priv->exclsem);
+  ret = nxsem_wait_uninterruptible(&priv->exclsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   if (!on && priv->power_enabled)
     {
@@ -431,8 +444,13 @@ static int kxtj9_read_sensor_data(FAR struct kxtj9_dev_s 
*priv,
 {
   int16_t acc_data[3];
   uint8_t data;
+  int ret;
 
-  nxsem_wait_uninterruptible(&priv->exclsem);
+  ret = nxsem_wait_uninterruptible(&priv->exclsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   kxtj9_reg_read(priv, XOUT_L, (uint8_t *)acc_data, 6);
 
@@ -525,7 +543,8 @@ static ssize_t kxtj9_read(FAR struct file *filep, FAR char 
*buffer,
     {
       /* Get the next sample data */
 
-      ret = kxtj9_read_sensor_data(priv, (FAR struct kxtj9_sensor_data 
*)buffer);
+      ret = kxtj9_read_sensor_data(priv,
+                                   (FAR struct kxtj9_sensor_data *)buffer);
       if (ret < 0)
         {
           snerr("ERROR: kxtj9_read_sensor_data failed: %d\n", ret);
diff --git a/drivers/sensors/lps25h.c b/drivers/sensors/lps25h.c
index 34a0bb2..7efc611 100644
--- a/drivers/sensors/lps25h.c
+++ b/drivers/sensors/lps25h.c
@@ -343,7 +343,11 @@ static int lps25h_open(FAR struct file *filep)
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&dev->devsem);
+  ret = nxsem_wait_uninterruptible(&dev->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   dev->config->set_power(dev->config, true);
   ret = lps25h_read_reg8(dev, &addr, &value);
@@ -372,7 +376,11 @@ static int lps25h_close(FAR struct file *filep)
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&dev->devsem);
+  ret = nxsem_wait_uninterruptible(&dev->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   dev->config->irq_enable(dev->config, false);
   dev->irqenabled = false;
@@ -395,7 +403,11 @@ static ssize_t lps25h_read(FAR struct file *filep, FAR 
char *buffer,
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&dev->devsem);
+  ret = nxsem_wait_uninterruptible(&dev->devsem);
+  if (ret < 0)
+    {
+      return (ssize_t)ret;
+    }
 
   ret = lps25h_configure_dev(dev);
   if (ret < 0)
@@ -706,7 +718,11 @@ static int lps25h_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&dev->devsem);
+  ret = nxsem_wait_uninterruptible(&dev->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   switch (cmd)
     {
diff --git a/drivers/sensors/max44009.c b/drivers/sensors/max44009.c
index 1f002aa..64dfa10 100644
--- a/drivers/sensors/max44009.c
+++ b/drivers/sensors/max44009.c
@@ -106,7 +106,8 @@ static ssize_t max44009_read(FAR struct file *filep, FAR 
char *buffer,
                              size_t buflen);
 static ssize_t max44009_write(FAR struct file *filep, FAR const char *buffer,
                               size_t buflen);
-static int max44009_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
+static int max44009_ioctl(FAR struct file *filep, int cmd,
+                          unsigned long arg);
 static int max44009_poll(FAR struct file *filep, FAR struct pollfd *fds,
                          bool setup);
 
@@ -235,7 +236,11 @@ static int max44009_open(FAR struct file *filep)
   DEBUGASSERT(inode && inode->i_private);
   priv = (FAR struct max44009_dev_s *)inode->i_private;
 
-  nxsem_wait_uninterruptible(&priv->dev_sem);
+  ret = nxsem_wait_uninterruptible(&priv->dev_sem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   use_count = priv->cref + 1;
   if (use_count == 1)
@@ -272,6 +277,7 @@ static int max44009_close(FAR struct file *filep)
   FAR struct inode *inode;
   FAR struct max44009_dev_s *priv;
   int use_count;
+  int ret;
 
   DEBUGASSERT(filep);
   inode = filep->f_inode;
@@ -279,7 +285,11 @@ static int max44009_close(FAR struct file *filep)
   DEBUGASSERT(inode && inode->i_private);
   priv = (FAR struct max44009_dev_s *)inode->i_private;
 
-  nxsem_wait_uninterruptible(&priv->dev_sem);
+  ret = nxsem_wait_uninterruptible(&priv->dev_sem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   use_count = priv->cref - 1;
   if (use_count == 0)
@@ -318,7 +328,11 @@ static ssize_t max44009_read(FAR struct file *filep, FAR 
char *buffer,
   DEBUGASSERT(inode && inode->i_private);
   priv = (FAR struct max44009_dev_s *)inode->i_private;
 
-  nxsem_wait_uninterruptible(&priv->dev_sem);
+  ret = nxsem_wait_uninterruptible(&priv->dev_sem);
+  if (ret < 0)
+    {
+      return (ssize_t)ret;
+    }
 
   ret = max44009_read_data(priv, &data);
   if (ret < 0)
@@ -665,7 +679,8 @@ static int max44009_read_data(FAR struct max44009_dev_s 
*priv,
    *
    * E[3..0] = Exponent, M[7..0]: Mantissa.
    *
-   * Lux can be calculated as (full resolution): (M[7..0] << E[3..0]) * 0.045.
+   * Lux can be calculated as (full resolution):
+   *     (M[7..0] << E[3..0]) * 0.045.
    *
    * Lux can also be calculated using only HBYTE:
    *     (M[7..4] << E[3..0]) * 0.72
@@ -717,7 +732,11 @@ static int max44009_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
   DEBUGASSERT(inode && inode->i_private);
   priv = (FAR struct max44009_dev_s *)inode->i_private;
 
-  nxsem_wait_uninterruptible(&priv->dev_sem);
+  ret = nxsem_wait_uninterruptible(&priv->dev_sem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   switch (cmd)
     {
@@ -787,7 +806,11 @@ static int max44009_poll(FAR struct file *filep, FAR 
struct pollfd *fds,
   DEBUGASSERT(inode && inode->i_private);
   priv = (FAR struct max44009_dev_s *)inode->i_private;
 
-  nxsem_wait_uninterruptible(&priv->dev_sem);
+  ret = nxsem_wait_uninterruptible(&priv->dev_sem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   if (setup)
     {
@@ -799,8 +822,8 @@ static int max44009_poll(FAR struct file *filep, FAR struct 
pollfd *fds,
           goto out;
         }
 
-      /* This is a request to set up the poll.  Find an available slot for the
-       * poll structure reference.
+      /* This is a request to set up the poll.  Find an available slot for
+       * the poll structure reference.
        */
 
       for (i = 0; i < CONFIG_MAX44009_NPOLLWAITERS; i++)
diff --git a/drivers/sensors/scd30.c b/drivers/sensors/scd30.c
index 28dacb2..dcde8c5 100644
--- a/drivers/sensors/scd30.c
+++ b/drivers/sensors/scd30.c
@@ -153,8 +153,9 @@ static void scd30_set_command_param(FAR struct scd30_word_s 
*param,
                                     uint16_t value);
 static int scd30_check_data_crc(FAR const struct scd30_word_s *words,
                                 unsigned int num_words);
-static uint16_t scd30_data_word_to_uint16(FAR const struct scd30_word_s *word);
-static float scd30_data_words_to_float(FAR const struct scd30_word_s words[2]);
+static uint16_t scd30_data_word2uint16(FAR const struct scd30_word_s *word);
+static float scd30_data_words_to_float(
+                                FAR const struct scd30_word_s words[2]);
 
 /* Driver features */
 
@@ -361,7 +362,8 @@ static void scd30_set_command_param(FAR struct scd30_word_s 
*param,
  * Name: scd30_data_words_to_float
  ****************************************************************************/
 
-static float scd30_data_words_to_float(FAR const struct scd30_word_s words[2])
+static float scd30_data_words_to_float(
+  FAR const struct scd30_word_s words[2])
 {
   uint8_t data[4];
   float value;
@@ -375,10 +377,10 @@ static float scd30_data_words_to_float(FAR const struct 
scd30_word_s words[2])
 }
 
 /****************************************************************************
- * Name: scd30_data_word_to_uint16
+ * Name: scd30_data_word2uint16
  ****************************************************************************/
 
-static uint16_t scd30_data_word_to_uint16(FAR const struct scd30_word_s *word)
+static uint16_t scd30_data_word2uint16(FAR const struct scd30_word_s *word)
 {
   return (word[0].data[0] << 8) | (word[0].data[1]);
 }
@@ -392,7 +394,7 @@ static int scd30_check_data_crc(FAR const struct 
scd30_word_s *words,
 {
   while (num_words)
     {
-      if (scd30_crc_word(scd30_data_word_to_uint16(words)) != words->crc)
+      if (scd30_crc_word(scd30_data_word2uint16(words)) != words->crc)
         {
           return -1;
         }
@@ -487,7 +489,7 @@ static int scd30_read_values(FAR struct scd30_dev_s *priv, 
FAR float *temp,
               return ret;
             }
 
-          if (scd30_data_word_to_uint16(data) != 0x0001)
+          if (scd30_data_word2uint16(data) != 0x0001)
             {
               if (!wait)
                 {
@@ -614,7 +616,11 @@ static int scd30_open(FAR struct file *filep)
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Increment the count of open references on the driver */
 
@@ -649,10 +655,15 @@ static int scd30_close(FAR struct file *filep)
 {
   FAR struct inode       *inode = filep->f_inode;
   FAR struct scd30_dev_s *priv  = inode->i_private;
+  int ret;
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Decrement the count of open references on the driver */
 
@@ -695,7 +706,11 @@ static ssize_t scd30_read(FAR struct file *filep, FAR char 
*buffer,
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return (ssize_t)ret;
+    }
 
 #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
   if (priv->unlinked)
@@ -765,7 +780,11 @@ static int scd30_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
 #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
   if (priv->unlinked)
@@ -804,7 +823,8 @@ static int scd30_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
           /* Start measurements (and set pressure compensation). */
 
           scd30_set_command_param(&param, priv->pressure_comp);
-          ret = scd30_write_cmd(priv, SCD30_CMD_START_MEASUREMENT, &param, 1);
+          ret = scd30_write_cmd(priv, SCD30_CMD_START_MEASUREMENT,
+                                &param, 1);
           if (ret >= 0)
             {
               priv->started = true;
@@ -972,13 +992,18 @@ static int scd30_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
 static int scd30_unlink(FAR struct inode *inode)
 {
   FAR struct scd30_dev_s *priv;
+  int ret;
 
   DEBUGASSERT(inode != NULL && inode->i_private != NULL);
   priv = (FAR struct scd30_dev_s *)inode->i_private;
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Are there open references to the driver data structure? */
 
diff --git a/drivers/sensors/sgp30.c b/drivers/sensors/sgp30.c
index 5a8ce07..bed0ada 100644
--- a/drivers/sensors/sgp30.c
+++ b/drivers/sensors/sgp30.c
@@ -114,10 +114,12 @@ struct sgp30_cmd_s
 static int sgp30_do_transfer(FAR struct i2c_master_s *i2c,
                              FAR struct i2c_msg_s *msgv,
                              size_t nmsg);
-static int sgp30_write_cmd(FAR struct sgp30_dev_s *priv, struct sgp30_cmd_s 
cmd,
+static int sgp30_write_cmd(FAR struct sgp30_dev_s *priv,
+                           struct sgp30_cmd_s cmd,
                            FAR struct sgp30_word_s *params,
                            unsigned int num_params);
-static int sgp30_read_cmd(FAR struct sgp30_dev_s *priv, struct sgp30_cmd_s cmd,
+static int sgp30_read_cmd(FAR struct sgp30_dev_s *priv,
+                          struct sgp30_cmd_s cmd,
                           FAR struct sgp30_word_s *words,
                           unsigned int num_words);
 
@@ -128,7 +130,8 @@ static void sgp30_set_command_param(FAR struct sgp30_word_s 
*param,
                                     uint16_t value);
 static int sgp30_check_data_crc(FAR const struct sgp30_word_s *words,
                                 unsigned int num_words);
-static uint16_t sgp30_data_word_to_uint16(FAR const struct sgp30_word_s *word);
+static uint16_t sgp30_data_word_to_uint16(
+                                FAR const struct sgp30_word_s *word);
 
 /* Driver features */
 
@@ -273,7 +276,8 @@ static int sgp30_do_transfer(FAR struct i2c_master_s *i2c,
  * Name: sgp30_write_cmd
  ****************************************************************************/
 
-static int sgp30_write_cmd(FAR struct sgp30_dev_s *priv, struct sgp30_cmd_s 
cmd,
+static int sgp30_write_cmd(FAR struct sgp30_dev_s *priv,
+                           struct sgp30_cmd_s cmd,
                            FAR struct sgp30_word_s *params,
                            unsigned int num_params)
 {
@@ -310,7 +314,8 @@ static int sgp30_write_cmd(FAR struct sgp30_dev_s *priv, 
struct sgp30_cmd_s cmd,
  * Name: sgp30_read_cmd
  ****************************************************************************/
 
-static int sgp30_read_cmd(FAR struct sgp30_dev_s *priv, struct sgp30_cmd_s cmd,
+static int sgp30_read_cmd(FAR struct sgp30_dev_s *priv,
+                          struct sgp30_cmd_s cmd,
                           FAR struct sgp30_word_s *words,
                           unsigned int num_words)
 {
@@ -415,7 +420,8 @@ static void sgp30_set_command_param(FAR struct sgp30_word_s 
*param,
  * Name: sgp30_data_word_to_uint16
  ****************************************************************************/
 
-static uint16_t sgp30_data_word_to_uint16(FAR const struct sgp30_word_s *word)
+static uint16_t sgp30_data_word_to_uint16(
+    FAR const struct sgp30_word_s *word)
 {
   return (word[0].data[0] << 8) | (word[0].data[1]);
 }
@@ -567,7 +573,11 @@ static int sgp30_open(FAR struct file *filep)
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Increment the count of open references on the driver */
 
@@ -581,10 +591,12 @@ static int sgp30_open(FAR struct file *filep)
 
       if (sgp30_read_cmd(priv, SGP30_CMD_GET_SERIAL_ID, serial, 3) >= 0
           && sgp30_check_data_crc(serial, 3) >= 0 &&
-          sgp30_read_cmd(priv, SGP30_CMD_GET_FEATURE_SET_VERSION, buf, 1) >= 0
+          sgp30_read_cmd(priv,
+                         SGP30_CMD_GET_FEATURE_SET_VERSION, buf, 1) >= 0
           && sgp30_check_data_crc(buf, 1) >= 0)
         {
-          struct timespec start, curr;
+          struct timespec start;
+          struct timespec curr;
           sgp30_dbg("serial id: %04x-%04x-%04x\n",
                     sgp30_data_word_to_uint16(serial + 0),
                     sgp30_data_word_to_uint16(serial + 1),
@@ -599,23 +611,26 @@ static int sgp30_open(FAR struct file *filep)
           ret = sgp30_write_cmd(priv, SGP30_CMD_INIT_AIR_QUALITY, NULL, 0);
           if (ret < 0)
             {
-              sgp30_dbg("sgp30_write_cmd(SGP30_CMD_INIT_AIR_QUALITY) failed, 
%d\n",
-                        ret);
+              sgp30_dbg("sgp30_write_cmd(SGP30_CMD_INIT_AIR_QUALITY)"
+                         " failed, %d\n", ret);
             }
           else
             {
               uint32_t repeat = SGP30_INIT_RETRIES;
               clock_gettime(CLOCK_REALTIME, &curr);
               sgp30_dbg("sgp30_write_cmd(SGP30_CMD_INIT_AIR_QUALITY)\n");
-              while (repeat-- && time_has_passed_ms(&curr, &start, 
SGP30_INIT_LIMIT_MS))
+              while (repeat-- &&
+                     time_has_passed_ms(&curr, &start, SGP30_INIT_LIMIT_MS))
                 {
-                  /* Infrequently the SGP30_CMD_INIT_AIR_QUALITY message 
delivery
-                   * takes suspiciously long time (SGP30_INIT_LIMIT_MS or 
more) and
-                   * in these cases the TVOC values will never reach the 
correct
-                   * level (not even after 24 hours).
-                   * If this delay is detected, the sensor is given a "General 
Call"
-                   * soft reset as described in the SGP30 datasheet and 
initialization
-                   * is tried again after CONFIG_SGP30_RESET_DELAY_US.
+                  /* Infrequently the SGP30_CMD_INIT_AIR_QUALITY message
+                   * delivery takes suspiciously long time
+                   * (SGP30_INIT_LIMIT_MS or more) and in these cases the
+                   * TVOC values will never reach the correct level (not
+                   * even after 24 hours).
+                   * If this delay is detected, the sensor is given a
+                   * "General Call" soft reset as described in the SGP30
+                   * datasheet and initialization is tried again after
+                   * CONFIG_SGP30_RESET_DELAY_US.
                    */
 
                   ret = sgp30_soft_reset(priv);
@@ -624,14 +639,17 @@ static int sgp30_open(FAR struct file *filep)
                       sgp30_dbg("sgp30_soft_reset failed, %d\n", ret);
                       return ret;
                     }
+
                   nxsig_usleep(CONFIG_SGP30_RESET_DELAY_US);
 
                   clock_gettime(CLOCK_REALTIME, &start);
-                  ret = sgp30_write_cmd(priv, SGP30_CMD_INIT_AIR_QUALITY, 
NULL, 0);
+                  ret = sgp30_write_cmd(priv, SGP30_CMD_INIT_AIR_QUALITY,
+                                        NULL, 0);
                   clock_gettime(CLOCK_REALTIME, &curr);
                   if (ret < 0)
                     {
-                      sgp30_dbg("sgp30_write_cmd(SGP30_CMD_INIT_AIR_QUALITY) 
failed, %d\n", ret);
+                      sgp30_dbg("sgp30_write_cmd(SGP30_CMD_INIT_AIR_QUALITY)"
+                                 " failed, %d\n", ret);
                     }
                 }
             }
@@ -666,10 +684,15 @@ static int sgp30_close(FAR struct file *filep)
 {
   FAR struct inode       *inode = filep->f_inode;
   FAR struct sgp30_dev_s *priv  = inode->i_private;
+  int ret;
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Decrement the count of open references on the driver */
 
@@ -709,7 +732,11 @@ static ssize_t sgp30_read(FAR struct file *filep, FAR char 
*buffer,
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
 #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
   if (priv->unlinked)
@@ -804,7 +831,11 @@ static int sgp30_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
 #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
   if (priv->unlinked)
@@ -968,13 +999,18 @@ static int sgp30_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
 static int sgp30_unlink(FAR struct inode *inode)
 {
   FAR struct sgp30_dev_s *priv;
+  int ret;
 
   DEBUGASSERT(inode != NULL && inode->i_private != NULL);
   priv = (FAR struct sgp30_dev_s *)inode->i_private;
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Are there open references to the driver data structure? */
 
diff --git a/drivers/sensors/sht21.c b/drivers/sensors/sht21.c
index 7b84348..e511293 100644
--- a/drivers/sensors/sht21.c
+++ b/drivers/sensors/sht21.c
@@ -382,10 +382,15 @@ static int sht21_open(FAR struct file *filep)
 {
   FAR struct inode       *inode = filep->f_inode;
   FAR struct sht21_dev_s *priv  = inode->i_private;
+  int ret;
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Increment the count of open references on the driver */
 
@@ -410,10 +415,15 @@ static int sht21_close(FAR struct file *filep)
 {
   FAR struct inode       *inode = filep->f_inode;
   FAR struct sht21_dev_s *priv  = inode->i_private;
+  int ret;
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Decrement the count of open references on the driver */
 
@@ -440,7 +450,8 @@ static int sht21_close(FAR struct file *filep)
  * Name: sht21_read
  ****************************************************************************/
 
-static ssize_t sht21_read(FAR struct file *filep, FAR char *buffer, size_t 
buflen)
+static ssize_t sht21_read(FAR struct file *filep, FAR char *buffer,
+                          size_t buflen)
 {
   FAR struct inode       *inode  = filep->f_inode;
   FAR struct sht21_dev_s *priv   = inode->i_private;
@@ -451,7 +462,11 @@ static ssize_t sht21_read(FAR struct file *filep, FAR char 
*buffer, size_t bufle
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return (ssize_t)ret;
+    }
 
 #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
   if (priv->unlinked)
@@ -507,7 +522,11 @@ static int sht21_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
 #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
   if (priv->unlinked)
@@ -582,13 +601,18 @@ static int sht21_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
 static int sht21_unlink(FAR struct inode *inode)
 {
   FAR struct sht21_dev_s *priv;
+  int ret;
 
   DEBUGASSERT(inode != NULL && inode->i_private != NULL);
   priv = (FAR struct sht21_dev_s *)inode->i_private;
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Are there open references to the driver data structure? */
 
diff --git a/drivers/sensors/sht3x.c b/drivers/sensors/sht3x.c
index 0d7b57a..008dd91 100644
--- a/drivers/sensors/sht3x.c
+++ b/drivers/sensors/sht3x.c
@@ -320,10 +320,10 @@ static uint8_t sht3x_crc_word(uint16_t word)
 }
 
 /****************************************************************************
- * Name: sht3x_data_word_to_uint16
+ * Name: sht3x_data_word2uint16
  ****************************************************************************/
 
-static uint16_t sht3x_data_word_to_uint16(FAR const struct sht3x_word_s *word)
+static uint16_t sht3x_data_word2uint16(FAR const struct sht3x_word_s *word)
 {
   return (word[0].data[0] << 8) | (word[0].data[1]);
 }
@@ -337,7 +337,7 @@ static int sht3x_check_data_crc(FAR const struct 
sht3x_word_s *words,
 {
   while (num_words)
     {
-      if (sht3x_crc_word(sht3x_data_word_to_uint16(words)) != words->crc)
+      if (sht3x_crc_word(sht3x_data_word2uint16(words)) != words->crc)
         {
           return -1;
         }
@@ -427,8 +427,8 @@ static int sht3x_read_values(FAR struct sht3x_dev_s *priv,
       return ret;
     }
 
-  temp16 = sht3x_data_word_to_uint16(data);
-  rh16 = sht3x_data_word_to_uint16(&data[1]);
+  temp16 = sht3x_data_word2uint16(data);
+  rh16 = sht3x_data_word2uint16(&data[1]);
   add_sensor_randomness(ts.tv_nsec ^ ((int)temp16 << 16 | rh16));
 
   priv->data.temperature = sht3x_temp_to_celsius(temp16);
@@ -453,10 +453,15 @@ static int sht3x_open(FAR struct file *filep)
 {
   FAR struct inode       *inode = filep->f_inode;
   FAR struct sht3x_dev_s *priv  = inode->i_private;
+  int ret;
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Increment the count of open references on the driver */
 
@@ -481,10 +486,15 @@ static int sht3x_close(FAR struct file *filep)
 {
   FAR struct inode       *inode = filep->f_inode;
   FAR struct sht3x_dev_s *priv  = inode->i_private;
+  int ret;
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Decrement the count of open references on the driver */
 
@@ -541,7 +551,11 @@ static int sht3x_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
 #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
   if (priv->unlinked)
@@ -609,13 +623,18 @@ static int sht3x_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
 static int sht3x_unlink(FAR struct inode *inode)
 {
   FAR struct sht3x_dev_s *priv;
+  int ret;
 
   DEBUGASSERT(inode != NULL && inode->i_private != NULL);
   priv = (FAR struct sht3x_dev_s *)inode->i_private;
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Are there open references to the driver data structure? */
 
diff --git a/drivers/sensors/sps30.c b/drivers/sensors/sps30.c
index 1054720..e42bc14 100644
--- a/drivers/sensors/sps30.c
+++ b/drivers/sensors/sps30.c
@@ -145,8 +145,8 @@ static void sps30_set_command_param(FAR struct sps30_word_s 
*param,
                                     uint16_t value);
 static int sps30_check_data_crc(FAR const struct sps30_word_s *words,
                                 unsigned int num_words);
-static uint16_t sps30_data_word_to_uint16(FAR const struct sps30_word_s *word);
-static float sps30_data_words_to_float(FAR const struct sps30_word_s words[2]);
+static uint16_t sps30_data_word2uint16(FAR const struct sps30_word_s *word);
+static float sps30_data_words2float(FAR const struct sps30_word_s words[2]);
 
 /* Driver features */
 
@@ -372,10 +372,10 @@ static void sps30_set_command_param(FAR struct 
sps30_word_s *param,
 }
 
 /****************************************************************************
- * Name: sps30_data_words_to_float
+ * Name: sps30_data_words2float
  ****************************************************************************/
 
-static float sps30_data_words_to_float(FAR const struct sps30_word_s words[2])
+static float sps30_data_words2float(FAR const struct sps30_word_s words[2])
 {
   uint8_t data[4];
   float value;
@@ -389,10 +389,10 @@ static float sps30_data_words_to_float(FAR const struct 
sps30_word_s words[2])
 }
 
 /****************************************************************************
- * Name: sps30_data_word_to_uint16
+ * Name: sps30_data_word2uint16
  ****************************************************************************/
 
-static uint16_t sps30_data_word_to_uint16(FAR const struct sps30_word_s *word)
+static uint16_t sps30_data_word2uint16(FAR const struct sps30_word_s *word)
 {
   return (word[0].data[0] << 8) | (word[0].data[1]);
 }
@@ -406,7 +406,7 @@ static int sps30_check_data_crc(FAR const struct 
sps30_word_s *words,
 {
   while (num_words)
     {
-      if (sps30_crc_word(sps30_data_word_to_uint16(words)) != words->crc)
+      if (sps30_crc_word(sps30_data_word2uint16(words)) != words->crc)
         {
           return -1;
         }
@@ -493,7 +493,7 @@ static int sps30_read_values(FAR struct sps30_dev_s *priv,
               return ret;
             }
 
-          if (sps30_data_word_to_uint16(data) != 0x0001)
+          if (sps30_data_word2uint16(data) != 0x0001)
             {
               if (!wait)
                 {
@@ -542,25 +542,25 @@ static int sps30_read_values(FAR struct sps30_dev_s *priv,
                             ((data[18].crc ^ data[19].crc) << 8));
 
       priv->data.mass_concenration_pm1_0 =
-          sps30_data_words_to_float(data + 0);
+          sps30_data_words2float(data + 0);
       priv->data.mass_concenration_pm2_5 =
-          sps30_data_words_to_float(data + 2);
+          sps30_data_words2float(data + 2);
       priv->data.mass_concenration_pm4_0 =
-          sps30_data_words_to_float(data + 4);
+          sps30_data_words2float(data + 4);
       priv->data.mass_concenration_pm10 =
-          sps30_data_words_to_float(data + 6);
+          sps30_data_words2float(data + 6);
       priv->data.number_concenration_pm0_5 =
-          sps30_data_words_to_float(data + 8);
+          sps30_data_words2float(data + 8);
       priv->data.number_concenration_pm1_0 =
-          sps30_data_words_to_float(data + 10);
+          sps30_data_words2float(data + 10);
       priv->data.number_concenration_pm2_5 =
-          sps30_data_words_to_float(data + 12);
+          sps30_data_words2float(data + 12);
       priv->data.number_concenration_pm4_0 =
-          sps30_data_words_to_float(data + 14);
+          sps30_data_words2float(data + 14);
       priv->data.number_concenration_pm10 =
-          sps30_data_words_to_float(data + 16);
+          sps30_data_words2float(data + 16);
       priv->data.typical_particle_size =
-          sps30_data_words_to_float(data + 18);
+          sps30_data_words2float(data + 18);
       priv->last_update = ts;
       priv->valid = true;
 
@@ -665,17 +665,24 @@ static int sps30_open(FAR struct file *filep)
 {
   FAR struct inode *inode = filep->f_inode;
   FAR struct sps30_dev_s *priv  = inode->i_private;
-  union
-  {
-    uint32_t u32[8];
-    char c[32];
-  } code, sn;
+  union article_u
+    {
+      uint32_t u32[8];
+      char c[32];
+    };
+
+  union article_u code;
+  union article_u sn;
 
   int ret;
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Increment the count of open references on the driver */
 
@@ -738,10 +745,15 @@ static int sps30_close(FAR struct file *filep)
 {
   FAR struct inode       *inode = filep->f_inode;
   FAR struct sps30_dev_s *priv  = inode->i_private;
+  int ret;
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Decrement the count of open references on the driver */
 
@@ -780,7 +792,11 @@ static ssize_t sps30_read(FAR struct file *filep, FAR char 
*buffer,
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
 #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
   if (priv->unlinked)
@@ -865,7 +881,11 @@ static int sps30_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
 #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
   if (priv->unlinked)
@@ -899,7 +919,8 @@ static int sps30_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
           /* Start measurements (and set pressure compensation). */
 
           sps30_set_command_param(&param, SPS30_MEASUREMENT_MODE);
-          ret = sps30_write_cmd(priv, SPS30_CMD_START_MEASUREMENT, &param, 1);
+          ret = sps30_write_cmd(priv, SPS30_CMD_START_MEASUREMENT,
+                                &param, 1);
           if (ret >= 0)
             {
               priv->started = true;
@@ -989,13 +1010,18 @@ static int sps30_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
 static int sps30_unlink(FAR struct inode *inode)
 {
   FAR struct sps30_dev_s *priv;
+  int ret;
 
   DEBUGASSERT(inode != NULL && inode->i_private != NULL);
   priv = (FAR struct sps30_dev_s *)inode->i_private;
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Are there open references to the driver data structure? */
 
@@ -1028,7 +1054,7 @@ static int sps30_unlink(FAR struct inode *inode)
  *   Register the SPS30 character device as 'devpath'
  *
  * Input Parameters:
- *   devpath - The full path to the driver to register. E.g., "/dev/particle0"
+ *   devpath - The full path to the driver to register e.g., "/dev/particle0"
  *   i2c     - An instance of the I2C interface to use to communicate with
  *             the SPS30
  *   addr    - The I2C address of the SPS30. The I2C address of SPS30 is
diff --git a/drivers/sensors/t67xx.c b/drivers/sensors/t67xx.c
index 7bb00ff..201cdb3 100644
--- a/drivers/sensors/t67xx.c
+++ b/drivers/sensors/t67xx.c
@@ -471,7 +471,8 @@ static int t67xx_read_gas_ppm(FAR struct t67xx_dev_s *priv,
     }
   else if (warming_up)
     {
-      snwarn("WARN: sensor still warming up after %d secs\n", 
T67XX_UPTIME_FULL_SEC);
+      snwarn("WARN: sensor still warming up after %d secs\n",
+              T67XX_UPTIME_FULL_SEC);
     }
 
   /* Read the CO2 level. */
@@ -635,7 +636,11 @@ static ssize_t t67xx_read(FAR struct file *filep, FAR char 
*buffer,
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* How many samples were requested to get? */
 
@@ -691,7 +696,11 @@ static int t67xx_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
 
   /* Get exclusive access */
 
-  nxsem_wait_uninterruptible(&priv->devsem);
+  ret = nxsem_wait_uninterruptible(&priv->devsem);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   switch (cmd)
     {

Reply via email to