mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
nuttx/drivers: Replace irqsave() with enter_critical_section(); replace irqrestore() with leave_critical_section()
This commit is contained in:
+23
-26
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -51,6 +51,7 @@
|
||||
#include <queue.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/serial/serial.h>
|
||||
@@ -68,10 +69,6 @@
|
||||
# include "composite.h"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
@@ -282,7 +279,7 @@ static uint16_t cdcacm_fillrequest(FAR struct cdcacm_dev_s *priv, uint8_t *reqbu
|
||||
|
||||
/* Disable interrupts */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
@@ -350,7 +347,7 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv)
|
||||
}
|
||||
#endif
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
@@ -834,7 +831,7 @@ static void cdcacm_rdcomplete(FAR struct usbdev_ep_s *ep,
|
||||
|
||||
/* Process the received data unless this is some unusual condition */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
switch (req->result)
|
||||
{
|
||||
case 0: /* Normal completion */
|
||||
@@ -845,7 +842,7 @@ static void cdcacm_rdcomplete(FAR struct usbdev_ep_s *ep,
|
||||
case -ESHUTDOWN: /* Disconnection */
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSHUTDOWN), 0);
|
||||
priv->nrdq--;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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 */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sq_addlast((FAR sq_entry_t *)reqcontainer, &priv->reqlist);
|
||||
priv->nwrq++;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Send the next packet unless this was some unusual termination
|
||||
* condition
|
||||
@@ -1079,10 +1076,10 @@ static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver,
|
||||
reqcontainer->req->priv = reqcontainer;
|
||||
reqcontainer->req->callback = cdcacm_wrcomplete;
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sq_addlast((FAR sq_entry_t *)reqcontainer, &priv->reqlist);
|
||||
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) */
|
||||
@@ -1208,7 +1205,7 @@ static void cdcacm_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
* of them)
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
DEBUGASSERT(priv->nwrq == CONFIG_CDCACM_NWRREQS);
|
||||
while (!sq_empty(&priv->reqlist))
|
||||
{
|
||||
@@ -1221,7 +1218,7 @@ static void cdcacm_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
}
|
||||
|
||||
DEBUGASSERT(priv->nwrq == 0);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Clear out all data in the circular buffer */
|
||||
|
||||
@@ -1648,7 +1645,7 @@ static void cdcacm_disconnect(FAR struct usbdevclass_driver_s *driver,
|
||||
* connection.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
#ifdef CONFIG_SERIAL_REMOVABLE
|
||||
uart_connected(&priv->serdev, false);
|
||||
#endif
|
||||
@@ -1662,7 +1659,7 @@ static void cdcacm_disconnect(FAR struct usbdevclass_driver_s *driver,
|
||||
priv->serdev.xmit.head = 0;
|
||||
priv->serdev.xmit.tail = 0;
|
||||
priv->rxhead = 0;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Perform the soft connect function so that we will we can be
|
||||
* 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:
|
||||
{
|
||||
int count;
|
||||
irqstate_t state = irqsave();
|
||||
irqstate_t flags = enter_critical_section();
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
irqrestore(state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
*(int *)arg = count;
|
||||
ret = 0;
|
||||
@@ -2011,7 +2008,7 @@ static int cdcuart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
case FIONWRITE:
|
||||
{
|
||||
int count;
|
||||
irqstate_t state = irqsave();
|
||||
irqstate_t flags = enter_critical_section();
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
irqrestore(state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
*(int *)arg = count;
|
||||
ret = 0;
|
||||
@@ -2083,7 +2080,7 @@ static void cdcuart_rxint(FAR struct uart_dev_s *dev, bool enable)
|
||||
* in the following.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
if (enable)
|
||||
{
|
||||
/* 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->rxenabled = false;
|
||||
}
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
+10
-13
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/usb/usb.h>
|
||||
@@ -55,10 +56,6 @@
|
||||
|
||||
#ifdef CONFIG_USBDEV_COMPOSITE
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
@@ -368,7 +365,7 @@ static void composite_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
{
|
||||
/* Unbind the constituent class drivers */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
CLASS_UNBIND(priv->dev1, 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);
|
||||
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.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
priv->config = COMPOSITE_CONFIGIDNONE;
|
||||
CLASS_DISCONNECT(priv->dev1, dev);
|
||||
CLASS_DISCONNECT(priv->dev2, dev);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Perform the soft connect function so that we will we can be
|
||||
* re-enumerated.
|
||||
@@ -716,10 +713,10 @@ static void composite_suspend(FAR struct usbdevclass_driver_s *driver,
|
||||
|
||||
/* Forward the suspend event to the constituent devices */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
CLASS_SUSPEND(priv->dev1, 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 */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
CLASS_RESUME(priv->dev1, priv->usbdev);
|
||||
CLASS_RESUME(priv->dev2, priv->usbdev);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
+19
-18
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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>
|
||||
*
|
||||
* This logic emulates the Prolific PL2303 serial/USB converter
|
||||
@@ -53,6 +53,7 @@
|
||||
#include <queue.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/arch.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 */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
@@ -605,7 +606,7 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv)
|
||||
}
|
||||
#endif
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
@@ -1216,7 +1217,7 @@ static void usbclass_rdcomplete(FAR struct usbdev_ep_s *ep,
|
||||
|
||||
/* Process the received data unless this is some unusual condition */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
switch (req->result)
|
||||
{
|
||||
case 0: /* Normal completion */
|
||||
@@ -1227,7 +1228,7 @@ static void usbclass_rdcomplete(FAR struct usbdev_ep_s *ep,
|
||||
case -ESHUTDOWN: /* Disconnection */
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSHUTDOWN), 0);
|
||||
priv->nrdq--;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return;
|
||||
|
||||
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);
|
||||
}
|
||||
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 */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sq_addlast((FAR sq_entry_t *)reqcontainer, &priv->reqlist);
|
||||
priv->nwrq++;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Send the next packet unless this was some unusual termination
|
||||
* condition
|
||||
@@ -1448,10 +1449,10 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
||||
reqcontainer->req->priv = reqcontainer;
|
||||
reqcontainer->req->callback = usbclass_wrcomplete;
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sq_addlast((FAR sq_entry_t *)reqcontainer, &priv->reqlist);
|
||||
priv->nwrq++; /* Count of write requests available */
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* Report if we are selfpowered */
|
||||
@@ -1573,7 +1574,7 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
* of them
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
DEBUGASSERT(priv->nwrq == CONFIG_PL2303_NWRREQS);
|
||||
while (!sq_empty(&priv->reqlist))
|
||||
{
|
||||
@@ -1585,7 +1586,7 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
}
|
||||
}
|
||||
DEBUGASSERT(priv->nwrq == 0);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* Clear out all data in the circular buffer */
|
||||
@@ -1900,7 +1901,7 @@ static void usbclass_disconnect(FAR struct usbdevclass_driver_s *driver,
|
||||
* connection.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
#ifdef CONFIG_SERIAL_REMOVABLE
|
||||
uart_connected(&priv->serdev, false);
|
||||
#endif
|
||||
@@ -1914,7 +1915,7 @@ static void usbclass_disconnect(FAR struct usbdevclass_driver_s *driver,
|
||||
priv->serdev.xmit.head = 0;
|
||||
priv->serdev.xmit.tail = 0;
|
||||
priv->rxhead = 0;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Perform the soft connect function so that we will we can be
|
||||
* re-enumerated.
|
||||
@@ -2136,7 +2137,7 @@ static void usbser_rxint(FAR struct uart_dev_s *dev, bool enable)
|
||||
* in the following.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
if (enable)
|
||||
{
|
||||
/* 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->rxenabled = false;
|
||||
}
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
#undef usbtrace
|
||||
|
||||
@@ -140,10 +140,10 @@ usbtrace_idset_t usbtrace_enable(usbtrace_idset_t idset)
|
||||
|
||||
/* The following read and write must be atomic */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
ret = g_maskedidset;
|
||||
g_maskedidset = idset;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
#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 */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
if ((g_maskedidset & TRACE_ID2BIT(event)) != 0)
|
||||
{
|
||||
#ifdef CONFIG_USBDEV_TRACE
|
||||
@@ -196,7 +196,7 @@ void usbtrace(uint16_t event, uint16_t value)
|
||||
#endif
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
#endif /* CONFIG_USBDEV_TRACE || CONFIG_DEBUG && CONFIG_DEBUG_USB */
|
||||
|
||||
|
||||
+16
-15
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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>
|
||||
*
|
||||
* Mass storage class device. Bulk-only with SCSI subclass.
|
||||
@@ -71,6 +71,7 @@
|
||||
#include <queue.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/kthread.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->callback = usbmsc_wrcomplete;
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
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) */
|
||||
@@ -477,7 +478,7 @@ static void usbmsc_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
* of them
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
while (!sq_empty(&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;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -868,14 +869,14 @@ static void usbmsc_disconnect(FAR struct usbdevclass_driver_s *driver,
|
||||
|
||||
/* Reset the configuration */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
usbmsc_resetconfig(priv);
|
||||
|
||||
/* Signal the worker thread */
|
||||
|
||||
priv->theventset |= USBMSC_EVENT_DISCONNECT;
|
||||
usbmsc_scsi_signal(priv);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Perform the soft connect function so that we will we can be
|
||||
* 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 */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
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 */
|
||||
|
||||
@@ -1681,10 +1682,10 @@ int usbmsc_exportluns(FAR void *handle)
|
||||
/* Signal to start the thread */
|
||||
|
||||
uvdbg("Signalling for the SCSI worker thread\n");
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
priv->theventset |= USBMSC_EVENT_READY;
|
||||
usbmsc_scsi_signal(priv);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
errout_with_lock:
|
||||
usbmsc_scsi_unlock(priv);
|
||||
@@ -1792,10 +1793,10 @@ void usbmsc_uninitialize(FAR void *handle)
|
||||
{
|
||||
/* Yes.. Ask the thread to stop */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
priv->theventset |= USBMSC_EVENT_TERMINATEREQUEST;
|
||||
usbmsc_scsi_signal(priv);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
usbmsc_scsi_unlock(priv);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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>
|
||||
*
|
||||
* Mass storage class device. Bulk-only with SCSI subclass.
|
||||
@@ -67,6 +67,7 @@
|
||||
#include <queue.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/arch.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.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
priv->thwaiting = true;
|
||||
|
||||
/* 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 */
|
||||
|
||||
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 */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
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.
|
||||
* 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
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
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 */
|
||||
|
||||
@@ -2413,9 +2414,9 @@ static int usbmsc_cmdfinishstate(FAR struct usbmsc_dev_s *priv)
|
||||
* that is it not NULL)
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
privreq = (FAR struct usbmsc_req_s *)sq_remfirst(&priv->wrreqlist);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* 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? */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
if (priv->shortpacket)
|
||||
{
|
||||
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;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2524,9 +2525,9 @@ static int usbmsc_cmdstatusstate(FAR struct usbmsc_dev_s *priv)
|
||||
|
||||
/* Take a request from the wrreqlist */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
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.
|
||||
* 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)
|
||||
{
|
||||
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);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* Return to the IDLE state */
|
||||
@@ -2663,7 +2664,7 @@ int usbmsc_scsi_main(int argc, char *argv[])
|
||||
*/
|
||||
|
||||
usbmsc_scsi_lock(priv);
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
if (priv->theventset == USBMSC_EVENT_NOEVENTS)
|
||||
{
|
||||
usbmsc_scsi_wait(priv);
|
||||
@@ -2730,7 +2731,7 @@ int usbmsc_scsi_main(int argc, char *argv[])
|
||||
priv->thstate = USBMSC_STATE_IDLE;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Loop processing each SCSI command state. Each state handling
|
||||
* 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.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
if (priv->thwaiting)
|
||||
{
|
||||
priv->thwaiting = false;
|
||||
sem_post(&priv->thwaitsem);
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user