diff options
author | Bhanu Prakash Gollapudi <bprakash@broadcom.com> | 2012-06-07 05:19:36 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-07-20 03:58:24 -0400 |
commit | d71fb3bdeee80565eda4d3453ff6d9f6f8176745 (patch) | |
tree | 2b2e1c6a92a201348d3d0862271f864d60841ef7 /drivers | |
parent | 5c17ae217ad13463f821c3bab774335777da9c33 (diff) |
[SCSI] bnx2fc: use list_entry instead of explicit cast
Use list_for_each_entry_safe() instead of explicit cast to avoid relying on
struct layout
Signed-off-by: Bhanu Prakash Gollapudi <bprakash@broadcom.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 5 | ||||
-rw-r--r-- | drivers/scsi/bnx2fc/bnx2fc_io.c | 21 | ||||
-rw-r--r-- | drivers/scsi/bnx2fc/bnx2fc_tgt.c | 15 |
3 files changed, 13 insertions, 28 deletions
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index 17ab9f7d2e26..0c9caa6747ae 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c | |||
@@ -2151,13 +2151,10 @@ mod_err: | |||
2151 | **/ | 2151 | **/ |
2152 | static struct bnx2fc_hba *bnx2fc_find_hba_for_cnic(struct cnic_dev *cnic) | 2152 | static struct bnx2fc_hba *bnx2fc_find_hba_for_cnic(struct cnic_dev *cnic) |
2153 | { | 2153 | { |
2154 | struct list_head *list; | ||
2155 | struct list_head *temp; | ||
2156 | struct bnx2fc_hba *hba; | 2154 | struct bnx2fc_hba *hba; |
2157 | 2155 | ||
2158 | /* Called with bnx2fc_dev_lock held */ | 2156 | /* Called with bnx2fc_dev_lock held */ |
2159 | list_for_each_safe(list, temp, &adapter_list) { | 2157 | list_for_each_entry(hba, &adapter_list, list) { |
2160 | hba = (struct bnx2fc_hba *)list; | ||
2161 | if (hba->cnic == cnic) | 2158 | if (hba->cnic == cnic) |
2162 | return hba; | 2159 | return hba; |
2163 | } | 2160 | } |
diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c index a4fdc3d47f44..73f231ccd45b 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c | |||
@@ -405,11 +405,10 @@ free_cmd_pool: | |||
405 | goto free_cmgr; | 405 | goto free_cmgr; |
406 | 406 | ||
407 | for (i = 0; i < num_possible_cpus() + 1; i++) { | 407 | for (i = 0; i < num_possible_cpus() + 1; i++) { |
408 | struct list_head *list; | 408 | struct bnx2fc_cmd *tmp, *io_req; |
409 | struct list_head *tmp; | ||
410 | 409 | ||
411 | list_for_each_safe(list, tmp, &cmgr->free_list[i]) { | 410 | list_for_each_entry_safe(io_req, tmp, |
412 | struct bnx2fc_cmd *io_req = (struct bnx2fc_cmd *)list; | 411 | &cmgr->free_list[i], link) { |
413 | list_del(&io_req->link); | 412 | list_del(&io_req->link); |
414 | kfree(io_req); | 413 | kfree(io_req); |
415 | } | 414 | } |
@@ -1436,9 +1435,7 @@ static void bnx2fc_lun_reset_cmpl(struct bnx2fc_cmd *io_req) | |||
1436 | { | 1435 | { |
1437 | struct scsi_cmnd *sc_cmd = io_req->sc_cmd; | 1436 | struct scsi_cmnd *sc_cmd = io_req->sc_cmd; |
1438 | struct bnx2fc_rport *tgt = io_req->tgt; | 1437 | struct bnx2fc_rport *tgt = io_req->tgt; |
1439 | struct list_head *list; | 1438 | struct bnx2fc_cmd *cmd, *tmp; |
1440 | struct list_head *tmp; | ||
1441 | struct bnx2fc_cmd *cmd; | ||
1442 | int tm_lun = sc_cmd->device->lun; | 1439 | int tm_lun = sc_cmd->device->lun; |
1443 | int rc = 0; | 1440 | int rc = 0; |
1444 | int lun; | 1441 | int lun; |
@@ -1449,9 +1446,8 @@ static void bnx2fc_lun_reset_cmpl(struct bnx2fc_cmd *io_req) | |||
1449 | * Walk thru the active_ios queue and ABORT the IO | 1446 | * Walk thru the active_ios queue and ABORT the IO |
1450 | * that matches with the LUN that was reset | 1447 | * that matches with the LUN that was reset |
1451 | */ | 1448 | */ |
1452 | list_for_each_safe(list, tmp, &tgt->active_cmd_queue) { | 1449 | list_for_each_entry_safe(cmd, tmp, &tgt->active_cmd_queue, link) { |
1453 | BNX2FC_TGT_DBG(tgt, "LUN RST cmpl: scan for pending IOs\n"); | 1450 | BNX2FC_TGT_DBG(tgt, "LUN RST cmpl: scan for pending IOs\n"); |
1454 | cmd = (struct bnx2fc_cmd *)list; | ||
1455 | lun = cmd->sc_cmd->device->lun; | 1451 | lun = cmd->sc_cmd->device->lun; |
1456 | if (lun == tm_lun) { | 1452 | if (lun == tm_lun) { |
1457 | /* Initiate ABTS on this cmd */ | 1453 | /* Initiate ABTS on this cmd */ |
@@ -1476,9 +1472,7 @@ static void bnx2fc_lun_reset_cmpl(struct bnx2fc_cmd *io_req) | |||
1476 | static void bnx2fc_tgt_reset_cmpl(struct bnx2fc_cmd *io_req) | 1472 | static void bnx2fc_tgt_reset_cmpl(struct bnx2fc_cmd *io_req) |
1477 | { | 1473 | { |
1478 | struct bnx2fc_rport *tgt = io_req->tgt; | 1474 | struct bnx2fc_rport *tgt = io_req->tgt; |
1479 | struct list_head *list; | 1475 | struct bnx2fc_cmd *cmd, *tmp; |
1480 | struct list_head *tmp; | ||
1481 | struct bnx2fc_cmd *cmd; | ||
1482 | int rc = 0; | 1476 | int rc = 0; |
1483 | 1477 | ||
1484 | /* called with tgt_lock held */ | 1478 | /* called with tgt_lock held */ |
@@ -1487,9 +1481,8 @@ static void bnx2fc_tgt_reset_cmpl(struct bnx2fc_cmd *io_req) | |||
1487 | * Walk thru the active_ios queue and ABORT the IO | 1481 | * Walk thru the active_ios queue and ABORT the IO |
1488 | * that matches with the LUN that was reset | 1482 | * that matches with the LUN that was reset |
1489 | */ | 1483 | */ |
1490 | list_for_each_safe(list, tmp, &tgt->active_cmd_queue) { | 1484 | list_for_each_entry_safe(cmd, tmp, &tgt->active_cmd_queue, link) { |
1491 | BNX2FC_TGT_DBG(tgt, "TGT RST cmpl: scan for pending IOs\n"); | 1485 | BNX2FC_TGT_DBG(tgt, "TGT RST cmpl: scan for pending IOs\n"); |
1492 | cmd = (struct bnx2fc_cmd *)list; | ||
1493 | /* Initiate ABTS */ | 1486 | /* Initiate ABTS */ |
1494 | if (!test_and_set_bit(BNX2FC_FLAG_ISSUE_ABTS, | 1487 | if (!test_and_set_bit(BNX2FC_FLAG_ISSUE_ABTS, |
1495 | &cmd->req_flags)) { | 1488 | &cmd->req_flags)) { |
diff --git a/drivers/scsi/bnx2fc/bnx2fc_tgt.c b/drivers/scsi/bnx2fc/bnx2fc_tgt.c index 85ffdeaa3b85..b9d0d9cb17f9 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_tgt.c +++ b/drivers/scsi/bnx2fc/bnx2fc_tgt.c | |||
@@ -150,8 +150,7 @@ tgt_init_err: | |||
150 | void bnx2fc_flush_active_ios(struct bnx2fc_rport *tgt) | 150 | void bnx2fc_flush_active_ios(struct bnx2fc_rport *tgt) |
151 | { | 151 | { |
152 | struct bnx2fc_cmd *io_req; | 152 | struct bnx2fc_cmd *io_req; |
153 | struct list_head *list; | 153 | struct bnx2fc_cmd *tmp; |
154 | struct list_head *tmp; | ||
155 | int rc; | 154 | int rc; |
156 | int i = 0; | 155 | int i = 0; |
157 | BNX2FC_TGT_DBG(tgt, "Entered flush_active_ios - %d\n", | 156 | BNX2FC_TGT_DBG(tgt, "Entered flush_active_ios - %d\n", |
@@ -160,9 +159,8 @@ void bnx2fc_flush_active_ios(struct bnx2fc_rport *tgt) | |||
160 | spin_lock_bh(&tgt->tgt_lock); | 159 | spin_lock_bh(&tgt->tgt_lock); |
161 | tgt->flush_in_prog = 1; | 160 | tgt->flush_in_prog = 1; |
162 | 161 | ||
163 | list_for_each_safe(list, tmp, &tgt->active_cmd_queue) { | 162 | list_for_each_entry_safe(io_req, tmp, &tgt->active_cmd_queue, link) { |
164 | i++; | 163 | i++; |
165 | io_req = (struct bnx2fc_cmd *)list; | ||
166 | list_del_init(&io_req->link); | 164 | list_del_init(&io_req->link); |
167 | io_req->on_active_queue = 0; | 165 | io_req->on_active_queue = 0; |
168 | BNX2FC_IO_DBG(io_req, "cmd_queue cleanup\n"); | 166 | BNX2FC_IO_DBG(io_req, "cmd_queue cleanup\n"); |
@@ -191,9 +189,8 @@ void bnx2fc_flush_active_ios(struct bnx2fc_rport *tgt) | |||
191 | } | 189 | } |
192 | } | 190 | } |
193 | 191 | ||
194 | list_for_each_safe(list, tmp, &tgt->active_tm_queue) { | 192 | list_for_each_entry_safe(io_req, tmp, &tgt->active_tm_queue, link) { |
195 | i++; | 193 | i++; |
196 | io_req = (struct bnx2fc_cmd *)list; | ||
197 | list_del_init(&io_req->link); | 194 | list_del_init(&io_req->link); |
198 | io_req->on_tmf_queue = 0; | 195 | io_req->on_tmf_queue = 0; |
199 | BNX2FC_IO_DBG(io_req, "tm_queue cleanup\n"); | 196 | BNX2FC_IO_DBG(io_req, "tm_queue cleanup\n"); |
@@ -201,9 +198,8 @@ void bnx2fc_flush_active_ios(struct bnx2fc_rport *tgt) | |||
201 | complete(&io_req->tm_done); | 198 | complete(&io_req->tm_done); |
202 | } | 199 | } |
203 | 200 | ||
204 | list_for_each_safe(list, tmp, &tgt->els_queue) { | 201 | list_for_each_entry_safe(io_req, tmp, &tgt->els_queue, link) { |
205 | i++; | 202 | i++; |
206 | io_req = (struct bnx2fc_cmd *)list; | ||
207 | list_del_init(&io_req->link); | 203 | list_del_init(&io_req->link); |
208 | io_req->on_active_queue = 0; | 204 | io_req->on_active_queue = 0; |
209 | 205 | ||
@@ -227,9 +223,8 @@ void bnx2fc_flush_active_ios(struct bnx2fc_rport *tgt) | |||
227 | } | 223 | } |
228 | } | 224 | } |
229 | 225 | ||
230 | list_for_each_safe(list, tmp, &tgt->io_retire_queue) { | 226 | list_for_each_entry_safe(io_req, tmp, &tgt->io_retire_queue, link) { |
231 | i++; | 227 | i++; |
232 | io_req = (struct bnx2fc_cmd *)list; | ||
233 | list_del_init(&io_req->link); | 228 | list_del_init(&io_req->link); |
234 | 229 | ||
235 | BNX2FC_IO_DBG(io_req, "retire_queue flush\n"); | 230 | BNX2FC_IO_DBG(io_req, "retire_queue flush\n"); |