2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-22 12:14:01 +08:00

[SCSI] qla2xxx: Refactor call to qla2xxx_read_sfp for thermal temperature.

Eliminate duplicate code by refactoring the calls to qla2xxx_read_sfp()
in qla2x00_get_thermal_temp(). This keeps the parameter values separate
from the mailbox register mechanics. This also allows qla2xxx_read_sfp()
to be the sole "spec" for READ SFP semantics.

Signed-off_by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Madhuranath Iyengar <Madhu.Iyengar@qlogic.com>
Signed-off-by: James Bottomley <jbottomley@parallels.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
This commit is contained in:
Joe Carnuccio 2011-05-10 11:30:16 -07:00 committed by James Bottomley
parent 6766df9e8a
commit 6ad11eaa8a

View File

@ -4142,63 +4142,32 @@ int
qla2x00_get_thermal_temp(scsi_qla_host_t *vha, uint16_t *temp, uint16_t *frac) qla2x00_get_thermal_temp(scsi_qla_host_t *vha, uint16_t *temp, uint16_t *frac)
{ {
int rval; int rval;
mbx_cmd_t mc; uint8_t byte;
mbx_cmd_t *mcp = &mc;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
DEBUG11(printk(KERN_INFO "%s(%ld): entered.\n", __func__, ha->host_no)); DEBUG11(printk(KERN_INFO "%s(%ld): entered.\n", __func__, vha->host_no));
/* High bits. */ /* Integer part */
mcp->mb[0] = MBC_READ_SFP; rval = qla2x00_read_sfp(vha, 0, &byte, 0x98, 0x01, 1, BIT_13|BIT_0);
mcp->mb[1] = 0x98;
mcp->mb[2] = 0;
mcp->mb[3] = 0;
mcp->mb[6] = 0;
mcp->mb[7] = 0;
mcp->mb[8] = 1;
mcp->mb[9] = 0x01;
mcp->mb[10] = BIT_13|BIT_0;
mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
mcp->in_mb = MBX_1|MBX_0;
mcp->tov = MBX_TOV_SECONDS;
mcp->flags = 0;
rval = qla2x00_mailbox_command(vha, mcp);
if (rval != QLA_SUCCESS) { if (rval != QLA_SUCCESS) {
DEBUG2_3_11(printk(KERN_WARNING DEBUG2_3_11(printk(KERN_WARNING
"%s(%ld): failed=%x (%x).\n", __func__, "%s(%ld): failed=%x.\n", __func__, vha->host_no, rval));
vha->host_no, rval, mcp->mb[0]));
ha->flags.thermal_supported = 0; ha->flags.thermal_supported = 0;
goto fail; goto fail;
} }
*temp = mcp->mb[1] & 0xFF; *temp = byte;
/* Low bits. */ /* Fraction part */
mcp->mb[0] = MBC_READ_SFP; rval = qla2x00_read_sfp(vha, 0, &byte, 0x98, 0x10, 1, BIT_13|BIT_0);
mcp->mb[1] = 0x98;
mcp->mb[2] = 0;
mcp->mb[3] = 0;
mcp->mb[6] = 0;
mcp->mb[7] = 0;
mcp->mb[8] = 1;
mcp->mb[9] = 0x10;
mcp->mb[10] = BIT_13|BIT_0;
mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
mcp->in_mb = MBX_1|MBX_0;
mcp->tov = MBX_TOV_SECONDS;
mcp->flags = 0;
rval = qla2x00_mailbox_command(vha, mcp);
if (rval != QLA_SUCCESS) { if (rval != QLA_SUCCESS) {
DEBUG2_3_11(printk(KERN_WARNING DEBUG2_3_11(printk(KERN_WARNING
"%s(%ld): failed=%x (%x).\n", __func__, "%s(%ld): failed=%x.\n", __func__, vha->host_no, rval));
vha->host_no, rval, mcp->mb[0]));
ha->flags.thermal_supported = 0; ha->flags.thermal_supported = 0;
goto fail; goto fail;
} }
*frac = ((mcp->mb[1] & 0xFF) >> 6) * 25; *frac = (byte >> 6) * 25;
if (rval == QLA_SUCCESS) DEBUG11(printk(KERN_INFO "%s(%ld): done.\n", __func__, vha->host_no));
DEBUG11(printk(KERN_INFO
"%s(%ld): done.\n", __func__, ha->host_no));
fail: fail:
return rval; return rval;
} }