Skip to content

Commit

Permalink
PCI/AER: Fix aer_inject error codes
Browse files Browse the repository at this point in the history
EPERM means "Operation not permitted", which doesn't reflect the lack of
support for AER.  EPROTONOSUPPORT (Protocol not supported) is a better
choice of error code if the device or its root port lack support for AER.

Likewise, EINVAL means "Invalid argument", which is not suitable for cases
where the AER error device is missing or unusable.  ENODEV and
EPROTONOSUPPORT, respectively, fit better.

Suggested-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Borislav Petkov <bp@suse.de>
CC: Prarit Bhargava <prarit@redhat.com>
  • Loading branch information
jdelvare authored and bjorn-helgaas committed Mar 8, 2016
1 parent 0e6053d commit 20ac75e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/pci/pcie/aer/aer_inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ static int aer_inject(struct aer_error_inj *einj)

pos_cap_err = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
if (!pos_cap_err) {
ret = -EPERM;
ret = -EPROTONOSUPPORT;
goto out_put;
}
pci_read_config_dword(dev, pos_cap_err + PCI_ERR_UNCOR_SEVER, &sever);
Expand All @@ -373,7 +373,7 @@ static int aer_inject(struct aer_error_inj *einj)

rp_pos_cap_err = pci_find_ext_capability(rpdev, PCI_EXT_CAP_ID_ERR);
if (!rp_pos_cap_err) {
ret = -EPERM;
ret = -EPROTONOSUPPORT;
goto out_put;
}

Expand Down Expand Up @@ -481,12 +481,12 @@ static int aer_inject(struct aer_error_inj *einj)
if (find_aer_device(rpdev, &edev)) {
if (!get_service_data(edev)) {
printk(KERN_WARNING "AER service is not initialized\n");
ret = -EINVAL;
ret = -EPROTONOSUPPORT;
goto out_put;
}
aer_irq(-1, edev);
} else
ret = -EINVAL;
ret = -ENODEV;
out_put:
kfree(err_alloc);
kfree(rperr_alloc);
Expand Down

0 comments on commit 20ac75e

Please sign in to comment.