mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
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:
@@ -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 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user