[gpio:for-next 51/71] drivers/gpio/gpio-dwapb.c:627:7-17: WARNING: Unsigned expression compared with zero: pp -> irq [ j ] >= 0 (fwd)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Coccinelle considers that the irq field is unsigned so the test pp->irq[j]
>= 0 is always true.

julia


---------- Forwarded message ----------
Date: Fri, 25 May 2018 21:40:23 +0800
From: kbuild test robot <lkp@xxxxxxxxx>
To: kbuild@xxxxxx
Cc: Julia Lawall <julia.lawall@xxxxxxx>
Subject: [gpio:for-next 51/71] drivers/gpio/gpio-dwapb.c:627:7-17: WARNING:
    Unsigned expression compared with zero: pp -> irq [ j ] >= 0

CC: kbuild-all@xxxxxx
CC: linux-gpio@xxxxxxxxxxxxxxx
TO: Phil Edworthy <phil.edworthy@xxxxxxxxxxx>
CC: Linus Walleij <linus.walleij@xxxxxxxxxx>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git for-next
head:   84bf021ecee4e50b63ab5e5563a5202e69cb5623
commit: da069d5d2b814d9887989dcdb29fb0202eac8b38 [51/71] gpio: dwapb: Rework support for 1 interrupt per port A GPIO
:::::: branch date: 23 hours ago
:::::: commit date: 2 days ago

>> drivers/gpio/gpio-dwapb.c:627:7-17: WARNING: Unsigned expression compared with zero: pp -> irq [ j ] >= 0

# https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git/commit/?id=da069d5d2b814d9887989dcdb29fb0202eac8b38
git remote add gpio https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git
git remote update gpio
git checkout da069d5d2b814d9887989dcdb29fb0202eac8b38
vim +627 drivers/gpio/gpio-dwapb.c

7779b3455 Jamie Iles    2014-02-25  557
3d2613c42 Weike Chen    2014-09-17  558  static struct dwapb_platform_data *
4ba8cfa79 Jiang Qiu     2016-04-28  559  dwapb_gpio_get_pdata(struct device *dev)
3d2613c42 Weike Chen    2014-09-17  560  {
4ba8cfa79 Jiang Qiu     2016-04-28  561  	struct fwnode_handle *fwnode;
3d2613c42 Weike Chen    2014-09-17  562  	struct dwapb_platform_data *pdata;
3d2613c42 Weike Chen    2014-09-17  563  	struct dwapb_port_property *pp;
3d2613c42 Weike Chen    2014-09-17  564  	int nports;
da069d5d2 Phil Edworthy 2018-05-23  565  	int i, j;
3d2613c42 Weike Chen    2014-09-17  566
4ba8cfa79 Jiang Qiu     2016-04-28  567  	nports = device_get_child_node_count(dev);
3d2613c42 Weike Chen    2014-09-17  568  	if (nports == 0)
3d2613c42 Weike Chen    2014-09-17  569  		return ERR_PTR(-ENODEV);
3d2613c42 Weike Chen    2014-09-17  570
da9df93e9 Axel Lin      2014-12-28  571  	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
3d2613c42 Weike Chen    2014-09-17  572  	if (!pdata)
3d2613c42 Weike Chen    2014-09-17  573  		return ERR_PTR(-ENOMEM);
3d2613c42 Weike Chen    2014-09-17  574
da9df93e9 Axel Lin      2014-12-28  575  	pdata->properties = devm_kcalloc(dev, nports, sizeof(*pp), GFP_KERNEL);
da9df93e9 Axel Lin      2014-12-28  576  	if (!pdata->properties)
3d2613c42 Weike Chen    2014-09-17  577  		return ERR_PTR(-ENOMEM);
3d2613c42 Weike Chen    2014-09-17  578
3d2613c42 Weike Chen    2014-09-17  579  	pdata->nports = nports;
3d2613c42 Weike Chen    2014-09-17  580
3d2613c42 Weike Chen    2014-09-17  581  	i = 0;
4ba8cfa79 Jiang Qiu     2016-04-28  582  	device_for_each_child_node(dev, fwnode)  {
da069d5d2 Phil Edworthy 2018-05-23  583  		struct device_node *np = NULL;
da069d5d2 Phil Edworthy 2018-05-23  584
3d2613c42 Weike Chen    2014-09-17  585  		pp = &pdata->properties[i++];
4ba8cfa79 Jiang Qiu     2016-04-28  586  		pp->fwnode = fwnode;
3d2613c42 Weike Chen    2014-09-17  587
4ba8cfa79 Jiang Qiu     2016-04-28  588  		if (fwnode_property_read_u32(fwnode, "reg", &pp->idx) ||
3d2613c42 Weike Chen    2014-09-17  589  		    pp->idx >= DWAPB_MAX_PORTS) {
e81591815 Jiang Qiu     2016-04-28  590  			dev_err(dev,
e81591815 Jiang Qiu     2016-04-28  591  				"missing/invalid port index for port%d\n", i);
bfab7c8ff Wei Yongjun   2016-07-10  592  			fwnode_handle_put(fwnode);
3d2613c42 Weike Chen    2014-09-17  593  			return ERR_PTR(-EINVAL);
3d2613c42 Weike Chen    2014-09-17  594  		}
3d2613c42 Weike Chen    2014-09-17  595
4ba8cfa79 Jiang Qiu     2016-04-28  596  		if (fwnode_property_read_u32(fwnode, "snps,nr-gpios",
3d2613c42 Weike Chen    2014-09-17  597  					 &pp->ngpio)) {
e81591815 Jiang Qiu     2016-04-28  598  			dev_info(dev,
e81591815 Jiang Qiu     2016-04-28  599  				 "failed to get number of gpios for port%d\n",
e81591815 Jiang Qiu     2016-04-28  600  				 i);
3d2613c42 Weike Chen    2014-09-17  601  			pp->ngpio = 32;
3d2613c42 Weike Chen    2014-09-17  602  		}
3d2613c42 Weike Chen    2014-09-17  603
da069d5d2 Phil Edworthy 2018-05-23  604  		pp->irq_shared	= false;
da069d5d2 Phil Edworthy 2018-05-23  605  		pp->gpio_base	= -1;
da069d5d2 Phil Edworthy 2018-05-23  606
3d2613c42 Weike Chen    2014-09-17  607  		/*
3d2613c42 Weike Chen    2014-09-17  608  		 * Only port A can provide interrupts in all configurations of
3d2613c42 Weike Chen    2014-09-17  609  		 * the IP.
3d2613c42 Weike Chen    2014-09-17  610  		 */
da069d5d2 Phil Edworthy 2018-05-23  611  		if (pp->idx != 0)
e6ca26abd Phil Edworthy 2018-04-26  612  			continue;
e6ca26abd Phil Edworthy 2018-04-26  613
da069d5d2 Phil Edworthy 2018-05-23  614  		if (dev->of_node && fwnode_property_read_bool(fwnode,
da069d5d2 Phil Edworthy 2018-05-23  615  						  "interrupt-controller")) {
da069d5d2 Phil Edworthy 2018-05-23  616  			np = to_of_node(fwnode);
3d2613c42 Weike Chen    2014-09-17  617  		}
3d2613c42 Weike Chen    2014-09-17  618
e6ca26abd Phil Edworthy 2018-04-26  619  		for (j = 0; j < pp->ngpio; j++) {
da069d5d2 Phil Edworthy 2018-05-23  620  			pp->irq[j] = -ENXIO;
da069d5d2 Phil Edworthy 2018-05-23  621
da069d5d2 Phil Edworthy 2018-05-23  622  			if (np)
da069d5d2 Phil Edworthy 2018-05-23  623  				pp->irq[j] = of_irq_get(np, j);
da069d5d2 Phil Edworthy 2018-05-23  624  			else if (has_acpi_companion(dev))
e6ca26abd Phil Edworthy 2018-04-26  625  				pp->irq[j] = platform_get_irq(to_platform_device(dev), j);
da069d5d2 Phil Edworthy 2018-05-23  626
da069d5d2 Phil Edworthy 2018-05-23 @627  			if (pp->irq[j] >= 0)
e6ca26abd Phil Edworthy 2018-04-26  628  				pp->has_irq = true;
e6ca26abd Phil Edworthy 2018-04-26  629  		}
e6cb3486f Jiang Qiu     2016-04-28  630
da069d5d2 Phil Edworthy 2018-05-23  631  		if (!pp->has_irq)
da069d5d2 Phil Edworthy 2018-05-23  632  			dev_warn(dev, "no irq for port%d\n", pp->idx);
3d2613c42 Weike Chen    2014-09-17  633  	}
3d2613c42 Weike Chen    2014-09-17  634
3d2613c42 Weike Chen    2014-09-17  635  	return pdata;
3d2613c42 Weike Chen    2014-09-17  636  }
3d2613c42 Weike Chen    2014-09-17  637

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux