Kinetis GPIO: 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 11:33:03 -06:00
parent f1341dad9c
commit 34a2839244
8 changed files with 23 additions and 28 deletions

View File

@ -568,19 +568,17 @@ void kinetis_pinirqinitialize(void);
* 3. Call kinetis_pinirqenable() to enable interrupts on the pin.
*
* Parameters:
* pinset - Pin configuration
* pinisr -:wq
:wq: Pin interrupt service routine
* arg:r - And argument that will be provided to the interrupt service routine.
* pinset - Pin configuration
* pinisr - Pin interrupt service routine
* arg - An argument that will be provided to the interrupt service routine.
*
* Return Value:
* 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.
* Zero (OK) is returned on success; a negated errno value is returned on any
* failure to indicate the nature of the failure.
*
************************************************************************************/
xcpt_t kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr, void *arg);
int kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr, void *arg);
/************************************************************************************
* Name: kinetis_pinirqenable

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/kinetis/kinetis_pinirq.c
*
* Copyright (C) 2011, 2013, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2013, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -262,21 +262,20 @@ void kinetis_pinirqinitialize(void)
* 3. Call kinetis_pinirqenable() to enable interrupts on the pin.
*
* Parameters:
* - pinset: Pin configuration
* - pinisr: Pin interrupt service routine
* pinset - Pin configuration
* pinisr - Pin interrupt service routine
* arg - An argument that will be provided to the interrupt service routine.
*
* Returns:
* The previous value of the interrupt handler function pointer. This
* value may, for example, be used to restore the previous handler whe
* multiple handlers are used.
* Zero (OK) is returned on success; a negated errno value is returned on any
* failure to indicate the nature of the failure.
*
****************************************************************************/
************************************************************************************/
xcpt_t kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr, void *arg)
int kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr, void *arg)
{
#ifdef HAVE_PORTINTS
struct kinetis_pinirq_s *isrtab;
xcpt_t oldisr;
irqstate_t flags;
unsigned int port;
unsigned int pin;
@ -331,16 +330,15 @@ xcpt_t kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr, void *arg)
/* Get the old PIN ISR and set the new PIN ISR */
oldisr = isrtab[pin].handler;
isrtab[pin].handler = pinisr;
isrtab[pin].arg = arg;
/* And return the old PIN isr address */
leave_critical_section(flags);
return oldisr;
return OK;
#else
return NULL;
return -ENOSYS;
#endif /* HAVE_PORTINTS */
}

View File

@ -169,7 +169,7 @@ int k64_sdhc_initialize(void)
/* Attached the card detect interrupt (but don't enable it yet) */
kinetis_pinirqattach(GPIO_SD_CARDDETECT, k64_cdinterrupt, NULL);
(void)kinetis_pinirqattach(GPIO_SD_CARDDETECT, k64_cdinterrupt, NULL);
/* Configure the write protect GPIO -- None */

View File

@ -139,7 +139,6 @@ 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;
uint32_t pinset;
/* Map the button id to the GPIO bit set. */
@ -163,12 +162,12 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
* Attach the new button handler.
*/
oldhandler = kinetis_pinirqattach(pinset, irqhandler, NULL);
(void)kinetis_pinirqattach(pinset, irqhandler, NULL);
/* Then make sure that interrupts are enabled on the pin */
kinetis_pinirqenable(pinset);
return oldhandler;
return NULL;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -170,7 +170,7 @@ int k66_sdhc_initialize(void)
/* Attached the card detect interrupt (but don't enable it yet) */
kinetis_pinirqattach(GPIO_SD_CARDDETECT, k66_cdinterrupt, NULL);
(void)kinetis_pinirqattach(GPIO_SD_CARDDETECT, k66_cdinterrupt, NULL);
/* Configure the write protect GPIO -- None */

View File

@ -217,7 +217,7 @@ int board_app_initialize(uintptr_t arg)
/* Attached the card detect interrupt (but don't enable it yet) */
kinetis_pinconfig(GPIO_SD_CARDDETECT);
kinetis_pinirqattach(GPIO_SD_CARDDETECT, kinetis_cdinterrupt, NULL);
(void)kinetis_pinirqattach(GPIO_SD_CARDDETECT, kinetis_cdinterrupt, NULL);
/* Mount the SDHC-based MMC/SD block driver */
/* First, get an instance of the SDHC interface */

View File

@ -224,7 +224,7 @@ int board_app_initialize(uintptr_t arg)
/* Attached the card detect interrupt (but don't enable it yet) */
kinetis_pinconfig(GPIO_SD_CARDDETECT);
kinetis_pinirqattach(GPIO_SD_CARDDETECT, kinetis_cdinterrupt, NULL);
(void)kinetis_pinirqattach(GPIO_SD_CARDDETECT, kinetis_cdinterrupt, NULL);
/* Configure the write protect GPIO */

View File

@ -166,7 +166,7 @@ int k64_sdhc_initialize(void)
/* Attached the card detect interrupt (but don't enable it yet) */
kinetis_pinirqattach(GPIO_SD_CARDDETECT, k64_cdinterrupt, NULL);
(void)kinetis_pinirqattach(GPIO_SD_CARDDETECT, k64_cdinterrupt, NULL);
/* Configure the write protect GPIO -- None */