* [PATCH] soc: fsl: qe: fix static checker warning
@ 2021-08-11 7:10 Maxim Kochetkov
2021-08-13 21:39 ` Li Yang
0 siblings, 1 reply; 2+ messages in thread
From: Maxim Kochetkov @ 2021-08-11 7:10 UTC (permalink / raw)
To: Qiang Zhao, Li Yang, Maxim Kochetkov, Saravana Kannan
Cc: Dan Carpenter, linuxppc-dev, linux-arm-kernel, linux-kernel
The patch be7ecbd240b2: "soc: fsl: qe: convert QE interrupt
controller to platform_device" from Aug 3, 2021, leads to the
following static checker warning:
drivers/soc/fsl/qe/qe_ic.c:438 qe_ic_init()
warn: unsigned 'qe_ic->virq_low' is never less than zero.
In old variant irq_of_parse_and_map() returns zero if failed so
unsigned int for virq_high/virq_low was ok.
In new variant platform_get_irq() returns negative error codes
if failed so we need to use int for virq_high/virq_low.
Also simplify high_handler checking and remove the curly braces
to make checkpatch happy.
Fixes: be7ecbd240b2 ("soc: fsl: qe: convert QE interrupt controller to platform_device")
Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/soc/fsl/qe/qe_ic.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/soc/fsl/qe/qe_ic.c b/drivers/soc/fsl/qe/qe_ic.c
index e710d554425d..bff34ee2150a 100644
--- a/drivers/soc/fsl/qe/qe_ic.c
+++ b/drivers/soc/fsl/qe/qe_ic.c
@@ -54,8 +54,8 @@ struct qe_ic {
struct irq_chip hc_irq;
/* VIRQ numbers of QE high/low irqs */
- unsigned int virq_high;
- unsigned int virq_low;
+ int virq_high;
+ int virq_low;
};
/*
@@ -435,9 +435,8 @@ static int qe_ic_init(struct platform_device *pdev)
qe_ic->virq_high = platform_get_irq(pdev, 0);
qe_ic->virq_low = platform_get_irq(pdev, 1);
- if (qe_ic->virq_low < 0) {
+ if (qe_ic->virq_low < 0)
return -ENODEV;
- }
if (qe_ic->virq_high != qe_ic->virq_low) {
low_handler = qe_ic_cascade_low;
@@ -459,7 +458,7 @@ static int qe_ic_init(struct platform_device *pdev)
irq_set_handler_data(qe_ic->virq_low, qe_ic);
irq_set_chained_handler(qe_ic->virq_low, low_handler);
- if (qe_ic->virq_high && qe_ic->virq_high != qe_ic->virq_low) {
+ if (high_handler) {
irq_set_handler_data(qe_ic->virq_high, qe_ic);
irq_set_chained_handler(qe_ic->virq_high, high_handler);
}
--
2.31.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] soc: fsl: qe: fix static checker warning
2021-08-11 7:10 [PATCH] soc: fsl: qe: fix static checker warning Maxim Kochetkov
@ 2021-08-13 21:39 ` Li Yang
0 siblings, 0 replies; 2+ messages in thread
From: Li Yang @ 2021-08-13 21:39 UTC (permalink / raw)
To: Maxim Kochetkov
Cc: Qiang Zhao, Saravana Kannan, linuxppc-dev,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
Dan Carpenter, lkml
On Wed, Aug 11, 2021 at 2:10 AM Maxim Kochetkov <fido_max@inbox.ru> wrote:
>
> The patch be7ecbd240b2: "soc: fsl: qe: convert QE interrupt
> controller to platform_device" from Aug 3, 2021, leads to the
> following static checker warning:
>
> drivers/soc/fsl/qe/qe_ic.c:438 qe_ic_init()
> warn: unsigned 'qe_ic->virq_low' is never less than zero.
>
> In old variant irq_of_parse_and_map() returns zero if failed so
> unsigned int for virq_high/virq_low was ok.
> In new variant platform_get_irq() returns negative error codes
> if failed so we need to use int for virq_high/virq_low.
>
> Also simplify high_handler checking and remove the curly braces
> to make checkpatch happy.
>
> Fixes: be7ecbd240b2 ("soc: fsl: qe: convert QE interrupt controller to platform_device")
> Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/soc/fsl/qe/qe_ic.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/soc/fsl/qe/qe_ic.c b/drivers/soc/fsl/qe/qe_ic.c
> index e710d554425d..bff34ee2150a 100644
> --- a/drivers/soc/fsl/qe/qe_ic.c
> +++ b/drivers/soc/fsl/qe/qe_ic.c
> @@ -54,8 +54,8 @@ struct qe_ic {
> struct irq_chip hc_irq;
>
> /* VIRQ numbers of QE high/low irqs */
> - unsigned int virq_high;
> - unsigned int virq_low;
> + int virq_high;
> + int virq_low;
> };
>
> /*
> @@ -435,9 +435,8 @@ static int qe_ic_init(struct platform_device *pdev)
> qe_ic->virq_high = platform_get_irq(pdev, 0);
> qe_ic->virq_low = platform_get_irq(pdev, 1);
>
> - if (qe_ic->virq_low < 0) {
> + if (qe_ic->virq_low < 0)
Probably should be <= 0 here.
> return -ENODEV;
> - }
>
> if (qe_ic->virq_high != qe_ic->virq_low) {
Probably we should check if qe_ic->virq_high > 0 here if we rely on
this to decide whether to set the handler later.
Applied with the above changes. Thanks
> low_handler = qe_ic_cascade_low;
> @@ -459,7 +458,7 @@ static int qe_ic_init(struct platform_device *pdev)
> irq_set_handler_data(qe_ic->virq_low, qe_ic);
> irq_set_chained_handler(qe_ic->virq_low, low_handler);
>
> - if (qe_ic->virq_high && qe_ic->virq_high != qe_ic->virq_low) {
> + if (high_handler) {
> irq_set_handler_data(qe_ic->virq_high, qe_ic);
> irq_set_chained_handler(qe_ic->virq_high, high_handler);
> }
> --
> 2.31.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-13 21:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11 7:10 [PATCH] soc: fsl: qe: fix static checker warning Maxim Kochetkov
2021-08-13 21:39 ` Li Yang
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).