Commit 9c17c3b1 authored by Bart Van Assche's avatar Bart Van Assche Committed by Martin K. Petersen

scsi: qla2xxx: Reduce the number of casts in GID list code

This patch makes the code that parses the GID list easier to read without
changing the behavior of the code.

Cc: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Tested-by: default avatarHimanshu Madhani <hmadhani@marvell.com>
Reviewed-by: default avatarHimanshu Madhani <hmadhani@marvell.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 57bf595a
...@@ -57,10 +57,9 @@ qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused) ...@@ -57,10 +57,9 @@ qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused)
{ {
scsi_qla_host_t *vha = s->private; scsi_qla_host_t *vha = s->private;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
struct gid_list_info *gid_list; struct gid_list_info *gid_list, *gid;
dma_addr_t gid_list_dma; dma_addr_t gid_list_dma;
fc_port_t fc_port; fc_port_t fc_port;
char *id_iter;
int rc, i; int rc, i;
uint16_t entries, loop_id; uint16_t entries, loop_id;
struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; struct qla_tgt *tgt = vha->vha_tgt.qla_tgt;
...@@ -82,13 +81,11 @@ qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused) ...@@ -82,13 +81,11 @@ qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused)
if (rc != QLA_SUCCESS) if (rc != QLA_SUCCESS)
goto out_free_id_list; goto out_free_id_list;
id_iter = (char *)gid_list; gid = gid_list;
seq_puts(s, "Port Name Port ID Loop ID\n"); seq_puts(s, "Port Name Port ID Loop ID\n");
for (i = 0; i < entries; i++) { for (i = 0; i < entries; i++) {
struct gid_list_info *gid =
(struct gid_list_info *)id_iter;
loop_id = le16_to_cpu(gid->loop_id); loop_id = le16_to_cpu(gid->loop_id);
memset(&fc_port, 0, sizeof(fc_port_t)); memset(&fc_port, 0, sizeof(fc_port_t));
...@@ -99,7 +96,7 @@ qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused) ...@@ -99,7 +96,7 @@ qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused)
fc_port.port_name, fc_port.d_id.b.domain, fc_port.port_name, fc_port.d_id.b.domain,
fc_port.d_id.b.area, fc_port.d_id.b.al_pa, fc_port.d_id.b.area, fc_port.d_id.b.al_pa,
fc_port.loop_id); fc_port.loop_id);
id_iter += ha->gid_list_info_size; gid = (void *)gid + ha->gid_list_info_size;
} }
out_free_id_list: out_free_id_list:
dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha),
......
...@@ -5086,7 +5086,7 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha) ...@@ -5086,7 +5086,7 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
uint16_t index; uint16_t index;
uint16_t entries; uint16_t entries;
char *id_iter; struct gid_list_info *gid;
uint16_t loop_id; uint16_t loop_id;
uint8_t domain, area, al_pa; uint8_t domain, area, al_pa;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
...@@ -5161,18 +5161,16 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha) ...@@ -5161,18 +5161,16 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
new_fcport->flags &= ~FCF_FABRIC_DEVICE; new_fcport->flags &= ~FCF_FABRIC_DEVICE;
/* Add devices to port list. */ /* Add devices to port list. */
id_iter = (char *)ha->gid_list; gid = ha->gid_list;
for (index = 0; index < entries; index++) { for (index = 0; index < entries; index++) {
domain = ((struct gid_list_info *)id_iter)->domain; domain = gid->domain;
area = ((struct gid_list_info *)id_iter)->area; area = gid->area;
al_pa = ((struct gid_list_info *)id_iter)->al_pa; al_pa = gid->al_pa;
if (IS_QLA2100(ha) || IS_QLA2200(ha)) if (IS_QLA2100(ha) || IS_QLA2200(ha))
loop_id = (uint16_t) loop_id = gid->loop_id_2100;
((struct gid_list_info *)id_iter)->loop_id_2100;
else else
loop_id = le16_to_cpu( loop_id = le16_to_cpu(gid->loop_id);
((struct gid_list_info *)id_iter)->loop_id); gid = (void *)gid + ha->gid_list_info_size;
id_iter += ha->gid_list_info_size;
/* Bypass reserved domain fields. */ /* Bypass reserved domain fields. */
if ((domain & 0xf0) == 0xf0) if ((domain & 0xf0) == 0xf0)
......
...@@ -1290,8 +1290,7 @@ static int qla24xx_get_loop_id(struct scsi_qla_host *vha, const uint8_t *s_id, ...@@ -1290,8 +1290,7 @@ static int qla24xx_get_loop_id(struct scsi_qla_host *vha, const uint8_t *s_id,
{ {
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
dma_addr_t gid_list_dma; dma_addr_t gid_list_dma;
struct gid_list_info *gid_list; struct gid_list_info *gid_list, *gid;
char *id_iter;
int res, rc, i; int res, rc, i;
uint16_t entries; uint16_t entries;
...@@ -1314,11 +1313,9 @@ static int qla24xx_get_loop_id(struct scsi_qla_host *vha, const uint8_t *s_id, ...@@ -1314,11 +1313,9 @@ static int qla24xx_get_loop_id(struct scsi_qla_host *vha, const uint8_t *s_id,
goto out_free_id_list; goto out_free_id_list;
} }
id_iter = (char *)gid_list; gid = gid_list;
res = -ENOENT; res = -ENOENT;
for (i = 0; i < entries; i++) { for (i = 0; i < entries; i++) {
struct gid_list_info *gid = (struct gid_list_info *)id_iter;
if ((gid->al_pa == s_id[2]) && if ((gid->al_pa == s_id[2]) &&
(gid->area == s_id[1]) && (gid->area == s_id[1]) &&
(gid->domain == s_id[0])) { (gid->domain == s_id[0])) {
...@@ -1326,7 +1323,7 @@ static int qla24xx_get_loop_id(struct scsi_qla_host *vha, const uint8_t *s_id, ...@@ -1326,7 +1323,7 @@ static int qla24xx_get_loop_id(struct scsi_qla_host *vha, const uint8_t *s_id,
res = 0; res = 0;
break; break;
} }
id_iter += ha->gid_list_info_size; gid = (void *)gid + ha->gid_list_info_size;
} }
out_free_id_list: out_free_id_list:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment