summaryrefslogtreecommitdiffstats
path: root/sys/dev/ray
diff options
context:
space:
mode:
authordmlb <dmlb@FreeBSD.org>2000-06-10 13:52:06 +0000
committerdmlb <dmlb@FreeBSD.org>2000-06-10 13:52:06 +0000
commitdefb974a0d75f0bb89ca6519d8fba6471686d6c2 (patch)
tree1f926596261ed26510cf79e35324d88254d3dd42 /sys/dev/ray
parent60e2d87a745c9d5f2eef99a6bf0daf7c41a6c480 (diff)
downloadFreeBSD-src-defb974a0d75f0bb89ca6519d8fba6471686d6c2.zip
FreeBSD-src-defb974a0d75f0bb89ca6519d8fba6471686d6c2.tar.gz
Add macros for freeing a set of malloc runq entries and adding them to the
runq queue, safely checking for ENXIO
Diffstat (limited to 'sys/dev/ray')
-rw-r--r--sys/dev/ray/if_rayvar.h22
1 files changed, 22 insertions, 0 deletions
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));
OpenPOWER on IntegriCloud