From 52560bba37bbde74c00a51d6d645a76300355027 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 18 Nov 2016 08:41:27 -0600 Subject: [PATCH] ENC28J60: Allow either HP or LP work queue to be used. --- drivers/net/Kconfig | 18 ++++++++++++++++++ drivers/net/enc28j60.c | 16 ++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 8852ead7b8..adf7aa5f1a 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -218,6 +218,24 @@ config ENC28J60_FREQUENCY ---help--- Define to use a different bus frequency +choice + prompt "Work queue" + default ENC28J60_LPWORK if SCHED_LPWORK + default ENC28J60_HPWORK if !SCHED_LPWORK && SCHED_HPWORK + depends on SCHED_WORKQUEUE + ---help--- + Work queue support is required to use the ENC28J60 driver. If the low priority work queue is available, then it should be used by the ENC28J60. + +config ENC28J60_HPWORK + bool "High priority" + depends on SCHED_HPWORK + +config ENC28J60_LPWORK + bool "Low priority" + depends on SCHED_LPWORK + +endchoice # Work queue + config ENC28J60_HALFDUPPLEX bool "Enable half dupplex" default n diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c index 98edc13417..78da85e04c 100644 --- a/drivers/net/enc28j60.c +++ b/drivers/net/enc28j60.c @@ -115,8 +115,16 @@ /* We need to have the work queue to handle SPI interrupts */ -#ifndef CONFIG_SCHED_WORKQUEUE +#if !defined(CONFIG_SCHED_WORKQUEUE) # error "Worker thread support is required (CONFIG_SCHED_WORKQUEUE)" +#else +# if defined(CONFIG_ENC28J60_HPWORK) +# define ENCWORK HPWORK +# elif defined(CONFIG_ENC28J60_LPWORK) +# define ENCWORK LPWORK +# else +# error "Neither CONFIG_ENC28J60_HPWORK nor CONFIG_ENC28J60_LPWORK defined" +# endif #endif /* CONFIG_ENC28J60_DUMPPACKET will dump the contents of each packet to the console. */ @@ -1852,7 +1860,7 @@ static int enc_interrupt(int irq, FAR void *context) */ priv->lower->disable(priv->lower); - return work_queue(HPWORK, &priv->irqwork, enc_irqworker, (FAR void *)priv, 0); + return work_queue(ENCWORK, &priv->irqwork, enc_irqworker, (FAR void *)priv, 0); } /**************************************************************************** @@ -1944,7 +1952,7 @@ static void enc_txtimeout(int argc, uint32_t arg, ...) * can occur until we restart the Tx timeout watchdog. */ - ret = work_queue(HPWORK, &priv->towork, enc_toworker, (FAR void *)priv, 0); + ret = work_queue(ENCWORK, &priv->towork, enc_toworker, (FAR void *)priv, 0); DEBUGASSERT(ret == OK); UNUSED(ret); } @@ -2040,7 +2048,7 @@ static void enc_polltimer(int argc, uint32_t arg, ...) * occur until we restart the poll timeout watchdog. */ - ret = work_queue(HPWORK, &priv->pollwork, enc_pollworker, (FAR void *)priv, 0); + ret = work_queue(ENCWORK, &priv->pollwork, enc_pollworker, (FAR void *)priv, 0); DEBUGASSERT(ret == OK); UNUSED(ret); }