From defb974a0d75f0bb89ca6519d8fba6471686d6c2 Mon Sep 17 00:00:00 2001 From: dmlb Date: Sat, 10 Jun 2000 13:52:06 +0000 Subject: Add macros for freeing a set of malloc runq entries and adding them to the runq queue, safely checking for ENXIO --- sys/dev/ray/if_rayvar.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'sys/dev/ray') diff --git a/sys/dev/ray/if_rayvar.h b/sys/dev/ray/if_rayvar.h index 818ef1f9..d44a83c 100644 --- a/sys/dev/ray/if_rayvar.h +++ b/sys/dev/ray/if_rayvar.h @@ -202,6 +202,7 @@ static int mib_info[RAY_MIB_MAX+1][3] = RAY_MIB_INFO; #define RAY_COM_FWAIT 0x0008 /* Do not run the queue */ #define RAY_COM_FCHKRUNNING 0x0010 /* Check IFF_RUNNING */ #define RAY_COM_FDETACHED 0x0020 /* Card is gone */ +#define RAY_COM_FWOKEN 0x0040 /* Woken by detach */ #define RAY_COM_FLAGS_PRINTFB \ "\020" \ "\001WOK" \ @@ -254,6 +255,27 @@ static int mib_info[RAY_MIB_MAX+1][3] = RAY_MIB_INFO; #define RAY_COM_MALLOC(function, flags) \ ray_com_malloc((function), (flags), __STRING(function)); +#define RAY_COM_FREE(com, ncom) do { \ + int i; \ + for (i = 0; i < ncom; i++) \ + FREE(com[i], M_RAYCOM); \ +} while (0) + +/* + * This macro handles adding commands to the runq and quickly + * getting away when the card is detached. The macro returns + * from the current function with ENXIO. + */ +#define RAY_COM_RUNQ(sc, com, ncom, mesg, error) do { \ + (error) = ray_com_runq_add((sc), (com), (ncom), (mesg)); \ + if ((error) == ENXIO) { \ + RAY_COM_FREE((com), (ncom)); \ + return (error); \ + } else if ((error) && ((error) != ENXIO)) \ + RAY_PRINTF(sc, "got error from runq 0x%x", (error)); \ +} while (0) + + #define RAY_COM_INIT(com, function, flags) \ ray_com_init((com), (function), (flags), __STRING(function)); -- cgit v1.1