mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jesper Nilsson <jesper.nilsson@axis.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>,
	<linux-pci@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH] PCI: Map PCI bios specific error to generic errno
Date: Thu, 1 Sep 2022 17:23:24 +0200	[thread overview]
Message-ID: <20220901152324.29654-1-jesper.nilsson@axis.com> (raw)

pci_read_config_byte() may return a PCI bios specific error value
(in my case PCIBIOS_DEVICE_NOT_FOUND 0x86) which is nonsensical
to return to the caller of of_irq_parse_pci() which expects
a negative errno if something goes wrong.

Use the appropriate mapping function before passing the error on.

Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
---
 drivers/pci/of.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/of.c b/drivers/pci/of.c
index 196834ed44fe..130bcfe61e04 100644
--- a/drivers/pci/of.c
+++ b/drivers/pci/of.c
@@ -440,8 +440,10 @@ static int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *
 	 * for PCI. If you do different, then don't use that routine.
 	 */
 	rc = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin);
-	if (rc != 0)
+	if (rc != 0) {
+		rc = pcibios_err_to_errno(rc);
 		goto err;
+	}
 	/* No pin, exit with no error message. */
 	if (pin == 0)
 		return -ENODEV;
-- 
2.36.0


                 reply	other threads:[~2022-09-01 15:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220901152324.29654-1-jesper.nilsson@axis.com \
    --to=jesper.nilsson@axis.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®