2022-09-07 14:44:20

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH -next v2 1/5] misc: microchip: pci1xxxx: fix error handling in gp_aux_bus_probe()

From: Wei Yongjun <[email protected]>

In some error handling path, resoures alloced may not released.
This patch fix them.

Fixes: 393fc2f5948f ("misc: microchip: pci1xxxx: load auxiliary bus driver for the PIO function in the multi-function endpoint of pci1xxxx device.")
Signed-off-by: Wei Yongjun <[email protected]>
---
v1 - > v2: add fixes tag, fix pci_alloc_irq_vectors handing
---
drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
index bfc03028b34d..11f79f239006 100644
--- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
+++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
@@ -87,12 +87,13 @@ static int gp_aux_bus_probe(struct pci_dev *pdev, const struct pci_device_id *id
retval = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);

if (retval < 0)
- return retval;
+ goto err_aux_dev_init_1;

- pdev->irq = pci_irq_vector(pdev, 0);
- if (pdev->irq < 0)
- return retval;
+ retval = pci_irq_vector(pdev, 0);
+ if (retval < 0)
+ goto err_aux_dev_init_1;

+ pdev->irq = retval;
aux_bus->aux_device_wrapper[1]->gp_aux_data.irq_num = pdev->irq;

retval = auxiliary_device_init(&aux_bus->aux_device_wrapper[1]->aux_dev);
--
2.34.1


2022-09-07 14:44:43

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH -next v2 4/5] misc: microchip: pci1xxxx: Add missing MODULE_DEVICE_TABLE

From: Wei Yongjun <[email protected]>

This patch adds missing MODULE_DEVICE_TABLE definition which generates
correct modalias for automatic loading of this driver when it is built
as an external module.

Fixes: 7d3e4d807df2 ("misc: microchip: pci1xxxx: load gpio driver for the gpio controller auxiliary device enumerated by the auxiliary bus driver.")
Signed-off-by: Wei Yongjun <[email protected]>
---
v1 -> v2: add fixes tag
---
drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
index 4f26871994ee..fa80a7788596 100644
--- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
+++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
@@ -411,6 +411,7 @@ static const struct auxiliary_device_id pci1xxxx_gpio_auxiliary_id_table[] = {
{.name = "mchp_pci1xxxx_gp.gp_gpio"},
{}
};
+MODULE_DEVICE_TABLE(auxiliary, pci1xxxx_gpio_auxiliary_id_table);

static struct auxiliary_driver pci1xxxx_gpio_driver = {
.driver = {
--
2.34.1

2022-09-07 14:44:48

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH -next v2 5/5] misc: microchip: pci1xxxx: use module_auxiliary_driver

From: Wei Yongjun <[email protected]>

Use the module_auxiliary_driver() macro to make the code simpler
by eliminating module_init and module_exit calls.

Signed-off-by: Wei Yongjun <[email protected]>
---
drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
index fa80a7788596..9cc771c604ed 100644
--- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
+++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
@@ -421,19 +421,7 @@ static struct auxiliary_driver pci1xxxx_gpio_driver = {
.probe = pci1xxxx_gpio_probe,
.id_table = pci1xxxx_gpio_auxiliary_id_table
};
-
-static int __init pci1xxxx_gpio_driver_init(void)
-{
- return auxiliary_driver_register(&pci1xxxx_gpio_driver);
-}
-
-static void __exit pci1xxxx_gpio_driver_exit(void)
-{
- auxiliary_driver_unregister(&pci1xxxx_gpio_driver);
-}
-
-module_init(pci1xxxx_gpio_driver_init);
-module_exit(pci1xxxx_gpio_driver_exit);
+module_auxiliary_driver(pci1xxxx_gpio_driver);

MODULE_DESCRIPTION("Microchip Technology Inc. PCI1xxxx GPIO controller");
MODULE_AUTHOR("Kumaravel Thiagarajan <[email protected]>");
--
2.34.1

2022-09-07 14:45:05

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH -next v2 3/5] misc: microchip: pci1xxxx: Make symbol 'pci1xxxx_gpio_auxiliary_id_table' static

From: Wei Yongjun <[email protected]>

The sparse tool complains as follows:

drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c:409:34: warning:
symbol 'pci1xxxx_gpio_auxiliary_id_table' was not declared. Should it be static?

This symbol is not used outside of mchp_pci1xxxx_gpio.c, so marks it static.

Fixes: 7d3e4d807df2 ("misc: microchip: pci1xxxx: load gpio driver for the gpio controller auxiliary device enumerated by the auxiliary bus driver.")
Reported-by: kernel test robot <[email protected]>
Signed-off-by: Wei Yongjun <[email protected]>
---
v1 -> v2: add fixes tag and reported-by
---
drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
index 47e6e87938ae..4f26871994ee 100644
--- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
+++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
@@ -407,7 +407,7 @@ static int pci1xxxx_gpio_probe(struct auxiliary_device *aux_dev,

static SIMPLE_DEV_PM_OPS(pci1xxxx_gpio_pm_ops, pci1xxxx_gpio_suspend, pci1xxxx_gpio_resume);

-const struct auxiliary_device_id pci1xxxx_gpio_auxiliary_id_table[] = {
+static const struct auxiliary_device_id pci1xxxx_gpio_auxiliary_id_table[] = {
{.name = "mchp_pci1xxxx_gp.gp_gpio"},
{}
};
--
2.34.1

2022-09-07 15:23:17

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH -next v2 2/5] misc: microchip: pci1xxxx: Fix missing spin_lock_init()

From: Wei Yongjun <[email protected]>

The driver allocates the spinlock but not initialize it.
Use spin_lock_init() on it to initialize it correctly.

Fixes: 7d3e4d807df2 ("misc: microchip: pci1xxxx: load gpio driver for the gpio controller auxiliary device enumerated by the auxiliary bus driver.")
Signed-off-by: Wei Yongjun <[email protected]>
---
v1 -> v2: add fixes tag
---
drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
index 230503cca2ff..47e6e87938ae 100644
--- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
+++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
@@ -383,6 +383,7 @@ static int pci1xxxx_gpio_probe(struct auxiliary_device *aux_dev,
if (!priv)
return -ENOMEM;

+ spin_lock_init(&priv->lock);
priv->aux_dev = aux_dev;

if (!devm_request_mem_region(&aux_dev->dev, pdata->region_start, 0x800, aux_dev->name))
--
2.34.1

2022-09-08 06:02:11

by Kumaravel Thiagarajan

[permalink] [raw]
Subject: RE: [PATCH -next v2 1/5] misc: microchip: pci1xxxx: fix error handling in gp_aux_bus_probe()

> -----Original Message-----
> From: Wei Yongjun <[email protected]>
> Sent: Wednesday, September 7, 2022 8:28 PM
> To: Kumaravel Thiagarajan - I21417
> <[email protected]>; Arnd Bergmann
> <[email protected]>; Greg Kroah-Hartman <[email protected]>
> Cc: Wei Yongjun <[email protected]>; [email protected];
> [email protected]
> Subject: [PATCH -next v2 1/5] misc: microchip: pci1xxxx: fix error handling in
> gp_aux_bus_probe()
>
>
> From: Wei Yongjun <[email protected]>
>
> In some error handling path, resoures alloced may not released.
> This patch fix them.
Greg, I have identified some more improvements necessary for the gp_aux_bus_probe function.
I am working on it.
But this patch can still be applied.

>
> Fixes: 393fc2f5948f ("misc: microchip: pci1xxxx: load auxiliary bus driver for the PIO function in the multi-function endpoint of pci1xxxx device.")

Reviewed-by: Kumaravel Thiagarajan <[email protected]>

> Signed-off-by: Wei Yongjun <[email protected]>
> ---
> v1 - > v2: add fixes tag, fix pci_alloc_irq_vectors handing
> ---
> drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
> b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
> index bfc03028b34d..11f79f239006 100644
> --- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
> +++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
> @@ -87,12 +87,13 @@ static int gp_aux_bus_probe(struct pci_dev *pdev,
> const struct pci_device_id *id
> retval = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
>
> if (retval < 0)
> - return retval;
> + goto err_aux_dev_init_1;
>
> - pdev->irq = pci_irq_vector(pdev, 0);
> - if (pdev->irq < 0)
> - return retval;
> + retval = pci_irq_vector(pdev, 0);
> + if (retval < 0)
> + goto err_aux_dev_init_1;
>
> + pdev->irq = retval;
> aux_bus->aux_device_wrapper[1]->gp_aux_data.irq_num = pdev->irq;
>
> retval = auxiliary_device_init(&aux_bus->aux_device_wrapper[1]-
> >aux_dev);
> --
> 2.34.1

2022-09-08 06:03:25

by Kumaravel Thiagarajan

[permalink] [raw]
Subject: RE: [PATCH -next v2 2/5] misc: microchip: pci1xxxx: Fix missing spin_lock_init()

> -----Original Message-----
> From: Wei Yongjun <[email protected]>
> Sent: Wednesday, September 7, 2022 8:28 PM
> To: Kumaravel Thiagarajan - I21417
> <[email protected]>; Arnd Bergmann
> <[email protected]>; Greg Kroah-Hartman <[email protected]>
> Cc: Wei Yongjun <[email protected]>; [email protected];
> [email protected]
> Subject: [PATCH -next v2 2/5] misc: microchip: pci1xxxx: Fix missing
> spin_lock_init()
>
> From: Wei Yongjun <[email protected]>
>
> The driver allocates the spinlock but not initialize it.
> Use spin_lock_init() on it to initialize it correctly.
>
> Fixes: 7d3e4d807df2 ("misc: microchip: pci1xxxx: load gpio driver for the gpio controller auxiliary device enumerated by the auxiliary bus driver.")

Reviewed-by: Kumaravel Thiagarajan <[email protected]>

> Signed-off-by: Wei Yongjun <[email protected]>
> ---
> v1 -> v2: add fixes tag
> ---
> drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
> b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
> index 230503cca2ff..47e6e87938ae 100644
> --- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
> +++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
> @@ -383,6 +383,7 @@ static int pci1xxxx_gpio_probe(struct auxiliary_device
> *aux_dev,
> if (!priv)
> return -ENOMEM;
>
> + spin_lock_init(&priv->lock);
> priv->aux_dev = aux_dev;
>
> if (!devm_request_mem_region(&aux_dev->dev, pdata->region_start,
> 0x800, aux_dev->name))
> --
> 2.34.1

2022-09-08 06:07:04

by Kumaravel Thiagarajan

[permalink] [raw]
Subject: RE: [PATCH -next v2 3/5] misc: microchip: pci1xxxx: Make symbol 'pci1xxxx_gpio_auxiliary_id_table' static

> -----Original Message-----
> From: Wei Yongjun <[email protected]>
> Sent: Wednesday, September 7, 2022 8:28 PM
> To: Kumaravel Thiagarajan - I21417
> <[email protected]>; Arnd Bergmann
> <[email protected]>; Greg Kroah-Hartman <[email protected]>
> Cc: Wei Yongjun <[email protected]>; [email protected];
> [email protected]; kernel test robot <[email protected]>
> Subject: [PATCH -next v2 3/5] misc: microchip: pci1xxxx: Make symbol
> 'pci1xxxx_gpio_auxiliary_id_table' static
>
> From: Wei Yongjun <[email protected]>
>
> The sparse tool complains as follows:
>
> drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c:409:34: warning:
> symbol 'pci1xxxx_gpio_auxiliary_id_table' was not declared. Should it be
> static?
>
> This symbol is not used outside of mchp_pci1xxxx_gpio.c, so marks it static.
>
> Fixes: 7d3e4d807df2 ("misc: microchip: pci1xxxx: load gpio driver for the gpio controller auxiliary device enumerated by the auxiliary bus driver.")
> Reported-by: kernel test robot <[email protected]>
> Signed-off-by: Wei Yongjun <[email protected]>

Reviewed-by: Kumaravel Thiagarajan <[email protected]>

> ---
> v1 -> v2: add fixes tag and reported-by
> ---
> drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
> b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
> index 47e6e87938ae..4f26871994ee 100644
> --- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
> +++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
> @@ -407,7 +407,7 @@ static int pci1xxxx_gpio_probe(struct auxiliary_device
> *aux_dev,
>
> static SIMPLE_DEV_PM_OPS(pci1xxxx_gpio_pm_ops,
> pci1xxxx_gpio_suspend, pci1xxxx_gpio_resume);
>
> -const struct auxiliary_device_id pci1xxxx_gpio_auxiliary_id_table[] = {
> +static const struct auxiliary_device_id pci1xxxx_gpio_auxiliary_id_table[] = {
> {.name = "mchp_pci1xxxx_gp.gp_gpio"},
> {}
> };
> --
> 2.34.1

2022-09-08 07:03:59

by Kumaravel Thiagarajan

[permalink] [raw]
Subject: RE: [PATCH -next v2 5/5] misc: microchip: pci1xxxx: use module_auxiliary_driver

> -----Original Message-----
> From: Wei Yongjun <[email protected]>
> Sent: Wednesday, September 7, 2022 8:28 PM
> To: Kumaravel Thiagarajan - I21417
> <[email protected]>; Arnd Bergmann
> <[email protected]>; Greg Kroah-Hartman <[email protected]>
> Cc: Wei Yongjun <[email protected]>; [email protected];
> [email protected]
> Subject: [PATCH -next v2 5/5] misc: microchip: pci1xxxx: use
> module_auxiliary_driver
>
> From: Wei Yongjun <[email protected]>
>
> Use the module_auxiliary_driver() macro to make the code simpler by
> eliminating module_init and module_exit calls.
>
> Signed-off-by: Wei Yongjun <[email protected]>
Fixes: 7d3e4d807df2 ("misc: microchip: pci1xxxx: load gpio driver for the gpio controller auxiliary device enumerated by the auxiliary bus driver.")

Reviewed-by: Kumaravel Thiagarajan <[email protected]>

> ---
> drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c | 14 +-------------
> 1 file changed, 1 insertion(+), 13 deletions(-)
>
> diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
> b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
> index fa80a7788596..9cc771c604ed 100644
> --- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
> +++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
> @@ -421,19 +421,7 @@ static struct auxiliary_driver pci1xxxx_gpio_driver = {
> .probe = pci1xxxx_gpio_probe,
> .id_table = pci1xxxx_gpio_auxiliary_id_table };
> -
> -static int __init pci1xxxx_gpio_driver_init(void) -{
> - return auxiliary_driver_register(&pci1xxxx_gpio_driver);
> -}
> -
> -static void __exit pci1xxxx_gpio_driver_exit(void) -{
> - auxiliary_driver_unregister(&pci1xxxx_gpio_driver);
> -}
> -
> -module_init(pci1xxxx_gpio_driver_init);
> -module_exit(pci1xxxx_gpio_driver_exit);
> +module_auxiliary_driver(pci1xxxx_gpio_driver);
>
> MODULE_DESCRIPTION("Microchip Technology Inc. PCI1xxxx GPIO
> controller"); MODULE_AUTHOR("Kumaravel Thiagarajan
> <[email protected]>");
> --
> 2.34.1

2022-09-08 07:07:51

by Kumaravel Thiagarajan

[permalink] [raw]
Subject: RE: [PATCH -next v2 4/5] misc: microchip: pci1xxxx: Add missing MODULE_DEVICE_TABLE

> -----Original Message-----
> From: Wei Yongjun <[email protected]>
> Sent: Wednesday, September 7, 2022 8:28 PM
> To: Kumaravel Thiagarajan - I21417
> <[email protected]>; Arnd Bergmann
> <[email protected]>; Greg Kroah-Hartman <[email protected]>
> Cc: Wei Yongjun <[email protected]>; [email protected];
> [email protected]
> Subject: [PATCH -next v2 4/5] misc: microchip: pci1xxxx: Add missing
> MODULE_DEVICE_TABLE
>
> From: Wei Yongjun <[email protected]>
>
> This patch adds missing MODULE_DEVICE_TABLE definition which generates
> correct modalias for automatic loading of this driver when it is built as an
> external module.
>
> Fixes: 7d3e4d807df2 ("misc: microchip: pci1xxxx: load gpio driver for the gpio controller auxiliary device enumerated by the auxiliary bus driver.")
> Signed-off-by: Wei Yongjun <[email protected]>

Reviewed-by: Kumaravel Thiagarajan <[email protected]>

> ---
> v1 -> v2: add fixes tag
> ---
> drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
> b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
> index 4f26871994ee..fa80a7788596 100644
> --- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
> +++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gpio.c
> @@ -411,6 +411,7 @@ static const struct auxiliary_device_id
> pci1xxxx_gpio_auxiliary_id_table[] = {
> {.name = "mchp_pci1xxxx_gp.gp_gpio"},
> {}
> };
> +MODULE_DEVICE_TABLE(auxiliary, pci1xxxx_gpio_auxiliary_id_table);
>
> static struct auxiliary_driver pci1xxxx_gpio_driver = {
> .driver = {
> --
> 2.34.1