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/pm8001/pm8001_sas.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/pm8001/pm8001_sas.c')
-rw-r--r-- | drivers/scsi/pm8001/pm8001_sas.c | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 6ae059ebb4bb..7dbbf8bb4d88 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c | |||
@@ -669,30 +669,6 @@ int pm8001_dev_found(struct domain_device *dev) | |||
669 | return pm8001_dev_found_notify(dev); | 669 | return pm8001_dev_found_notify(dev); |
670 | } | 670 | } |
671 | 671 | ||
672 | /** | ||
673 | * pm8001_alloc_task - allocate a task structure for TMF | ||
674 | */ | ||
675 | static struct sas_task *pm8001_alloc_task(void) | ||
676 | { | ||
677 | struct sas_task *task = kzalloc(sizeof(*task), GFP_KERNEL); | ||
678 | if (task) { | ||
679 | INIT_LIST_HEAD(&task->list); | ||
680 | spin_lock_init(&task->task_state_lock); | ||
681 | task->task_state_flags = SAS_TASK_STATE_PENDING; | ||
682 | init_timer(&task->timer); | ||
683 | init_completion(&task->completion); | ||
684 | } | ||
685 | return task; | ||
686 | } | ||
687 | |||
688 | static void pm8001_free_task(struct sas_task *task) | ||
689 | { | ||
690 | if (task) { | ||
691 | BUG_ON(!list_empty(&task->list)); | ||
692 | kfree(task); | ||
693 | } | ||
694 | } | ||
695 | |||
696 | static void pm8001_task_done(struct sas_task *task) | 672 | static void pm8001_task_done(struct sas_task *task) |
697 | { | 673 | { |
698 | if (!del_timer(&task->timer)) | 674 | if (!del_timer(&task->timer)) |
@@ -728,7 +704,7 @@ static int pm8001_exec_internal_tmf_task(struct domain_device *dev, | |||
728 | struct pm8001_hba_info *pm8001_ha = pm8001_find_ha_by_dev(dev); | 704 | struct pm8001_hba_info *pm8001_ha = pm8001_find_ha_by_dev(dev); |
729 | 705 | ||
730 | for (retry = 0; retry < 3; retry++) { | 706 | for (retry = 0; retry < 3; retry++) { |
731 | task = pm8001_alloc_task(); | 707 | task = sas_alloc_task(GFP_KERNEL); |
732 | if (!task) | 708 | if (!task) |
733 | return -ENOMEM; | 709 | return -ENOMEM; |
734 | 710 | ||
@@ -789,14 +765,13 @@ static int pm8001_exec_internal_tmf_task(struct domain_device *dev, | |||
789 | SAS_ADDR(dev->sas_addr), | 765 | SAS_ADDR(dev->sas_addr), |
790 | task->task_status.resp, | 766 | task->task_status.resp, |
791 | task->task_status.stat)); | 767 | task->task_status.stat)); |
792 | pm8001_free_task(task); | 768 | sas_free_task(task); |
793 | task = NULL; | 769 | task = NULL; |
794 | } | 770 | } |
795 | } | 771 | } |
796 | ex_err: | 772 | ex_err: |
797 | BUG_ON(retry == 3 && task != NULL); | 773 | BUG_ON(retry == 3 && task != NULL); |
798 | if (task != NULL) | 774 | sas_free_task(task); |
799 | pm8001_free_task(task); | ||
800 | return res; | 775 | return res; |
801 | } | 776 | } |
802 | 777 | ||
@@ -811,7 +786,7 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha, | |||
811 | struct sas_task *task = NULL; | 786 | struct sas_task *task = NULL; |
812 | 787 | ||
813 | for (retry = 0; retry < 3; retry++) { | 788 | for (retry = 0; retry < 3; retry++) { |
814 | task = pm8001_alloc_task(); | 789 | task = sas_alloc_task(GFP_KERNEL); |
815 | if (!task) | 790 | if (!task) |
816 | return -ENOMEM; | 791 | return -ENOMEM; |
817 | 792 | ||
@@ -864,14 +839,13 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha, | |||
864 | SAS_ADDR(dev->sas_addr), | 839 | SAS_ADDR(dev->sas_addr), |
865 | task->task_status.resp, | 840 | task->task_status.resp, |
866 | task->task_status.stat)); | 841 | task->task_status.stat)); |
867 | pm8001_free_task(task); | 842 | sas_free_task(task); |
868 | task = NULL; | 843 | task = NULL; |
869 | } | 844 | } |
870 | } | 845 | } |
871 | ex_err: | 846 | ex_err: |
872 | BUG_ON(retry == 3 && task != NULL); | 847 | BUG_ON(retry == 3 && task != NULL); |
873 | if (task != NULL) | 848 | sas_free_task(task); |
874 | pm8001_free_task(task); | ||
875 | return res; | 849 | return res; |
876 | } | 850 | } |
877 | 851 | ||