#include <scst_const.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
+#ifndef RHEL_RELEASE_CODE
+typedef _Bool bool;
+#endif
+#define true 1
+#define false 0
+#endif
+
#include "scst_sgv.h"
/*
#define SCST_INTERFACE_VERSION \
SCST_VERSION_STRING "$Revision$" SCST_CONST_VERSION
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
-#ifndef RHEL_RELEASE_CODE
-typedef _Bool bool;
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18))
+#define COMPLETION_INITIALIZER_ONSTACK(work) \
+ ({ init_completion(&work); work; })
+
+/*
+ * Lockdep needs to run a non-constant initializer for on-stack
+ * completions - so we use the _ONSTACK() variant for those that
+ * are on the kernel stack:
+ */
+#ifdef CONFIG_LOCKDEP
+# define DECLARE_COMPLETION_ONSTACK(work) \
+ struct completion work = COMPLETION_INITIALIZER_ONSTACK(work)
+#else
+# define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work)
#endif
-#define true 1
-#define false 0
+
#endif
#define SCST_LOCAL_NAME "scst_lcl_drvr"
for details."
#endif
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18))
-#define COMPLETION_INITIALIZER_ONSTACK(work) \
- ({ init_completion(&work); work; })
-
-/*
- * Lockdep needs to run a non-constant initializer for on-stack
- * completions - so we use the _ONSTACK() variant for those that
- * are on the kernel stack:
- */
-#ifdef CONFIG_LOCKDEP
-# define DECLARE_COMPLETION_ONSTACK(work) \
- struct completion work = COMPLETION_INITIALIZER_ONSTACK(work)
-#else
-# define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work)
-#endif
-
-#endif
-
#define DEV_USER_MAJOR 237
#define DEV_USER_CMD_HASH_ORDER 6
#define DEV_USER_ATTACH_TIMEOUT (5*HZ)
TRACE_DBG("%s", "init_result_fn() returned");
}
-#ifdef CONFIG_LOCKDEP
- if (res == 0) {
- /* ToDo: make it on-stack */
- sess->shutdown_compl = kmalloc(sizeof(*sess->shutdown_compl),
- GFP_KERNEL);
- if (sess->shutdown_compl == NULL)
- res = -ENOMEM;
- else
- init_completion(sess->shutdown_compl);
- }
-#endif
-
spin_lock_irq(&sess->sess_list_lock);
if (res == 0)
void (*unreg_done_fn) (struct scst_session *sess))
{
unsigned long flags;
- struct completion *pc;
-#ifndef CONFIG_LOCKDEP
- DECLARE_COMPLETION(c);
-#endif
+ DECLARE_COMPLETION_ONSTACK(c);
int rc, lun;
TRACE_ENTRY();
TRACE_MGMT_DBG("Unregistering session %p (wait %d)", sess, wait);
-#ifdef CONFIG_LOCKDEP
- pc = sess->shutdown_compl;
-#else
- pc = &c;
-#endif
-
sess->unreg_done_fn = unreg_done_fn;
/* Abort all outstanding commands and clear reservation, if necessary */
spin_lock_irqsave(&scst_mgmt_lock, flags);
if (wait)
- sess->shutdown_compl = pc;
-#ifdef CONFIG_LOCKDEP
- else
- sess->shutdown_compl = NULL;
-#endif
+ sess->shutdown_compl = &c;
spin_unlock_irqrestore(&scst_mgmt_lock, flags);
if (wait) {
TRACE_DBG("Waiting for session %p to complete", sess);
- wait_for_completion(pc);
+ wait_for_completion(&c);
}
-#ifdef CONFIG_LOCKDEP
- kfree(pc);
-#endif
-
TRACE_EXIT();
return;
}