nuttx/net: Replace irqsave() with enter_critical_section(); replace irqrestore() with leave_critical_section()
This commit is contained in:
parent
e6bd3544f6
commit
aa3e778dc6
|
@ -48,7 +48,7 @@
|
|||
#include <netinet/in.h>
|
||||
|
||||
#include <nuttx/net/net.h>
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "arp/arp.h"
|
||||
|
||||
|
@ -104,10 +104,10 @@ void arp_wait_setup(in_addr_t ipaddr, FAR struct arp_notify_s *notify)
|
|||
|
||||
/* Add the wait structure to the list with interrupts disabled */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
notify->nt_flink = g_arp_waiters;
|
||||
g_arp_waiters = notify;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -134,7 +134,7 @@ int arp_wait_cancel(FAR struct arp_notify_s *notify)
|
|||
* head of the list).
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
for (prev = NULL, curr = g_arp_waiters;
|
||||
curr && curr != notify;
|
||||
prev = curr, curr = curr->nt_flink);
|
||||
|
@ -154,7 +154,7 @@ int arp_wait_cancel(FAR struct arp_notify_s *notify)
|
|||
ret = OK;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
(void)sem_destroy(¬ify->nt_sem);
|
||||
return ret;
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ int arp_wait(FAR struct arp_notify_s *notify, FAR struct timespec *timeout)
|
|||
* enabled while we wait.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
DEBUGVERIFY(clock_gettime(CLOCK_REALTIME, &abstime));
|
||||
|
||||
abstime.tv_sec += timeout->tv_sec;
|
||||
|
@ -220,7 +220,7 @@ int arp_wait(FAR struct arp_notify_s *notify, FAR struct timespec *timeout)
|
|||
|
||||
/* Re-enable interrupts and return the result of the wait */
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include <netinet/in.h>
|
||||
|
||||
#include <nuttx/net/net.h>
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "icmpv6/icmpv6.h"
|
||||
|
||||
|
@ -105,10 +105,10 @@ void icmpv6_wait_setup(const net_ipv6addr_t ipaddr,
|
|||
|
||||
/* Add the wait structure to the list with interrupts disabled */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
notify->nt_flink = g_icmpv6_waiters;
|
||||
g_icmpv6_waiters = notify;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -136,7 +136,7 @@ int icmpv6_wait_cancel(FAR struct icmpv6_notify_s *notify)
|
|||
* head of the list).
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
for (prev = NULL, curr = g_icmpv6_waiters;
|
||||
curr && curr != notify;
|
||||
prev = curr, curr = curr->nt_flink);
|
||||
|
@ -156,7 +156,7 @@ int icmpv6_wait_cancel(FAR struct icmpv6_notify_s *notify)
|
|||
ret = OK;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
(void)sem_destroy(¬ify->nt_sem);
|
||||
return ret;
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ int icmpv6_wait(FAR struct icmpv6_notify_s *notify,
|
|||
* be re-enabled while we wait.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
DEBUGVERIFY(clock_gettime(CLOCK_REALTIME, &abstime));
|
||||
|
||||
abstime.tv_sec += timeout->tv_sec;
|
||||
|
@ -212,7 +212,7 @@ int icmpv6_wait(FAR struct icmpv6_notify_s *notify,
|
|||
|
||||
/* Re-enable interrupts and return the result of the wait */
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "netdev/netdev.h"
|
||||
#include "utils/utils.h"
|
||||
|
@ -170,10 +170,10 @@ void icmpv6_rwait_setup(FAR struct net_driver_s *dev,
|
|||
|
||||
/* Add the wait structure to the list with interrupts disabled */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
notify->rn_flink = g_icmpv6_rwaiters;
|
||||
g_icmpv6_rwaiters = notify;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
#else
|
||||
/* If there is only a single network device, then there can be only a
|
||||
|
@ -218,7 +218,7 @@ int icmpv6_rwait_cancel(FAR struct icmpv6_rnotify_s *notify)
|
|||
* head of the list).
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
for (prev = NULL, curr = g_icmpv6_rwaiters;
|
||||
curr && curr != notify;
|
||||
prev = curr, curr = curr->rn_flink);
|
||||
|
@ -238,7 +238,7 @@ int icmpv6_rwait_cancel(FAR struct icmpv6_rnotify_s *notify)
|
|||
ret = OK;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
(void)sem_destroy(¬ify->rn_sem);
|
||||
return ret;
|
||||
|
||||
|
@ -282,7 +282,7 @@ int icmpv6_rwait(FAR struct icmpv6_rnotify_s *notify,
|
|||
* be re-enabled while we wait.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
DEBUGVERIFY(clock_gettime(CLOCK_REALTIME, &abstime));
|
||||
|
||||
abstime.tv_sec += timeout->tv_sec;
|
||||
|
@ -308,7 +308,7 @@ int icmpv6_rwait(FAR struct icmpv6_rnotify_s *notify,
|
|||
|
||||
/* Re-enable interrupts and return the result of the wait */
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/net/iob.h>
|
||||
|
||||
|
@ -89,7 +90,7 @@ static FAR struct iob_s *iob_allocwait(bool throttled)
|
|||
* we are waiting for I/O buffers to become free.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
do
|
||||
{
|
||||
/* Try to get an I/O buffer. If successful, the semaphore count
|
||||
|
@ -158,7 +159,7 @@ static FAR struct iob_s *iob_allocwait(bool throttled)
|
|||
}
|
||||
while (ret == OK && iob == NULL);
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return iob;
|
||||
}
|
||||
|
||||
|
@ -219,7 +220,7 @@ FAR struct iob_s *iob_tryalloc(bool throttled)
|
|||
* to protect the free list: We disable interrupts very briefly.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
#if CONFIG_IOB_THROTTLE > 0
|
||||
/* If there are free I/O buffers for this allocation */
|
||||
|
@ -257,7 +258,7 @@ FAR struct iob_s *iob_tryalloc(bool throttled)
|
|||
g_throttle_sem.semcount--;
|
||||
DEBUGASSERT(g_throttle_sem.semcount >= -CONFIG_IOB_THROTTLE);
|
||||
#endif
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Put the I/O buffer in a known state */
|
||||
|
||||
|
@ -269,6 +270,6 @@ FAR struct iob_s *iob_tryalloc(bool throttled)
|
|||
}
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/net/iob.h>
|
||||
|
||||
|
@ -83,7 +84,7 @@ static FAR struct iob_qentry_s *iob_allocwait_qentry(void)
|
|||
* re-enabled while we are waiting for I/O buffers to become free.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
do
|
||||
{
|
||||
/* Try to get an I/O buffer chain container. If successful, the
|
||||
|
@ -152,7 +153,7 @@ static FAR struct iob_qentry_s *iob_allocwait_qentry(void)
|
|||
}
|
||||
while (ret == OK && !qentry);
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return qentry;
|
||||
}
|
||||
|
||||
|
@ -207,7 +208,7 @@ FAR struct iob_qentry_s *iob_tryalloc_qentry(void)
|
|||
* to protect the free list: We disable interrupts very briefly.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
iobq = g_iob_freeqlist;
|
||||
if (iobq)
|
||||
{
|
||||
|
@ -233,7 +234,7 @@ FAR struct iob_qentry_s *iob_tryalloc_qentry(void)
|
|||
iobq->qe_head = NULL; /* Nothing is contained */
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return iobq;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* net/iob/iob_free.c
|
||||
*
|
||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -50,27 +50,12 @@
|
|||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/net/iob.h>
|
||||
|
||||
#include "iob.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -128,7 +113,7 @@ FAR struct iob_s *iob_free(FAR struct iob_s *iob)
|
|||
* protect the free list: We disable interrupts very briefly.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
iob->io_flink = g_iob_freelist;
|
||||
g_iob_freelist = iob;
|
||||
|
||||
|
@ -138,7 +123,7 @@ FAR struct iob_s *iob_free(FAR struct iob_s *iob)
|
|||
#if CONFIG_IOB_THROTTLE > 0
|
||||
sem_post(&g_throttle_sem);
|
||||
#endif
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* And return the I/O buffer after the one that was freed */
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* net/iob/iob_free_qentry.c
|
||||
*
|
||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -49,6 +49,7 @@
|
|||
#include <semaphore.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/net/iob.h>
|
||||
|
||||
|
@ -95,14 +96,14 @@ FAR struct iob_qentry_s *iob_free_qentry(FAR struct iob_qentry_s *iobq)
|
|||
* measures to protect the free list: We disable interrupts very briefly.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
iobq->qe_flink = g_iob_freeqlist;
|
||||
g_iob_freeqlist = iobq;
|
||||
|
||||
/* Signal that an I/O buffer chain container is available */
|
||||
|
||||
sem_post(&g_qentry_sem);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* And return the I/O buffer chain container after the one that was freed */
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* net/utils/net_lock.c
|
||||
*
|
||||
* Copyright (C) 2011-2012, 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011-2012, 2014-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/net/net.h>
|
||||
|
||||
|
@ -197,7 +198,7 @@ int net_timedwait(sem_t *sem, FAR const struct timespec *abstime)
|
|||
irqstate_t flags;
|
||||
int ret;
|
||||
|
||||
flags = irqsave(); /* No interrupts */
|
||||
flags = enter_critical_section(); /* No interrupts */
|
||||
sched_lock(); /* No context switches */
|
||||
if (g_holder == me)
|
||||
{
|
||||
|
@ -235,7 +236,7 @@ int net_timedwait(sem_t *sem, FAR const struct timespec *abstime)
|
|||
}
|
||||
|
||||
sched_unlock();
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue