linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: fido_max@inbox.ru
Cc: linuxppc-dev@lists.ozlabs.org
Subject: [bug report] soc: fsl: qe: convert QE interrupt controller to platform_device
Date: Tue, 10 Aug 2021 10:48:07 +0300	[thread overview]
Message-ID: <20210810074807.GA21565@kili> (raw)

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	other threads:[~2021-08-10  7:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210810074807.GA21565@kili \
    --to=dan.carpenter@oracle.com \
    --cc=fido_max@inbox.ru \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).