STM32 L4: Pin 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 12:36:10 -06:00
parent 32383556fd
commit 7982b45367
6 changed files with 54 additions and 51 deletions

View File

@ -72,22 +72,22 @@ extern "C"
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
* Parameters:
* - pinset: gpio pin configuration
* - rising/falling edge: enables
* - event: generate event when set
* - func: when non-NULL, generate interrupt
* - arg: Argument passed to the interrupt callback
* Input Parameters:
* pinset - GPIO pin configuration
* risingedge - Enables interrupt on rising edges
* fallingedge - Enables interrupt on falling edges
* event - Generate event when set
* func - When non-NULL, generate interrupt
* arg - Argument passed to the interrupt callback
*
* Returns:
* The previous value of the interrupt handler function pointer. This value may,
* for example, be used to restore the previous handler when multiple handlers are
* used.
* Returned Value:
* Zero (OK) is returned on success, otherwise a negated errno value is returned
* to indicate the nature of the failure.
*
************************************************************************************/
xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
int stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
/****************************************************************************
* Name: stm32l4_exti_alarm

View File

@ -61,8 +61,8 @@
struct gpio_callback_s
{
xcpt_t callback;
void *arg;
xcpt_t callback; /* Callback entry point */
void *arg; /* The argument that accompanies the callback */
};
/****************************************************************************
@ -249,23 +249,25 @@ static int stm32l4_exti1510_isr(int irq, void *context, FAR void *arg)
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
* Parameters:
* - pinset: GPIO pin configuration
* - risingedge: Enables interrupt on rising edges
* - fallingedge: Enables interrupt on falling edges
* - event: Generate event when set
* - func: When non-NULL, generate interrupt
* - arg: Argument passed to the interrupt callback
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
* Returns:
* The previous value of the interrupt handler function pointer. This
* value may, for example, be used to restore the previous handler when
* multiple handlers are used.
* Input Parameters:
* pinset - GPIO pin configuration
* risingedge - Enables interrupt on rising edges
* fallingedge - Enables interrupt on falling edges
* event - Generate event when set
* func - When non-NULL, generate interrupt
* arg - Argument passed to the interrupt callback
*
****************************************************************************/
* Returned Value:
* Zero (OK) is returned on success, otherwise a negated errno value is returned
* to indicate the nature of the failure.
*
************************************************************************************/
xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg)
int stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg)
{
struct gpio_callback_s *shared_cbs;
uint32_t pin = pinset & GPIO_PIN_MASK;
@ -323,7 +325,6 @@ xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
oldhandler = g_gpio_handlers[pin].callback;
g_gpio_handlers[pin].callback = func;
g_gpio_handlers[pin].arg = arg;
@ -385,5 +386,5 @@ xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
/* Return the old IRQ handler */
return oldhandler;
return OK;
}

View File

@ -326,22 +326,22 @@ bool stm32l4_gpioread(uint32_t pinset);
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
* Parameters:
* - pinset: gpio pin configuration
* - rising/falling edge: enables
* - event: generate event when set
* - func: when non-NULL, generate interrupt
* - arg: Argument passed to the interrupt callback
* Input Parameters:
* pinset - GPIO pin configuration
* risingedge - Enables interrupt on rising edges
* fallingedge - Enables interrupt on falling edges
* event - Generate event when set
* func - When non-NULL, generate interrupt
* arg - Argument passed to the interrupt callback
*
* Returns:
* The previous value of the interrupt handler function pointer. This value may,
* for example, be used to restore the previous handler when multiple handlers are
* used.
* Returned Value:
* Zero (OK) is returned on success, otherwise a negated errno value is returned
* to indicate the nature of the failure.
*
************************************************************************************/
xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
int stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
/************************************************************************************
* Function: stm32l4_dumpgpio

View File

@ -152,15 +152,16 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = OK;
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler = stm32l4_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
ret = stm32l4_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
}
return oldhandler;
UNUSED(ret);
return NULL;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -327,17 +327,17 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = OK;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler = stm32l4_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
ret = stm32l4_gpiosetevent(g_buttons[id], true, true, true, irqhandler, arg);
}
return oldhandler;
UNUSED(ret);
return NULL;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -311,7 +311,8 @@ void stm32l4_usbhost_vbusdrive(int iface, bool enable)
#ifdef CONFIG_USBHOST
xcpt_t stm32l4_setup_overcurrent(xcpt_t handler)
{
return stm32l4_gpiosetevent(GPIO_OTGFS_OVER, true, true, true, handler, NULL);
(void)stm32l4_gpiosetevent(GPIO_OTGFS_OVER, true, true, true, handler, NULL);
return NULL;
}
#endif