diff options
author | Joe Carnuccio <joe.carnuccio@qlogic.com> | 2011-08-16 14:31:53 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2011-08-29 03:14:57 -0400 |
commit | b668ae37f10e5cefe65303150867e3fa2e631b93 (patch) | |
tree | 7e62ac2c6c50287c0ccdc470e2301f8cfde9d3bc /drivers/scsi/qla2xxx | |
parent | 697a4bc69159c3396035b0506ffa55c4b2d0b1f4 (diff) |
[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: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/qla2xxx')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_attr.c | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index c9c42a65566f..ac326c41e931 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c | |||
@@ -107,7 +107,7 @@ qla2x00_sysfs_write_fw_dump(struct file *filp, struct kobject *kobj, | |||
107 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); | 107 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
108 | break; | 108 | break; |
109 | } | 109 | } |
110 | return (count); | 110 | return -EINVAL; |
111 | } | 111 | } |
112 | 112 | ||
113 | static struct bin_attribute sysfs_fw_dump_attr = { | 113 | static struct bin_attribute sysfs_fw_dump_attr = { |
@@ -151,7 +151,7 @@ qla2x00_sysfs_write_nvram(struct file *filp, struct kobject *kobj, | |||
151 | 151 | ||
152 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size || | 152 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size || |
153 | !ha->isp_ops->write_nvram) | 153 | !ha->isp_ops->write_nvram) |
154 | return 0; | 154 | return -EINVAL; |
155 | 155 | ||
156 | /* Checksum NVRAM. */ | 156 | /* Checksum NVRAM. */ |
157 | if (IS_FWI2_CAPABLE(ha)) { | 157 | if (IS_FWI2_CAPABLE(ha)) { |
@@ -194,7 +194,7 @@ qla2x00_sysfs_write_nvram(struct file *filp, struct kobject *kobj, | |||
194 | qla2xxx_wake_dpc(vha); | 194 | qla2xxx_wake_dpc(vha); |
195 | qla2x00_wait_for_chip_reset(vha); | 195 | qla2x00_wait_for_chip_reset(vha); |
196 | 196 | ||
197 | return (count); | 197 | return count; |
198 | } | 198 | } |
199 | 199 | ||
200 | static struct bin_attribute sysfs_nvram_attr = { | 200 | static struct bin_attribute sysfs_nvram_attr = { |
@@ -268,10 +268,10 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, | |||
268 | int val, valid; | 268 | int val, valid; |
269 | 269 | ||
270 | if (off) | 270 | if (off) |
271 | return 0; | 271 | return -EINVAL; |
272 | 272 | ||
273 | if (unlikely(pci_channel_offline(ha->pdev))) | 273 | if (unlikely(pci_channel_offline(ha->pdev))) |
274 | return 0; | 274 | return -EAGAIN; |
275 | 275 | ||
276 | if (sscanf(buf, "%d:%x:%x", &val, &start, &size) < 1) | 276 | if (sscanf(buf, "%d:%x:%x", &val, &start, &size) < 1) |
277 | return -EINVAL; | 277 | return -EINVAL; |
@@ -282,7 +282,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, | |||
282 | case 0: | 282 | case 0: |
283 | if (ha->optrom_state != QLA_SREADING && | 283 | if (ha->optrom_state != QLA_SREADING && |
284 | ha->optrom_state != QLA_SWRITING) | 284 | ha->optrom_state != QLA_SWRITING) |
285 | break; | 285 | return -EINVAL; |
286 | 286 | ||
287 | ha->optrom_state = QLA_SWAITING; | 287 | ha->optrom_state = QLA_SWAITING; |
288 | 288 | ||
@@ -295,7 +295,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, | |||
295 | break; | 295 | break; |
296 | case 1: | 296 | case 1: |
297 | if (ha->optrom_state != QLA_SWAITING) | 297 | if (ha->optrom_state != QLA_SWAITING) |
298 | break; | 298 | return -EINVAL; |
299 | 299 | ||
300 | ha->optrom_region_start = start; | 300 | ha->optrom_region_start = start; |
301 | ha->optrom_region_size = start + size > ha->optrom_size ? | 301 | 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 | "(%x).\n", ha->optrom_region_size); | 309 | "(%x).\n", ha->optrom_region_size); |
310 | 310 | ||
311 | ha->optrom_state = QLA_SWAITING; | 311 | ha->optrom_state = QLA_SWAITING; |
312 | return count; | 312 | return -ENOMEM; |
313 | } | 313 | } |
314 | 314 | ||
315 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { | 315 | 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 | break; | 328 | break; |
329 | case 2: | 329 | case 2: |
330 | if (ha->optrom_state != QLA_SWAITING) | 330 | if (ha->optrom_state != QLA_SWAITING) |
331 | break; | 331 | return -EINVAL; |
332 | 332 | ||
333 | /* | 333 | /* |
334 | * We need to be more restrictive on which FLASH regions are | 334 | * 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 | "(%x)\n", ha->optrom_region_size); | 376 | "(%x)\n", ha->optrom_region_size); |
377 | 377 | ||
378 | ha->optrom_state = QLA_SWAITING; | 378 | ha->optrom_state = QLA_SWAITING; |
379 | return count; | 379 | return -ENOMEM; |
380 | } | 380 | } |
381 | 381 | ||
382 | ql_dbg(ql_dbg_user, vha, 0x7067, | 382 | ql_dbg(ql_dbg_user, vha, 0x7067, |
@@ -387,7 +387,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, | |||
387 | break; | 387 | break; |
388 | case 3: | 388 | case 3: |
389 | if (ha->optrom_state != QLA_SWRITING) | 389 | if (ha->optrom_state != QLA_SWRITING) |
390 | break; | 390 | return -ENOMEM; |
391 | 391 | ||
392 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { | 392 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
393 | ql_log(ql_log_warn, vha, 0x7068, | 393 | ql_log(ql_log_warn, vha, 0x7068, |
@@ -403,7 +403,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, | |||
403 | ha->optrom_region_start, ha->optrom_region_size); | 403 | ha->optrom_region_start, ha->optrom_region_size); |
404 | break; | 404 | break; |
405 | default: | 405 | default: |
406 | count = -EINVAL; | 406 | return -EINVAL; |
407 | } | 407 | } |
408 | return count; | 408 | return count; |
409 | } | 409 | } |
@@ -427,10 +427,10 @@ qla2x00_sysfs_read_vpd(struct file *filp, struct kobject *kobj, | |||
427 | struct qla_hw_data *ha = vha->hw; | 427 | struct qla_hw_data *ha = vha->hw; |
428 | 428 | ||
429 | if (unlikely(pci_channel_offline(ha->pdev))) | 429 | if (unlikely(pci_channel_offline(ha->pdev))) |
430 | return 0; | 430 | return -EAGAIN; |
431 | 431 | ||
432 | if (!capable(CAP_SYS_ADMIN)) | 432 | if (!capable(CAP_SYS_ADMIN)) |
433 | return 0; | 433 | return -EINVAL; |
434 | 434 | ||
435 | if (IS_NOCACHE_VPD_TYPE(ha)) | 435 | if (IS_NOCACHE_VPD_TYPE(ha)) |
436 | ha->isp_ops->read_optrom(vha, ha->vpd, ha->flt_region_vpd << 2, | 436 | 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 | 467 | ||
468 | /* Update flash version information for 4Gb & above. */ | 468 | /* Update flash version information for 4Gb & above. */ |
469 | if (!IS_FWI2_CAPABLE(ha)) | 469 | if (!IS_FWI2_CAPABLE(ha)) |
470 | goto done; | 470 | return -EINVAL; |
471 | 471 | ||
472 | tmp_data = vmalloc(256); | 472 | tmp_data = vmalloc(256); |
473 | if (!tmp_data) { | 473 | if (!tmp_data) { |
474 | ql_log(ql_log_warn, vha, 0x706b, | 474 | ql_log(ql_log_warn, vha, 0x706b, |
475 | "Unable to allocate memory for VPD information update.\n"); | 475 | "Unable to allocate memory for VPD information update.\n"); |
476 | goto done; | 476 | return -ENOMEM; |
477 | } | 477 | } |
478 | ha->isp_ops->get_flash_version(vha, tmp_data); | 478 | ha->isp_ops->get_flash_version(vha, tmp_data); |
479 | vfree(tmp_data); | 479 | vfree(tmp_data); |
480 | done: | 480 | |
481 | return count; | 481 | return count; |
482 | } | 482 | } |
483 | 483 | ||
@@ -534,8 +534,7 @@ do_read: | |||
534 | "Unable to read SFP data (%x/%x/%x).\n", rval, | 534 | "Unable to read SFP data (%x/%x/%x).\n", rval, |
535 | addr, offset); | 535 | addr, offset); |
536 | 536 | ||
537 | count = 0; | 537 | return -EIO; |
538 | break; | ||
539 | } | 538 | } |
540 | memcpy(buf, ha->sfp_data, SFP_BLOCK_SIZE); | 539 | memcpy(buf, ha->sfp_data, SFP_BLOCK_SIZE); |
541 | buf += SFP_BLOCK_SIZE; | 540 | buf += SFP_BLOCK_SIZE; |
@@ -565,7 +564,7 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj, | |||
565 | int type; | 564 | int type; |
566 | 565 | ||
567 | if (off != 0) | 566 | if (off != 0) |
568 | return 0; | 567 | return -EINVAL; |
569 | 568 | ||
570 | type = simple_strtol(buf, NULL, 10); | 569 | type = simple_strtol(buf, NULL, 10); |
571 | switch (type) { | 570 | switch (type) { |
@@ -586,7 +585,7 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj, | |||
586 | break; | 585 | break; |
587 | case 0x2025d: | 586 | case 0x2025d: |
588 | if (!IS_QLA81XX(ha)) | 587 | if (!IS_QLA81XX(ha)) |
589 | break; | 588 | return -EPERM; |
590 | 589 | ||
591 | ql_log(ql_log_info, vha, 0x706f, | 590 | ql_log(ql_log_info, vha, 0x706f, |
592 | "Issuing MPI reset.\n"); | 591 | "Issuing MPI reset.\n"); |
@@ -605,7 +604,7 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj, | |||
605 | if (!IS_QLA82XX(ha) || vha != base_vha) { | 604 | if (!IS_QLA82XX(ha) || vha != base_vha) { |
606 | ql_log(ql_log_info, vha, 0x7071, | 605 | ql_log(ql_log_info, vha, 0x7071, |
607 | "FCoE ctx reset no supported.\n"); | 606 | "FCoE ctx reset no supported.\n"); |
608 | return count; | 607 | return -EPERM; |
609 | } | 608 | } |
610 | 609 | ||
611 | ql_log(ql_log_info, vha, 0x7072, | 610 | ql_log(ql_log_info, vha, 0x7072, |
@@ -641,7 +640,7 @@ qla2x00_sysfs_write_edc(struct file *filp, struct kobject *kobj, | |||
641 | ha->edc_data_len = 0; | 640 | ha->edc_data_len = 0; |
642 | 641 | ||
643 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8) | 642 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8) |
644 | return 0; | 643 | return -EINVAL; |
645 | 644 | ||
646 | if (!ha->edc_data) { | 645 | if (!ha->edc_data) { |
647 | ha->edc_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, | 646 | 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 | if (!ha->edc_data) { | 648 | if (!ha->edc_data) { |
650 | ql_log(ql_log_warn, vha, 0x7073, | 649 | ql_log(ql_log_warn, vha, 0x7073, |
651 | "Unable to allocate memory for EDC write.\n"); | 650 | "Unable to allocate memory for EDC write.\n"); |
652 | return 0; | 651 | return -ENOMEM; |
653 | } | 652 | } |
654 | } | 653 | } |
655 | 654 | ||
@@ -670,7 +669,7 @@ qla2x00_sysfs_write_edc(struct file *filp, struct kobject *kobj, | |||
670 | ql_log(ql_log_warn, vha, 0x7074, | 669 | ql_log(ql_log_warn, vha, 0x7074, |
671 | "Unable to write EDC (%x) %02x:%04x:%02x:%02hhx\n", | 670 | "Unable to write EDC (%x) %02x:%04x:%02x:%02hhx\n", |
672 | rval, dev, adr, opt, len, buf[8]); | 671 | rval, dev, adr, opt, len, buf[8]); |
673 | return -EINVAL; | 672 | return -EIO; |
674 | } | 673 | } |
675 | 674 | ||
676 | return count; | 675 | return count; |
@@ -699,7 +698,7 @@ qla2x00_sysfs_write_edc_status(struct file *filp, struct kobject *kobj, | |||
699 | ha->edc_data_len = 0; | 698 | ha->edc_data_len = 0; |
700 | 699 | ||
701 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8) | 700 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8) |
702 | return 0; | 701 | return -EINVAL; |
703 | 702 | ||
704 | if (!ha->edc_data) { | 703 | if (!ha->edc_data) { |
705 | ha->edc_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, | 704 | 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 | if (!ha->edc_data) { | 706 | if (!ha->edc_data) { |
708 | ql_log(ql_log_warn, vha, 0x708c, | 707 | ql_log(ql_log_warn, vha, 0x708c, |
709 | "Unable to allocate memory for EDC status.\n"); | 708 | "Unable to allocate memory for EDC status.\n"); |
710 | return 0; | 709 | return -ENOMEM; |
711 | } | 710 | } |
712 | } | 711 | } |
713 | 712 | ||
@@ -727,7 +726,7 @@ qla2x00_sysfs_write_edc_status(struct file *filp, struct kobject *kobj, | |||
727 | ql_log(ql_log_info, vha, 0x7075, | 726 | ql_log(ql_log_info, vha, 0x7075, |
728 | "Unable to write EDC status (%x) %02x:%04x:%02x.\n", | 727 | "Unable to write EDC status (%x) %02x:%04x:%02x.\n", |
729 | rval, dev, adr, opt, len); | 728 | rval, dev, adr, opt, len); |
730 | return -EINVAL; | 729 | return -EIO; |
731 | } | 730 | } |
732 | 731 | ||
733 | ha->edc_data_len = len; | 732 | ha->edc_data_len = len; |
@@ -839,7 +838,7 @@ qla2x00_sysfs_read_dcbx_tlv(struct file *filp, struct kobject *kobj, | |||
839 | if (!ha->dcbx_tlv) { | 838 | if (!ha->dcbx_tlv) { |
840 | ql_log(ql_log_warn, vha, 0x7078, | 839 | ql_log(ql_log_warn, vha, 0x7078, |
841 | "Unable to allocate memory for DCBX TLV read-data.\n"); | 840 | "Unable to allocate memory for DCBX TLV read-data.\n"); |
842 | return 0; | 841 | return -ENOMEM; |
843 | } | 842 | } |
844 | 843 | ||
845 | do_read: | 844 | do_read: |
@@ -851,7 +850,7 @@ do_read: | |||
851 | if (rval != QLA_SUCCESS) { | 850 | if (rval != QLA_SUCCESS) { |
852 | ql_log(ql_log_warn, vha, 0x7079, | 851 | ql_log(ql_log_warn, vha, 0x7079, |
853 | "Unable to read DCBX TLV (%x).\n", rval); | 852 | "Unable to read DCBX TLV (%x).\n", rval); |
854 | count = 0; | 853 | return -EIO; |
855 | } | 854 | } |
856 | 855 | ||
857 | memcpy(buf, ha->dcbx_tlv, count); | 856 | memcpy(buf, ha->dcbx_tlv, count); |