* [PATCH] spi: davinci: Remove dead code in `davinci_spi_probe()`
@ 2023-04-23 3:24 Li Ningke
2023-04-24 11:48 ` Mark Brown
0 siblings, 1 reply; 7+ messages in thread
From: Li Ningke @ 2023-04-23 3:24 UTC (permalink / raw)
To: Mark Brown
Cc: hust-os-kernel-patches, Li Ningke, Dongliang Mu, linux-spi, linux-kernel
Smatch complains that
drivers/spi/spi-davinci.c:915 davinci_spi_probe() warn:
platform_get_irq() does not return zero
There is no need to check whether the return value is zero as
`platform_get_irq()` only returns non-zero IRQ number on success
or negative error number on failure, removing them to solve this
problem.
Signed-off-by: Li Ningke <lnk_01@hust.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
---
The issue is found by static analysis and the patch remains untested.
---
drivers/spi/spi-davinci.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index d112c2cac042..fdb241e3a7bf 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -912,8 +912,6 @@ static int davinci_spi_probe(struct platform_device *pdev)
init_completion(&dspi->done);
ret = platform_get_irq(pdev, 0);
- if (ret == 0)
- ret = -EINVAL;
if (ret < 0)
goto free_master;
dspi->irq = ret;
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] spi: davinci: Remove dead code in `davinci_spi_probe()`
2023-04-23 3:24 [PATCH] spi: davinci: Remove dead code in `davinci_spi_probe()` Li Ningke
@ 2023-04-24 11:48 ` Mark Brown
2023-04-24 12:03 ` Dongliang Mu
0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2023-04-24 11:48 UTC (permalink / raw)
To: Li Ningke; +Cc: hust-os-kernel-patches, Dongliang Mu, linux-spi, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 479 bytes --]
On Sun, Apr 23, 2023 at 03:24:46AM +0000, Li Ningke wrote:
> Smatch complains that
> drivers/spi/spi-davinci.c:915 davinci_spi_probe() warn:
> platform_get_irq() does not return zero
>
> There is no need to check whether the return value is zero as
> `platform_get_irq()` only returns non-zero IRQ number on success
> or negative error number on failure, removing them to solve this
> problem.
Is that check valid? 0 was a valid interrupt for some architectures...
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] spi: davinci: Remove dead code in `davinci_spi_probe()`
2023-04-24 11:48 ` Mark Brown
@ 2023-04-24 12:03 ` Dongliang Mu
2023-04-24 15:52 ` Mark Brown
0 siblings, 1 reply; 7+ messages in thread
From: Dongliang Mu @ 2023-04-24 12:03 UTC (permalink / raw)
To: Mark Brown, Li Ningke; +Cc: hust-os-kernel-patches, linux-spi, linux-kernel
On 2023/4/24 19:48, Mark Brown wrote:
> On Sun, Apr 23, 2023 at 03:24:46AM +0000, Li Ningke wrote:
>> Smatch complains that
>> drivers/spi/spi-davinci.c:915 davinci_spi_probe() warn:
>> platform_get_irq() does not return zero
>>
>> There is no need to check whether the return value is zero as
>> `platform_get_irq()` only returns non-zero IRQ number on success
>> or negative error number on failure, removing them to solve this
>> problem.
> Is that check valid? 0 was a valid interrupt for some architectures...
We just follow the comments of platform_get_irq().
/**
* platform_get_irq - get an IRQ for a device
* @dev: platform device
* @num: IRQ number index
*
* Gets an IRQ for a platform device and prints an error message if
finding the
* IRQ fails. Device drivers should check the return value for errors
so as to
* not pass a negative integer value to the request_irq() APIs.
*
* For example::
*
* int irq = platform_get_irq(pdev, 0);
* if (irq < 0)
* return irq;
*
* Return: non-zero IRQ number on success, negative error number on
failure.
*/
int platform_get_irq(struct platform_device *dev, unsigned int num)
{
int ret;
ret = platform_get_irq_optional(dev, num);
if (ret < 0)
return dev_err_probe(&dev->dev, ret,
"IRQ index %u not found\n", num);
return ret;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] spi: davinci: Remove dead code in `davinci_spi_probe()`
2023-04-24 12:03 ` Dongliang Mu
@ 2023-04-24 15:52 ` Mark Brown
2023-04-26 1:50 ` Dongliang Mu
0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2023-04-24 15:52 UTC (permalink / raw)
To: Dongliang Mu; +Cc: Li Ningke, hust-os-kernel-patches, linux-spi, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 666 bytes --]
On Mon, Apr 24, 2023 at 08:03:42PM +0800, Dongliang Mu wrote:
> On 2023/4/24 19:48, Mark Brown wrote:
> > Is that check valid? 0 was a valid interrupt for some architectures...
> We just follow the comments of platform_get_irq().
> * Gets an IRQ for a platform device and prints an error message if finding
> the
> * IRQ fails. Device drivers should check the return value for errors so as
> to
> * not pass a negative integer value to the request_irq() APIs.
I'm not sure that's universally true yet, though there were some moves
to try to get us there. arm, where this driver is used, was one of the
platforms with 0 as a valid interrupt.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] spi: davinci: Remove dead code in `davinci_spi_probe()`
2023-04-24 15:52 ` Mark Brown
@ 2023-04-26 1:50 ` Dongliang Mu
2023-04-26 14:13 ` Mark Brown
0 siblings, 1 reply; 7+ messages in thread
From: Dongliang Mu @ 2023-04-26 1:50 UTC (permalink / raw)
To: Mark Brown
Cc: Li Ningke, hust-os-kernel-patches, linux-spi, linux-kernel,
Dan Carpenter
On 2023/4/24 23:52, Mark Brown wrote:
> On Mon, Apr 24, 2023 at 08:03:42PM +0800, Dongliang Mu wrote:
>> On 2023/4/24 19:48, Mark Brown wrote:
>>> Is that check valid? 0 was a valid interrupt for some architectures...
>> We just follow the comments of platform_get_irq().
>> * Gets an IRQ for a platform device and prints an error message if finding
>> the
>> * IRQ fails. Device drivers should check the return value for errors so as
>> to
>> * not pass a negative integer value to the request_irq() APIs.
> I'm not sure that's universally true yet, though there were some moves
> to try to get us there. arm, where this driver is used, was one of the
> platforms with 0 as a valid interrupt.
Hi Brown,
First, we're sorry about the fact that our internal robot(beta) made a
mistake and sent our testing message to LKML. We have fixed the
incorrect logic.
Second, from code review of platform_get_irq /
platform_get_irq_optional, it would warn IRQ 0 as an invalid IRQ number.
out:
if (WARN(!ret, "0 is an invalid IRQ number\n"))
return -EINVAL;
return ret;
Dongliang Mu
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] spi: davinci: Remove dead code in `davinci_spi_probe()`
2023-04-26 1:50 ` Dongliang Mu
@ 2023-04-26 14:13 ` Mark Brown
2023-04-26 15:07 ` Dongliang Mu
0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2023-04-26 14:13 UTC (permalink / raw)
To: Dongliang Mu
Cc: Li Ningke, hust-os-kernel-patches, linux-spi, linux-kernel,
Dan Carpenter
[-- Attachment #1: Type: text/plain, Size: 358 bytes --]
On Wed, Apr 26, 2023 at 09:50:26AM +0800, Dongliang Mu wrote:
> Second, from code review of platform_get_irq / platform_get_irq_optional, it
> would warn IRQ 0 as an invalid IRQ number.
> out:
> if (WARN(!ret, "0 is an invalid IRQ number\n"))
> return -EINVAL;
> return ret;
Like I say I'm not sure that's actually accurate for all architectures
yet.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] spi: davinci: Remove dead code in `davinci_spi_probe()`
2023-04-26 14:13 ` Mark Brown
@ 2023-04-26 15:07 ` Dongliang Mu
0 siblings, 0 replies; 7+ messages in thread
From: Dongliang Mu @ 2023-04-26 15:07 UTC (permalink / raw)
To: Mark Brown
Cc: Li Ningke, hust-os-kernel-patches, linux-spi, linux-kernel,
Dan Carpenter
On 2023/4/26 22:13, Mark Brown wrote:
> On Wed, Apr 26, 2023 at 09:50:26AM +0800, Dongliang Mu wrote:
>
>> Second, from code review of platform_get_irq / platform_get_irq_optional, it
>> would warn IRQ 0 as an invalid IRQ number.
>> out:
>> if (WARN(!ret, "0 is an invalid IRQ number\n"))
>> return -EINVAL;
>> return ret;
> Like I say I'm not sure that's actually accurate for all architectures
> yet.
I see. Let's wait and see. When it becomes stable and universal for all
architectures, we could clean up them all together.
Currently our team just works to make Smatch happy :)
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-04-26 15:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-23 3:24 [PATCH] spi: davinci: Remove dead code in `davinci_spi_probe()` Li Ningke
2023-04-24 11:48 ` Mark Brown
2023-04-24 12:03 ` Dongliang Mu
2023-04-24 15:52 ` Mark Brown
2023-04-26 1:50 ` Dongliang Mu
2023-04-26 14:13 ` Mark Brown
2023-04-26 15:07 ` Dongliang Mu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).