Skip to content

Commit

Permalink
[SCSI] qla2xxx: Return sysfs error codes appropriate to conditions.
Browse files Browse the repository at this point in the history
Return sysfs error codes that match the conditions encountered.
This prevents sysfs from retrying a request which is conditioned
to fail under the current circumstance.

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
  • Loading branch information
Joe Carnuccio authored and James Bottomley committed Aug 29, 2011
1 parent 697a4bc commit b668ae3
Showing 1 changed file with 29 additions and 30 deletions.
59 changes: 29 additions & 30 deletions drivers/scsi/qla2xxx/qla_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ qla2x00_sysfs_write_fw_dump(struct file *filp, struct kobject *kobj,
set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
break;
}
return (count);
return -EINVAL;
}

static struct bin_attribute sysfs_fw_dump_attr = {
Expand Down Expand Up @@ -151,7 +151,7 @@ qla2x00_sysfs_write_nvram(struct file *filp, struct kobject *kobj,

if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size ||
!ha->isp_ops->write_nvram)
return 0;
return -EINVAL;

/* Checksum NVRAM. */
if (IS_FWI2_CAPABLE(ha)) {
Expand Down Expand Up @@ -194,7 +194,7 @@ qla2x00_sysfs_write_nvram(struct file *filp, struct kobject *kobj,
qla2xxx_wake_dpc(vha);
qla2x00_wait_for_chip_reset(vha);

return (count);
return count;
}

static struct bin_attribute sysfs_nvram_attr = {
Expand Down Expand Up @@ -268,10 +268,10 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
int val, valid;

if (off)
return 0;
return -EINVAL;

if (unlikely(pci_channel_offline(ha->pdev)))
return 0;
return -EAGAIN;

if (sscanf(buf, "%d:%x:%x", &val, &start, &size) < 1)
return -EINVAL;
Expand All @@ -282,7 +282,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
case 0:
if (ha->optrom_state != QLA_SREADING &&
ha->optrom_state != QLA_SWRITING)
break;
return -EINVAL;

ha->optrom_state = QLA_SWAITING;

Expand All @@ -295,7 +295,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
break;
case 1:
if (ha->optrom_state != QLA_SWAITING)
break;
return -EINVAL;

ha->optrom_region_start = start;
ha->optrom_region_size = start + size > ha->optrom_size ?
Expand All @@ -309,7 +309,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
"(%x).\n", ha->optrom_region_size);

ha->optrom_state = QLA_SWAITING;
return count;
return -ENOMEM;
}

if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
Expand All @@ -328,7 +328,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
break;
case 2:
if (ha->optrom_state != QLA_SWAITING)
break;
return -EINVAL;

/*
* We need to be more restrictive on which FLASH regions are
Expand Down Expand Up @@ -376,7 +376,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
"(%x)\n", ha->optrom_region_size);

ha->optrom_state = QLA_SWAITING;
return count;
return -ENOMEM;
}

ql_dbg(ql_dbg_user, vha, 0x7067,
Expand All @@ -387,7 +387,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
break;
case 3:
if (ha->optrom_state != QLA_SWRITING)
break;
return -ENOMEM;

if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
ql_log(ql_log_warn, vha, 0x7068,
Expand All @@ -403,7 +403,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
ha->optrom_region_start, ha->optrom_region_size);
break;
default:
count = -EINVAL;
return -EINVAL;
}
return count;
}
Expand All @@ -427,10 +427,10 @@ qla2x00_sysfs_read_vpd(struct file *filp, struct kobject *kobj,
struct qla_hw_data *ha = vha->hw;

if (unlikely(pci_channel_offline(ha->pdev)))
return 0;
return -EAGAIN;

if (!capable(CAP_SYS_ADMIN))
return 0;
return -EINVAL;

if (IS_NOCACHE_VPD_TYPE(ha))
ha->isp_ops->read_optrom(vha, ha->vpd, ha->flt_region_vpd << 2,
Expand Down Expand Up @@ -467,17 +467,17 @@ qla2x00_sysfs_write_vpd(struct file *filp, struct kobject *kobj,

/* Update flash version information for 4Gb & above. */
if (!IS_FWI2_CAPABLE(ha))
goto done;
return -EINVAL;

tmp_data = vmalloc(256);
if (!tmp_data) {
ql_log(ql_log_warn, vha, 0x706b,
"Unable to allocate memory for VPD information update.\n");
goto done;
return -ENOMEM;
}
ha->isp_ops->get_flash_version(vha, tmp_data);
vfree(tmp_data);
done:

return count;
}

Expand Down Expand Up @@ -534,8 +534,7 @@ qla2x00_sysfs_read_sfp(struct file *filp, struct kobject *kobj,
"Unable to read SFP data (%x/%x/%x).\n", rval,
addr, offset);

count = 0;
break;
return -EIO;
}
memcpy(buf, ha->sfp_data, SFP_BLOCK_SIZE);
buf += SFP_BLOCK_SIZE;
Expand Down Expand Up @@ -565,7 +564,7 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj,
int type;

if (off != 0)
return 0;
return -EINVAL;

type = simple_strtol(buf, NULL, 10);
switch (type) {
Expand All @@ -586,7 +585,7 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj,
break;
case 0x2025d:
if (!IS_QLA81XX(ha))
break;
return -EPERM;

ql_log(ql_log_info, vha, 0x706f,
"Issuing MPI reset.\n");
Expand All @@ -605,7 +604,7 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj,
if (!IS_QLA82XX(ha) || vha != base_vha) {
ql_log(ql_log_info, vha, 0x7071,
"FCoE ctx reset no supported.\n");
return count;
return -EPERM;
}

ql_log(ql_log_info, vha, 0x7072,
Expand Down Expand Up @@ -641,15 +640,15 @@ qla2x00_sysfs_write_edc(struct file *filp, struct kobject *kobj,
ha->edc_data_len = 0;

if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8)
return 0;
return -EINVAL;

if (!ha->edc_data) {
ha->edc_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
&ha->edc_data_dma);
if (!ha->edc_data) {
ql_log(ql_log_warn, vha, 0x7073,
"Unable to allocate memory for EDC write.\n");
return 0;
return -ENOMEM;
}
}

Expand All @@ -670,7 +669,7 @@ qla2x00_sysfs_write_edc(struct file *filp, struct kobject *kobj,
ql_log(ql_log_warn, vha, 0x7074,
"Unable to write EDC (%x) %02x:%04x:%02x:%02hhx\n",
rval, dev, adr, opt, len, buf[8]);
return -EINVAL;
return -EIO;
}

return count;
Expand Down Expand Up @@ -699,15 +698,15 @@ qla2x00_sysfs_write_edc_status(struct file *filp, struct kobject *kobj,
ha->edc_data_len = 0;

if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8)
return 0;
return -EINVAL;

if (!ha->edc_data) {
ha->edc_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
&ha->edc_data_dma);
if (!ha->edc_data) {
ql_log(ql_log_warn, vha, 0x708c,
"Unable to allocate memory for EDC status.\n");
return 0;
return -ENOMEM;
}
}

Expand All @@ -727,7 +726,7 @@ qla2x00_sysfs_write_edc_status(struct file *filp, struct kobject *kobj,
ql_log(ql_log_info, vha, 0x7075,
"Unable to write EDC status (%x) %02x:%04x:%02x.\n",
rval, dev, adr, opt, len);
return -EINVAL;
return -EIO;
}

ha->edc_data_len = len;
Expand Down Expand Up @@ -839,7 +838,7 @@ qla2x00_sysfs_read_dcbx_tlv(struct file *filp, struct kobject *kobj,
if (!ha->dcbx_tlv) {
ql_log(ql_log_warn, vha, 0x7078,
"Unable to allocate memory for DCBX TLV read-data.\n");
return 0;
return -ENOMEM;
}

do_read:
Expand All @@ -851,7 +850,7 @@ qla2x00_sysfs_read_dcbx_tlv(struct file *filp, struct kobject *kobj,
if (rval != QLA_SUCCESS) {
ql_log(ql_log_warn, vha, 0x7079,
"Unable to read DCBX TLV (%x).\n", rval);
count = 0;
return -EIO;
}

memcpy(buf, ha->dcbx_tlv, count);
Expand Down

0 comments on commit b668ae3

Please sign in to comment.