Commit b668ae37 authored by Joe Carnuccio's avatar Joe Carnuccio Committed by James Bottomley

[SCSI] qla2xxx: Return sysfs error codes appropriate to conditions.

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: default avatarJoe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: default avatarChad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent 697a4bc6
...@@ -107,7 +107,7 @@ qla2x00_sysfs_write_fw_dump(struct file *filp, struct kobject *kobj, ...@@ -107,7 +107,7 @@ qla2x00_sysfs_write_fw_dump(struct file *filp, struct kobject *kobj,
set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
break; break;
} }
return (count); return -EINVAL;
} }
static struct bin_attribute sysfs_fw_dump_attr = { static struct bin_attribute sysfs_fw_dump_attr = {
...@@ -151,7 +151,7 @@ qla2x00_sysfs_write_nvram(struct file *filp, struct kobject *kobj, ...@@ -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 || if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size ||
!ha->isp_ops->write_nvram) !ha->isp_ops->write_nvram)
return 0; return -EINVAL;
/* Checksum NVRAM. */ /* Checksum NVRAM. */
if (IS_FWI2_CAPABLE(ha)) { if (IS_FWI2_CAPABLE(ha)) {
...@@ -194,7 +194,7 @@ qla2x00_sysfs_write_nvram(struct file *filp, struct kobject *kobj, ...@@ -194,7 +194,7 @@ qla2x00_sysfs_write_nvram(struct file *filp, struct kobject *kobj,
qla2xxx_wake_dpc(vha); qla2xxx_wake_dpc(vha);
qla2x00_wait_for_chip_reset(vha); qla2x00_wait_for_chip_reset(vha);
return (count); return count;
} }
static struct bin_attribute sysfs_nvram_attr = { static struct bin_attribute sysfs_nvram_attr = {
...@@ -268,10 +268,10 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, ...@@ -268,10 +268,10 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
int val, valid; int val, valid;
if (off) if (off)
return 0; return -EINVAL;
if (unlikely(pci_channel_offline(ha->pdev))) if (unlikely(pci_channel_offline(ha->pdev)))
return 0; return -EAGAIN;
if (sscanf(buf, "%d:%x:%x", &val, &start, &size) < 1) if (sscanf(buf, "%d:%x:%x", &val, &start, &size) < 1)
return -EINVAL; return -EINVAL;
...@@ -282,7 +282,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, ...@@ -282,7 +282,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
case 0: case 0:
if (ha->optrom_state != QLA_SREADING && if (ha->optrom_state != QLA_SREADING &&
ha->optrom_state != QLA_SWRITING) ha->optrom_state != QLA_SWRITING)
break; return -EINVAL;
ha->optrom_state = QLA_SWAITING; ha->optrom_state = QLA_SWAITING;
...@@ -295,7 +295,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, ...@@ -295,7 +295,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
break; break;
case 1: case 1:
if (ha->optrom_state != QLA_SWAITING) if (ha->optrom_state != QLA_SWAITING)
break; return -EINVAL;
ha->optrom_region_start = start; ha->optrom_region_start = start;
ha->optrom_region_size = start + size > ha->optrom_size ? ha->optrom_region_size = start + size > ha->optrom_size ?
...@@ -309,7 +309,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, ...@@ -309,7 +309,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
"(%x).\n", ha->optrom_region_size); "(%x).\n", ha->optrom_region_size);
ha->optrom_state = QLA_SWAITING; ha->optrom_state = QLA_SWAITING;
return count; return -ENOMEM;
} }
if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
...@@ -328,7 +328,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, ...@@ -328,7 +328,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
break; break;
case 2: case 2:
if (ha->optrom_state != QLA_SWAITING) if (ha->optrom_state != QLA_SWAITING)
break; return -EINVAL;
/* /*
* We need to be more restrictive on which FLASH regions are * We need to be more restrictive on which FLASH regions are
...@@ -376,7 +376,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, ...@@ -376,7 +376,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
"(%x)\n", ha->optrom_region_size); "(%x)\n", ha->optrom_region_size);
ha->optrom_state = QLA_SWAITING; ha->optrom_state = QLA_SWAITING;
return count; return -ENOMEM;
} }
ql_dbg(ql_dbg_user, vha, 0x7067, ql_dbg(ql_dbg_user, vha, 0x7067,
...@@ -387,7 +387,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, ...@@ -387,7 +387,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
break; break;
case 3: case 3:
if (ha->optrom_state != QLA_SWRITING) if (ha->optrom_state != QLA_SWRITING)
break; return -ENOMEM;
if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
ql_log(ql_log_warn, vha, 0x7068, ql_log(ql_log_warn, vha, 0x7068,
...@@ -403,7 +403,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, ...@@ -403,7 +403,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
ha->optrom_region_start, ha->optrom_region_size); ha->optrom_region_start, ha->optrom_region_size);
break; break;
default: default:
count = -EINVAL; return -EINVAL;
} }
return count; return count;
} }
...@@ -427,10 +427,10 @@ qla2x00_sysfs_read_vpd(struct file *filp, struct kobject *kobj, ...@@ -427,10 +427,10 @@ qla2x00_sysfs_read_vpd(struct file *filp, struct kobject *kobj,
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
if (unlikely(pci_channel_offline(ha->pdev))) if (unlikely(pci_channel_offline(ha->pdev)))
return 0; return -EAGAIN;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return 0; return -EINVAL;
if (IS_NOCACHE_VPD_TYPE(ha)) if (IS_NOCACHE_VPD_TYPE(ha))
ha->isp_ops->read_optrom(vha, ha->vpd, ha->flt_region_vpd << 2, ha->isp_ops->read_optrom(vha, ha->vpd, ha->flt_region_vpd << 2,
...@@ -467,17 +467,17 @@ qla2x00_sysfs_write_vpd(struct file *filp, struct kobject *kobj, ...@@ -467,17 +467,17 @@ qla2x00_sysfs_write_vpd(struct file *filp, struct kobject *kobj,
/* Update flash version information for 4Gb & above. */ /* Update flash version information for 4Gb & above. */
if (!IS_FWI2_CAPABLE(ha)) if (!IS_FWI2_CAPABLE(ha))
goto done; return -EINVAL;
tmp_data = vmalloc(256); tmp_data = vmalloc(256);
if (!tmp_data) { if (!tmp_data) {
ql_log(ql_log_warn, vha, 0x706b, ql_log(ql_log_warn, vha, 0x706b,
"Unable to allocate memory for VPD information update.\n"); "Unable to allocate memory for VPD information update.\n");
goto done; return -ENOMEM;
} }
ha->isp_ops->get_flash_version(vha, tmp_data); ha->isp_ops->get_flash_version(vha, tmp_data);
vfree(tmp_data); vfree(tmp_data);
done:
return count; return count;
} }
...@@ -534,8 +534,7 @@ qla2x00_sysfs_read_sfp(struct file *filp, struct kobject *kobj, ...@@ -534,8 +534,7 @@ qla2x00_sysfs_read_sfp(struct file *filp, struct kobject *kobj,
"Unable to read SFP data (%x/%x/%x).\n", rval, "Unable to read SFP data (%x/%x/%x).\n", rval,
addr, offset); addr, offset);
count = 0; return -EIO;
break;
} }
memcpy(buf, ha->sfp_data, SFP_BLOCK_SIZE); memcpy(buf, ha->sfp_data, SFP_BLOCK_SIZE);
buf += SFP_BLOCK_SIZE; buf += SFP_BLOCK_SIZE;
...@@ -565,7 +564,7 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj, ...@@ -565,7 +564,7 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj,
int type; int type;
if (off != 0) if (off != 0)
return 0; return -EINVAL;
type = simple_strtol(buf, NULL, 10); type = simple_strtol(buf, NULL, 10);
switch (type) { switch (type) {
...@@ -586,7 +585,7 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj, ...@@ -586,7 +585,7 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj,
break; break;
case 0x2025d: case 0x2025d:
if (!IS_QLA81XX(ha)) if (!IS_QLA81XX(ha))
break; return -EPERM;
ql_log(ql_log_info, vha, 0x706f, ql_log(ql_log_info, vha, 0x706f,
"Issuing MPI reset.\n"); "Issuing MPI reset.\n");
...@@ -605,7 +604,7 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj, ...@@ -605,7 +604,7 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj,
if (!IS_QLA82XX(ha) || vha != base_vha) { if (!IS_QLA82XX(ha) || vha != base_vha) {
ql_log(ql_log_info, vha, 0x7071, ql_log(ql_log_info, vha, 0x7071,
"FCoE ctx reset no supported.\n"); "FCoE ctx reset no supported.\n");
return count; return -EPERM;
} }
ql_log(ql_log_info, vha, 0x7072, ql_log(ql_log_info, vha, 0x7072,
...@@ -641,7 +640,7 @@ qla2x00_sysfs_write_edc(struct file *filp, struct kobject *kobj, ...@@ -641,7 +640,7 @@ qla2x00_sysfs_write_edc(struct file *filp, struct kobject *kobj,
ha->edc_data_len = 0; ha->edc_data_len = 0;
if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8) if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8)
return 0; return -EINVAL;
if (!ha->edc_data) { if (!ha->edc_data) {
ha->edc_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, ha->edc_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
...@@ -649,7 +648,7 @@ qla2x00_sysfs_write_edc(struct file *filp, struct kobject *kobj, ...@@ -649,7 +648,7 @@ qla2x00_sysfs_write_edc(struct file *filp, struct kobject *kobj,
if (!ha->edc_data) { if (!ha->edc_data) {
ql_log(ql_log_warn, vha, 0x7073, ql_log(ql_log_warn, vha, 0x7073,
"Unable to allocate memory for EDC write.\n"); "Unable to allocate memory for EDC write.\n");
return 0; return -ENOMEM;
} }
} }
...@@ -670,7 +669,7 @@ qla2x00_sysfs_write_edc(struct file *filp, struct kobject *kobj, ...@@ -670,7 +669,7 @@ qla2x00_sysfs_write_edc(struct file *filp, struct kobject *kobj,
ql_log(ql_log_warn, vha, 0x7074, ql_log(ql_log_warn, vha, 0x7074,
"Unable to write EDC (%x) %02x:%04x:%02x:%02hhx\n", "Unable to write EDC (%x) %02x:%04x:%02x:%02hhx\n",
rval, dev, adr, opt, len, buf[8]); rval, dev, adr, opt, len, buf[8]);
return -EINVAL; return -EIO;
} }
return count; return count;
...@@ -699,7 +698,7 @@ qla2x00_sysfs_write_edc_status(struct file *filp, struct kobject *kobj, ...@@ -699,7 +698,7 @@ qla2x00_sysfs_write_edc_status(struct file *filp, struct kobject *kobj,
ha->edc_data_len = 0; ha->edc_data_len = 0;
if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8) if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8)
return 0; return -EINVAL;
if (!ha->edc_data) { if (!ha->edc_data) {
ha->edc_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, ha->edc_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
...@@ -707,7 +706,7 @@ qla2x00_sysfs_write_edc_status(struct file *filp, struct kobject *kobj, ...@@ -707,7 +706,7 @@ qla2x00_sysfs_write_edc_status(struct file *filp, struct kobject *kobj,
if (!ha->edc_data) { if (!ha->edc_data) {
ql_log(ql_log_warn, vha, 0x708c, ql_log(ql_log_warn, vha, 0x708c,
"Unable to allocate memory for EDC status.\n"); "Unable to allocate memory for EDC status.\n");
return 0; return -ENOMEM;
} }
} }
...@@ -727,7 +726,7 @@ qla2x00_sysfs_write_edc_status(struct file *filp, struct kobject *kobj, ...@@ -727,7 +726,7 @@ qla2x00_sysfs_write_edc_status(struct file *filp, struct kobject *kobj,
ql_log(ql_log_info, vha, 0x7075, ql_log(ql_log_info, vha, 0x7075,
"Unable to write EDC status (%x) %02x:%04x:%02x.\n", "Unable to write EDC status (%x) %02x:%04x:%02x.\n",
rval, dev, adr, opt, len); rval, dev, adr, opt, len);
return -EINVAL; return -EIO;
} }
ha->edc_data_len = len; ha->edc_data_len = len;
...@@ -839,7 +838,7 @@ qla2x00_sysfs_read_dcbx_tlv(struct file *filp, struct kobject *kobj, ...@@ -839,7 +838,7 @@ qla2x00_sysfs_read_dcbx_tlv(struct file *filp, struct kobject *kobj,
if (!ha->dcbx_tlv) { if (!ha->dcbx_tlv) {
ql_log(ql_log_warn, vha, 0x7078, ql_log(ql_log_warn, vha, 0x7078,
"Unable to allocate memory for DCBX TLV read-data.\n"); "Unable to allocate memory for DCBX TLV read-data.\n");
return 0; return -ENOMEM;
} }
do_read: do_read:
...@@ -851,7 +850,7 @@ qla2x00_sysfs_read_dcbx_tlv(struct file *filp, struct kobject *kobj, ...@@ -851,7 +850,7 @@ qla2x00_sysfs_read_dcbx_tlv(struct file *filp, struct kobject *kobj,
if (rval != QLA_SUCCESS) { if (rval != QLA_SUCCESS) {
ql_log(ql_log_warn, vha, 0x7079, ql_log(ql_log_warn, vha, 0x7079,
"Unable to read DCBX TLV (%x).\n", rval); "Unable to read DCBX TLV (%x).\n", rval);
count = 0; return -EIO;
} }
memcpy(buf, ha->dcbx_tlv, count); memcpy(buf, ha->dcbx_tlv, count);
......
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