arch_phy_irq: Now returns int instead of xcpt_t oldhandler. The oldhandler is useless after the changes to the interrupt argument. Also access an argument for the PHY interrupt. phy_notify.c driver changed to exploit new interrupt argument passing.

This commit is contained in:
Gregory Nutt
2017-03-02 08:42:13 -06:00
parent 75446b349b
commit f5f9d82d5a
10 changed files with 88 additions and 256 deletions
+8 -24
View File
@@ -1,7 +1,7 @@
/************************************************************************************
* configs/sam4e-ek/src/sam_ethernet.c
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -83,14 +83,6 @@
# define phyinfo(x...)
#endif
/************************************************************************************
* Private Data
************************************************************************************/
#ifdef CONFIG_SAM34_GPIOD_IRQ
static xcpt_t g_emac_handler;
#endif
/************************************************************************************
* Private Functions
************************************************************************************/
@@ -184,23 +176,21 @@ void weak_function sam_netinitialize(void)
* asserts an interrupt. Must reside in OS space, but can
* signal tasks in user space. A value of NULL can be passed
* in order to detach and disable the PHY interrupt.
* arg - The argument that will accompany the interrupt
* enable - A function pointer that be unsed to enable or disable the
* PHY interrupt.
*
* Returned Value:
* The previous PHY interrupt handler address is returned. This allows you
* to temporarily replace an interrupt handler, then restore the original
* interrupt handler. NULL is returned if there is was not handler in
* place when the call was made.
* Zero (OK) returned on success; a negated errno value is returned on
* failure.
*
****************************************************************************/
#ifdef CONFIG_SAM34_GPIOD_IRQ
xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
int arch_phy_irq(FAR const char *intf, xcpt_t handler, void *arg,
phy_enable_t *enable)
{
irqstate_t flags;
xcpt_t *phandler;
xcpt_t oldhandler;
gpio_pinset_t pinset;
phy_enable_t enabler;
int irq;
@@ -213,7 +203,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
if (strcmp(intf, SAM34_EMAC_DEVNAME) == 0)
{
phyinfo("Select EMAC\n");
phandler = &g_emac_handler;
pinset = GPIO_PHY_IRQ;
irq = SAM_PHY_IRQ;
enabler = sam_emac_phy_enable;
@@ -230,11 +219,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
flags = enter_critical_section();
/* Get the old interrupt handler and save the new one */
oldhandler = *phandler;
*phandler = handler;
/* Configure the interrupt */
if (handler)
@@ -243,7 +227,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
sam_gpioirq(pinset);
phyinfo("Attach IRQ%d\n", irq);
(void)irq_attach(irq, handler, NULL);
(void)irq_attach(irq, handler, arg);
}
else
{
@@ -266,7 +250,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
/* Return the old handler (so that it can be restored) */
leave_critical_section(flags);
return oldhandler;
return OK;
}
#endif /* CONFIG_SAM34_GPIOD_IRQ */