Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: fsl: qe: fix static checker warning

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>
Signed-off-by: Li Yang <leoyang.li@nxp.com>

authored by

Maxim Kochetkov and committed by
Li Yang
c1e64c0a be7ecbd2

+5 -6
+5 -6
drivers/soc/fsl/qe/qe_ic.c
··· 54 54 struct irq_chip hc_irq; 55 55 56 56 /* VIRQ numbers of QE high/low irqs */ 57 - unsigned int virq_high; 58 - unsigned int virq_low; 57 + int virq_high; 58 + int virq_low; 59 59 }; 60 60 61 61 /* ··· 435 435 qe_ic->virq_high = platform_get_irq(pdev, 0); 436 436 qe_ic->virq_low = platform_get_irq(pdev, 1); 437 437 438 - if (qe_ic->virq_low < 0) { 438 + if (qe_ic->virq_low <= 0) 439 439 return -ENODEV; 440 - } 441 440 442 - if (qe_ic->virq_high != qe_ic->virq_low) { 441 + if (qe_ic->virq_high > 0 && qe_ic->virq_high != qe_ic->virq_low) { 443 442 low_handler = qe_ic_cascade_low; 444 443 high_handler = qe_ic_cascade_high; 445 444 } else { ··· 458 459 irq_set_handler_data(qe_ic->virq_low, qe_ic); 459 460 irq_set_chained_handler(qe_ic->virq_low, low_handler); 460 461 461 - if (qe_ic->virq_high && qe_ic->virq_high != qe_ic->virq_low) { 462 + if (high_handler) { 462 463 irq_set_handler_data(qe_ic->virq_high, qe_ic); 463 464 irq_set_chained_handler(qe_ic->virq_high, high_handler); 464 465 }