* [xilinx-xlnx:xlnx_rebase_v5.15_LTS 304/1079] drivers/tty/serial/xilinx_uartps.c:1518 cdns_get_id() warn: inconsistent returns '&bitmap_lock'.
@ 2022-04-06 8:23 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2022-04-06 8:23 UTC (permalink / raw)
To: kbuild, Michal Simek
Cc: lkp, kbuild-all, linux-arm-kernel, Shubhrajyoti Datta,
Radhey Shyam Pandey
tree: https://github.com/Xilinx/linux-xlnx xlnx_rebase_v5.15_LTS
head: 26346d468f90100952de38511adf57513f801cf7
commit: f0090478ae8a76b733a846f50dc5559fff3c461f [304/1079] serial: uartps: Change uart ID port allocation
config: powerpc64-randconfig-m031-20220405 (https://download.01.org/0day-ci/archive/20220406/202204061608.ed0SVSJO-lkp@intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 11.2.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
drivers/tty/serial/xilinx_uartps.c:1518 cdns_get_id() warn: inconsistent returns '&bitmap_lock'.
vim +1518 drivers/tty/serial/xilinx_uartps.c
f0090478ae8a76b Michal Simek 2018-09-20 1454 static int cdns_get_id(struct platform_device *pdev)
f0090478ae8a76b Michal Simek 2018-09-20 1455 {
f0090478ae8a76b Michal Simek 2018-09-20 1456 int id, ret;
f0090478ae8a76b Michal Simek 2018-09-20 1457
f0090478ae8a76b Michal Simek 2018-09-20 1458 mutex_lock(&bitmap_lock);
f0090478ae8a76b Michal Simek 2018-09-20 1459
f0090478ae8a76b Michal Simek 2018-09-20 1460 /* Alias list is stable that's why get alias bitmap only once */
f0090478ae8a76b Michal Simek 2018-09-20 1461 if (!alias_bitmap_initialized) {
f0090478ae8a76b Michal Simek 2018-09-20 1462 ret = of_alias_get_alias_list(cdns_uart_of_match, "serial",
f0090478ae8a76b Michal Simek 2018-09-20 1463 alias_bitmap, CDNS_UART_NR_PORTS);
f0090478ae8a76b Michal Simek 2018-09-20 1464 if (ret)
f0090478ae8a76b Michal Simek 2018-09-20 1465 return ret;
Missing mutex_unlock(&bitmap_lock);
f0090478ae8a76b Michal Simek 2018-09-20 1466
f0090478ae8a76b Michal Simek 2018-09-20 1467 alias_bitmap_initialized++;
f0090478ae8a76b Michal Simek 2018-09-20 1468 }
f0090478ae8a76b Michal Simek 2018-09-20 1469
f0090478ae8a76b Michal Simek 2018-09-20 1470 /* Make sure that alias ID is not taken by instance without alias */
f0090478ae8a76b Michal Simek 2018-09-20 1471 bitmap_or(bitmap, bitmap, alias_bitmap, CDNS_UART_NR_PORTS);
f0090478ae8a76b Michal Simek 2018-09-20 1472
f0090478ae8a76b Michal Simek 2018-09-20 1473 dev_dbg(&pdev->dev, "Alias bitmap: %*pb\n",
f0090478ae8a76b Michal Simek 2018-09-20 1474 CDNS_UART_NR_PORTS, bitmap);
f0090478ae8a76b Michal Simek 2018-09-20 1475
f0090478ae8a76b Michal Simek 2018-09-20 1476 /* Look for a serialN alias */
f0090478ae8a76b Michal Simek 2018-09-20 1477 id = of_alias_get_id(pdev->dev.of_node, "serial");
f0090478ae8a76b Michal Simek 2018-09-20 1478 if (id < 0) {
f0090478ae8a76b Michal Simek 2018-09-20 1479 dev_warn(&pdev->dev,
f0090478ae8a76b Michal Simek 2018-09-20 1480 "No serial alias passed. Using the first free id\n");
f0090478ae8a76b Michal Simek 2018-09-20 1481
f0090478ae8a76b Michal Simek 2018-09-20 1482 /*
f0090478ae8a76b Michal Simek 2018-09-20 1483 * Start with id 0 and check if there is no serial0 alias
f0090478ae8a76b Michal Simek 2018-09-20 1484 * which points to device which is compatible with this driver.
f0090478ae8a76b Michal Simek 2018-09-20 1485 * If alias exists then try next free position.
f0090478ae8a76b Michal Simek 2018-09-20 1486 */
f0090478ae8a76b Michal Simek 2018-09-20 1487 id = 0;
f0090478ae8a76b Michal Simek 2018-09-20 1488
f0090478ae8a76b Michal Simek 2018-09-20 1489 for (;;) {
f0090478ae8a76b Michal Simek 2018-09-20 1490 dev_info(&pdev->dev, "Checking id %d\n", id);
f0090478ae8a76b Michal Simek 2018-09-20 1491 id = find_next_zero_bit(bitmap, CDNS_UART_NR_PORTS, id);
f0090478ae8a76b Michal Simek 2018-09-20 1492
f0090478ae8a76b Michal Simek 2018-09-20 1493 /* No free empty instance */
f0090478ae8a76b Michal Simek 2018-09-20 1494 if (id == CDNS_UART_NR_PORTS) {
f0090478ae8a76b Michal Simek 2018-09-20 1495 dev_err(&pdev->dev, "No free ID\n");
f0090478ae8a76b Michal Simek 2018-09-20 1496 mutex_unlock(&bitmap_lock);
f0090478ae8a76b Michal Simek 2018-09-20 1497 return -EINVAL;
f0090478ae8a76b Michal Simek 2018-09-20 1498 }
f0090478ae8a76b Michal Simek 2018-09-20 1499
f0090478ae8a76b Michal Simek 2018-09-20 1500 dev_dbg(&pdev->dev, "The empty id is %d\n", id);
f0090478ae8a76b Michal Simek 2018-09-20 1501 /* Check if ID is empty */
f0090478ae8a76b Michal Simek 2018-09-20 1502 if (!test_and_set_bit(id, bitmap)) {
f0090478ae8a76b Michal Simek 2018-09-20 1503 /* Break the loop if bit is taken */
f0090478ae8a76b Michal Simek 2018-09-20 1504 dev_dbg(&pdev->dev,
f0090478ae8a76b Michal Simek 2018-09-20 1505 "Selected ID %d allocation passed\n",
f0090478ae8a76b Michal Simek 2018-09-20 1506 id);
f0090478ae8a76b Michal Simek 2018-09-20 1507 break;
f0090478ae8a76b Michal Simek 2018-09-20 1508 }
f0090478ae8a76b Michal Simek 2018-09-20 1509 dev_dbg(&pdev->dev,
f0090478ae8a76b Michal Simek 2018-09-20 1510 "Selected ID %d allocation failed\n", id);
f0090478ae8a76b Michal Simek 2018-09-20 1511 /* if taking bit fails then try next one */
f0090478ae8a76b Michal Simek 2018-09-20 1512 id++;
f0090478ae8a76b Michal Simek 2018-09-20 1513 }
f0090478ae8a76b Michal Simek 2018-09-20 1514 }
f0090478ae8a76b Michal Simek 2018-09-20 1515
f0090478ae8a76b Michal Simek 2018-09-20 1516 mutex_unlock(&bitmap_lock);
f0090478ae8a76b Michal Simek 2018-09-20 1517
f0090478ae8a76b Michal Simek 2018-09-20 @1518 return id;
f0090478ae8a76b Michal Simek 2018-09-20 1519 }
--
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
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] only message in thread
only message in thread, other threads:[~2022-04-06 8:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-06 8:23 [xilinx-xlnx:xlnx_rebase_v5.15_LTS 304/1079] drivers/tty/serial/xilinx_uartps.c:1518 cdns_get_id() warn: inconsistent returns '&bitmap_lock' Dan Carpenter
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).