mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
nuttx/drivers: Replace irqsave() with enter_critical_section(); replace irqrestore() with leave_critical_section()
This commit is contained in:
@@ -59,7 +59,7 @@
|
|||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/analog/adc.h>
|
#include <nuttx/analog/adc.h>
|
||||||
|
|
||||||
#include <arch/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
@@ -134,7 +134,7 @@ static int adc_open(FAR struct file *filep)
|
|||||||
{
|
{
|
||||||
/* Yes.. perform one time hardware initialization. */
|
/* Yes.. perform one time hardware initialization. */
|
||||||
|
|
||||||
irqstate_t flags = irqsave();
|
irqstate_t flags = enter_critical_section();
|
||||||
ret = dev->ad_ops->ao_setup(dev);
|
ret = dev->ad_ops->ao_setup(dev);
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
@@ -152,7 +152,7 @@ static int adc_open(FAR struct file *filep)
|
|||||||
dev->ad_ocount = tmp;
|
dev->ad_ocount = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,9 +201,9 @@ static int adc_close(FAR struct file *filep)
|
|||||||
|
|
||||||
/* Free the IRQ and disable the ADC device */
|
/* Free the IRQ and disable the ADC device */
|
||||||
|
|
||||||
flags = irqsave(); /* Disable interrupts */
|
flags = enter_critical_section(); /* Disable interrupts */
|
||||||
dev->ad_ops->ao_shutdown(dev); /* Disable the ADC */
|
dev->ad_ops->ao_shutdown(dev); /* Disable the ADC */
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
sem_post(&dev->ad_closesem);
|
sem_post(&dev->ad_closesem);
|
||||||
}
|
}
|
||||||
@@ -244,7 +244,7 @@ static ssize_t adc_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
|
|||||||
{
|
{
|
||||||
/* Interrupts must be disabled while accessing the ad_recv FIFO */
|
/* Interrupts must be disabled while accessing the ad_recv FIFO */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
while (dev->ad_recv.af_head == dev->ad_recv.af_tail)
|
while (dev->ad_recv.af_head == dev->ad_recv.af_tail)
|
||||||
{
|
{
|
||||||
/* The receive FIFO is empty -- was non-blocking mode selected? */
|
/* The receive FIFO is empty -- was non-blocking mode selected? */
|
||||||
@@ -340,7 +340,7 @@ static ssize_t adc_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
|
|||||||
ret = nread;
|
ret = nread;
|
||||||
|
|
||||||
return_with_irqdisabled:
|
return_with_irqdisabled:
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
avdbg("Returning: %d\n", ret);
|
avdbg("Returning: %d\n", ret);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/analog/dac.h>
|
#include <nuttx/analog/dac.h>
|
||||||
|
|
||||||
#include <arch/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
@@ -143,7 +143,7 @@ static int dac_open(FAR struct file *filep)
|
|||||||
{
|
{
|
||||||
/* Yes.. perform one time hardware initialization. */
|
/* Yes.. perform one time hardware initialization. */
|
||||||
|
|
||||||
irqstate_t flags = irqsave();
|
irqstate_t flags = enter_critical_section();
|
||||||
ret = dev->ad_ops->ao_setup(dev);
|
ret = dev->ad_ops->ao_setup(dev);
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
@@ -157,7 +157,7 @@ static int dac_open(FAR struct file *filep)
|
|||||||
dev->ad_ocount = tmp;
|
dev->ad_ocount = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,9 +217,9 @@ static int dac_close(FAR struct file *filep)
|
|||||||
|
|
||||||
/* Free the IRQ and disable the DAC device */
|
/* Free the IRQ and disable the DAC device */
|
||||||
|
|
||||||
flags = irqsave(); /* Disable interrupts */
|
flags = enter_critical_section(); /* Disable interrupts */
|
||||||
dev->ad_ops->ao_shutdown(dev); /* Disable the DAC */
|
dev->ad_ops->ao_shutdown(dev); /* Disable the DAC */
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
sem_post(&dev->ad_closesem);
|
sem_post(&dev->ad_closesem);
|
||||||
}
|
}
|
||||||
@@ -289,7 +289,7 @@ static ssize_t dac_write(FAR struct file *filep, FAR const char *buffer, size_t
|
|||||||
|
|
||||||
/* Interrupts must disabled throughout the following */
|
/* Interrupts must disabled throughout the following */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Check if the TX FIFO was empty when we started. That is a clue that we have
|
/* Check if the TX FIFO was empty when we started. That is a clue that we have
|
||||||
* to kick off a new TX sequence.
|
* to kick off a new TX sequence.
|
||||||
@@ -442,7 +442,7 @@ static ssize_t dac_write(FAR struct file *filep, FAR const char *buffer, size_t
|
|||||||
ret = nsent;
|
ret = nsent;
|
||||||
|
|
||||||
return_with_irqdisabled:
|
return_with_irqdisabled:
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-17
@@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Audio device driver for Wolfson Microelectronics WM8904 Audio codec.
|
* Audio device driver for Wolfson Microelectronics WM8904 Audio codec.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* References:
|
* References:
|
||||||
@@ -59,6 +59,7 @@
|
|||||||
#include <queue.h>
|
#include <queue.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
#include <nuttx/wqueue.h>
|
#include <nuttx/wqueue.h>
|
||||||
@@ -72,14 +73,6 @@
|
|||||||
|
|
||||||
#include "wm8904.h"
|
#include "wm8904.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Types
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -1324,7 +1317,7 @@ static void wm8904_senddone(FAR struct i2s_dev_s *i2s,
|
|||||||
* against that possibility.
|
* against that possibility.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Add the completed buffer to the end of our doneq. We do not yet
|
/* Add the completed buffer to the end of our doneq. We do not yet
|
||||||
* decrement the reference count.
|
* decrement the reference count.
|
||||||
@@ -1341,7 +1334,7 @@ static void wm8904_senddone(FAR struct i2s_dev_s *i2s,
|
|||||||
/* REVISIT: This can be overwritten */
|
/* REVISIT: This can be overwritten */
|
||||||
|
|
||||||
priv->result = result;
|
priv->result = result;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Now send a message to the worker thread, informing it that there are
|
/* Now send a message to the worker thread, informing it that there are
|
||||||
* buffers in the done queue that need to be cleaned up.
|
* buffers in the done queue that need to be cleaned up.
|
||||||
@@ -1376,13 +1369,13 @@ static void wm8904_returnbuffers(FAR struct wm8904_dev_s *priv)
|
|||||||
* use interrupt controls to protect against that possibility.
|
* use interrupt controls to protect against that possibility.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
while (dq_peek(&priv->doneq) != NULL)
|
while (dq_peek(&priv->doneq) != NULL)
|
||||||
{
|
{
|
||||||
/* Take the next buffer from the queue of completed transfers */
|
/* Take the next buffer from the queue of completed transfers */
|
||||||
|
|
||||||
apb = (FAR struct ap_buffer_s *)dq_remfirst(&priv->doneq);
|
apb = (FAR struct ap_buffer_s *)dq_remfirst(&priv->doneq);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
audvdbg("Returning: apb=%p curbyte=%d nbytes=%d flags=%04x\n",
|
audvdbg("Returning: apb=%p curbyte=%d nbytes=%d flags=%04x\n",
|
||||||
apb, apb->curbyte, apb->nbytes, apb->flags);
|
apb, apb->curbyte, apb->nbytes, apb->flags);
|
||||||
@@ -1417,10 +1410,10 @@ static void wm8904_returnbuffers(FAR struct wm8904_dev_s *priv)
|
|||||||
#else
|
#else
|
||||||
priv->dev.upper(priv->dev.priv, AUDIO_CALLBACK_DEQUEUE, apb, OK);
|
priv->dev.upper(priv->dev.priv, AUDIO_CALLBACK_DEQUEUE, apb, OK);
|
||||||
#endif
|
#endif
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -1468,9 +1461,9 @@ static int wm8904_sendbuffer(FAR struct wm8904_dev_s *priv)
|
|||||||
* to avoid a possible race condition.
|
* to avoid a possible race condition.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->inflight++;
|
priv->inflight++;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Send the entire audio buffer via I2S. What is a reasonable timeout
|
/* Send the entire audio buffer via I2S. What is a reasonable timeout
|
||||||
* to use? This would depend on the bit rate and size of the buffer.
|
* to use? This would depend on the bit rate and size of the buffer.
|
||||||
|
|||||||
+13
-13
@@ -58,7 +58,7 @@
|
|||||||
# include <nuttx/wqueue.h>
|
# include <nuttx/wqueue.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <arch/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
#ifdef CONFIG_CAN
|
#ifdef CONFIG_CAN
|
||||||
|
|
||||||
@@ -308,7 +308,7 @@ static void can_txready_work(FAR void *arg)
|
|||||||
* be performed with interrupt disabled.
|
* be performed with interrupt disabled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
if (dev->cd_xmit.tx_head != dev->cd_xmit.tx_tail)
|
if (dev->cd_xmit.tx_head != dev->cd_xmit.tx_tail)
|
||||||
{
|
{
|
||||||
/* Send the next message in the FIFO. */
|
/* Send the next message in the FIFO. */
|
||||||
@@ -333,7 +333,7 @@ static void can_txready_work(FAR void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -382,7 +382,7 @@ static int can_open(FAR struct file *filep)
|
|||||||
{
|
{
|
||||||
/* Yes.. perform one time hardware initialization. */
|
/* Yes.. perform one time hardware initialization. */
|
||||||
|
|
||||||
irqstate_t flags = irqsave();
|
irqstate_t flags = enter_critical_section();
|
||||||
ret = dev_setup(dev);
|
ret = dev_setup(dev);
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
@@ -403,7 +403,7 @@ static int can_open(FAR struct file *filep)
|
|||||||
dev->cd_ocount = 1;
|
dev->cd_ocount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -486,9 +486,9 @@ static int can_close(FAR struct file *filep)
|
|||||||
|
|
||||||
/* Free the IRQ and disable the CAN device */
|
/* Free the IRQ and disable the CAN device */
|
||||||
|
|
||||||
flags = irqsave(); /* Disable interrupts */
|
flags = enter_critical_section(); /* Disable interrupts */
|
||||||
dev_shutdown(dev); /* Disable the CAN */
|
dev_shutdown(dev); /* Disable the CAN */
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
sem_post(&dev->cd_closesem);
|
sem_post(&dev->cd_closesem);
|
||||||
}
|
}
|
||||||
@@ -525,7 +525,7 @@ static ssize_t can_read(FAR struct file *filep, FAR char *buffer,
|
|||||||
{
|
{
|
||||||
/* Interrupts must be disabled while accessing the cd_recv FIFO */
|
/* Interrupts must be disabled while accessing the cd_recv FIFO */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
while (dev->cd_recv.rx_head == dev->cd_recv.rx_tail)
|
while (dev->cd_recv.rx_head == dev->cd_recv.rx_tail)
|
||||||
{
|
{
|
||||||
/* The receive FIFO is empty -- was non-blocking mode selected? */
|
/* The receive FIFO is empty -- was non-blocking mode selected? */
|
||||||
@@ -592,7 +592,7 @@ static ssize_t can_read(FAR struct file *filep, FAR char *buffer,
|
|||||||
ret = nread;
|
ret = nread;
|
||||||
|
|
||||||
return_with_irqdisabled:
|
return_with_irqdisabled:
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -701,7 +701,7 @@ static ssize_t can_write(FAR struct file *filep, FAR const char *buffer,
|
|||||||
|
|
||||||
/* Interrupts must disabled throughout the following */
|
/* Interrupts must disabled throughout the following */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Check if the TX is inactive when we started. In certain race conditions,
|
/* Check if the TX is inactive when we started. In certain race conditions,
|
||||||
* there may be a pending interrupt to kick things back off, but we will
|
* there may be a pending interrupt to kick things back off, but we will
|
||||||
@@ -811,7 +811,7 @@ static ssize_t can_write(FAR struct file *filep, FAR const char *buffer,
|
|||||||
ret = nsent;
|
ret = nsent;
|
||||||
|
|
||||||
return_with_irqdisabled:
|
return_with_irqdisabled:
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -836,7 +836,7 @@ static inline ssize_t can_rtrread(FAR struct can_dev_s *dev,
|
|||||||
|
|
||||||
/* Disable interrupts through this operation */
|
/* Disable interrupts through this operation */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Find an available slot in the pending RTR list */
|
/* Find an available slot in the pending RTR list */
|
||||||
|
|
||||||
@@ -866,7 +866,7 @@ static inline ssize_t can_rtrread(FAR struct can_dev_s *dev,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/input/ads7843e.c
|
* drivers/input/ads7843e.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011-2012, 2014 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011-2012, 2014, 2016 Gregory Nutt. All rights reserved.
|
||||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||||
* Diego Sanchez <dsanchez@nx-engineering.com>
|
* Diego Sanchez <dsanchez@nx-engineering.com>
|
||||||
*
|
*
|
||||||
@@ -63,6 +63,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/wdog.h>
|
#include <nuttx/wdog.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
@@ -340,7 +341,7 @@ static int ads7843e_sample(FAR struct ads7843e_dev_s *priv,
|
|||||||
* from changing until it has been reported.
|
* from changing until it has been reported.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Is there new ADS7843E sample data available? */
|
/* Is there new ADS7843E sample data available? */
|
||||||
|
|
||||||
@@ -375,7 +376,7 @@ static int ads7843e_sample(FAR struct ads7843e_dev_s *priv,
|
|||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,7 +399,7 @@ static int ads7843e_waitsample(FAR struct ads7843e_dev_s *priv,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
sched_lock();
|
sched_lock();
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Now release the semaphore that manages mutually exclusive access to
|
/* Now release the semaphore that manages mutually exclusive access to
|
||||||
* the device structure. This may cause other tasks to become ready to
|
* the device structure. This may cause other tasks to become ready to
|
||||||
@@ -448,7 +449,7 @@ errout:
|
|||||||
* have pre-emption disabled.
|
* have pre-emption disabled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Restore pre-emption. We might get suspended here but that is okay
|
/* Restore pre-emption. We might get suspended here but that is okay
|
||||||
* because we already have our sample. Note: this means that if there
|
* because we already have our sample. Note: this means that if there
|
||||||
@@ -1235,7 +1236,7 @@ int ads7843e_register(FAR struct spi_dev_s *spi,
|
|||||||
#ifdef CONFIG_ADS7843E_MULTIPLE
|
#ifdef CONFIG_ADS7843E_MULTIPLE
|
||||||
priv->flink = g_ads7843elist;
|
priv->flink = g_ads7843elist;
|
||||||
g_ads7843elist = priv;
|
g_ads7843elist = priv;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Schedule work to perform the initial sampling and to set the data
|
/* Schedule work to perform the initial sampling and to set the data
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/input/ajoystick.h>
|
#include <nuttx/input/ajoystick.h>
|
||||||
|
|
||||||
#include <arch/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
@@ -216,7 +216,7 @@ static void ajoy_enable(FAR struct ajoy_upperhalf_s *priv)
|
|||||||
* interrupts must be disabled.
|
* interrupts must be disabled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Visit each opened reference to the device */
|
/* Visit each opened reference to the device */
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ static void ajoy_enable(FAR struct ajoy_upperhalf_s *priv)
|
|||||||
lower->al_enable(lower, 0, 0, NULL, NULL);
|
lower->al_enable(lower, 0, 0, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -314,7 +314,7 @@ static void ajoy_sample(FAR struct ajoy_upperhalf_s *priv)
|
|||||||
* interrupts must be disabled.
|
* interrupts must be disabled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Sample the new button state */
|
/* Sample the new button state */
|
||||||
|
|
||||||
@@ -386,7 +386,7 @@ static void ajoy_sample(FAR struct ajoy_upperhalf_s *priv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
priv->au_sample = sample;
|
priv->au_sample = sample;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -485,10 +485,10 @@ static int ajoy_close(FAR struct file *filep)
|
|||||||
* detection anyway.
|
* detection anyway.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
closing = opriv->ao_closing;
|
closing = opriv->ao_closing;
|
||||||
opriv->ao_closing = true;
|
opriv->ao_closing = true;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
if (closing)
|
if (closing)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
#include <nuttx/input/buttons.h>
|
#include <nuttx/input/buttons.h>
|
||||||
|
|
||||||
#include <arch/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
#undef __KERNEL__
|
#undef __KERNEL__
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
@@ -135,7 +135,7 @@ static void btn_enable(FAR const struct btn_lowerhalf_s *lower,
|
|||||||
|
|
||||||
/* Start with all interrupts disabled */
|
/* Start with all interrupts disabled */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
btn_disable();
|
btn_disable();
|
||||||
|
|
||||||
illvdbg("press: %02x release: %02x handler: %p arg: %p\n",
|
illvdbg("press: %02x release: %02x handler: %p arg: %p\n",
|
||||||
@@ -164,7 +164,7 @@ static void btn_enable(FAR const struct btn_lowerhalf_s *lower,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -182,7 +182,7 @@ static void btn_disable(void)
|
|||||||
|
|
||||||
/* Disable each button interrupt */
|
/* Disable each button interrupt */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
for (id = 0; id < NUM_BUTTONS; id++)
|
for (id = 0; id < NUM_BUTTONS; id++)
|
||||||
{
|
{
|
||||||
(void)board_button_irq(id, NULL);
|
(void)board_button_irq(id, NULL);
|
||||||
@@ -192,7 +192,7 @@ static void btn_disable(void)
|
|||||||
|
|
||||||
g_btnhandler = NULL;
|
g_btnhandler = NULL;
|
||||||
g_btnarg = NULL;
|
g_btnarg = NULL;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/input/buttons.h>
|
#include <nuttx/input/buttons.h>
|
||||||
|
|
||||||
#include <arch/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
@@ -212,7 +212,7 @@ static void btn_enable(FAR struct btn_upperhalf_s *priv)
|
|||||||
* interrupts must be disabled.
|
* interrupts must be disabled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Visit each opened reference to the device */
|
/* Visit each opened reference to the device */
|
||||||
|
|
||||||
@@ -262,7 +262,7 @@ static void btn_enable(FAR struct btn_upperhalf_s *priv)
|
|||||||
lower->bl_enable(lower, 0, 0, NULL, NULL);
|
lower->bl_enable(lower, 0, 0, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -310,7 +310,7 @@ static void btn_sample(FAR struct btn_upperhalf_s *priv)
|
|||||||
* interrupts must be disabled.
|
* interrupts must be disabled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Sample the new button state */
|
/* Sample the new button state */
|
||||||
|
|
||||||
@@ -382,7 +382,7 @@ static void btn_sample(FAR struct btn_upperhalf_s *priv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
priv->bu_sample = sample;
|
priv->bu_sample = sample;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -481,10 +481,10 @@ static int btn_close(FAR struct file *filep)
|
|||||||
* detection anyway.
|
* detection anyway.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
closing = opriv->bo_closing;
|
closing = opriv->bo_closing;
|
||||||
opriv->bo_closing = true;
|
opriv->bo_closing = true;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
if (closing)
|
if (closing)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/input/djoystick.h>
|
#include <nuttx/input/djoystick.h>
|
||||||
|
|
||||||
#include <arch/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
@@ -216,7 +216,7 @@ static void djoy_enable(FAR struct djoy_upperhalf_s *priv)
|
|||||||
* interrupts must be disabled.
|
* interrupts must be disabled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Visit each opened reference to the device */
|
/* Visit each opened reference to the device */
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ static void djoy_enable(FAR struct djoy_upperhalf_s *priv)
|
|||||||
lower->dl_enable(lower, 0, 0, NULL, NULL);
|
lower->dl_enable(lower, 0, 0, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -314,7 +314,7 @@ static void djoy_sample(FAR struct djoy_upperhalf_s *priv)
|
|||||||
* interrupts must be disabled.
|
* interrupts must be disabled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Sample the new button state */
|
/* Sample the new button state */
|
||||||
|
|
||||||
@@ -386,7 +386,7 @@ static void djoy_sample(FAR struct djoy_upperhalf_s *priv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
priv->du_sample = sample;
|
priv->du_sample = sample;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -485,10 +485,10 @@ static int djoy_close(FAR struct file *filep)
|
|||||||
* detection anyway.
|
* detection anyway.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
closing = opriv->do_closing;
|
closing = opriv->do_closing;
|
||||||
opriv->do_closing = true;
|
opriv->do_closing = true;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
if (closing)
|
if (closing)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/input/max11802.c
|
* drivers/input/max11802.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011-2012, 2014-2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011-2012, 2014-2016 Gregory Nutt. All rights reserved.
|
||||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||||
* Petteri Aimonen <jpa@nx.mail.kapsi.fi>
|
* Petteri Aimonen <jpa@nx.mail.kapsi.fi>
|
||||||
*
|
*
|
||||||
@@ -57,6 +57,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/wdog.h>
|
#include <nuttx/wdog.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
@@ -305,7 +306,7 @@ static int max11802_sample(FAR struct max11802_dev_s *priv,
|
|||||||
* from changing until it has been reported.
|
* from changing until it has been reported.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Is there new MAX11802 sample data available? */
|
/* Is there new MAX11802 sample data available? */
|
||||||
|
|
||||||
@@ -340,7 +341,7 @@ static int max11802_sample(FAR struct max11802_dev_s *priv,
|
|||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,7 +364,7 @@ static int max11802_waitsample(FAR struct max11802_dev_s *priv,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
sched_lock();
|
sched_lock();
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Now release the semaphore that manages mutually exclusive access to
|
/* Now release the semaphore that manages mutually exclusive access to
|
||||||
* the device structure. This may cause other tasks to become ready to
|
* the device structure. This may cause other tasks to become ready to
|
||||||
@@ -413,7 +414,7 @@ errout:
|
|||||||
* have pre-emption disabled.
|
* have pre-emption disabled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Restore pre-emption. We might get suspended here but that is okay
|
/* Restore pre-emption. We might get suspended here but that is okay
|
||||||
* because we already have our sample. Note: this means that if there
|
* because we already have our sample. Note: this means that if there
|
||||||
@@ -1267,10 +1268,10 @@ int max11802_register(FAR struct spi_dev_s *spi,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_MAX11802_MULTIPLE
|
#ifdef CONFIG_MAX11802_MULTIPLE
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->flink = g_max11802list;
|
priv->flink = g_max11802list;
|
||||||
g_max11802list = priv;
|
g_max11802list = priv;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Schedule work to perform the initial sampling and to set the data
|
/* Schedule work to perform the initial sampling and to set the data
|
||||||
|
|||||||
+4
-3
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/input/mxt.c
|
* drivers/input/mxt.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -58,6 +58,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
@@ -673,7 +674,7 @@ static inline int mxt_waitsample(FAR struct mxt_dev_s *priv)
|
|||||||
* from changing until it has been reported.
|
* from changing until it has been reported.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Now release the semaphore that manages mutually exclusive access to
|
/* Now release the semaphore that manages mutually exclusive access to
|
||||||
* the device structure. This may cause other tasks to become ready to
|
* the device structure. This may cause other tasks to become ready to
|
||||||
@@ -719,7 +720,7 @@ errout:
|
|||||||
* have pre-emption disabled.
|
* have pre-emption disabled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/input/tsc2007.c
|
* drivers/input/tsc2007.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011-2012, 2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* References:
|
* References:
|
||||||
@@ -62,6 +62,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
@@ -299,7 +300,7 @@ static int tsc2007_sample(FAR struct tsc2007_dev_s *priv,
|
|||||||
* from changing until it has been reported.
|
* from changing until it has been reported.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Is there new TSC2007 sample data available? */
|
/* Is there new TSC2007 sample data available? */
|
||||||
|
|
||||||
@@ -334,7 +335,7 @@ static int tsc2007_sample(FAR struct tsc2007_dev_s *priv,
|
|||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,7 +358,7 @@ static int tsc2007_waitsample(FAR struct tsc2007_dev_s *priv,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
sched_lock();
|
sched_lock();
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Now release the semaphore that manages mutually exclusive access to
|
/* Now release the semaphore that manages mutually exclusive access to
|
||||||
* the device structure. This may cause other tasks to become ready to
|
* the device structure. This may cause other tasks to become ready to
|
||||||
@@ -403,7 +404,7 @@ errout:
|
|||||||
* have pre-emption disabled.
|
* have pre-emption disabled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Restore pre-emption. We might get suspended here but that is okay
|
/* Restore pre-emption. We might get suspended here but that is okay
|
||||||
* because we already have our sample. Note: this means that if there
|
* because we already have our sample. Note: this means that if there
|
||||||
@@ -1297,10 +1298,10 @@ int tsc2007_register(FAR struct i2c_master_s *dev,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_TSC2007_MULTIPLE
|
#ifdef CONFIG_TSC2007_MULTIPLE
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->flink = g_tsc2007list;
|
priv->flink = g_tsc2007list;
|
||||||
g_tsc2007list = priv;
|
g_tsc2007list = priv;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Schedule work to perform the initial sampling and to set the data
|
/* Schedule work to perform the initial sampling and to set the data
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/leds/userled_upper.c
|
* drivers/leds/userled_upper.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -52,6 +52,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/leds/userled.h>
|
#include <nuttx/leds/userled.h>
|
||||||
@@ -253,10 +254,10 @@ static int userled_close(FAR struct file *filep)
|
|||||||
* detection anyway.
|
* detection anyway.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
closing = opriv->bo_closing;
|
closing = opriv->bo_closing;
|
||||||
opriv->bo_closing = true;
|
opriv->bo_closing = true;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
if (closing)
|
if (closing)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -861,7 +861,7 @@ static int cs89x0_ifdown(struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* Disable the Ethernet interrupt */
|
/* Disable the Ethernet interrupt */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
up_disable_irq(CONFIG_CS89x0_IRQ);
|
up_disable_irq(CONFIG_CS89x0_IRQ);
|
||||||
|
|
||||||
/* Cancel the TX poll timer and TX timeout timers */
|
/* Cancel the TX poll timer and TX timeout timers */
|
||||||
@@ -872,7 +872,7 @@ static int cs89x0_ifdown(struct net_driver_s *dev)
|
|||||||
/* Reset the device */
|
/* Reset the device */
|
||||||
|
|
||||||
cs89x0->cs_bifup = false;
|
cs89x0->cs_bifup = false;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -900,7 +900,7 @@ static int cs89x0_txavail(struct net_driver_s *dev)
|
|||||||
struct cs89x0_driver_s *cs89x0 = (struct cs89x0_driver_s *)dev->d_private;
|
struct cs89x0_driver_s *cs89x0 = (struct cs89x0_driver_s *)dev->d_private;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Ignore the notification if the interface is not yet up */
|
/* Ignore the notification if the interface is not yet up */
|
||||||
|
|
||||||
@@ -914,7 +914,7 @@ static int cs89x0_txavail(struct net_driver_s *dev)
|
|||||||
(void)devif_poll(&cs89x0->cs_dev, cs89x0_txpoll);
|
(void)devif_poll(&cs89x0->cs_dev, cs89x0_txpoll);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1411,7 +1411,7 @@ static int dm9x_ifdown(struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* Disable the DM9X interrupt */
|
/* Disable the DM9X interrupt */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
up_disable_irq(CONFIG_DM9X_IRQ);
|
up_disable_irq(CONFIG_DM9X_IRQ);
|
||||||
|
|
||||||
/* Cancel the TX poll timer and TX timeout timers */
|
/* Cancel the TX poll timer and TX timeout timers */
|
||||||
@@ -1428,7 +1428,7 @@ static int dm9x_ifdown(struct net_driver_s *dev)
|
|||||||
putreg(DM9X_ISR, DM9X_INT_ALL); /* Clear interrupt status */
|
putreg(DM9X_ISR, DM9X_INT_ALL); /* Clear interrupt status */
|
||||||
|
|
||||||
dm9x->dm_bifup = false;
|
dm9x->dm_bifup = false;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1457,7 +1457,7 @@ static int dm9x_txavail(struct net_driver_s *dev)
|
|||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
ndbg("Polling\n");
|
ndbg("Polling\n");
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Ignore the notification if the interface is not yet up */
|
/* Ignore the notification if the interface is not yet up */
|
||||||
|
|
||||||
@@ -1475,7 +1475,7 @@ static int dm9x_txavail(struct net_driver_s *dev)
|
|||||||
(void)devif_poll(&dm9x->dm_dev, dm9x_txpoll);
|
(void)devif_poll(&dm9x->dm_dev, dm9x_txpoll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -847,7 +847,7 @@ static int e1000_ifdown(struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* Disable the Ethernet interrupt */
|
/* Disable the Ethernet interrupt */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
e1000_turn_off(e1000);
|
e1000_turn_off(e1000);
|
||||||
|
|
||||||
@@ -866,7 +866,7 @@ static int e1000_ifdown(struct net_driver_s *dev)
|
|||||||
/* Mark the device "down" */
|
/* Mark the device "down" */
|
||||||
|
|
||||||
e1000->bifup = false;
|
e1000->bifup = false;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -900,7 +900,7 @@ static int e1000_txavail(struct net_driver_s *dev)
|
|||||||
* level processing.
|
* level processing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Ignore the notification if the interface is not yet up */
|
/* Ignore the notification if the interface is not yet up */
|
||||||
|
|
||||||
@@ -914,7 +914,7 @@ static int e1000_txavail(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,8 @@
|
|||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/wdog.h>
|
#include <nuttx/wdog.h>
|
||||||
#include <nuttx/spi/spi.h>
|
#include <nuttx/spi/spi.h>
|
||||||
#include <nuttx/wqueue.h>
|
#include <nuttx/wqueue.h>
|
||||||
@@ -2149,7 +2149,7 @@ static int enc_ifdown(struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* Disable the Ethernet interrupt */
|
/* Disable the Ethernet interrupt */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->lower->disable(priv->lower);
|
priv->lower->disable(priv->lower);
|
||||||
|
|
||||||
/* Cancel the TX poll timer and TX timeout timers */
|
/* Cancel the TX poll timer and TX timeout timers */
|
||||||
@@ -2163,7 +2163,7 @@ static int enc_ifdown(struct net_driver_s *dev)
|
|||||||
enc_pwrsave(priv);
|
enc_pwrsave(priv);
|
||||||
|
|
||||||
priv->ifstate = ENCSTATE_DOWN;
|
priv->ifstate = ENCSTATE_DOWN;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Un-lock the SPI bus */
|
/* Un-lock the SPI bus */
|
||||||
|
|
||||||
@@ -2201,7 +2201,7 @@ static int enc_txavail(struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* Ignore the notification if the interface is not yet up */
|
/* Ignore the notification if the interface is not yet up */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
if (priv->ifstate == ENCSTATE_UP)
|
if (priv->ifstate == ENCSTATE_UP)
|
||||||
{
|
{
|
||||||
/* Check if the hardware is ready to send another packet. The driver
|
/* Check if the hardware is ready to send another packet. The driver
|
||||||
@@ -2220,7 +2220,7 @@ static int enc_txavail(struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* Un-lock the SPI bus */
|
/* Un-lock the SPI bus */
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
enc_unlock(priv);
|
enc_unlock(priv);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2317,7 +2317,7 @@ static int enc_ifdown(struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* Disable the Ethernet interrupt */
|
/* Disable the Ethernet interrupt */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->lower->disable(priv->lower);
|
priv->lower->disable(priv->lower);
|
||||||
|
|
||||||
/* Cancel the TX poll timer and TX timeout timers */
|
/* Cancel the TX poll timer and TX timeout timers */
|
||||||
@@ -2331,7 +2331,7 @@ static int enc_ifdown(struct net_driver_s *dev)
|
|||||||
enc_pwrsave(priv);
|
enc_pwrsave(priv);
|
||||||
|
|
||||||
priv->ifstate = ENCSTATE_DOWN;
|
priv->ifstate = ENCSTATE_DOWN;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Un-lock the SPI bus */
|
/* Un-lock the SPI bus */
|
||||||
|
|
||||||
@@ -2370,7 +2370,7 @@ static int enc_txavail(struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* Ignore the notification if the interface is not yet up */
|
/* Ignore the notification if the interface is not yet up */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
if (priv->ifstate == ENCSTATE_RUNNING)
|
if (priv->ifstate == ENCSTATE_RUNNING)
|
||||||
{
|
{
|
||||||
/* Check if the hardware is ready to send another packet. The driver
|
/* Check if the hardware is ready to send another packet. The driver
|
||||||
@@ -2389,7 +2389,7 @@ static int enc_txavail(struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* Un-lock the SPI bus */
|
/* Un-lock the SPI bus */
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
enc_unlock(priv);
|
enc_unlock(priv);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
+10
-10
@@ -284,7 +284,7 @@ static int ftmac100_transmit(FAR struct ftmac100_driver_s *priv)
|
|||||||
FAR struct ftmac100_txdes_s *txdes;
|
FAR struct ftmac100_txdes_s *txdes;
|
||||||
int len = priv->ft_dev.d_len;
|
int len = priv->ft_dev.d_len;
|
||||||
//irqstate_t flags;
|
//irqstate_t flags;
|
||||||
//flags = irqsave();
|
//flags = enter_critical_section();
|
||||||
//nvdbg("flags=%08x\n", flags);
|
//nvdbg("flags=%08x\n", flags);
|
||||||
|
|
||||||
txdes = ftmac100_current_txdes(priv);
|
txdes = ftmac100_current_txdes(priv);
|
||||||
@@ -323,7 +323,7 @@ static int ftmac100_transmit(FAR struct ftmac100_driver_s *priv)
|
|||||||
(void)wd_start(priv->ft_txtimeout, FTMAC100_TXTIMEOUT,
|
(void)wd_start(priv->ft_txtimeout, FTMAC100_TXTIMEOUT,
|
||||||
ftmac100_txtimeout_expiry, 1, (wdparm_t)priv);
|
ftmac100_txtimeout_expiry, 1, (wdparm_t)priv);
|
||||||
|
|
||||||
//irqrestore(flags);
|
//leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -981,11 +981,11 @@ static void ftmac100_interrupt_work(FAR void *arg)
|
|||||||
/* Process pending Ethernet interrupts */
|
/* Process pending Ethernet interrupts */
|
||||||
|
|
||||||
state = net_lock();
|
state = net_lock();
|
||||||
//flags = irqsave();
|
//flags = enter_critical_section();
|
||||||
|
|
||||||
ftmac100_interrupt_process(priv);
|
ftmac100_interrupt_process(priv);
|
||||||
|
|
||||||
//irqrestore(flags);
|
//leave_critical_section(flags);
|
||||||
net_unlock(state);
|
net_unlock(state);
|
||||||
|
|
||||||
/* Re-enable Ethernet interrupts */
|
/* Re-enable Ethernet interrupts */
|
||||||
@@ -1024,7 +1024,7 @@ static int ftmac100_interrupt(int irq, FAR void *context)
|
|||||||
* condition here.
|
* condition here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
priv->status = getreg32 (&iobase->isr);
|
priv->status = getreg32 (&iobase->isr);
|
||||||
|
|
||||||
@@ -1055,7 +1055,7 @@ static int ftmac100_interrupt(int irq, FAR void *context)
|
|||||||
|
|
||||||
work_queue(HPWORK, &priv->ft_work, ftmac100_interrupt_work, priv, 0);
|
work_queue(HPWORK, &priv->ft_work, ftmac100_interrupt_work, priv, 0);
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
#else
|
#else
|
||||||
/* Process the interrupt now */
|
/* Process the interrupt now */
|
||||||
putreg32 (INT_MASK_ALL_DISABLED, &iobase->imr);
|
putreg32 (INT_MASK_ALL_DISABLED, &iobase->imr);
|
||||||
@@ -1374,7 +1374,7 @@ static int ftmac100_ifdown(struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* Disable the Ethernet interrupt */
|
/* Disable the Ethernet interrupt */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
up_disable_irq(CONFIG_FTMAC100_IRQ);
|
up_disable_irq(CONFIG_FTMAC100_IRQ);
|
||||||
|
|
||||||
/* Cancel the TX poll timer and TX timeout timers */
|
/* Cancel the TX poll timer and TX timeout timers */
|
||||||
@@ -1392,7 +1392,7 @@ static int ftmac100_ifdown(struct net_driver_s *dev)
|
|||||||
/* Mark the device "down" */
|
/* Mark the device "down" */
|
||||||
|
|
||||||
priv->ft_bifup = false;
|
priv->ft_bifup = false;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1501,12 +1501,12 @@ static int ftmac100_txavail(struct net_driver_s *dev)
|
|||||||
* level processing.
|
* level processing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Perform the out-of-cycle poll now */
|
/* Perform the out-of-cycle poll now */
|
||||||
|
|
||||||
ftmac100_txavail_process(priv);
|
ftmac100_txavail_process(priv);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
@@ -911,7 +911,7 @@ static int skel_ifdown(FAR struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* Disable the Ethernet interrupt */
|
/* Disable the Ethernet interrupt */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
up_disable_irq(CONFIG_skeleton_IRQ);
|
up_disable_irq(CONFIG_skeleton_IRQ);
|
||||||
|
|
||||||
/* Cancel the TX poll timer and TX timeout timers */
|
/* Cancel the TX poll timer and TX timeout timers */
|
||||||
@@ -927,7 +927,7 @@ static int skel_ifdown(FAR struct net_driver_s *dev)
|
|||||||
/* Mark the device "down" */
|
/* Mark the device "down" */
|
||||||
|
|
||||||
priv->sk_bifup = false;
|
priv->sk_bifup = false;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1036,12 +1036,12 @@ static int skel_txavail(FAR struct net_driver_s *dev)
|
|||||||
* level processing.
|
* level processing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Perform the out-of-cycle poll now */
|
/* Perform the out-of-cycle poll now */
|
||||||
|
|
||||||
skel_txavail_process(priv);
|
skel_txavail_process(priv);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
+4
-4
@@ -584,7 +584,7 @@ static int vnet_ifdown(struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* Disable the Ethernet interrupt */
|
/* Disable the Ethernet interrupt */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Cancel the TX poll timer and TX timeout timers */
|
/* Cancel the TX poll timer and TX timeout timers */
|
||||||
|
|
||||||
@@ -598,7 +598,7 @@ static int vnet_ifdown(struct net_driver_s *dev)
|
|||||||
/* Mark the device "down" */
|
/* Mark the device "down" */
|
||||||
|
|
||||||
vnet->sk_bifup = false;
|
vnet->sk_bifup = false;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -630,7 +630,7 @@ static int vnet_txavail(struct net_driver_s *dev)
|
|||||||
* level processing.
|
* level processing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Ignore the notification if the interface is not yet up */
|
/* Ignore the notification if the interface is not yet up */
|
||||||
|
|
||||||
@@ -652,7 +652,7 @@ static int vnet_txavail(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
#include <nuttx/power/pm.h>
|
#include <nuttx/power/pm.h>
|
||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
#include <arch/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
#include "pm.h"
|
#include "pm.h"
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ void pm_activity(int priority)
|
|||||||
{
|
{
|
||||||
/* Add the priority to the accumulated counts in a critical section. */
|
/* Add the priority to the accumulated counts in a critical section. */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
accum = (uint32_t)g_pmglobals.accum + priority;
|
accum = (uint32_t)g_pmglobals.accum + priority;
|
||||||
|
|
||||||
/* Make sure that we do not overflow the underlying uint16_t representation */
|
/* Make sure that we do not overflow the underlying uint16_t representation */
|
||||||
@@ -159,7 +159,7 @@ void pm_activity(int priority)
|
|||||||
(void)pm_update(tmp);
|
(void)pm_update(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <nuttx/power/pm.h>
|
#include <nuttx/power/pm.h>
|
||||||
#include <arch/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
#include "pm.h"
|
#include "pm.h"
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ int pm_changestate(enum pm_state_e newstate)
|
|||||||
* re-enabled.
|
* re-enabled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* First, prepare the drivers for the state change. In this phase,
|
/* First, prepare the drivers for the state change. In this phase,
|
||||||
* drivers may refuse the state state change.
|
* drivers may refuse the state state change.
|
||||||
@@ -220,7 +220,7 @@ int pm_changestate(enum pm_state_e newstate)
|
|||||||
|
|
||||||
/* Restore the interrupt state */
|
/* Restore the interrupt state */
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
#include <nuttx/power/pm.h>
|
#include <nuttx/power/pm.h>
|
||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
#include <arch/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
#include "pm.h"
|
#include "pm.h"
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ enum pm_state_e pm_checkstate(void)
|
|||||||
* logic in pm_activity().
|
* logic in pm_activity().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Check the elapsed time. In periods of low activity, time slicing is
|
/* Check the elapsed time. In periods of low activity, time slicing is
|
||||||
* controlled by IDLE loop polling; in periods of higher activity, time
|
* controlled by IDLE loop polling; in periods of higher activity, time
|
||||||
@@ -148,7 +148,7 @@ enum pm_state_e pm_checkstate(void)
|
|||||||
(void)pm_update(accum);
|
(void)pm_update(accum);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Return the recommended state. Assuming that we are called from the
|
/* Return the recommended state. Assuming that we are called from the
|
||||||
* IDLE thread at the lowest priority level, any updates scheduled on the
|
* IDLE thread at the lowest priority level, any updates scheduled on the
|
||||||
|
|||||||
+3
-3
@@ -60,7 +60,7 @@
|
|||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/pwm.h>
|
#include <nuttx/pwm.h>
|
||||||
|
|
||||||
#include <arch/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
#ifdef CONFIG_PWM
|
#ifdef CONFIG_PWM
|
||||||
|
|
||||||
@@ -351,7 +351,7 @@ static int pwm_start(FAR struct pwm_upperhalf_s *upper, unsigned int oflags)
|
|||||||
{
|
{
|
||||||
/* Disable interrupts to avoid race conditions */
|
/* Disable interrupts to avoid race conditions */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Indicate that if will be waiting for the pulse count to complete.
|
/* Indicate that if will be waiting for the pulse count to complete.
|
||||||
* Note that we will only wait if a non-zero pulse count is specified
|
* Note that we will only wait if a non-zero pulse count is specified
|
||||||
@@ -398,7 +398,7 @@ static int pwm_start(FAR struct pwm_upperhalf_s *upper, unsigned int oflags)
|
|||||||
upper->waiting = false;
|
upper->waiting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/sensors/zerocross.h>
|
#include <nuttx/sensors/zerocross.h>
|
||||||
|
|
||||||
#include <arch/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
#ifdef CONFIG_ZEROCROSS
|
#ifdef CONFIG_ZEROCROSS
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ static void zerocross_enable(FAR struct zc_upperhalf_s *priv)
|
|||||||
* interrupts must be disabled.
|
* interrupts must be disabled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Enable interrupts */
|
/* Enable interrupts */
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ static void zerocross_enable(FAR struct zc_upperhalf_s *priv)
|
|||||||
|
|
||||||
lower->zc_enable(lower, (zc_interrupt_t)zerocross_interrupt, priv);
|
lower->zc_enable(lower, (zc_interrupt_t)zerocross_interrupt, priv);
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -193,7 +193,7 @@ static void zerocross_interrupt(FAR const struct zc_lowerhalf_s *lower,
|
|||||||
* interrupts must be disabled.
|
* interrupts must be disabled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Update sample value */
|
/* Update sample value */
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ static void zerocross_interrupt(FAR const struct zc_lowerhalf_s *lower,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
@@ -308,10 +308,10 @@ static int zc_close(FAR struct file *filep)
|
|||||||
* detection anyway.
|
* detection anyway.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
closing = opriv->do_closing;
|
closing = opriv->do_closing;
|
||||||
opriv->do_closing = true;
|
opriv->do_closing = true;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
if (closing)
|
if (closing)
|
||||||
{
|
{
|
||||||
|
|||||||
+22
-22
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* drivers/serial/serial.c
|
* drivers/serial/serial.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2009, 2011-2013, 2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -227,7 +227,7 @@ static int uart_putxmitchar(FAR uart_dev_t *dev, int ch, bool oktoblock)
|
|||||||
* the following steps must be atomic.
|
* the following steps must be atomic.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_REMOVABLE
|
#ifdef CONFIG_SERIAL_REMOVABLE
|
||||||
/* Check if the removable device is no longer connected while we
|
/* Check if the removable device is no longer connected while we
|
||||||
@@ -257,7 +257,7 @@ static int uart_putxmitchar(FAR uart_dev_t *dev, int ch, bool oktoblock)
|
|||||||
uart_disabletxint(dev);
|
uart_disabletxint(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_REMOVABLE
|
#ifdef CONFIG_SERIAL_REMOVABLE
|
||||||
/* Check if the removable device was disconnected while we were
|
/* Check if the removable device was disconnected while we were
|
||||||
@@ -366,9 +366,9 @@ static ssize_t uart_write(FAR struct file *filep, FAR const char *buffer,
|
|||||||
|
|
||||||
if (dev->isconsole)
|
if (dev->isconsole)
|
||||||
{
|
{
|
||||||
irqstate_t flags = irqsave();
|
irqstate_t flags = enter_critical_section();
|
||||||
ret = uart_irqwrite(dev, buffer, buflen);
|
ret = uart_irqwrite(dev, buffer, buflen);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -712,7 +712,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen
|
|||||||
* that the following operations are atomic.
|
* that the following operations are atomic.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_DMA
|
#ifdef CONFIG_SERIAL_DMA
|
||||||
/* If RX buffer is empty move tail and head to zero position */
|
/* If RX buffer is empty move tail and head to zero position */
|
||||||
@@ -751,7 +751,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen
|
|||||||
ret = uart_takesem(&dev->recvsem, true);
|
ret = uart_takesem(&dev->recvsem, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Was a signal received while waiting for data to be
|
/* Was a signal received while waiting for data to be
|
||||||
* received? Was a removable device disconnected while
|
* received? Was a removable device disconnected while
|
||||||
@@ -799,7 +799,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_DMA
|
#ifdef CONFIG_SERIAL_DMA
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* If RX buffer is empty move tail and head to zero position */
|
/* If RX buffer is empty move tail and head to zero position */
|
||||||
|
|
||||||
@@ -808,7 +808,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen
|
|||||||
rxbuf->head = rxbuf->tail = 0;
|
rxbuf->head = rxbuf->tail = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Notify DMA that there is free space in the RX buffer */
|
/* Notify DMA that there is free space in the RX buffer */
|
||||||
|
|
||||||
@@ -885,7 +885,7 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
case FIONREAD:
|
case FIONREAD:
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
irqstate_t state = irqsave();
|
irqstate_t flags = enter_critical_section();
|
||||||
|
|
||||||
/* Determine the number of bytes available in the buffer */
|
/* Determine the number of bytes available in the buffer */
|
||||||
|
|
||||||
@@ -898,7 +898,7 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
count = dev->recv.size - (dev->recv.tail - dev->recv.head);
|
count = dev->recv.size - (dev->recv.tail - dev->recv.head);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(state);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
*(FAR int *)((uintptr_t)arg) = count;
|
*(FAR int *)((uintptr_t)arg) = count;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@@ -908,7 +908,7 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
case FIONWRITE:
|
case FIONWRITE:
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
irqstate_t state = irqsave();
|
irqstate_t flags = enter_critical_section();
|
||||||
|
|
||||||
/* Determine the number of bytes free in the buffer */
|
/* Determine the number of bytes free in the buffer */
|
||||||
|
|
||||||
@@ -921,7 +921,7 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
count = dev->xmit.size - (dev->xmit.head - dev->xmit.tail) - 1;
|
count = dev->xmit.size - (dev->xmit.head - dev->xmit.tail) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(state);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
*(FAR int *)((uintptr_t)arg) = count;
|
*(FAR int *)((uintptr_t)arg) = count;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@@ -1182,14 +1182,14 @@ static int uart_close(FAR struct file *filep)
|
|||||||
|
|
||||||
/* Free the IRQ and disable the UART */
|
/* Free the IRQ and disable the UART */
|
||||||
|
|
||||||
flags = irqsave(); /* Disable interrupts */
|
flags = enter_critical_section(); /* Disable interrupts */
|
||||||
uart_detach(dev); /* Detach interrupts */
|
uart_detach(dev); /* Detach interrupts */
|
||||||
if (!dev->isconsole) /* Check for the serial console UART */
|
if (!dev->isconsole) /* Check for the serial console UART */
|
||||||
{
|
{
|
||||||
uart_shutdown(dev); /* Disable the UART */
|
uart_shutdown(dev); /* Disable the UART */
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* We need to re-initialize the semaphores if this is the last close
|
/* We need to re-initialize the semaphores if this is the last close
|
||||||
* of the device, as the close might be caused by pthread_cancel() of
|
* of the device, as the close might be caused by pthread_cancel() of
|
||||||
@@ -1269,7 +1269,7 @@ static int uart_open(FAR struct file *filep)
|
|||||||
|
|
||||||
if (tmp == 1)
|
if (tmp == 1)
|
||||||
{
|
{
|
||||||
irqstate_t flags = irqsave();
|
irqstate_t flags = enter_critical_section();
|
||||||
|
|
||||||
/* If this is the console, then the UART has already been initialized. */
|
/* If this is the console, then the UART has already been initialized. */
|
||||||
|
|
||||||
@@ -1280,7 +1280,7 @@ static int uart_open(FAR struct file *filep)
|
|||||||
ret = uart_setup(dev);
|
ret = uart_setup(dev);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
goto errout_with_sem;
|
goto errout_with_sem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1295,7 +1295,7 @@ static int uart_open(FAR struct file *filep)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
uart_shutdown(dev);
|
uart_shutdown(dev);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
goto errout_with_sem;
|
goto errout_with_sem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1306,7 +1306,7 @@ static int uart_open(FAR struct file *filep)
|
|||||||
dev->recv.head = 0;
|
dev->recv.head = 0;
|
||||||
dev->recv.tail = 0;
|
dev->recv.tail = 0;
|
||||||
|
|
||||||
/* Initialise termios state */
|
/* Initialize termios state */
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
#ifdef CONFIG_SERIAL_TERMIOS
|
||||||
dev->tc_iflag = 0;
|
dev->tc_iflag = 0;
|
||||||
@@ -1331,7 +1331,7 @@ static int uart_open(FAR struct file *filep)
|
|||||||
/* Enable the RX interrupt */
|
/* Enable the RX interrupt */
|
||||||
|
|
||||||
uart_enablerxint(dev);
|
uart_enablerxint(dev);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save the new open count on success */
|
/* Save the new open count on success */
|
||||||
@@ -1454,7 +1454,7 @@ void uart_connected(FAR uart_dev_t *dev, bool connected)
|
|||||||
* function may be called from interrupt handling logic.
|
* function may be called from interrupt handling logic.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
dev->disconnected = !connected;
|
dev->disconnected = !connected;
|
||||||
if (!connected)
|
if (!connected)
|
||||||
{
|
{
|
||||||
@@ -1487,6 +1487,6 @@ void uart_connected(FAR uart_dev_t *dev, bool connected)
|
|||||||
uart_pollnotify(dev, (POLLERR | POLLHUP));
|
uart_pollnotify(dev, (POLLERR | POLLHUP));
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -900,18 +900,18 @@ static int u16550_ioctl(struct file *filep, int cmd, unsigned long arg)
|
|||||||
|
|
||||||
case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */
|
case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */
|
||||||
{
|
{
|
||||||
irqstate_t flags = irqsave();
|
irqstate_t flags = enter_critical_section();
|
||||||
u16550_enablebreaks(priv, true);
|
u16550_enablebreaks(priv, true);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TIOCCBRK: /* BSD compatibility: Turn break off, unconditionally */
|
case TIOCCBRK: /* BSD compatibility: Turn break off, unconditionally */
|
||||||
{
|
{
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
u16550_enablebreaks(priv, false);
|
u16550_enablebreaks(priv, false);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1010,7 +1010,7 @@ static void u16550_txint(struct uart_dev_s *dev, bool enable)
|
|||||||
FAR struct u16550_s *priv = (FAR struct u16550_s *)dev->priv;
|
FAR struct u16550_s *priv = (FAR struct u16550_s *)dev->priv;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
if (enable)
|
if (enable)
|
||||||
{
|
{
|
||||||
priv->ier |= UART_IER_ETBEI;
|
priv->ier |= UART_IER_ETBEI;
|
||||||
@@ -1028,7 +1028,7 @@ static void u16550_txint(struct uart_dev_s *dev, bool enable)
|
|||||||
u16550_serialout(priv, UART_IER_OFFSET, priv->ier);
|
u16550_serialout(priv, UART_IER_OFFSET, priv->ier);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/syslog/ramlog.h>
|
#include <nuttx/syslog/ramlog.h>
|
||||||
|
|
||||||
#include <arch/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
#ifdef CONFIG_RAMLOG
|
#ifdef CONFIG_RAMLOG
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ static void ramlog_pollnotify(FAR struct ramlog_dev_s *priv,
|
|||||||
|
|
||||||
for (i = 0; i < CONFIG_RAMLOG_NPOLLWAITERS; i++)
|
for (i = 0; i < CONFIG_RAMLOG_NPOLLWAITERS; i++)
|
||||||
{
|
{
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
fds = priv->rl_fds[i];
|
fds = priv->rl_fds[i];
|
||||||
if (fds)
|
if (fds)
|
||||||
{
|
{
|
||||||
@@ -192,7 +192,7 @@ static void ramlog_pollnotify(FAR struct ramlog_dev_s *priv,
|
|||||||
sem_post(fds->sem);
|
sem_post(fds->sem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -210,7 +210,7 @@ static int ramlog_addchar(FAR struct ramlog_dev_s *priv, char ch)
|
|||||||
|
|
||||||
/* Disable interrupts (in case we are NOT called from interrupt handler) */
|
/* Disable interrupts (in case we are NOT called from interrupt handler) */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Calculate the write index AFTER the next byte is written */
|
/* Calculate the write index AFTER the next byte is written */
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ static int ramlog_addchar(FAR struct ramlog_dev_s *priv, char ch)
|
|||||||
{
|
{
|
||||||
/* Yes... Return an indication that nothing was saved in the buffer. */
|
/* Yes... Return an indication that nothing was saved in the buffer. */
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ static int ramlog_addchar(FAR struct ramlog_dev_s *priv, char ch)
|
|||||||
|
|
||||||
priv->rl_buffer[priv->rl_head] = ch;
|
priv->rl_buffer[priv->rl_head] = ch;
|
||||||
priv->rl_head = nexthead;
|
priv->rl_head = nexthead;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,7 +494,7 @@ static ssize_t ramlog_write(FAR struct file *filep, FAR const char *buffer, size
|
|||||||
|
|
||||||
/* Are there threads waiting for read data? */
|
/* Are there threads waiting for read data? */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
#ifndef CONFIG_RAMLOG_NONBLOCKING
|
#ifndef CONFIG_RAMLOG_NONBLOCKING
|
||||||
for (i = 0; i < priv->rl_nwaiters; i++)
|
for (i = 0; i < priv->rl_nwaiters; i++)
|
||||||
{
|
{
|
||||||
@@ -507,7 +507,7 @@ static ssize_t ramlog_write(FAR struct file *filep, FAR const char *buffer, size
|
|||||||
/* Notify all poll/select waiters that they can write to the FIFO */
|
/* Notify all poll/select waiters that they can write to the FIFO */
|
||||||
|
|
||||||
ramlog_pollnotify(priv, POLLIN);
|
ramlog_pollnotify(priv, POLLIN);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+23
-26
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbdev/cdcacm.c
|
* drivers/usbdev/cdcacm.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011-2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011-2013, 2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -51,6 +51,7 @@
|
|||||||
#include <queue.h>
|
#include <queue.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/serial/serial.h>
|
#include <nuttx/serial/serial.h>
|
||||||
@@ -68,10 +69,6 @@
|
|||||||
# include "composite.h"
|
# include "composite.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -282,7 +279,7 @@ static uint16_t cdcacm_fillrequest(FAR struct cdcacm_dev_s *priv, uint8_t *reqbu
|
|||||||
|
|
||||||
/* Disable interrupts */
|
/* Disable interrupts */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Transfer bytes while we have bytes available and there is room in the request */
|
/* Transfer bytes while we have bytes available and there is room in the request */
|
||||||
|
|
||||||
@@ -317,7 +314,7 @@ static uint16_t cdcacm_fillrequest(FAR struct cdcacm_dev_s *priv, uint8_t *reqbu
|
|||||||
uart_datasent(serdev);
|
uart_datasent(serdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return nbytes;
|
return nbytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,7 +347,7 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Use our IN endpoint for the transfer */
|
/* Use our IN endpoint for the transfer */
|
||||||
|
|
||||||
@@ -404,7 +401,7 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -834,7 +831,7 @@ static void cdcacm_rdcomplete(FAR struct usbdev_ep_s *ep,
|
|||||||
|
|
||||||
/* Process the received data unless this is some unusual condition */
|
/* Process the received data unless this is some unusual condition */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
switch (req->result)
|
switch (req->result)
|
||||||
{
|
{
|
||||||
case 0: /* Normal completion */
|
case 0: /* Normal completion */
|
||||||
@@ -845,7 +842,7 @@ static void cdcacm_rdcomplete(FAR struct usbdev_ep_s *ep,
|
|||||||
case -ESHUTDOWN: /* Disconnection */
|
case -ESHUTDOWN: /* Disconnection */
|
||||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSHUTDOWN), 0);
|
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSHUTDOWN), 0);
|
||||||
priv->nrdq--;
|
priv->nrdq--;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default: /* Some other error occurred */
|
default: /* Some other error occurred */
|
||||||
@@ -862,7 +859,7 @@ static void cdcacm_rdcomplete(FAR struct usbdev_ep_s *ep,
|
|||||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16_t)-req->result);
|
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16_t)-req->result);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -898,10 +895,10 @@ static void cdcacm_wrcomplete(FAR struct usbdev_ep_s *ep,
|
|||||||
|
|
||||||
/* Return the write request to the free list */
|
/* Return the write request to the free list */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
sq_addlast((FAR sq_entry_t *)reqcontainer, &priv->reqlist);
|
sq_addlast((FAR sq_entry_t *)reqcontainer, &priv->reqlist);
|
||||||
priv->nwrq++;
|
priv->nwrq++;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Send the next packet unless this was some unusual termination
|
/* Send the next packet unless this was some unusual termination
|
||||||
* condition
|
* condition
|
||||||
@@ -1079,10 +1076,10 @@ static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver,
|
|||||||
reqcontainer->req->priv = reqcontainer;
|
reqcontainer->req->priv = reqcontainer;
|
||||||
reqcontainer->req->callback = cdcacm_wrcomplete;
|
reqcontainer->req->callback = cdcacm_wrcomplete;
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
sq_addlast((FAR sq_entry_t *)reqcontainer, &priv->reqlist);
|
sq_addlast((FAR sq_entry_t *)reqcontainer, &priv->reqlist);
|
||||||
priv->nwrq++; /* Count of write requests available */
|
priv->nwrq++; /* Count of write requests available */
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Report if we are selfpowered (unless we are part of a composite device) */
|
/* Report if we are selfpowered (unless we are part of a composite device) */
|
||||||
@@ -1208,7 +1205,7 @@ static void cdcacm_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||||||
* of them)
|
* of them)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
DEBUGASSERT(priv->nwrq == CONFIG_CDCACM_NWRREQS);
|
DEBUGASSERT(priv->nwrq == CONFIG_CDCACM_NWRREQS);
|
||||||
while (!sq_empty(&priv->reqlist))
|
while (!sq_empty(&priv->reqlist))
|
||||||
{
|
{
|
||||||
@@ -1221,7 +1218,7 @@ static void cdcacm_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEBUGASSERT(priv->nwrq == 0);
|
DEBUGASSERT(priv->nwrq == 0);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Clear out all data in the circular buffer */
|
/* Clear out all data in the circular buffer */
|
||||||
|
|
||||||
@@ -1648,7 +1645,7 @@ static void cdcacm_disconnect(FAR struct usbdevclass_driver_s *driver,
|
|||||||
* connection.
|
* connection.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
#ifdef CONFIG_SERIAL_REMOVABLE
|
#ifdef CONFIG_SERIAL_REMOVABLE
|
||||||
uart_connected(&priv->serdev, false);
|
uart_connected(&priv->serdev, false);
|
||||||
#endif
|
#endif
|
||||||
@@ -1662,7 +1659,7 @@ static void cdcacm_disconnect(FAR struct usbdevclass_driver_s *driver,
|
|||||||
priv->serdev.xmit.head = 0;
|
priv->serdev.xmit.head = 0;
|
||||||
priv->serdev.xmit.tail = 0;
|
priv->serdev.xmit.tail = 0;
|
||||||
priv->rxhead = 0;
|
priv->rxhead = 0;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Perform the soft connect function so that we will we can be
|
/* Perform the soft connect function so that we will we can be
|
||||||
* re-enumerated (unless we are part of a composite device)
|
* re-enumerated (unless we are part of a composite device)
|
||||||
@@ -1988,7 +1985,7 @@ static int cdcuart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
case FIONREAD:
|
case FIONREAD:
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
irqstate_t state = irqsave();
|
irqstate_t flags = enter_critical_section();
|
||||||
|
|
||||||
/* Determine the number of bytes available in the buffer. */
|
/* Determine the number of bytes available in the buffer. */
|
||||||
|
|
||||||
@@ -2001,7 +1998,7 @@ static int cdcuart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
count = serdev->recv.size - (serdev->recv.tail - serdev->recv.head);
|
count = serdev->recv.size - (serdev->recv.tail - serdev->recv.head);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(state);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
*(int *)arg = count;
|
*(int *)arg = count;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@@ -2011,7 +2008,7 @@ static int cdcuart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
case FIONWRITE:
|
case FIONWRITE:
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
irqstate_t state = irqsave();
|
irqstate_t flags = enter_critical_section();
|
||||||
|
|
||||||
/* Determine the number of bytes free in the buffer. */
|
/* Determine the number of bytes free in the buffer. */
|
||||||
|
|
||||||
@@ -2024,7 +2021,7 @@ static int cdcuart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
count = serdev->xmit.size - (serdev->xmit.head - serdev->xmit.tail) - 1;
|
count = serdev->xmit.size - (serdev->xmit.head - serdev->xmit.tail) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(state);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
*(int *)arg = count;
|
*(int *)arg = count;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@@ -2083,7 +2080,7 @@ static void cdcuart_rxint(FAR struct uart_dev_s *dev, bool enable)
|
|||||||
* in the following.
|
* in the following.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
if (enable)
|
if (enable)
|
||||||
{
|
{
|
||||||
/* RX "interrupts" are enabled. Is this a transition from disabled
|
/* RX "interrupts" are enabled. Is this a transition from disabled
|
||||||
@@ -2132,7 +2129,7 @@ static void cdcuart_rxint(FAR struct uart_dev_s *dev, bool enable)
|
|||||||
priv->rxhead = serdev->recv.head;
|
priv->rxhead = serdev->recv.head;
|
||||||
priv->rxenabled = false;
|
priv->rxenabled = false;
|
||||||
}
|
}
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
+10
-13
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbdev/composite.c
|
* drivers/usbdev/composite.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/usb/usb.h>
|
#include <nuttx/usb/usb.h>
|
||||||
@@ -55,10 +56,6 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_USBDEV_COMPOSITE
|
#ifdef CONFIG_USBDEV_COMPOSITE
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -368,7 +365,7 @@ static void composite_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||||||
{
|
{
|
||||||
/* Unbind the constituent class drivers */
|
/* Unbind the constituent class drivers */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
CLASS_UNBIND(priv->dev1, dev);
|
CLASS_UNBIND(priv->dev1, dev);
|
||||||
CLASS_UNBIND(priv->dev2, dev);
|
CLASS_UNBIND(priv->dev2, dev);
|
||||||
|
|
||||||
@@ -380,7 +377,7 @@ static void composite_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||||||
composite_freereq(dev->ep0, priv->ctrlreq);
|
composite_freereq(dev->ep0, priv->ctrlreq);
|
||||||
priv->ctrlreq = NULL;
|
priv->ctrlreq = NULL;
|
||||||
}
|
}
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,11 +662,11 @@ static void composite_disconnect(FAR struct usbdevclass_driver_s *driver,
|
|||||||
* the disconnection.
|
* the disconnection.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->config = COMPOSITE_CONFIGIDNONE;
|
priv->config = COMPOSITE_CONFIGIDNONE;
|
||||||
CLASS_DISCONNECT(priv->dev1, dev);
|
CLASS_DISCONNECT(priv->dev1, dev);
|
||||||
CLASS_DISCONNECT(priv->dev2, dev);
|
CLASS_DISCONNECT(priv->dev2, dev);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Perform the soft connect function so that we will we can be
|
/* Perform the soft connect function so that we will we can be
|
||||||
* re-enumerated.
|
* re-enumerated.
|
||||||
@@ -716,10 +713,10 @@ static void composite_suspend(FAR struct usbdevclass_driver_s *driver,
|
|||||||
|
|
||||||
/* Forward the suspend event to the constituent devices */
|
/* Forward the suspend event to the constituent devices */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
CLASS_SUSPEND(priv->dev1, priv->usbdev);
|
CLASS_SUSPEND(priv->dev1, priv->usbdev);
|
||||||
CLASS_SUSPEND(priv->dev2, priv->usbdev);
|
CLASS_SUSPEND(priv->dev2, priv->usbdev);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -758,10 +755,10 @@ static void composite_resume(FAR struct usbdevclass_driver_s *driver,
|
|||||||
|
|
||||||
/* Forward the resume event to the constituent devices */
|
/* Forward the resume event to the constituent devices */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
CLASS_RESUME(priv->dev1, priv->usbdev);
|
CLASS_RESUME(priv->dev1, priv->usbdev);
|
||||||
CLASS_RESUME(priv->dev2, priv->usbdev);
|
CLASS_RESUME(priv->dev2, priv->usbdev);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
+19
-18
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbdev/pl2303.c
|
* drivers/usbdev/pl2303.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2013, 2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008-2013, 2015-2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* This logic emulates the Prolific PL2303 serial/USB converter
|
* This logic emulates the Prolific PL2303 serial/USB converter
|
||||||
@@ -53,6 +53,7 @@
|
|||||||
#include <queue.h>
|
#include <queue.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/serial/serial.h>
|
#include <nuttx/serial/serial.h>
|
||||||
@@ -537,7 +538,7 @@ static uint16_t usbclass_fillrequest(FAR struct pl2303_dev_s *priv, uint8_t *req
|
|||||||
|
|
||||||
/* Disable interrupts */
|
/* Disable interrupts */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Transfer bytes while we have bytes available and there is room in the request */
|
/* Transfer bytes while we have bytes available and there is room in the request */
|
||||||
|
|
||||||
@@ -572,7 +573,7 @@ static uint16_t usbclass_fillrequest(FAR struct pl2303_dev_s *priv, uint8_t *req
|
|||||||
uart_datasent(serdev);
|
uart_datasent(serdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return nbytes;
|
return nbytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -605,7 +606,7 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Use our IN endpoint for the transfer */
|
/* Use our IN endpoint for the transfer */
|
||||||
|
|
||||||
@@ -659,7 +660,7 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1216,7 +1217,7 @@ static void usbclass_rdcomplete(FAR struct usbdev_ep_s *ep,
|
|||||||
|
|
||||||
/* Process the received data unless this is some unusual condition */
|
/* Process the received data unless this is some unusual condition */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
switch (req->result)
|
switch (req->result)
|
||||||
{
|
{
|
||||||
case 0: /* Normal completion */
|
case 0: /* Normal completion */
|
||||||
@@ -1227,7 +1228,7 @@ static void usbclass_rdcomplete(FAR struct usbdev_ep_s *ep,
|
|||||||
case -ESHUTDOWN: /* Disconnection */
|
case -ESHUTDOWN: /* Disconnection */
|
||||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSHUTDOWN), 0);
|
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSHUTDOWN), 0);
|
||||||
priv->nrdq--;
|
priv->nrdq--;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default: /* Some other error occurred */
|
default: /* Some other error occurred */
|
||||||
@@ -1243,7 +1244,7 @@ static void usbclass_rdcomplete(FAR struct usbdev_ep_s *ep,
|
|||||||
{
|
{
|
||||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16_t)-req->result);
|
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16_t)-req->result);
|
||||||
}
|
}
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -1279,10 +1280,10 @@ static void usbclass_wrcomplete(FAR struct usbdev_ep_s *ep,
|
|||||||
|
|
||||||
/* Return the write request to the free list */
|
/* Return the write request to the free list */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
sq_addlast((FAR sq_entry_t *)reqcontainer, &priv->reqlist);
|
sq_addlast((FAR sq_entry_t *)reqcontainer, &priv->reqlist);
|
||||||
priv->nwrq++;
|
priv->nwrq++;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Send the next packet unless this was some unusual termination
|
/* Send the next packet unless this was some unusual termination
|
||||||
* condition
|
* condition
|
||||||
@@ -1448,10 +1449,10 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
|||||||
reqcontainer->req->priv = reqcontainer;
|
reqcontainer->req->priv = reqcontainer;
|
||||||
reqcontainer->req->callback = usbclass_wrcomplete;
|
reqcontainer->req->callback = usbclass_wrcomplete;
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
sq_addlast((FAR sq_entry_t *)reqcontainer, &priv->reqlist);
|
sq_addlast((FAR sq_entry_t *)reqcontainer, &priv->reqlist);
|
||||||
priv->nwrq++; /* Count of write requests available */
|
priv->nwrq++; /* Count of write requests available */
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Report if we are selfpowered */
|
/* Report if we are selfpowered */
|
||||||
@@ -1573,7 +1574,7 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||||||
* of them
|
* of them
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
DEBUGASSERT(priv->nwrq == CONFIG_PL2303_NWRREQS);
|
DEBUGASSERT(priv->nwrq == CONFIG_PL2303_NWRREQS);
|
||||||
while (!sq_empty(&priv->reqlist))
|
while (!sq_empty(&priv->reqlist))
|
||||||
{
|
{
|
||||||
@@ -1585,7 +1586,7 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEBUGASSERT(priv->nwrq == 0);
|
DEBUGASSERT(priv->nwrq == 0);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear out all data in the circular buffer */
|
/* Clear out all data in the circular buffer */
|
||||||
@@ -1900,7 +1901,7 @@ static void usbclass_disconnect(FAR struct usbdevclass_driver_s *driver,
|
|||||||
* connection.
|
* connection.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
#ifdef CONFIG_SERIAL_REMOVABLE
|
#ifdef CONFIG_SERIAL_REMOVABLE
|
||||||
uart_connected(&priv->serdev, false);
|
uart_connected(&priv->serdev, false);
|
||||||
#endif
|
#endif
|
||||||
@@ -1914,7 +1915,7 @@ static void usbclass_disconnect(FAR struct usbdevclass_driver_s *driver,
|
|||||||
priv->serdev.xmit.head = 0;
|
priv->serdev.xmit.head = 0;
|
||||||
priv->serdev.xmit.tail = 0;
|
priv->serdev.xmit.tail = 0;
|
||||||
priv->rxhead = 0;
|
priv->rxhead = 0;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Perform the soft connect function so that we will we can be
|
/* Perform the soft connect function so that we will we can be
|
||||||
* re-enumerated.
|
* re-enumerated.
|
||||||
@@ -2136,7 +2137,7 @@ static void usbser_rxint(FAR struct uart_dev_s *dev, bool enable)
|
|||||||
* in the following.
|
* in the following.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
if (enable)
|
if (enable)
|
||||||
{
|
{
|
||||||
/* RX "interrupts" are enabled. Is this a transition from disabled
|
/* RX "interrupts" are enabled. Is this a transition from disabled
|
||||||
@@ -2185,7 +2186,7 @@ static void usbser_rxint(FAR struct uart_dev_s *dev, bool enable)
|
|||||||
priv->rxhead = serdev->recv.head;
|
priv->rxhead = serdev->recv.head;
|
||||||
priv->rxenabled = false;
|
priv->rxenabled = false;
|
||||||
}
|
}
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <arch/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
#include <nuttx/usb/usbdev_trace.h>
|
||||||
#undef usbtrace
|
#undef usbtrace
|
||||||
|
|
||||||
@@ -140,10 +140,10 @@ usbtrace_idset_t usbtrace_enable(usbtrace_idset_t idset)
|
|||||||
|
|
||||||
/* The following read and write must be atomic */
|
/* The following read and write must be atomic */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
ret = g_maskedidset;
|
ret = g_maskedidset;
|
||||||
g_maskedidset = idset;
|
g_maskedidset = idset;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_USBDEV_TRACE || CONFIG_DEBUG && CONFIG_DEBUG_USB */
|
#endif /* CONFIG_USBDEV_TRACE || CONFIG_DEBUG && CONFIG_DEBUG_USB */
|
||||||
@@ -166,7 +166,7 @@ void usbtrace(uint16_t event, uint16_t value)
|
|||||||
|
|
||||||
/* Check if tracing is enabled for this ID */
|
/* Check if tracing is enabled for this ID */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
if ((g_maskedidset & TRACE_ID2BIT(event)) != 0)
|
if ((g_maskedidset & TRACE_ID2BIT(event)) != 0)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_USBDEV_TRACE
|
#ifdef CONFIG_USBDEV_TRACE
|
||||||
@@ -196,7 +196,7 @@ void usbtrace(uint16_t event, uint16_t value)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_USBDEV_TRACE || CONFIG_DEBUG && CONFIG_DEBUG_USB */
|
#endif /* CONFIG_USBDEV_TRACE || CONFIG_DEBUG && CONFIG_DEBUG_USB */
|
||||||
|
|
||||||
|
|||||||
+16
-15
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbdev/usbmsc.c
|
* drivers/usbdev/usbmsc.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008-2012, 2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Mass storage class device. Bulk-only with SCSI subclass.
|
* Mass storage class device. Bulk-only with SCSI subclass.
|
||||||
@@ -71,6 +71,7 @@
|
|||||||
#include <queue.h>
|
#include <queue.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/kthread.h>
|
#include <nuttx/kthread.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
@@ -360,9 +361,9 @@ static int usbmsc_bind(FAR struct usbdevclass_driver_s *driver,
|
|||||||
reqcontainer->req->priv = reqcontainer;
|
reqcontainer->req->priv = reqcontainer;
|
||||||
reqcontainer->req->callback = usbmsc_wrcomplete;
|
reqcontainer->req->callback = usbmsc_wrcomplete;
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
sq_addlast((FAR sq_entry_t *)reqcontainer, &priv->wrreqlist);
|
sq_addlast((FAR sq_entry_t *)reqcontainer, &priv->wrreqlist);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Report if we are selfpowered (unless we are part of a composite device) */
|
/* Report if we are selfpowered (unless we are part of a composite device) */
|
||||||
@@ -477,7 +478,7 @@ static void usbmsc_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||||||
* of them
|
* of them
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
while (!sq_empty(&priv->wrreqlist))
|
while (!sq_empty(&priv->wrreqlist))
|
||||||
{
|
{
|
||||||
reqcontainer = (struct usbmsc_req_s *)sq_remfirst(&priv->wrreqlist);
|
reqcontainer = (struct usbmsc_req_s *)sq_remfirst(&priv->wrreqlist);
|
||||||
@@ -495,7 +496,7 @@ static void usbmsc_unbind(FAR struct usbdevclass_driver_s *driver,
|
|||||||
priv->epbulkin = NULL;
|
priv->epbulkin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -868,14 +869,14 @@ static void usbmsc_disconnect(FAR struct usbdevclass_driver_s *driver,
|
|||||||
|
|
||||||
/* Reset the configuration */
|
/* Reset the configuration */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
usbmsc_resetconfig(priv);
|
usbmsc_resetconfig(priv);
|
||||||
|
|
||||||
/* Signal the worker thread */
|
/* Signal the worker thread */
|
||||||
|
|
||||||
priv->theventset |= USBMSC_EVENT_DISCONNECT;
|
priv->theventset |= USBMSC_EVENT_DISCONNECT;
|
||||||
usbmsc_scsi_signal(priv);
|
usbmsc_scsi_signal(priv);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Perform the soft connect function so that we will we can be
|
/* Perform the soft connect function so that we will we can be
|
||||||
* re-enumerated (unless we are part of a composite device)
|
* re-enumerated (unless we are part of a composite device)
|
||||||
@@ -1088,9 +1089,9 @@ void usbmsc_wrcomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req)
|
|||||||
|
|
||||||
/* Return the write request to the free list */
|
/* Return the write request to the free list */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
sq_addlast((FAR sq_entry_t *)privreq, &priv->wrreqlist);
|
sq_addlast((FAR sq_entry_t *)privreq, &priv->wrreqlist);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Process the received data unless this is some unusual condition */
|
/* Process the received data unless this is some unusual condition */
|
||||||
|
|
||||||
@@ -1157,9 +1158,9 @@ void usbmsc_rdcomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req)
|
|||||||
|
|
||||||
/* Add the filled read request from the rdreqlist */
|
/* Add the filled read request from the rdreqlist */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
sq_addlast((FAR sq_entry_t *)privreq, &priv->rdreqlist);
|
sq_addlast((FAR sq_entry_t *)privreq, &priv->rdreqlist);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Signal the worker thread that there is received data to be processed */
|
/* Signal the worker thread that there is received data to be processed */
|
||||||
|
|
||||||
@@ -1681,10 +1682,10 @@ int usbmsc_exportluns(FAR void *handle)
|
|||||||
/* Signal to start the thread */
|
/* Signal to start the thread */
|
||||||
|
|
||||||
uvdbg("Signalling for the SCSI worker thread\n");
|
uvdbg("Signalling for the SCSI worker thread\n");
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->theventset |= USBMSC_EVENT_READY;
|
priv->theventset |= USBMSC_EVENT_READY;
|
||||||
usbmsc_scsi_signal(priv);
|
usbmsc_scsi_signal(priv);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
errout_with_lock:
|
errout_with_lock:
|
||||||
usbmsc_scsi_unlock(priv);
|
usbmsc_scsi_unlock(priv);
|
||||||
@@ -1792,10 +1793,10 @@ void usbmsc_uninitialize(FAR void *handle)
|
|||||||
{
|
{
|
||||||
/* Yes.. Ask the thread to stop */
|
/* Yes.. Ask the thread to stop */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->theventset |= USBMSC_EVENT_TERMINATEREQUEST;
|
priv->theventset |= USBMSC_EVENT_TERMINATEREQUEST;
|
||||||
usbmsc_scsi_signal(priv);
|
usbmsc_scsi_signal(priv);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
usbmsc_scsi_unlock(priv);
|
usbmsc_scsi_unlock(priv);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbdev/usbmsc_scsi.c
|
* drivers/usbdev/usbmsc_scsi.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2010, 2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008-2010, 2012, 2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Mass storage class device. Bulk-only with SCSI subclass.
|
* Mass storage class device. Bulk-only with SCSI subclass.
|
||||||
@@ -67,6 +67,7 @@
|
|||||||
#include <queue.h>
|
#include <queue.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kthread.h>
|
#include <nuttx/kthread.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/scsi.h>
|
#include <nuttx/scsi.h>
|
||||||
@@ -379,7 +380,7 @@ static void usbmsc_scsi_wait(FAR struct usbmsc_dev_s *priv)
|
|||||||
* enabled while we wait for the event.
|
* enabled while we wait for the event.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->thwaiting = true;
|
priv->thwaiting = true;
|
||||||
|
|
||||||
/* Relinquish our lock on the SCSI state data */
|
/* Relinquish our lock on the SCSI state data */
|
||||||
@@ -399,7 +400,7 @@ static void usbmsc_scsi_wait(FAR struct usbmsc_dev_s *priv)
|
|||||||
/* Re-acquire our lock on the SCSI state data */
|
/* Re-acquire our lock on the SCSI state data */
|
||||||
|
|
||||||
usbmsc_scsi_lock(priv);
|
usbmsc_scsi_lock(priv);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -1631,9 +1632,9 @@ static int usbmsc_idlestate(FAR struct usbmsc_dev_s *priv)
|
|||||||
|
|
||||||
/* Take a request from the rdreqlist */
|
/* Take a request from the rdreqlist */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
privreq = (FAR struct usbmsc_req_s *)sq_remfirst(&priv->rdreqlist);
|
privreq = (FAR struct usbmsc_req_s *)sq_remfirst(&priv->rdreqlist);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Has anything been received? If not, just return an error.
|
/* Has anything been received? If not, just return an error.
|
||||||
* This will cause us to remain in the IDLE state. When a USB request is
|
* This will cause us to remain in the IDLE state. When a USB request is
|
||||||
@@ -2178,9 +2179,9 @@ static int usbmsc_cmdreadstate(FAR struct usbmsc_dev_s *priv)
|
|||||||
* that is it not NULL
|
* that is it not NULL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
privreq = (FAR struct usbmsc_req_s *)sq_remfirst(&priv->wrreqlist);
|
privreq = (FAR struct usbmsc_req_s *)sq_remfirst(&priv->wrreqlist);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* And submit the request to the bulk IN endpoint */
|
/* And submit the request to the bulk IN endpoint */
|
||||||
|
|
||||||
@@ -2413,9 +2414,9 @@ static int usbmsc_cmdfinishstate(FAR struct usbmsc_dev_s *priv)
|
|||||||
* that is it not NULL)
|
* that is it not NULL)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
privreq = (FAR struct usbmsc_req_s *)sq_remfirst(&priv->wrreqlist);
|
privreq = (FAR struct usbmsc_req_s *)sq_remfirst(&priv->wrreqlist);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Send the write request */
|
/* Send the write request */
|
||||||
|
|
||||||
@@ -2463,7 +2464,7 @@ static int usbmsc_cmdfinishstate(FAR struct usbmsc_dev_s *priv)
|
|||||||
{
|
{
|
||||||
/* Did the host stop sending unexpectedly early? */
|
/* Did the host stop sending unexpectedly early? */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
if (priv->shortpacket)
|
if (priv->shortpacket)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_CMDFINISHSHORTPKT), (uint16_t)priv->residue);
|
usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_CMDFINISHSHORTPKT), (uint16_t)priv->residue);
|
||||||
@@ -2478,7 +2479,7 @@ static int usbmsc_cmdfinishstate(FAR struct usbmsc_dev_s *priv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
priv->theventset |= USBMSC_EVENT_ABORTBULKOUT;
|
priv->theventset |= USBMSC_EVENT_ABORTBULKOUT;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -2524,9 +2525,9 @@ static int usbmsc_cmdstatusstate(FAR struct usbmsc_dev_s *priv)
|
|||||||
|
|
||||||
/* Take a request from the wrreqlist */
|
/* Take a request from the wrreqlist */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
privreq = (FAR struct usbmsc_req_s *)sq_remfirst(&priv->wrreqlist);
|
privreq = (FAR struct usbmsc_req_s *)sq_remfirst(&priv->wrreqlist);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* If there no request structures available, then just return an error.
|
/* If there no request structures available, then just return an error.
|
||||||
* This will cause us to remain in the CMDSTATUS status. When a request is
|
* This will cause us to remain in the CMDSTATUS status. When a request is
|
||||||
@@ -2589,9 +2590,9 @@ static int usbmsc_cmdstatusstate(FAR struct usbmsc_dev_s *priv)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_SNDSTATUSSUBMIT), (uint16_t)-ret);
|
usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_SNDSTATUSSUBMIT), (uint16_t)-ret);
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
(void)sq_addlast((FAR sq_entry_t *)privreq, &priv->wrreqlist);
|
(void)sq_addlast((FAR sq_entry_t *)privreq, &priv->wrreqlist);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return to the IDLE state */
|
/* Return to the IDLE state */
|
||||||
@@ -2663,7 +2664,7 @@ int usbmsc_scsi_main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
usbmsc_scsi_lock(priv);
|
usbmsc_scsi_lock(priv);
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
if (priv->theventset == USBMSC_EVENT_NOEVENTS)
|
if (priv->theventset == USBMSC_EVENT_NOEVENTS)
|
||||||
{
|
{
|
||||||
usbmsc_scsi_wait(priv);
|
usbmsc_scsi_wait(priv);
|
||||||
@@ -2730,7 +2731,7 @@ int usbmsc_scsi_main(int argc, char *argv[])
|
|||||||
priv->thstate = USBMSC_STATE_IDLE;
|
priv->thstate = USBMSC_STATE_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Loop processing each SCSI command state. Each state handling
|
/* Loop processing each SCSI command state. Each state handling
|
||||||
* function will do the following:
|
* function will do the following:
|
||||||
@@ -2810,14 +2811,14 @@ void usbmsc_scsi_signal(FAR struct usbmsc_dev_s *priv)
|
|||||||
* of the semaphore count are atomic.
|
* of the semaphore count are atomic.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
if (priv->thwaiting)
|
if (priv->thwaiting)
|
||||||
{
|
{
|
||||||
priv->thwaiting = false;
|
priv->thwaiting = false;
|
||||||
sem_post(&priv->thwaitsem);
|
sem_post(&priv->thwaitsem);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbhost/usbhost_cdcacm.c
|
* drivers/usbhost/usbhost_cdcacm.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -49,6 +49,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/wqueue.h>
|
#include <nuttx/wqueue.h>
|
||||||
@@ -503,14 +504,14 @@ static FAR struct usbhost_cdcacm_s *usbhost_allocclass(void)
|
|||||||
* our pre-allocated class instances from the free list.
|
* our pre-allocated class instances from the free list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
entry = g_freelist;
|
entry = g_freelist;
|
||||||
if (entry)
|
if (entry)
|
||||||
{
|
{
|
||||||
g_freelist = entry->flink;
|
g_freelist = entry->flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
uvdbg("Allocated: %p\n", entry);
|
uvdbg("Allocated: %p\n", entry);
|
||||||
return (FAR struct usbhost_cdcacm_s *)entry;
|
return (FAR struct usbhost_cdcacm_s *)entry;
|
||||||
}
|
}
|
||||||
@@ -555,10 +556,10 @@ static void usbhost_freeclass(FAR struct usbhost_cdcacm_s *usbclass)
|
|||||||
|
|
||||||
/* Just put the pre-allocated class structure back on the freelist */
|
/* Just put the pre-allocated class structure back on the freelist */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
entry->flink = g_freelist;
|
entry->flink = g_freelist;
|
||||||
g_freelist = entry;
|
g_freelist = entry;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static void usbhost_freeclass(FAR struct usbhost_cdcacm_s *usbclass)
|
static void usbhost_freeclass(FAR struct usbhost_cdcacm_s *usbclass)
|
||||||
@@ -587,7 +588,7 @@ static int usbhost_devno_alloc(FAR struct usbhost_cdcacm_s *priv)
|
|||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
int devno;
|
int devno;
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
for (devno = 0; devno < 32; devno++)
|
for (devno = 0; devno < 32; devno++)
|
||||||
{
|
{
|
||||||
uint32_t bitno = 1 << devno;
|
uint32_t bitno = 1 << devno;
|
||||||
@@ -595,12 +596,12 @@ static int usbhost_devno_alloc(FAR struct usbhost_cdcacm_s *priv)
|
|||||||
{
|
{
|
||||||
g_devinuse |= bitno;
|
g_devinuse |= bitno;
|
||||||
priv->minor = devno;
|
priv->minor = devno;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return -EMFILE;
|
return -EMFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -618,9 +619,9 @@ static void usbhost_devno_free(FAR struct usbhost_cdcacm_s *priv)
|
|||||||
|
|
||||||
if (devno >= 0 && devno < 32)
|
if (devno >= 0 && devno < 32)
|
||||||
{
|
{
|
||||||
irqstate_t flags = irqsave();
|
irqstate_t flags = enter_critical_section();
|
||||||
g_devinuse &= ~(1 << devno);
|
g_devinuse &= ~(1 << devno);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2113,7 +2114,7 @@ static int usbhost_disconnected(struct usbhost_class_s *usbclass)
|
|||||||
* is no longer available.
|
* is no longer available.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->disconnected = true;
|
priv->disconnected = true;
|
||||||
|
|
||||||
/* Let the upper half driver know that serial device is no longer
|
/* Let the upper half driver know that serial device is no longer
|
||||||
@@ -2181,7 +2182,7 @@ static int usbhost_disconnected(struct usbhost_class_s *usbclass)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2217,7 +2218,7 @@ static int usbhost_setup(FAR struct uart_dev_s *uartdev)
|
|||||||
* isconnect events.
|
* isconnect events.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
if (priv->disconnected)
|
if (priv->disconnected)
|
||||||
{
|
{
|
||||||
/* No... the block driver is no longer bound to the class. That means that
|
/* No... the block driver is no longer bound to the class. That means that
|
||||||
@@ -2235,7 +2236,7 @@ static int usbhost_setup(FAR struct uart_dev_s *uartdev)
|
|||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
usbhost_givesem(&priv->exclsem);
|
usbhost_givesem(&priv->exclsem);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -2275,7 +2276,7 @@ static void usbhost_shutdown(FAR struct uart_dev_s *uartdev)
|
|||||||
* no asynchronous disconnect events.
|
* no asynchronous disconnect events.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Check if the USB CDC/ACM device is still connected. If the
|
/* Check if the USB CDC/ACM device is still connected. If the
|
||||||
* CDC/ACM device is not connected and the reference count just
|
* CDC/ACM device is not connected and the reference count just
|
||||||
@@ -2291,7 +2292,7 @@ static void usbhost_shutdown(FAR struct uart_dev_s *uartdev)
|
|||||||
usbhost_destroy(priv);
|
usbhost_destroy(priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbhost/usbhost_findclass.c
|
* drivers/usbhost/usbhost_findclass.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010, 2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2010, 2015-2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -44,28 +44,12 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/usb/usb.h>
|
#include <nuttx/usb/usb.h>
|
||||||
#include <nuttx/usb/usbhost.h>
|
#include <nuttx/usb/usbhost.h>
|
||||||
#include <arch/irq.h>
|
|
||||||
|
|
||||||
#include "usbhost_registry.h"
|
#include "usbhost_registry.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Types
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Function Prototypes
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -167,7 +151,7 @@ const struct usbhost_registry_s *usbhost_findclass(const struct usbhost_id_s *id
|
|||||||
* protected by disabling interrupts.
|
* protected by disabling interrupts.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Examine each register class in the linked list */
|
/* Examine each register class in the linked list */
|
||||||
|
|
||||||
@@ -186,7 +170,7 @@ const struct usbhost_registry_s *usbhost_findclass(const struct usbhost_id_s *id
|
|||||||
{
|
{
|
||||||
/* Yes.. restore interrupts and return the class info */
|
/* Yes.. restore interrupts and return the class info */
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return usbclass;
|
return usbclass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -194,7 +178,7 @@ const struct usbhost_registry_s *usbhost_findclass(const struct usbhost_id_s *id
|
|||||||
|
|
||||||
/* Not found... restore interrupts and return NULL */
|
/* Not found... restore interrupts and return NULL */
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbhost/usbhost_hidkbd.c
|
* drivers/usbhost/usbhost_hidkbd.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011-2013, 2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011-2013, 2015-2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -54,6 +54,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/kthread.h>
|
#include <nuttx/kthread.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
@@ -704,7 +705,7 @@ static int usbhost_allocdevno(FAR struct usbhost_state_s *priv)
|
|||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
int devno;
|
int devno;
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
for (devno = 0; devno < 26; devno++)
|
for (devno = 0; devno < 26; devno++)
|
||||||
{
|
{
|
||||||
uint32_t bitno = 1 << devno;
|
uint32_t bitno = 1 << devno;
|
||||||
@@ -712,12 +713,12 @@ static int usbhost_allocdevno(FAR struct usbhost_state_s *priv)
|
|||||||
{
|
{
|
||||||
g_devinuse |= bitno;
|
g_devinuse |= bitno;
|
||||||
priv->devchar = 'a' + devno;
|
priv->devchar = 'a' + devno;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return -EMFILE;
|
return -EMFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -727,9 +728,9 @@ static void usbhost_freedevno(FAR struct usbhost_state_s *priv)
|
|||||||
|
|
||||||
if (devno >= 0 && devno < 26)
|
if (devno >= 0 && devno < 26)
|
||||||
{
|
{
|
||||||
irqstate_t flags = irqsave();
|
irqstate_t flags = enter_critical_section();
|
||||||
g_devinuse &= ~(1 << devno);
|
g_devinuse &= ~(1 << devno);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1268,7 +1269,7 @@ static int usbhost_kbdpoll(int argc, char *argv[])
|
|||||||
|
|
||||||
udbg("Keyboard removed, polling halted\n");
|
udbg("Keyboard removed, polling halted\n");
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->polling = false;
|
priv->polling = false;
|
||||||
|
|
||||||
/* Decrement the reference count held by this thread. */
|
/* Decrement the reference count held by this thread. */
|
||||||
@@ -1303,7 +1304,7 @@ static int usbhost_kbdpoll(int argc, char *argv[])
|
|||||||
usbhost_givesem(&priv->exclsem);
|
usbhost_givesem(&priv->exclsem);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2068,7 +2069,7 @@ static int usbhost_open(FAR struct file *filep)
|
|||||||
* events.
|
* events.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
if (priv->disconnected)
|
if (priv->disconnected)
|
||||||
{
|
{
|
||||||
/* No... the driver is no longer bound to the class. That means that
|
/* No... the driver is no longer bound to the class. That means that
|
||||||
@@ -2086,7 +2087,7 @@ static int usbhost_open(FAR struct file *filep)
|
|||||||
priv->open = true;
|
priv->open = true;
|
||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
usbhost_givesem(&priv->exclsem);
|
usbhost_givesem(&priv->exclsem);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -2120,7 +2121,7 @@ static int usbhost_close(FAR struct file *filep)
|
|||||||
* asynchronous poll or disconnect events.
|
* asynchronous poll or disconnect events.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->crefs--;
|
priv->crefs--;
|
||||||
|
|
||||||
/* Check if the USB mouse device is still connected. If the device is
|
/* Check if the USB mouse device is still connected. If the device is
|
||||||
@@ -2164,7 +2165,7 @@ static int usbhost_close(FAR struct file *filep)
|
|||||||
|
|
||||||
/* Skip giving the semaphore... it is no longer valid */
|
/* Skip giving the semaphore... it is no longer valid */
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
else /* if (priv->crefs == 1) */
|
else /* if (priv->crefs == 1) */
|
||||||
@@ -2180,7 +2181,7 @@ static int usbhost_close(FAR struct file *filep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
usbhost_givesem(&priv->exclsem);
|
usbhost_givesem(&priv->exclsem);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbhost/usbhost_hidmouse.c
|
* drivers/usbhost/usbhost_hidmouse.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014, 2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2014, 2015-2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -52,6 +52,7 @@
|
|||||||
#include <fixedmath.h>
|
#include <fixedmath.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/kthread.h>
|
#include <nuttx/kthread.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
@@ -564,7 +565,7 @@ static int usbhost_allocdevno(FAR struct usbhost_state_s *priv)
|
|||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
int devno;
|
int devno;
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
for (devno = 0; devno < 26; devno++)
|
for (devno = 0; devno < 26; devno++)
|
||||||
{
|
{
|
||||||
uint32_t bitno = 1 << devno;
|
uint32_t bitno = 1 << devno;
|
||||||
@@ -572,12 +573,12 @@ static int usbhost_allocdevno(FAR struct usbhost_state_s *priv)
|
|||||||
{
|
{
|
||||||
g_devinuse |= bitno;
|
g_devinuse |= bitno;
|
||||||
priv->devno = devno;
|
priv->devno = devno;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return -EMFILE;
|
return -EMFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -587,9 +588,9 @@ static void usbhost_freedevno(FAR struct usbhost_state_s *priv)
|
|||||||
|
|
||||||
if (devno >= 0 && devno < 26)
|
if (devno >= 0 && devno < 26)
|
||||||
{
|
{
|
||||||
irqstate_t flags = irqsave();
|
irqstate_t flags = enter_critical_section();
|
||||||
g_devinuse &= ~(1 << devno);
|
g_devinuse &= ~(1 << devno);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1234,7 +1235,7 @@ static int usbhost_mouse_poll(int argc, char *argv[])
|
|||||||
|
|
||||||
udbg("Mouse removed, polling halted\n");
|
udbg("Mouse removed, polling halted\n");
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->polling = false;
|
priv->polling = false;
|
||||||
|
|
||||||
/* Decrement the reference count held by this thread. */
|
/* Decrement the reference count held by this thread. */
|
||||||
@@ -1269,7 +1270,7 @@ static int usbhost_mouse_poll(int argc, char *argv[])
|
|||||||
usbhost_givesem(&priv->exclsem);
|
usbhost_givesem(&priv->exclsem);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1292,7 +1293,7 @@ static int usbhost_sample(FAR struct usbhost_state_s *priv,
|
|||||||
* from changing until it has been reported.
|
* from changing until it has been reported.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Is there new mouse data available? */
|
/* Is there new mouse data available? */
|
||||||
|
|
||||||
@@ -1329,7 +1330,7 @@ static int usbhost_sample(FAR struct usbhost_state_s *priv,
|
|||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1360,7 +1361,7 @@ static int usbhost_waitsample(FAR struct usbhost_state_s *priv,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
sched_lock();
|
sched_lock();
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Now release the semaphore that manages mutually exclusive access to
|
/* Now release the semaphore that manages mutually exclusive access to
|
||||||
* the device structure. This may cause other tasks to become ready to
|
* the device structure. This may cause other tasks to become ready to
|
||||||
@@ -1418,7 +1419,7 @@ errout:
|
|||||||
* have pre-emption disabled.
|
* have pre-emption disabled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Restore pre-emption. We might get suspended here but that is okay
|
/* Restore pre-emption. We might get suspended here but that is okay
|
||||||
* because we already have our sample. Note: this means that if there
|
* because we already have our sample. Note: this means that if there
|
||||||
@@ -2138,7 +2139,7 @@ static int usbhost_open(FAR struct file *filep)
|
|||||||
* events.
|
* events.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
if (priv->disconnected)
|
if (priv->disconnected)
|
||||||
{
|
{
|
||||||
/* No... the driver is no longer bound to the class. That means that
|
/* No... the driver is no longer bound to the class. That means that
|
||||||
@@ -2178,7 +2179,7 @@ static int usbhost_open(FAR struct file *filep)
|
|||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
usbhost_givesem(&priv->exclsem);
|
usbhost_givesem(&priv->exclsem);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -2212,7 +2213,7 @@ static int usbhost_close(FAR struct file *filep)
|
|||||||
* asynchronous poll or disconnect events.
|
* asynchronous poll or disconnect events.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->crefs--;
|
priv->crefs--;
|
||||||
|
|
||||||
/* Check if the USB mouse device is still connected. If the device is
|
/* Check if the USB mouse device is still connected. If the device is
|
||||||
@@ -2254,7 +2255,7 @@ static int usbhost_close(FAR struct file *filep)
|
|||||||
|
|
||||||
/* Skip giving the semaphore... it is no longer valid */
|
/* Skip giving the semaphore... it is no longer valid */
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
else /* if (priv->crefs == 1) */
|
else /* if (priv->crefs == 1) */
|
||||||
@@ -2270,7 +2271,7 @@ static int usbhost_close(FAR struct file *filep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
usbhost_givesem(&priv->exclsem);
|
usbhost_givesem(&priv->exclsem);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbhost/usbhost_hub.c
|
* drivers/usbhost/usbhost_hub.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Kaushal Parikh <kaushal@dspworks.in>
|
* Author: Kaushal Parikh <kaushal@dspworks.in>
|
||||||
* Gregory Nutt <gnutt@nuttx.org>
|
* Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
@@ -48,6 +48,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/wqueue.h>
|
#include <nuttx/wqueue.h>
|
||||||
@@ -980,7 +981,7 @@ static void usbhost_hub_event(FAR void *arg)
|
|||||||
* removed.
|
* removed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
if (!priv->disconnected)
|
if (!priv->disconnected)
|
||||||
{
|
{
|
||||||
/* Wait for the next hub event */
|
/* Wait for the next hub event */
|
||||||
@@ -993,7 +994,7 @@ static void usbhost_hub_event(FAR void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -1038,7 +1039,7 @@ static void usbhost_disconnect_event(FAR void *arg)
|
|||||||
* longer available.
|
* longer available.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Cancel any pending transfers on the interrupt IN pipe */
|
/* Cancel any pending transfers on the interrupt IN pipe */
|
||||||
|
|
||||||
@@ -1098,7 +1099,7 @@ static void usbhost_disconnect_event(FAR void *arg)
|
|||||||
|
|
||||||
kmm_free(hubclass);
|
kmm_free(hubclass);
|
||||||
hport->devclass = NULL;
|
hport->devclass = NULL;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -1463,7 +1464,7 @@ static int usbhost_disconnected(struct usbhost_class_s *hubclass)
|
|||||||
* any subsequent completions of asynchronous transfers.
|
* any subsequent completions of asynchronous transfers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->disconnected = true;
|
priv->disconnected = true;
|
||||||
|
|
||||||
/* Cancel any pending work. There may be pending HUB work associated with
|
/* Cancel any pending work. There may be pending HUB work associated with
|
||||||
@@ -1476,7 +1477,7 @@ static int usbhost_disconnected(struct usbhost_class_s *hubclass)
|
|||||||
|
|
||||||
ret = work_queue(LPWORK, &priv->work,
|
ret = work_queue(LPWORK, &priv->work,
|
||||||
(worker_t)usbhost_disconnect_event, hubclass, 0);
|
(worker_t)usbhost_disconnect_event, hubclass, 0);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <arch/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/usb/usbhost.h>
|
#include <nuttx/usb/usbhost.h>
|
||||||
|
|
||||||
#include "usbhost_registry.h"
|
#include "usbhost_registry.h"
|
||||||
@@ -104,14 +104,14 @@ int usbhost_registerclass(struct usbhost_registry_s *usbclass)
|
|||||||
* protected by disabling interrupts.
|
* protected by disabling interrupts.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Add the new class ID info to the head of the list */
|
/* Add the new class ID info to the head of the list */
|
||||||
|
|
||||||
usbclass->flink = g_classregistry;
|
usbclass->flink = g_classregistry;
|
||||||
g_classregistry = usbclass;
|
g_classregistry = usbclass;
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbhost/usbhost_skeleton.c
|
* drivers/usbhost/usbhost_skeleton.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -47,6 +47,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
@@ -293,7 +294,7 @@ static int usbhost_allocdevno(FAR struct usbhost_state_s *priv)
|
|||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
int devno;
|
int devno;
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
for (devno = 0; devno < 26; devno++)
|
for (devno = 0; devno < 26; devno++)
|
||||||
{
|
{
|
||||||
uint32_t bitno = 1 << devno;
|
uint32_t bitno = 1 << devno;
|
||||||
@@ -301,12 +302,12 @@ static int usbhost_allocdevno(FAR struct usbhost_state_s *priv)
|
|||||||
{
|
{
|
||||||
g_devinuse |= bitno;
|
g_devinuse |= bitno;
|
||||||
priv->devchar = 'a' + devno;
|
priv->devchar = 'a' + devno;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return -EMFILE;
|
return -EMFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,9 +317,9 @@ static void usbhost_freedevno(FAR struct usbhost_state_s *priv)
|
|||||||
|
|
||||||
if (devno >= 0 && devno < 26)
|
if (devno >= 0 && devno < 26)
|
||||||
{
|
{
|
||||||
irqstate_t flags = irqsave();
|
irqstate_t flags = enter_critical_section();
|
||||||
g_devinuse &= ~(1 << devno);
|
g_devinuse &= ~(1 << devno);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1003,7 +1004,7 @@ static int usbhost_disconnected(struct usbhost_class_s *usbclass)
|
|||||||
* longer available.
|
* longer available.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->disconnected = true;
|
priv->disconnected = true;
|
||||||
|
|
||||||
/* Now check the number of references on the class instance. If it is one,
|
/* Now check the number of references on the class instance. If it is one,
|
||||||
@@ -1036,7 +1037,7 @@ static int usbhost_disconnected(struct usbhost_class_s *usbclass)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbhost/usbhost_storage.c
|
* drivers/usbhost/usbhost_storage.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010-2013, 2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2010-2013, 2015-2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -48,6 +48,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
@@ -368,14 +369,14 @@ static inline FAR struct usbhost_state_s *usbhost_allocclass(void)
|
|||||||
* our pre-allocated class instances from the free list.
|
* our pre-allocated class instances from the free list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
entry = g_freelist;
|
entry = g_freelist;
|
||||||
if (entry)
|
if (entry)
|
||||||
{
|
{
|
||||||
g_freelist = entry->flink;
|
g_freelist = entry->flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
ullvdbg("Allocated: %p\n", entry);
|
ullvdbg("Allocated: %p\n", entry);
|
||||||
return (FAR struct usbhost_state_s *)entry;
|
return (FAR struct usbhost_state_s *)entry;
|
||||||
}
|
}
|
||||||
@@ -420,10 +421,10 @@ static inline void usbhost_freeclass(FAR struct usbhost_state_s *usbclass)
|
|||||||
|
|
||||||
/* Just put the pre-allocated class structure back on the freelist */
|
/* Just put the pre-allocated class structure back on the freelist */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
entry->flink = g_freelist;
|
entry->flink = g_freelist;
|
||||||
g_freelist = entry;
|
g_freelist = entry;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static inline void usbhost_freeclass(FAR struct usbhost_state_s *usbclass)
|
static inline void usbhost_freeclass(FAR struct usbhost_state_s *usbclass)
|
||||||
@@ -452,7 +453,7 @@ static int usbhost_allocdevno(FAR struct usbhost_state_s *priv)
|
|||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
int devno;
|
int devno;
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
for (devno = 0; devno < 26; devno++)
|
for (devno = 0; devno < 26; devno++)
|
||||||
{
|
{
|
||||||
uint32_t bitno = 1 << devno;
|
uint32_t bitno = 1 << devno;
|
||||||
@@ -460,12 +461,12 @@ static int usbhost_allocdevno(FAR struct usbhost_state_s *priv)
|
|||||||
{
|
{
|
||||||
g_devinuse |= bitno;
|
g_devinuse |= bitno;
|
||||||
priv->sdchar = 'a' + devno;
|
priv->sdchar = 'a' + devno;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return -EMFILE;
|
return -EMFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,9 +476,9 @@ static void usbhost_freedevno(FAR struct usbhost_state_s *priv)
|
|||||||
|
|
||||||
if (devno >= 0 && devno < 26)
|
if (devno >= 0 && devno < 26)
|
||||||
{
|
{
|
||||||
irqstate_t flags = irqsave();
|
irqstate_t flags = enter_critical_section();
|
||||||
g_devinuse &= ~(1 << devno);
|
g_devinuse &= ~(1 << devno);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1820,7 +1821,7 @@ static int usbhost_disconnected(struct usbhost_class_s *usbclass)
|
|||||||
* is no longer available.
|
* is no longer available.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->disconnected = true;
|
priv->disconnected = true;
|
||||||
|
|
||||||
/* Now check the number of references on the class instance. If it is one,
|
/* Now check the number of references on the class instance. If it is one,
|
||||||
@@ -1853,7 +1854,7 @@ static int usbhost_disconnected(struct usbhost_class_s *usbclass)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1887,7 +1888,7 @@ static int usbhost_open(FAR struct inode *inode)
|
|||||||
* events.
|
* events.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
if (priv->disconnected)
|
if (priv->disconnected)
|
||||||
{
|
{
|
||||||
/* No... the block driver is no longer bound to the class. That means that
|
/* No... the block driver is no longer bound to the class. That means that
|
||||||
@@ -1904,7 +1905,7 @@ static int usbhost_open(FAR struct inode *inode)
|
|||||||
priv->crefs++;
|
priv->crefs++;
|
||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
usbhost_givesem(&priv->exclsem);
|
usbhost_givesem(&priv->exclsem);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -1943,7 +1944,7 @@ static int usbhost_close(FAR struct inode *inode)
|
|||||||
* no asynchronous disconnect events.
|
* no asynchronous disconnect events.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Check if the USB mass storage device is still connected. If the
|
/* Check if the USB mass storage device is still connected. If the
|
||||||
* storage device is not connected and the reference count just
|
* storage device is not connected and the reference count just
|
||||||
@@ -1959,7 +1960,7 @@ static int usbhost_close(FAR struct inode *inode)
|
|||||||
usbhost_destroy(priv);
|
usbhost_destroy(priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <arch/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/usb/usbhost_trace.h>
|
#include <nuttx/usb/usbhost_trace.h>
|
||||||
#undef usbtrace
|
#undef usbtrace
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ void usbhost_trace_common(uint32_t event)
|
|||||||
|
|
||||||
/* Check if tracing is enabled for this ID */
|
/* Check if tracing is enabled for this ID */
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
if (!g_disabled)
|
if (!g_disabled)
|
||||||
{
|
{
|
||||||
/* Yes... save the new trace data at the head */
|
/* Yes... save the new trace data at the head */
|
||||||
@@ -170,7 +170,7 @@ void usbhost_trace_common(uint32_t event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_USBHOST_TRACE */
|
#endif /* CONFIG_USBHOST_TRACE */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/wireless/cc3000.c
|
* drivers/wireless/cc3000.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013-2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2013-2016 Gregory Nutt. All rights reserved.
|
||||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||||
* David_s5 <david_s5@nscdg.com>
|
* David_s5 <david_s5@nscdg.com>
|
||||||
*
|
*
|
||||||
@@ -63,6 +63,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
@@ -1377,10 +1378,10 @@ static int cc3000_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
|
|
||||||
DEBUGASSERT(psize != NULL);
|
DEBUGASSERT(psize != NULL);
|
||||||
rv = priv->rx_buffer_max_len;
|
rv = priv->rx_buffer_max_len;
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
priv->rx_buffer_max_len = *psize;
|
priv->rx_buffer_max_len = *psize;
|
||||||
priv->rx_buffer.pbuffer = kmm_realloc(priv->rx_buffer.pbuffer, *psize);
|
priv->rx_buffer.pbuffer = kmm_realloc(priv->rx_buffer.pbuffer, *psize);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
DEBUGASSERT(priv->rx_buffer.pbuffer);
|
DEBUGASSERT(priv->rx_buffer.pbuffer);
|
||||||
*psize = rv;
|
*psize = rv;
|
||||||
break;
|
break;
|
||||||
@@ -1588,7 +1589,7 @@ int cc3000_register(FAR struct spi_dev_s *spi,
|
|||||||
#ifdef CONFIG_CC3000_MULTIPLE
|
#ifdef CONFIG_CC3000_MULTIPLE
|
||||||
priv->flink = g_cc3000list;
|
priv->flink = g_cc3000list;
|
||||||
g_cc3000list = priv;
|
g_cc3000list = priv;
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* And return success (?) */
|
/* And return success (?) */
|
||||||
@@ -1726,7 +1727,7 @@ static int cc3000_add_socket(FAR struct cc3000_dev_s *priv, int sd)
|
|||||||
return sd;
|
return sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
for (s = 0; s < CONFIG_WL_MAX_SOCKETS; s++)
|
for (s = 0; s < CONFIG_WL_MAX_SOCKETS; s++)
|
||||||
{
|
{
|
||||||
if (priv->sockets[s].sd == FREE_SLOT)
|
if (priv->sockets[s].sd == FREE_SLOT)
|
||||||
@@ -1738,7 +1739,7 @@ static int cc3000_add_socket(FAR struct cc3000_dev_s *priv, int sd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return s >= CONFIG_WL_MAX_SOCKETS ? -1 : OK;
|
return s >= CONFIG_WL_MAX_SOCKETS ? -1 : OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1769,7 +1770,7 @@ static int cc3000_remove_socket(FAR struct cc3000_dev_s *priv, int sd)
|
|||||||
return sd;
|
return sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
if (priv->accepting_socket.acc.sd == sd)
|
if (priv->accepting_socket.acc.sd == sd)
|
||||||
{
|
{
|
||||||
priv->accepting_socket.acc.sd = CLOSE_SLOT;
|
priv->accepting_socket.acc.sd = CLOSE_SLOT;
|
||||||
@@ -1788,7 +1789,7 @@ static int cc3000_remove_socket(FAR struct cc3000_dev_s *priv, int sd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
if (ps)
|
if (ps)
|
||||||
{
|
{
|
||||||
sched_lock();
|
sched_lock();
|
||||||
@@ -1828,7 +1829,7 @@ static int cc3000_remote_closed_socket(FAR struct cc3000_dev_s *priv, int sd)
|
|||||||
return sd;
|
return sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
for (s = 0; s < CONFIG_WL_MAX_SOCKETS; s++)
|
for (s = 0; s < CONFIG_WL_MAX_SOCKETS; s++)
|
||||||
{
|
{
|
||||||
if (priv->sockets[s].sd == sd)
|
if (priv->sockets[s].sd == sd)
|
||||||
@@ -1837,7 +1838,7 @@ static int cc3000_remote_closed_socket(FAR struct cc3000_dev_s *priv, int sd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
return s >= CONFIG_WL_MAX_SOCKETS ? -1 : OK;
|
return s >= CONFIG_WL_MAX_SOCKETS ? -1 : OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user