diff options
author | Dan Williams <dan.j.williams@intel.com> | 2011-07-29 20:26:39 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2011-08-27 10:35:13 -0400 |
commit | 4fcf812ca392303aa79dd50e96e83a29faa13bd0 (patch) | |
tree | 411c33d701989b44ba2f4ecb64fd0cba92214958 /drivers/scsi/libsas/sas_init.c | |
parent | 7ca3c803e85080afdff4097e60fefec865027809 (diff) |
[SCSI] libsas: export sas_alloc_task()
Now that isci has added a 3rd open coded user of this functionality just
share the libsas version.
Acked-by: Jack Wang <jack_wang@usish.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/libsas/sas_init.c')
-rw-r--r-- | drivers/scsi/libsas/sas_init.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c index 2dc55343f671..dd56ea827665 100644 --- a/drivers/scsi/libsas/sas_init.c +++ b/drivers/scsi/libsas/sas_init.c | |||
@@ -37,7 +37,32 @@ | |||
37 | 37 | ||
38 | #include "../scsi_sas_internal.h" | 38 | #include "../scsi_sas_internal.h" |
39 | 39 | ||
40 | struct kmem_cache *sas_task_cache; | 40 | static struct kmem_cache *sas_task_cache; |
41 | |||
42 | struct sas_task *sas_alloc_task(gfp_t flags) | ||
43 | { | ||
44 | struct sas_task *task = kmem_cache_zalloc(sas_task_cache, flags); | ||
45 | |||
46 | if (task) { | ||
47 | INIT_LIST_HEAD(&task->list); | ||
48 | spin_lock_init(&task->task_state_lock); | ||
49 | task->task_state_flags = SAS_TASK_STATE_PENDING; | ||
50 | init_timer(&task->timer); | ||
51 | init_completion(&task->completion); | ||
52 | } | ||
53 | |||
54 | return task; | ||
55 | } | ||
56 | EXPORT_SYMBOL_GPL(sas_alloc_task); | ||
57 | |||
58 | void sas_free_task(struct sas_task *task) | ||
59 | { | ||
60 | if (task) { | ||
61 | BUG_ON(!list_empty(&task->list)); | ||
62 | kmem_cache_free(sas_task_cache, task); | ||
63 | } | ||
64 | } | ||
65 | EXPORT_SYMBOL_GPL(sas_free_task); | ||
41 | 66 | ||
42 | /*------------ SAS addr hash -----------*/ | 67 | /*------------ SAS addr hash -----------*/ |
43 | void sas_hash_addr(u8 *hashed, const u8 *sas_addr) | 68 | void sas_hash_addr(u8 *hashed, const u8 *sas_addr) |
@@ -293,8 +318,7 @@ EXPORT_SYMBOL_GPL(sas_domain_release_transport); | |||
293 | 318 | ||
294 | static int __init sas_class_init(void) | 319 | static int __init sas_class_init(void) |
295 | { | 320 | { |
296 | sas_task_cache = kmem_cache_create("sas_task", sizeof(struct sas_task), | 321 | sas_task_cache = KMEM_CACHE(sas_task, SLAB_HWCACHE_ALIGN); |
297 | 0, SLAB_HWCACHE_ALIGN, NULL); | ||
298 | if (!sas_task_cache) | 322 | if (!sas_task_cache) |
299 | return -ENOMEM; | 323 | return -ENOMEM; |
300 | 324 | ||