From d23c7b3b85d4d9b16b714037cd5802e59d50c49e Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 6 Oct 2010 11:02:24 +0000 Subject: [PATCH] ibmvstgt: started backporting. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@2353 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- ibmvstgt/src/ibmvstgt.c | 3 +++ ibmvstgt/src/libsrpnew.c | 22 ++++++++++++++++++++++ ibmvstgt/src/libsrpnew.h | 4 ++++ 3 files changed, 29 insertions(+) diff --git a/ibmvstgt/src/ibmvstgt.c b/ibmvstgt/src/ibmvstgt.c index f7101e28c..0a7c32635 100644 --- a/ibmvstgt/src/ibmvstgt.c +++ b/ibmvstgt/src/ibmvstgt.c @@ -46,7 +46,10 @@ #include #else #include +#endif +#if defined(INSIDE_KERNEL_TREE) || defined(__powerpc__) #include +#else #include "dummy_powerpc_defs.h" #endif diff --git a/ibmvstgt/src/libsrpnew.c b/ibmvstgt/src/libsrpnew.c index 8f1d77aca..18257b2ac 100644 --- a/ibmvstgt/src/libsrpnew.c +++ b/ibmvstgt/src/libsrpnew.c @@ -60,15 +60,29 @@ static int srp_iu_pool_alloc(struct srp_queue *q, size_t max, goto free_pool; spin_lock_init(&q->lock); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33) + q->queue = kfifo_init((void *) q->pool, max * sizeof(void *), + GFP_KERNEL, &q->lock); + if (IS_ERR(q->queue)) + goto free_item; +#else kfifo_init(&q->queue, (void *) q->pool, max * sizeof(void *)); +#endif for (i = 0, iue = q->items; i < max; i++) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33) + __kfifo_put(q->queue, (void *) &iue, sizeof(void *)); +#else kfifo_in(&q->queue, (void *) &iue, sizeof(void *)); +#endif iue->sbuf = ring[i]; iue++; } return 0; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33) +free_item: +#endif kfree(q->items); free_pool: kfree(q->pool); @@ -165,11 +179,15 @@ struct iu_entry *srp_iu_get(struct srp_target *target) { struct iu_entry *iue = NULL; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33) + kfifo_get(target->iu_queue.queue, (void *) &iue, sizeof(void *)); +#else if (kfifo_out_locked(&target->iu_queue.queue, (void *) &iue, sizeof(void *), &target->iu_queue.lock) != sizeof(void *)) { WARN_ONCE(1, "unexpected fifo state"); return NULL; } +#endif if (!iue) return iue; iue->target = target; @@ -181,8 +199,12 @@ EXPORT_SYMBOL_GPL(srp_iu_get); void srp_iu_put(struct iu_entry *iue) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33) + kfifo_put(iue->target->iu_queue.queue, (void *) &iue, sizeof(void *)); +#else kfifo_in_locked(&iue->target->iu_queue.queue, (void *) &iue, sizeof(void *), &iue->target->iu_queue.lock); +#endif } EXPORT_SYMBOL_GPL(srp_iu_put); diff --git a/ibmvstgt/src/libsrpnew.h b/ibmvstgt/src/libsrpnew.h index 0af5609d0..b37cc0d5d 100644 --- a/ibmvstgt/src/libsrpnew.h +++ b/ibmvstgt/src/libsrpnew.h @@ -25,7 +25,11 @@ struct srp_buf { struct srp_queue { void *pool; void *items; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33) + struct kfifo *queue; +#else struct kfifo queue; +#endif spinlock_t lock; };