mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
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:
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* configs/sam4e-ek/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,21 +54,6 @@
|
||||
|
||||
#ifdef CONFIG_ARCH_BUTTONS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAM34_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
static xcpt_t g_irq_scrollup;
|
||||
static xcpt_t g_irq_scrolldown;
|
||||
static xcpt_t g_irq_waku;
|
||||
static xcpt_t g_irq_tamp;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
@@ -81,10 +67,9 @@ static xcpt_t g_irq_tamp;
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAM34_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
static xcpt_t board_button_irqx(gpio_pinset_t pinset, int irq,
|
||||
xcpt_t irqhandler, xcpt_t *store, void *arg)
|
||||
static int board_button_irqx(gpio_pinset_t pinset, int irq, xcpt_t irqhandler,
|
||||
void *arg)
|
||||
{
|
||||
xcpt_t oldhandler;
|
||||
irqstate_t flags;
|
||||
|
||||
/* Disable interrupts until we are done. This guarantees that the following
|
||||
@@ -93,11 +78,6 @@ static xcpt_t board_button_irqx(gpio_pinset_t pinset, int irq,
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the old button interrupt handler and save the new one */
|
||||
|
||||
oldhandler = *store;
|
||||
*store = irqhandler;
|
||||
|
||||
/* Are we attaching or detaching? */
|
||||
|
||||
if (irqhandler != NULL)
|
||||
@@ -117,10 +97,7 @@ static xcpt_t board_button_irqx(gpio_pinset_t pinset, int irq,
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Return the old button handler (so that it can be restored) */
|
||||
|
||||
return oldhandler;
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -188,28 +165,24 @@ uint8_t board_buttons(void)
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAM34_GPIOA_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)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case BUTTON_SCROLLUP:
|
||||
return board_button_irqx(GPIO_SCROLLUP, IRQ_SCROLLUP,
|
||||
irqhandler, &g_irq_scrollup, arg);
|
||||
return board_button_irqx(GPIO_SCROLLUP, IRQ_SCROLLUP, irqhandler, arg);
|
||||
|
||||
case BUTTON_SCROLLDOWN:
|
||||
return board_button_irqx(GPIO_SCROLLDWN, IRQ_SCROLLDWN,
|
||||
irqhandler, &g_irq_scrolldown, arg);
|
||||
return board_button_irqx(GPIO_SCROLLDWN, IRQ_SCROLLDWN, irqhandler, arg);
|
||||
|
||||
case BUTTON_WAKU:
|
||||
return board_button_irqx(GPIO_WAKU, IRQ_WAKU,
|
||||
irqhandler, &g_irq_waku, arg);
|
||||
return board_button_irqx(GPIO_WAKU, IRQ_WAKU, irqhandler, arg);
|
||||
|
||||
case BUTTON_TAMP:
|
||||
return board_button_irqx(GPIO_TAMP, IRQ_TAMP,
|
||||
irqhandler, &g_irq_tamp, arg);
|
||||
return board_button_irqx(GPIO_TAMP, IRQ_TAMP, irqhandler, arg);
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user