aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Henzl <thenzl@redhat.com>2014-07-09 07:50:40 -0400
committerChristoph Hellwig <hch@lst.de>2014-07-25 17:17:04 -0400
commitef300544723b3be25c877e520b23831eaf7830e8 (patch)
treeef65e6b1ffd31fd94734f3ae60c1be4a940d252f
parent9f17609968af25a4082d4329abbc6e4f52eda7cd (diff)
pm8001: clean bitmap management functions
In the driver two different functions are used to free the same resource, this patch makes the code easier to read. In addittion to that, some minor optimisations were made too. Signed-off-by: Tomas Henzl <thenzl@redhat.com> Acked-by: Suresh Thiagarajan <Suresh.Thiagarajan@pmcs.com> Acked-by: Jack Wang <xjtuwjp@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--drivers/scsi/pm8001/pm8001_hwi.c10
-rw-r--r--drivers/scsi/pm8001/pm8001_sas.c31
-rw-r--r--drivers/scsi/pm8001/pm8001_sas.h1
3 files changed, 12 insertions, 30 deletions
diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index a97be015e52e..92943797d862 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -3100,7 +3100,7 @@ void pm8001_mpi_set_dev_state_resp(struct pm8001_hba_info *pm8001_ha,
3100 complete(pm8001_dev->setds_completion); 3100 complete(pm8001_dev->setds_completion);
3101 ccb->task = NULL; 3101 ccb->task = NULL;
3102 ccb->ccb_tag = 0xFFFFFFFF; 3102 ccb->ccb_tag = 0xFFFFFFFF;
3103 pm8001_ccb_free(pm8001_ha, tag); 3103 pm8001_tag_free(pm8001_ha, tag);
3104} 3104}
3105 3105
3106void pm8001_mpi_set_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) 3106void pm8001_mpi_set_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)
@@ -3119,7 +3119,7 @@ void pm8001_mpi_set_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)
3119 } 3119 }
3120 ccb->task = NULL; 3120 ccb->task = NULL;
3121 ccb->ccb_tag = 0xFFFFFFFF; 3121 ccb->ccb_tag = 0xFFFFFFFF;
3122 pm8001_ccb_free(pm8001_ha, tag); 3122 pm8001_tag_free(pm8001_ha, tag);
3123} 3123}
3124 3124
3125void 3125void
@@ -3181,7 +3181,7 @@ pm8001_mpi_get_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)
3181 complete(pm8001_ha->nvmd_completion); 3181 complete(pm8001_ha->nvmd_completion);
3182 ccb->task = NULL; 3182 ccb->task = NULL;
3183 ccb->ccb_tag = 0xFFFFFFFF; 3183 ccb->ccb_tag = 0xFFFFFFFF;
3184 pm8001_ccb_free(pm8001_ha, tag); 3184 pm8001_tag_free(pm8001_ha, tag);
3185} 3185}
3186 3186
3187int pm8001_mpi_local_phy_ctl(struct pm8001_hba_info *pm8001_ha, void *piomb) 3187int pm8001_mpi_local_phy_ctl(struct pm8001_hba_info *pm8001_ha, void *piomb)
@@ -3588,7 +3588,7 @@ int pm8001_mpi_reg_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)
3588 complete(pm8001_dev->dcompletion); 3588 complete(pm8001_dev->dcompletion);
3589 ccb->task = NULL; 3589 ccb->task = NULL;
3590 ccb->ccb_tag = 0xFFFFFFFF; 3590 ccb->ccb_tag = 0xFFFFFFFF;
3591 pm8001_ccb_free(pm8001_ha, htag); 3591 pm8001_tag_free(pm8001_ha, htag);
3592 return 0; 3592 return 0;
3593} 3593}
3594 3594
@@ -3672,7 +3672,7 @@ int pm8001_mpi_fw_flash_update_resp(struct pm8001_hba_info *pm8001_ha,
3672 complete(pm8001_ha->nvmd_completion); 3672 complete(pm8001_ha->nvmd_completion);
3673 ccb->task = NULL; 3673 ccb->task = NULL;
3674 ccb->ccb_tag = 0xFFFFFFFF; 3674 ccb->ccb_tag = 0xFFFFFFFF;
3675 pm8001_ccb_free(pm8001_ha, tag); 3675 pm8001_tag_free(pm8001_ha, tag);
3676 return 0; 3676 return 0;
3677} 3677}
3678 3678
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index 8a44bc92bc78..be55859042cd 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -58,25 +58,14 @@ static int pm8001_find_tag(struct sas_task *task, u32 *tag)
58} 58}
59 59
60/** 60/**
61 * pm8001_tag_clear - clear the tags bitmap 61 * pm8001_tag_free - free the no more needed tag
62 * @pm8001_ha: our hba struct 62 * @pm8001_ha: our hba struct
63 * @tag: the found tag associated with the task 63 * @tag: the found tag associated with the task
64 */ 64 */
65static void pm8001_tag_clear(struct pm8001_hba_info *pm8001_ha, u32 tag)
66{
67 void *bitmap = pm8001_ha->tags;
68 clear_bit(tag, bitmap);
69}
70
71void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag) 65void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag)
72{ 66{
73 pm8001_tag_clear(pm8001_ha, tag);
74}
75
76static void pm8001_tag_set(struct pm8001_hba_info *pm8001_ha, u32 tag)
77{
78 void *bitmap = pm8001_ha->tags; 67 void *bitmap = pm8001_ha->tags;
79 set_bit(tag, bitmap); 68 clear_bit(tag, bitmap);
80} 69}
81 70
82/** 71/**
@@ -86,14 +75,13 @@ static void pm8001_tag_set(struct pm8001_hba_info *pm8001_ha, u32 tag)
86 */ 75 */
87inline int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out) 76inline int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out)
88{ 77{
89 unsigned int index, tag; 78 unsigned int tag;
90 void *bitmap = pm8001_ha->tags; 79 void *bitmap = pm8001_ha->tags;
91 80
92 index = find_first_zero_bit(bitmap, pm8001_ha->tags_num); 81 tag = find_first_zero_bit(bitmap, pm8001_ha->tags_num);
93 tag = index;
94 if (tag >= pm8001_ha->tags_num) 82 if (tag >= pm8001_ha->tags_num)
95 return -SAS_QUEUE_FULL; 83 return -SAS_QUEUE_FULL;
96 pm8001_tag_set(pm8001_ha, tag); 84 set_bit(tag, bitmap);
97 *tag_out = tag; 85 *tag_out = tag;
98 return 0; 86 return 0;
99} 87}
@@ -102,7 +90,7 @@ void pm8001_tag_init(struct pm8001_hba_info *pm8001_ha)
102{ 90{
103 int i; 91 int i;
104 for (i = 0; i < pm8001_ha->tags_num; ++i) 92 for (i = 0; i < pm8001_ha->tags_num; ++i)
105 pm8001_tag_clear(pm8001_ha, i); 93 pm8001_tag_free(pm8001_ha, i);
106} 94}
107 95
108 /** 96 /**
@@ -501,11 +489,6 @@ int pm8001_queue_command(struct sas_task *task, const int num,
501 return pm8001_task_exec(task, num, gfp_flags, 0, NULL); 489 return pm8001_task_exec(task, num, gfp_flags, 0, NULL);
502} 490}
503 491
504void pm8001_ccb_free(struct pm8001_hba_info *pm8001_ha, u32 ccb_idx)
505{
506 pm8001_tag_clear(pm8001_ha, ccb_idx);
507}
508
509/** 492/**
510 * pm8001_ccb_task_free - free the sg for ssp and smp command, free the ccb. 493 * pm8001_ccb_task_free - free the sg for ssp and smp command, free the ccb.
511 * @pm8001_ha: our hba card information 494 * @pm8001_ha: our hba card information
@@ -542,7 +525,7 @@ void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha,
542 ccb->task = NULL; 525 ccb->task = NULL;
543 ccb->ccb_tag = 0xFFFFFFFF; 526 ccb->ccb_tag = 0xFFFFFFFF;
544 ccb->open_retry = 0; 527 ccb->open_retry = 0;
545 pm8001_ccb_free(pm8001_ha, ccb_idx); 528 pm8001_tag_free(pm8001_ha, ccb_idx);
546} 529}
547 530
548 /** 531 /**
diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h
index 1ee06f21803b..14106adec009 100644
--- a/drivers/scsi/pm8001/pm8001_sas.h
+++ b/drivers/scsi/pm8001/pm8001_sas.h
@@ -616,7 +616,6 @@ extern struct workqueue_struct *pm8001_wq;
616int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out); 616int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out);
617void pm8001_tag_init(struct pm8001_hba_info *pm8001_ha); 617void pm8001_tag_init(struct pm8001_hba_info *pm8001_ha);
618u32 pm8001_get_ncq_tag(struct sas_task *task, u32 *tag); 618u32 pm8001_get_ncq_tag(struct sas_task *task, u32 *tag);
619void pm8001_ccb_free(struct pm8001_hba_info *pm8001_ha, u32 ccb_idx);
620void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha, 619void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha,
621 struct sas_task *task, struct pm8001_ccb_info *ccb, u32 ccb_idx); 620 struct sas_task *task, struct pm8001_ccb_info *ccb, u32 ccb_idx);
622int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, 621int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,