Hello Maxim Kochetkov,

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.

drivers/soc/fsl/qe/qe_ic.c
    408 static int qe_ic_init(struct platform_device *pdev)
    409 {
    410         struct device *dev = &pdev->dev;
    411         void (*low_handler)(struct irq_desc *desc);
    412         void (*high_handler)(struct irq_desc *desc);
    413         struct qe_ic *qe_ic;
    414         struct resource *res;
    415         struct device_node *node = pdev->dev.of_node;
    416 
    417         res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
    418         if (res == NULL) {
    419                 dev_err(dev, "no memory resource defined\n");
    420                 return -ENODEV;
    421         }
    422 
    423         qe_ic = devm_kzalloc(dev, sizeof(*qe_ic), GFP_KERNEL);
    424         if (qe_ic == NULL)
    425                 return -ENOMEM;
    426 
    427         qe_ic->regs = devm_ioremap(dev, res->start, resource_size(res));
    428         if (qe_ic->regs == NULL) {
    429                 dev_err(dev, "failed to ioremap() registers\n");
    430                 return -ENODEV;
    431         }
    432 
    433         qe_ic->hc_irq = qe_ic_irq_chip;
    434 
    435         qe_ic->virq_high = platform_get_irq(pdev, 0);
    436         qe_ic->virq_low = platform_get_irq(pdev, 1);
    437 
--> 438         if (qe_ic->virq_low < 0) {
    439                 return -ENODEV;
    440         }

Unsigned can't be less than zero.  It's weird that it doesn't check
qe_ic->virq_high as well.  Also remove the curly braces to make
checkpatch happy?

    441 
    442         if (qe_ic->virq_high != qe_ic->virq_low) {
    443                 low_handler = qe_ic_cascade_low;
    444                 high_handler = qe_ic_cascade_high;
    445         } else {
    446                 low_handler = qe_ic_cascade_muxed_mpic;
    447                 high_handler = NULL;
    448         }
    449 
    450         qe_ic->irqhost = irq_domain_add_linear(node, NR_QE_IC_INTS,
    451                                                &qe_ic_host_ops, qe_ic);
    452         if (qe_ic->irqhost == NULL) {
    453                 dev_err(dev, "failed to add irq domain\n");
    454                 return -ENODEV;
    455         }
    456 
    457         qe_ic_write(qe_ic->regs, QEIC_CICR, 0);
    458 
    459         irq_set_handler_data(qe_ic->virq_low, qe_ic);
    460         irq_set_chained_handler(qe_ic->virq_low, low_handler);
    461 
    462         if (qe_ic->virq_high && qe_ic->virq_high != qe_ic->virq_low) {
    463                 irq_set_handler_data(qe_ic->virq_high, qe_ic);
    464                 irq_set_chained_handler(qe_ic->virq_high, high_handler);
    465         }
    466         return 0;
    467 }

regards,
dan carpenter

Reply via email to