aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bnx2fc/bnx2fc_io.c
diff options
context:
space:
mode:
authorBhanu Prakash Gollapudi <bprakash@broadcom.com>2012-06-07 05:19:36 -0400
committerJames Bottomley <JBottomley@Parallels.com>2012-07-20 03:58:24 -0400
commitd71fb3bdeee80565eda4d3453ff6d9f6f8176745 (patch)
tree2b2e1c6a92a201348d3d0862271f864d60841ef7 /drivers/scsi/bnx2fc/bnx2fc_io.c
parent5c17ae217ad13463f821c3bab774335777da9c33 (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/scsi/bnx2fc/bnx2fc_io.c')
-rw-r--r--drivers/scsi/bnx2fc/bnx2fc_io.c21
1 files changed, 7 insertions, 14 deletions
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)
1476static void bnx2fc_tgt_reset_cmpl(struct bnx2fc_cmd *io_req) 1472static 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)) {