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:
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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>
|
||||
* Diego Sanchez <dsanchez@nx-engineering.com>
|
||||
*
|
||||
@@ -63,6 +63,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wdog.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.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Is there new ADS7843E sample data available? */
|
||||
|
||||
@@ -375,7 +376,7 @@ static int ads7843e_sample(FAR struct ads7843e_dev_s *priv,
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -398,7 +399,7 @@ static int ads7843e_waitsample(FAR struct ads7843e_dev_s *priv,
|
||||
*/
|
||||
|
||||
sched_lock();
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Now release the semaphore that manages mutually exclusive access to
|
||||
* the device structure. This may cause other tasks to become ready to
|
||||
@@ -448,7 +449,7 @@ errout:
|
||||
* have pre-emption disabled.
|
||||
*/
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Restore pre-emption. We might get suspended here but that is okay
|
||||
* 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
|
||||
priv->flink = g_ads7843elist;
|
||||
g_ads7843elist = priv;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
#endif
|
||||
|
||||
/* Schedule work to perform the initial sampling and to set the data
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/input/ajoystick.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
@@ -216,7 +216,7 @@ static void ajoy_enable(FAR struct ajoy_upperhalf_s *priv)
|
||||
* interrupts must be disabled.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -314,7 +314,7 @@ static void ajoy_sample(FAR struct ajoy_upperhalf_s *priv)
|
||||
* interrupts must be disabled.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Sample the new button state */
|
||||
|
||||
@@ -386,7 +386,7 @@ static void ajoy_sample(FAR struct ajoy_upperhalf_s *priv)
|
||||
#endif
|
||||
|
||||
priv->au_sample = sample;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -485,10 +485,10 @@ static int ajoy_close(FAR struct file *filep)
|
||||
* detection anyway.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
closing = opriv->ao_closing;
|
||||
opriv->ao_closing = true;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (closing)
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/input/buttons.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#undef __KERNEL__
|
||||
#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 */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
btn_disable();
|
||||
|
||||
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 */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
for (id = 0; id < NUM_BUTTONS; id++)
|
||||
{
|
||||
(void)board_button_irq(id, NULL);
|
||||
@@ -192,7 +192,7 @@ static void btn_disable(void)
|
||||
|
||||
g_btnhandler = NULL;
|
||||
g_btnarg = NULL;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/input/buttons.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
@@ -212,7 +212,7 @@ static void btn_enable(FAR struct btn_upperhalf_s *priv)
|
||||
* interrupts must be disabled.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -310,7 +310,7 @@ static void btn_sample(FAR struct btn_upperhalf_s *priv)
|
||||
* interrupts must be disabled.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Sample the new button state */
|
||||
|
||||
@@ -382,7 +382,7 @@ static void btn_sample(FAR struct btn_upperhalf_s *priv)
|
||||
#endif
|
||||
|
||||
priv->bu_sample = sample;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -481,10 +481,10 @@ static int btn_close(FAR struct file *filep)
|
||||
* detection anyway.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
closing = opriv->bo_closing;
|
||||
opriv->bo_closing = true;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (closing)
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/input/djoystick.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
@@ -216,7 +216,7 @@ static void djoy_enable(FAR struct djoy_upperhalf_s *priv)
|
||||
* interrupts must be disabled.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -314,7 +314,7 @@ static void djoy_sample(FAR struct djoy_upperhalf_s *priv)
|
||||
* interrupts must be disabled.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Sample the new button state */
|
||||
|
||||
@@ -386,7 +386,7 @@ static void djoy_sample(FAR struct djoy_upperhalf_s *priv)
|
||||
#endif
|
||||
|
||||
priv->du_sample = sample;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -485,10 +485,10 @@ static int djoy_close(FAR struct file *filep)
|
||||
* detection anyway.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
closing = opriv->do_closing;
|
||||
opriv->do_closing = true;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (closing)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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>
|
||||
* Petteri Aimonen <jpa@nx.mail.kapsi.fi>
|
||||
*
|
||||
@@ -57,6 +57,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wdog.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.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Is there new MAX11802 sample data available? */
|
||||
|
||||
@@ -340,7 +341,7 @@ static int max11802_sample(FAR struct max11802_dev_s *priv,
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -363,7 +364,7 @@ static int max11802_waitsample(FAR struct max11802_dev_s *priv,
|
||||
*/
|
||||
|
||||
sched_lock();
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Now release the semaphore that manages mutually exclusive access to
|
||||
* the device structure. This may cause other tasks to become ready to
|
||||
@@ -413,7 +414,7 @@ errout:
|
||||
* have pre-emption disabled.
|
||||
*/
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Restore pre-emption. We might get suspended here but that is okay
|
||||
* 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
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
priv->flink = g_max11802list;
|
||||
g_max11802list = priv;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
#endif
|
||||
|
||||
/* Schedule work to perform the initial sampling and to set the data
|
||||
|
||||
+4
-3
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -58,6 +58,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/arch.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.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Now release the semaphore that manages mutually exclusive access to
|
||||
* the device structure. This may cause other tasks to become ready to
|
||||
@@ -719,7 +720,7 @@ errout:
|
||||
* have pre-emption disabled.
|
||||
*/
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* 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>
|
||||
*
|
||||
* References:
|
||||
@@ -62,6 +62,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/arch.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.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Is there new TSC2007 sample data available? */
|
||||
|
||||
@@ -334,7 +335,7 @@ static int tsc2007_sample(FAR struct tsc2007_dev_s *priv,
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -357,7 +358,7 @@ static int tsc2007_waitsample(FAR struct tsc2007_dev_s *priv,
|
||||
*/
|
||||
|
||||
sched_lock();
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Now release the semaphore that manages mutually exclusive access to
|
||||
* the device structure. This may cause other tasks to become ready to
|
||||
@@ -403,7 +404,7 @@ errout:
|
||||
* have pre-emption disabled.
|
||||
*/
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Restore pre-emption. We might get suspended here but that is okay
|
||||
* 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
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
priv->flink = g_tsc2007list;
|
||||
g_tsc2007list = priv;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
#endif
|
||||
|
||||
/* Schedule work to perform the initial sampling and to set the data
|
||||
|
||||
Reference in New Issue
Block a user