ENCX24J600: Fix some warnings. Update interface to use newer parameter passing to interrupt handlers

This commit is contained in:
Gregory Nutt 2017-08-21 16:23:22 -06:00
parent 17ca117104
commit 241c1433ef
3 changed files with 26 additions and 14 deletions

View File

@ -98,13 +98,15 @@ struct stm32_lower_s
{
const struct enc_lower_s lower; /* Low-level MCU interface */
xcpt_t handler; /* ENCX24J600 interrupt handler */
FAR void *arg; /* Arguement that accompanies the handler */
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static int up_attach(FAR const struct enc_lower_s *lower, xcpt_t handler);
static int up_attach(FAR const struct enc_lower_s *lower, xcpt_t handler,
FAR void *arg);
static void up_enable(FAR const struct enc_lower_s *lower);
static void up_disable(FAR const struct enc_lower_s *lower);
@ -126,6 +128,7 @@ static struct stm32_lower_s g_enclower =
.disable = up_disable
},
.handler = NULL,
.arg = NULL
};
/****************************************************************************
@ -136,13 +139,15 @@ static struct stm32_lower_s g_enclower =
* Name: struct enc_lower_s methods
****************************************************************************/
static int up_attach(FAR const struct enc_lower_s *lower, xcpt_t handler)
static int up_attach(FAR const struct enc_lower_s *lower, xcpt_t handler,
FAR void *arg)
{
FAR struct stm32_lower_s *priv = (FAR struct stm32_lower_s *)lower;
/* Just save the handler for use when the interrupt is enabled */
priv->handler = handler;
priv->arg = arg;
return OK;
}
@ -150,11 +155,15 @@ static void up_enable(FAR const struct enc_lower_s *lower)
{
FAR struct stm32_lower_s *priv = (FAR struct stm32_lower_s *)lower;
DEBUGASSERT(priv->handler);
DEBUGASSERT(priv->handler != NULL);
(void)stm32_gpiosetevent(GPIO_ENCX24J600_INTR, false, true, true,
priv->handler, NULL);
priv->handler, priv->arg);
}
/* REVISIT: Since the interrupt is torn down completely, any interrupts
* the occur while "disabled" will be lost.
*/
static void up_disable(FAR const struct enc_lower_s *lower)
{
(void)stm32_gpiosetevent(GPIO_ENCX24J600_INTR, false, true, true,

View File

@ -341,7 +341,7 @@ static void enc_txif(FAR struct enc_driver_s *priv);
static void enc_pktif(FAR struct enc_driver_s *priv);
static void enc_rxabtif(FAR struct enc_driver_s *priv);
static void enc_irqworker(FAR void *arg);
static int enc_interrupt(int irq, FAR void *context);
static int enc_interrupt(int irq, FAR void *context, FAR void *arg);
/* Watchdog timer expirations */
@ -1454,8 +1454,6 @@ static void enc_rxdispatch(FAR struct enc_driver_s *priv)
FAR struct enc_descr_s *descr;
struct enc_descr_s *next;
int ret = ERROR;
/* Process the RX queue */
descr = (FAR struct enc_descr_s *)sq_peek(&priv->rxqueue);
@ -1475,7 +1473,7 @@ static void enc_rxdispatch(FAR struct enc_driver_s *priv)
#ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */
pkt_input(&priv->dev);
(void)pkt_input(&priv->dev);
#endif
/* We only accept IP packets of the configured type and ARP packets */
@ -1533,7 +1531,7 @@ static void enc_rxdispatch(FAR struct enc_driver_s *priv)
/* Give the IPv6 packet to the network layer */
ret = ipv6_input(&priv->dev);
(void)ipv6_input(&priv->dev);
/* Free the packet */
@ -1976,9 +1974,12 @@ static void enc_irqworker(FAR void *arg)
*
****************************************************************************/
static int enc_interrupt(int irq, FAR void *context)
static int enc_interrupt(int irq, FAR void *context, FAR void *arg)
{
register FAR struct enc_driver_s *priv = &g_encx24j600[0];
FAR struct enc_driver_s *priv = &g_encx24j600[0];
DEBUGASSERT(arg != NULL);
priv = (FAR struct enc_driver_s *)arg;
/* In complex environments, we cannot do SPI transfers from the interrupt
* handler because semaphores are probably used to lock the SPI bus. In
@ -1995,7 +1996,8 @@ static int enc_interrupt(int irq, FAR void *context)
*/
priv->lower->disable(priv->lower);
return work_queue(ENCWORK, &priv->irqwork, enc_irqworker, (FAR void *)priv, 0);
return work_queue(ENCWORK, &priv->irqwork, enc_irqworker,
(FAR void *)priv, 0);
}
/****************************************************************************
@ -2829,7 +2831,7 @@ int enc_initialize(FAR struct spi_dev_s *spi,
/* Attach the interrupt to the driver (but don't enable it yet) */
if (lower->attach(lower, enc_interrupt))
if (lower->attach(lower, enc_interrupt, priv) < 0)
{
/* We could not attach the ISR to the interrupt */

View File

@ -86,7 +86,8 @@
struct enc_lower_s
{
int (*attach)(FAR const struct enc_lower_s *lower, xcpt_t handler);
int (*attach)(FAR const struct enc_lower_s *lower, xcpt_t handler,
FAR void *arg);
void (*enable)(FAR const struct enc_lower_s *lower);
void (*disable)(FAR const struct enc_lower_s *lower);
};