2024-05-27 17:50:19

by Ilpo Järvinen

[permalink] [raw]
Subject: [PATCH 1/1] leds: ss4200: Convert PCIBIOS_* return codes to errnos

ich7_lpc_probe() uses pci_read_config_dword() that returns PCIBIOS_*
codes. The error handling code assumes incorrectly it's a normal errno
and checks for < 0. The return code is returned from the probe function
as is but probe functions should return normal errnos.

Remove < 0 from the check and convert PCIBIOS_* returns code using
pcibios_err_to_errno() into normal errno before returning it.

Fixes: a328e95b82c1 ("leds: LED driver for Intel NAS SS4200 series (v5)")
Cc: [email protected]
Signed-off-by: Ilpo Järvinen <[email protected]>
---
drivers/leds/leds-ss4200.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
index fcaa34706b6c..2ef9fc7371bd 100644
--- a/drivers/leds/leds-ss4200.c
+++ b/drivers/leds/leds-ss4200.c
@@ -356,8 +356,10 @@ static int ich7_lpc_probe(struct pci_dev *dev,

nas_gpio_pci_dev = dev;
status = pci_read_config_dword(dev, PMBASE, &g_pm_io_base);
- if (status)
+ if (status) {
+ status = pcibios_err_to_errno(status);
goto out;
+ }
g_pm_io_base &= 0x00000ff80;

status = pci_read_config_dword(dev, GPIO_CTRL, &gc);
@@ -369,8 +371,9 @@ static int ich7_lpc_probe(struct pci_dev *dev,
}

status = pci_read_config_dword(dev, GPIO_BASE, &nas_gpio_io_base);
- if (0 > status) {
+ if (status) {
dev_info(&dev->dev, "Unable to read GPIOBASE.\n");
+ status = pcibios_err_to_errno(status);
goto out;
}
dev_dbg(&dev->dev, ": GPIOBASE = 0x%08x\n", nas_gpio_io_base);
--
2.39.2



2024-05-31 15:05:48

by Lee Jones

[permalink] [raw]
Subject: Re: (subset) [PATCH 1/1] leds: ss4200: Convert PCIBIOS_* return codes to errnos

On Mon, 27 May 2024 16:27:00 +0300, Ilpo Järvinen wrote:
> ich7_lpc_probe() uses pci_read_config_dword() that returns PCIBIOS_*
> codes. The error handling code assumes incorrectly it's a normal errno
> and checks for < 0. The return code is returned from the probe function
> as is but probe functions should return normal errnos.
>
> Remove < 0 from the check and convert PCIBIOS_* returns code using
> pcibios_err_to_errno() into normal errno before returning it.
>
> [...]

Applied, thanks!

[1/1] leds: ss4200: Convert PCIBIOS_* return codes to errnos
commit: c1f69631a8f438997621c9ff322452b744525048

--
Lee Jones [李琼斯]