ibmvstgt: started backporting.

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@2353 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2010-10-06 11:02:24 +00:00
parent 7c399c3226
commit d23c7b3b85
3 changed files with 29 additions and 0 deletions

View File

@@ -46,7 +46,10 @@
#include <asm/vio.h>
#else
#include <linux/mod_devicetable.h>
#endif
#if defined(INSIDE_KERNEL_TREE) || defined(__powerpc__)
#include <linux/of.h>
#else
#include "dummy_powerpc_defs.h"
#endif

View File

@@ -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);

View File

@@ -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;
};