Kinetis-L 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:55:26 -06:00
parent c7943586d8
commit edbc0eaace
2 changed files with 29 additions and 20 deletions
+4 -4
View File
@@ -368,15 +368,15 @@ bool kl_gpioread(uint32_t pinset);
* Parameters:
* - pinset: Pin configuration
* - pinisr: Pin interrupt service routine
* - pinarg: The argument that will accompany the pin interrupt
*
* 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.
* Zero (OK) is returned on success; On any failure, a negated errno value is
* returned to indicate the nature of the failure.
*
************************************************************************************/
xcpt_t kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr);
int kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr, void *pinarg);
/************************************************************************************
* Name: kl_gpioirqenable
+25 -16
View File
@@ -76,6 +76,12 @@
* Private Types
****************************************************************************/
struct g_portisrs_s
{
xcpt_t handler; /* Entery hander entry point */
void *arg; /* The argument that accompanies the interrupt handler */
};
/****************************************************************************
* Private Data
****************************************************************************/
@@ -87,11 +93,11 @@
*/
#ifdef CONFIG_KL_PORTAINTS
static xcpt_t g_portaisrs[32];
static struct g_portisrs_s g_portaisrs[32];
#endif
#ifdef CONFIG_KL_PORTDINTS
static xcpt_t g_portdisrs[32];
static struct g_portisrs_s g_portdisrs[32];
#endif
/****************************************************************************
@@ -131,11 +137,14 @@ static int kl_portinterrupt(int irq, FAR void *context,
* interrupt handler for the pin.
*/
if (isrtab[i])
if (isrtab[i].handler != NULL)
{
xcpt_t handler = irstab[i].handler;
void *arg = irstab[i].arg;
/* There is a registered interrupt handler... invoke it */
(void)isrtab[i](irq, context);
(void)handler(irq, context, arg);
}
/* Writing a one to the ISFR register will clear the pending
@@ -219,20 +228,20 @@ void kl_gpioirqinitialize(void)
* Parameters:
* - pinset: Pin configuration
* - pinisr: Pin interrupt service routine
* - pinarg: The argument that will accompany the pin interrupt
*
* 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.
* Returns:
* Zero (OK) is returned on success; On any failure, a negated errno value is
* returned to indicate the nature of the failure.
*
****************************************************************************/
************************************************************************************/
xcpt_t kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr)
int kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr, void *pinarg)
{
#ifdef HAVE_PORTINTS
xcpt_t *isrtab;
xcpt_t oldisr;
irqstate_t flags;
struct g_portisrs_s *isrtab;
irqstate_t flags;
unsigned int port;
unsigned int pin;
@@ -271,16 +280,16 @@ xcpt_t kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr)
/* Get the old PIN ISR and set the new PIN ISR */
oldisr = isrtab[pin];
isrtab[pin] = pinisr;
isrtab[pin].handler = pinisr;
isrtab[pin].arg = pinarg;
/* And return the old PIN isr address */
leave_critical_section(flags);
return oldisr;
return OK;
#else
return NULL;
return -ENOSYS;
#endif /* HAVE_PORTINTS */
}