board_button_irq: Button IRQ logic no longer returns the xcpt_t oldhandler. There value is useless and dangerous after the recent changes to interrupt argument passing.

This commit is contained in:
Gregory Nutt 2017-03-02 15:27:55 -06:00
parent 0f46d714a9
commit 4f5e0e3519
16 changed files with 67 additions and 85 deletions

View File

@ -178,10 +178,11 @@ uint8_t board_buttons(void)
****************************************************************************/
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC43_GPIO_IRQ)
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
#if 0 /* Not yet implemented */
irqstate_t flags;
int ret = -EINVAL;
int irq;
/* Verify that the button ID is within range */
@ -213,9 +214,10 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
}
leave_critical_section(flags);
ret = OK;
}
return OK;
return ret;
#else
return -ENOSYS;
#endif /* Not yet implemented */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* configs/saml21-xplained/src/sam_buttons.c
*
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -53,22 +54,6 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
#if defined(CONFIG_PORTA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
static xcpt_t g_irqsw0;
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -123,9 +108,9 @@ uint8_t board_buttons(void)
****************************************************************************/
#if defined(CONFIG_PORTA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
if (id == BUTTON_SW0)
{
@ -137,22 +122,19 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
flags = enter_critical_section();
/* Get the old button interrupt handler and save the new one */
oldhandler = *g_irqsw0;
*g_irqsw0 = irqhandler;
/* Configure the interrupt */
sam_portirq(IRQ_SW0);
(void)irq_attach(IRQ_SW0, irqhandler, arg);
sam_portirqenable(IRQ_SW0);
leave_critical_section(flags);
ret = OK;
}
/* Return the old button handler (so that it can be restored) */
return oldhandler;
return ret;
}
#endif

View File

@ -84,8 +84,8 @@
****************************************************************************/
#ifdef HAVE_IRQBUTTONS
static xcpt_t board_button_irqx(gpio_pinset_t pinset, int irq,
xcpt_t irqhandler, void *arg)
static int board_button_irqx(gpio_pinset_t pinset, int irq, xcpt_t irqhandler,
void *arg)
{
irqstate_t flags;

View File

@ -1,7 +1,7 @@
/****************************************************************************
* configs/stm3210e-eval/src/stm32_buttons.c
*
* Copyright (C) 2009, 2011, 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2009, 2011, 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -160,7 +160,7 @@ uint8_t board_buttons(void)
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@ -172,7 +172,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* configs/stm3220g-eval/src/stm32_buttons.c
*
* Copyright (C) 2012, 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -156,7 +156,7 @@ uint8_t board_buttons(void)
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@ -168,7 +168,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* configs/stm3240g-eval/src/stm32_buttons.c
*
* Copyright (C) 2011, 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -156,7 +156,7 @@ uint8_t board_buttons(void)
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@ -168,7 +168,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* configs/stm32f103-minimum/src/stm32_buttons.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -151,7 +151,7 @@ uint8_t board_buttons(void)
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@ -163,7 +163,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif

View File

@ -1,7 +1,7 @@
/****************************************************************************
* configs/stm32f3discovery/src/stm32_buttons.c
*
* Copyright (C) 2013, 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -151,7 +151,7 @@ uint8_t board_buttons(void)
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@ -163,7 +163,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* configs/stm32f429i-disco/src/stm32_buttons.c
*
* Copyright (C) 2011-2012, 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2011-2012, 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -151,7 +151,7 @@ uint8_t board_buttons(void)
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@ -163,7 +163,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* configs/stm32f4discovery/src/stm32_buttons.c
*
* Copyright (C) 2011-2012, 2014=2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2011-2012, 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -151,7 +151,7 @@ uint8_t board_buttons(void)
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@ -163,7 +163,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* configs/stm32f4discovery/src/stm32_pm_buttons.c
*
* Copyright (C) 2012, 2015-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2015-2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
* Diego Sanchez <dsanchez@nx-engineering.com>
*
@ -130,14 +130,7 @@ void stm32_pm_buttons(void)
board_button_initialize();
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t oldhandler = board_button_irq(0, button_handler, NULL);
if (oldhandler != NULL)
{
_warn("WARNING: oldhandler:%p is not NULL! "
"Button events may be lost or aliased!\n",
oldhandler);
}
(void)board_button_irq(0, button_handler, NULL);
#endif
}

View File

@ -1,7 +1,7 @@
/****************************************************************************
* configs/stm32f746g-disco/src/stm32_buttons.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -39,6 +39,8 @@
#include <nuttx/config.h>
#include <errno.h>
#include <nuttx/irq.h>
#include <nuttx/board.h>
@ -103,9 +105,10 @@ uint8_t board_buttons(void)
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
#warning Missing logic
return -ENOSYS;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -149,9 +150,9 @@ uint8_t board_buttons(void)
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
int ret = OK;
int ret = -EINVAL;
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
@ -159,8 +160,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
UNUSED(ret);
return NULL;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -244,19 +244,13 @@ void board_button_initialize(void)
{
stm32l4_configgpio(g_buttons[i]);
/* It's not clear if this is correct; I think so, but then there are
* conflicts with the 'buttons' sample app.
*/
/* It's not clear if this is correct; I think so, but then there are
* conflicts with the 'buttons' sample app.
*/
#if 0
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t oldhandler = board_button_irq(i, button_handler);
if (oldhandler != NULL)
{
warn("WARNING: oldhandler:%p is not NULL! "
"Button events may be lost or aliased!\n",
oldhandler);
}
(void)board_button_irq(i, button_handler);
#endif
#endif
}
@ -324,9 +318,9 @@ uint8_t board_buttons(void)
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
int ret = OK;
int ret = -EINVAL;
/* The following should be atomic */
@ -335,8 +329,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
ret = stm32l4_gpiosetevent(g_buttons[id], true, true, true, irqhandler, arg);
}
UNUSED(ret);
return NULL;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* configs/stm32ldiscovery/src/board_buttons.c
*
* Copyright (C) 2013-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2013-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -151,7 +151,7 @@ uint8_t board_buttons(void)
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@ -163,7 +163,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* configs/stm32vldiscovery/src/stm32_buttons.c
*
* Copyright (C) 2012, 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Freddie Chopin <freddie_chopin@op.pl>
*
@ -106,7 +106,7 @@ uint8_t board_buttons(void)
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@ -115,7 +115,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
oldhandler = stm32_gpiosetevent(GPIO_BTN_0, true, true, true, irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */