2024-05-27 14:35:17

by Ilpo Järvinen

[permalink] [raw]
Subject: [PATCH 1/2] gpio: amd8111: Convert PCIBIOS_* return codes to errnos

amd_gpio_init() uses pci_read_config_dword() that returns PCIBIOS_*
codes. The return code is then returned as is but amd_gpio_init() is
a module init function that should return normal errnos.

Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal
errno before returning it from amd_gpio_init().

Fixes: f942a7de047d ("gpio: add a driver for GPIO pins found on AMD-8111 south bridge chips")
Cc: [email protected]
Signed-off-by: Ilpo Järvinen <[email protected]>
---
drivers/gpio/gpio-amd8111.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-amd8111.c b/drivers/gpio/gpio-amd8111.c
index 6f3ded619c8b..3377667a28de 100644
--- a/drivers/gpio/gpio-amd8111.c
+++ b/drivers/gpio/gpio-amd8111.c
@@ -195,8 +195,10 @@ static int __init amd_gpio_init(void)

found:
err = pci_read_config_dword(pdev, 0x58, &gp.pmbase);
- if (err)
+ if (err) {
+ err = pcibios_err_to_errno(err);
goto out;
+ }
err = -EIO;
gp.pmbase &= 0x0000FF00;
if (gp.pmbase == 0)
--
2.39.2



2024-05-27 17:18:58

by Ilpo Järvinen

[permalink] [raw]
Subject: [PATCH 2/2] gpio: rdc321x: Convert PCIBIOS_* return codes to errnos

rdc_gpio_config() uses pci_{read,write}_config_dword() that return
PCIBIOS_* codes. rdc_gpio_config() is used for
direction_{input,output}() in the struct gpio_chip which both require
normal errnos to be returned.

Similarly, rdc321x_gpio_probe() that is probe function returns
PCIBIOS_* codes without converting them first into normal errnos.

Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal
errno before returning them to fix both issues.

Fixes: 9956d02d6e60 ("gpio: Add support for RDC321x GPIO controller")
Cc: [email protected]
Signed-off-by: Ilpo Järvinen <[email protected]>
---
drivers/gpio/gpio-rdc321x.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-rdc321x.c b/drivers/gpio/gpio-rdc321x.c
index 01ed2517e9fd..ec7fb9220a47 100644
--- a/drivers/gpio/gpio-rdc321x.c
+++ b/drivers/gpio/gpio-rdc321x.c
@@ -102,7 +102,7 @@ static int rdc_gpio_config(struct gpio_chip *chip,
unlock:
spin_unlock(&gpch->lock);

- return err;
+ return pcibios_err_to_errno(err);
}

/* configure GPIO pin as input */
@@ -170,13 +170,13 @@ static int rdc321x_gpio_probe(struct platform_device *pdev)
rdc321x_gpio_dev->reg1_data_base,
&rdc321x_gpio_dev->data_reg[0]);
if (err)
- return err;
+ return pcibios_err_to_errno(err);

err = pci_read_config_dword(rdc321x_gpio_dev->sb_pdev,
rdc321x_gpio_dev->reg2_data_base,
&rdc321x_gpio_dev->data_reg[1]);
if (err)
- return err;
+ return pcibios_err_to_errno(err);

dev_info(&pdev->dev, "registering %d GPIOs\n",
rdc321x_gpio_dev->chip.ngpio);
--
2.39.2


2024-05-30 09:22:01

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH 1/2] gpio: amd8111: Convert PCIBIOS_* return codes to errnos

From: Bartosz Golaszewski <[email protected]>


On Mon, 27 May 2024 16:23:44 +0300, Ilpo Järvinen wrote:
> amd_gpio_init() uses pci_read_config_dword() that returns PCIBIOS_*
> codes. The return code is then returned as is but amd_gpio_init() is
> a module init function that should return normal errnos.
>
> Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal
> errno before returning it from amd_gpio_init().
>
> [...]

Applied, thanks!

[1/2] gpio: amd8111: Convert PCIBIOS_* return codes to errnos
commit: d4cde6e42f2eb56436cab6d1931738ec09e64f74
[2/2] gpio: rdc321x: Convert PCIBIOS_* return codes to errnos
commit: 9a73e037f4b5eb45c9ecccb191d39c280abe7cbd

Best regards,
--
Bartosz Golaszewski <[email protected]>

2024-05-30 09:23:26

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH 1/2] gpio: amd8111: Convert PCIBIOS_* return codes to errnos

On Mon, May 27, 2024 at 3:23 PM Ilpo Järvinen
<[email protected]> wrote:
>
> amd_gpio_init() uses pci_read_config_dword() that returns PCIBIOS_*
> codes. The return code is then returned as is but amd_gpio_init() is
> a module init function that should return normal errnos.
>
> Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal
> errno before returning it from amd_gpio_init().
>
> Fixes: f942a7de047d ("gpio: add a driver for GPIO pins found on AMD-8111 south bridge chips")
> Cc: [email protected]

I dropped these.

Bart

> Signed-off-by: Ilpo Järvinen <[email protected]>
> ---
> drivers/gpio/gpio-amd8111.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-amd8111.c b/drivers/gpio/gpio-amd8111.c
> index 6f3ded619c8b..3377667a28de 100644
> --- a/drivers/gpio/gpio-amd8111.c
> +++ b/drivers/gpio/gpio-amd8111.c
> @@ -195,8 +195,10 @@ static int __init amd_gpio_init(void)
>
> found:
> err = pci_read_config_dword(pdev, 0x58, &gp.pmbase);
> - if (err)
> + if (err) {
> + err = pcibios_err_to_errno(err);
> goto out;
> + }
> err = -EIO;
> gp.pmbase &= 0x0000FF00;
> if (gp.pmbase == 0)
> --
> 2.39.2
>