gpio: zynq: Update on gpio zynq driver
Subsystems (3)
cover gpio: zynq: Update on gpio zynq driver
This patch series does the following:
-Simplified the code by using module_platform_driver(). -Fixing coverity warnings.
Srinivas Neeli (3):
gpio: zynq: use module_platform_driver to simplify the code
gpio: zynq: Check return value of pm_runtime_get_sync
gpio: zynq: Check return value of irq_get_irq_data
drivers/gpio/gpio-zynq.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-)
Signature · 1 line
2.9.1
PATCH 1/3 gpio: zynq: use module_platform_driver to simplify the code
module_platform_driver() makes the code simpler by eliminating boilerplate code.
--- drivers/gpio/gpio-zynq.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)
drivers/gpio/gpio-zynq.c +1 -16
@@ -1020,22 +1020,7 @@ static struct platform_driver zynq_gpio_driver = { .remove = zynq_gpio_remove, }; -/** -* zynq_gpio_init - Initial driver registration call -* -* Return: value from platform_driver_register -*/ -static int __init zynq_gpio_init (void ) -{ -return platform_driver_register (&zynq_gpio_driver); -} -postcore_initcall (zynq_gpio_init); - -static void __exit zynq_gpio_exit(void) -{ -platform_driver_unregister (&zynq_gpio_driver); -} -module_exit (zynq_gpio_exit); +module_platform_driver (zynq_gpio_driver);MODULE_AUTHOR ("Xilinx Inc." );MODULE_DESCRIPTION ("Zynq GPIO driver" );
Signature · 1 line
2.9.1
A message that is not in the archive (sent off-list or not yet received): CAHp75Vddd6ygr4mJ9Z+SuGZmfLcgDLWLZaxby2XE2mX8War-qQ@mail.gmail.com
Re: [PATCH 1/3] gpio: zynq: use module_platform_driver to simplify the code
Quoted 21 lines · Andy Shevchenko
Quoted 17 lines · Srinivas Neeli
module_platform_driver()makes the code simpler by eliminating boilerplate code.Signed-off-by Srinivas Neeli <[email protected]>--- drivers/gpio/gpio-zynq.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)drivers/gpio/gpio-zynq.c +0
-0@@ -1020,22 +1020,7 @@ static struct platform_driver zynq_gpio_driver = { .remove = zynq_gpio_remove, };
Quoted 15 lines
drivers/gpio/gpio-zynq.c static struct platform_driver zynq_gpio_driver = { · line 1032
Quoted 10 lines
drivers/gpio/gpio-zynq.c +0
-10-/** -* zynq_gpio_init - Initial driver registration call -* -* Return: value from platform_driver_register -*/ -static int __init zynq_gpio_init (void ) -{ -return platform_driver_register (&zynq_gpio_driver); -} -postcore_initcall (zynq_gpio_init);It’s not an equivalent. Have you tested on actual hardware? If no, there is no go for this change.
Yep, this has been like this since the initial introduction of this driver. Unfortunately there's no documented reason so unless we can test it, it has to stay this way.
Bartosz
RE: [PATCH 1/3] gpio: zynq: use module_platform_driver to simplify the code
HI baratosz and Andy,
Quoted 49 lines
-----Original Message-----
From: Bartosz Golaszewski <[email protected]>
Sent: Tuesday, April 13, 2021 4:14 PM
To: Andy Shevchenko <[email protected]>
Cc: Srinivas Neeli <[email protected]>; [email protected]; Michal Simek <[email protected]>; Shubhrajyoti Datta <[email protected]>; Srinivas Goud <[email protected]>; [email protected]; linux-arm- [email protected]; [email protected]; git <[email protected]>
Subject: Re: [PATCH 1/3] gpio: zynq: usemodule_platform_driverto simplify the codeQuoted 13 lines · Andy Shevchenko
Quoted 9 lines · Srinivas Neeli
module_platform_driver()makes the code simpler by eliminating boilerplate code.Signed-off-by Srinivas Neeli <[email protected]>--- drivers/gpio/gpio-zynq.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)Quoted 5 lines
drivers/gpio/gpio-zynq.c static struct platform_driver zynq_gpio_driver
Quoted 5 lines
drivers/gpio/gpio-zynq.c +0
-0@@ -1020,22 +1020,7 @@ static struct platform_driver zynq_gpio_driver= {
Quoted 16 lines
drivers/gpio/gpio-zynq.c static struct platform_driver zynq_gpio_driver = { · line 1032
Quoted 12 lines
drivers/gpio/gpio-zynq.c +0
-9.remove = zynq_gpio_remove, }; -/** -* zynq_gpio_init - Initial driver registration call -* -* Return: value from platform_driver_register -*/ -static int __init zynq_gpio_init(void) -{ -return platform_driver_register (&zynq_gpio_driver); -} -postcore_initcall (zynq_gpio_init);It’s not an equivalent. Have you tested on actual hardware? If no, there is
Quoted 7 lines
no go for this change.
Quoted 1 line
Yep, this has been like this since the initial introduction of this driver. Unfortunately there's no documented reason so unless we can test it, it has to stay this way.
I tested driver, functionality wise everything working fine. Based on below conversation, I moved driver to module driver.
https://lore.kernel.org/patchwork/patch/818202/
Thanks
Srinivas Neeli
Quoted 1 line
Bartosz
Re: [PATCH 1/3] gpio: zynq: use module_platform_driver to simplify the code
Quoted 3 lines · Srinivas Neeli
HI baratosz and Andy,
It's Bartosz. You literally just need to copy & paste the name from my email...
Quoted 52 lines
Quoted 52 lines
-----Original Message-----
From: Bartosz Golaszewski <[email protected]>
Sent: Tuesday, April 13, 2021 4:14 PM
To: Andy Shevchenko <[email protected]>
Cc: Srinivas Neeli <[email protected]>; [email protected]; Michal Simek <[email protected]>; Shubhrajyoti Datta <[email protected]>; Srinivas Goud <[email protected]>; [email protected]; linux-arm- [email protected]; [email protected]; git <[email protected]>
Subject: Re: [PATCH 1/3] gpio: zynq: usemodule_platform_driverto simplify the codeQuoted 13 lines · Andy Shevchenko
Quoted 9 lines · Srinivas Neeli
module_platform_driver()makes the code simpler by eliminating boilerplate code.Signed-off-by Srinivas Neeli <[email protected]>--- drivers/gpio/gpio-zynq.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)Quoted 5 lines
drivers/gpio/gpio-zynq.c static struct platform_driver zynq_gpio_driver
Quoted 5 lines
drivers/gpio/gpio-zynq.c +0
-0@@ -1020,22 +1020,7 @@ static struct platform_driver zynq_gpio_driver= {
Quoted 16 lines
drivers/gpio/gpio-zynq.c static struct platform_driver zynq_gpio_driver = { · line 1032
Quoted 12 lines
drivers/gpio/gpio-zynq.c +0
-9.remove = zynq_gpio_remove, }; -/** -* zynq_gpio_init - Initial driver registration call -* -* Return: value from platform_driver_register -*/ -static int __init zynq_gpio_init(void) -{ -return platform_driver_register (&zynq_gpio_driver); -} -postcore_initcall (zynq_gpio_init);It’s not an equivalent. Have you tested on actual hardware? If no, there is
no go for this change.
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Yep, this has been like this since the initial introduction of this driver. Unfortunately there's no documented reason so unless we can test it, it has to stay this way.
I tested driver, functionality wise everything working fine. Based on below conversation, I moved driver to module driver.
https://lore.kernel.org/patchwork/patch/818202/
Andy: How about we give it a try then? If anyone yells, we'll just revert it.
Quoted 4 lines
Thanks
Srinivas NeeliQuoted 1 line
Bartosz
Bartosz
Re: [PATCH 1/3] gpio: zynq: use module_platform_driver to simplify the code
Quoted 5 lines · Bartosz Golaszewski
Quoted 4 lines · Srinivas Neeli
Quoted 4 lines
From: Bartosz Golaszewski <[email protected]>
Sent: Tuesday, April 13, 2021 4:14 PM
On Sat, Apr 10, 2021 at 12:08 AM Andy Shevchenko <[email protected]> wrote:
...
Quoted 10 lines
Quoted 8 lines
Quoted 4 lines
Yep, this has been like this since the initial introduction of this driver. Unfortunately there's no documented reason so unless we can test it, it has to stay this way.
I tested driver, functionality wise everything working fine. Based on below conversation, I moved driver to module driver.
https://lore.kernel.org/patchwork/patch/818202/Andy: How about we give it a try then? If anyone yells, we'll just revert it.
Sounds like a plan!
Signature · 2 lines
With Best Regards, Andy Shevchenko
RE: [PATCH 1/3] gpio: zynq: use module_platform_driver to simplify the code
In reply to Bartosz GolaszewskiHi,
Quoted 77 lines
-----Original Message-----
From: Bartosz Golaszewski <[email protected]>
Sent: Friday, April 16, 2021 11:58 PM
To: Srinivas Neeli <[email protected]>
Cc: Andy Shevchenko <[email protected]>; [email protected]; Michal Simek <[email protected]>; Shubhrajyoti Datta <[email protected]>; Srinivas Goud <[email protected]>; linux- [email protected]; [email protected]; linux- [email protected]; git <[email protected]>
Subject: Re: [PATCH 1/3] gpio: zynq: usemodule_platform_driverto simplify the codeQuoted 3 lines · Srinivas Neeli
HI baratosz and Andy,
It's Bartosz. You literally just need to copy & paste the name from my email...
Quoted 18 lines
Quoted 18 lines
-----Original Message-----
From: Bartosz Golaszewski <[email protected]>
Sent: Tuesday, April 13, 2021 4:14 PM
To: Andy Shevchenko <[email protected]>
Cc: Srinivas Neeli <[email protected]>; [email protected]; Michal Simek <[email protected]>; Shubhrajyoti Datta <[email protected]>; Srinivas Goud <[email protected]>; [email protected]; linux-arm- [email protected]; [email protected]; git <[email protected]>
Subject: Re: [PATCH 1/3] gpio: zynq: usemodule_platform_driverto simplify the codeQuoted 4 lines · Andy Shevchenko
On Friday, April 9, 2021, Srinivas Neeli <[email protected]>
Quoted 39 lines · wrote:
Quoted 39 lines
Quoted 9 lines
Quoted 9 lines
module_platform_driver()makes the code simpler by eliminating boilerplate code.Signed-off-by Srinivas Neeli <[email protected]>--- drivers/gpio/gpio-zynq.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)Quoted 6 lines
Quoted 6 lines
drivers/gpio/gpio-zynq.c +0
-0@@ -1020,22 +1020,7 @@ static struct platform_driver
zynq_gpio_driver= {
Quoted 16 lines
drivers/gpio/gpio-zynq.c static struct platform_driver zynq_gpio_driver = { · line 1032
Quoted 11 lines
.remove = zynq_gpio_remove, };drivers/gpio/gpio-zynq.c +0
-9-/** -* zynq_gpio_init - Initial driver registration call -* -* Return: value from platform_driver_register -*/ -static int __init zynq_gpio_init(void) -{ -return platform_driver_register (&zynq_gpio_driver); -} -postcore_initcall (zynq_gpio_init);It’s not an equivalent. Have you tested on actual hardware? If no, there is
no go for this change.
Quoted 1 line
Yep, this has been like this since the initial introduction of this driver. Unfortunately there's no documented reason so unless we can test it, it has to stay this way.
Quoted 6 lines
Quoted 4 lines
I tested driver, functionality wise everything working fine. Based on below conversation, I moved driver to module driver.
https://lore.kernel.org/patchwork/patch/818202/Andy: How about we give it a try then? If anyone yells, we'll just revert it.
Could you please apply this series to gpio for-next branch if there are no issues .
Quoted 7 lines
Quoted 5 lines
Thanks
Srinivas NeeliQuoted 1 line
Bartosz
Bartosz
Thanks
Srinivas Neeli
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Bartosz Golaszewski
AppliedRe: [PATCH 1/3] gpio: zynq: use module_platform_driver to simplify the code
Quoted 6 lines · Srinivas Neeli
Quoted 3 lines
Andy: How about we give it a try then? If anyone yells, we'll just revert it.
Could you please apply this series to gpio for-next branch if there are no issues .
Applied, thanks!
Bart
PATCH 2/3 gpio: zynq: Check return value of pm_runtime_get_sync
In reply to Srinivas NeeliReturn value of "pm_runtime_get_sync" API was neither captured nor checked. Fixed it by capturing the return value and then checking for any warning.
Addresses-Coverity: "check_return"
--- drivers/gpio/gpio-zynq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpio/gpio-zynq.c +4 -1
@@ -1001,8 +1001,11 @@ static int zynq_gpio_probe(struct platform_device *pdev)static int zynq_gpio_remove (struct platform_device *pdev) {struct zynq_gpio *gpio =platform_get_drvdata (pdev); +int ret; -pm_runtime_get_sync (&pdev->dev); + ret =pm_runtime_get_sync (&pdev->dev); +if (ret <0 ) +dev_warn (&pdev->dev,"pm_runtime_get_sync() Failed\n" );gpiochip_remove (&gpio->chip);clk_disable_unprepare (gpio->clk);device_set_wakeup_capable (&pdev->dev,0 );
Signature · 1 line
2.9.1
PATCH 3/3 gpio: zynq: Check return value of irq_get_irq_data
In reply to Srinivas NeeliIn two different instances the return value of "irq_get_irq_data" API was neither captured nor checked.
Fixed it by capturing the return value and then checking for any error.
Addresses-Coverity: "returned_null"
--- drivers/gpio/gpio-zynq.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpio/gpio-zynq.c +10 -0
@@ -736,6 +736,11 @@ static int __maybe_unused zynq_gpio_suspend(struct device *dev)struct zynq_gpio *gpio =dev_get_drvdata (dev);struct irq_data *data =irq_get_irq_data (gpio->irq); +if (!data) { +dev_err (dev,"irq_get_irq_data() failed\n" ); +return -EINVAL ; + } +if (!device_may_wakeup (dev))disable_irq (gpio->irq);
@@ -753,6 +758,11 @@ static int __maybe_unused zynq_gpio_resume(struct device *dev)struct irq_data *data =irq_get_irq_data (gpio->irq);int ret; +if (!data) { +dev_err (dev,"irq_get_irq_data() failed\n" ); +return -EINVAL ; + } +if (!device_may_wakeup (dev))enable_irq (gpio->irq);
Signature · 1 line
2.9.1
Re: [PATCH 3/3] gpio: zynq: Check return value of irq_get_irq_data
Quoted 15 lines · Srinivas Neeli
In two different instances the return value of "
irq_get_irq_data" API was neither captured nor checked.
Fixed it by capturing the return value and then checking for any error.Addresses-Coverity: "
returned_null"Signed-off-by Srinivas Neeli <[email protected]>--- drivers/gpio/gpio-zynq.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/gpio/gpio-zynq.c +0
-0
drivers/gpio/gpio-zynq.c static int __maybe_unused zynq_gpio_suspend(struct device *dev) · line 740
Quoted 5 lines
drivers/gpio/gpio-zynq.c +2
-0@@ -736,6 +736,11 @@ static int __maybe_unused zynq_gpio_suspend(struct device *dev)struct zynq_gpio *gpio =dev_get_drvdata (dev);struct irq_data *data =irq_get_irq_data (gpio->irq); +if (!data) { +dev_err (dev,"irq_get_irq_data() failed\n" );
It will be useful to include a tag such as "suspend: " in the error message to uniquely identify where it failed from.
drivers/gpio/gpio-zynq.c static int __maybe_unused zynq_gpio_resume(struct device *dev) · line 762
Quoted 12 lines
drivers/gpio/gpio-zynq.c +5
-0+return -EINVAL ; + } +if (!device_may_wakeup (dev))disable_irq (gpio->irq);@@ -753,6 +758,11 @@ static int __maybe_unused zynq_gpio_resume(struct device *dev)struct irq_data *data =irq_get_irq_data (gpio->irq);int ret; +if (!data) { +dev_err (dev,"irq_get_irq_data() failed\n" );
Ditto. Suggest using "resume: " tag here.
Quoted 9 lines
drivers/gpio/gpio-zynq.c +3
-0+return -EINVAL ; + } +if (!device_may_wakeup (dev))enable_irq (gpio->irq);Signature · 1 line
2.9.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel