From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, Michal Simek <monstr@monstr.eu>
Cc: lkp@intel.com, kbuild-all@lists.01.org,
linux-arm-kernel@lists.infradead.org,
Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>,
Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Subject: [xilinx-xlnx:xlnx_rebase_v5.15_LTS 304/1079] drivers/tty/serial/xilinx_uartps.c:1518 cdns_get_id() warn: inconsistent returns '&bitmap_lock'.
Date: Wed, 6 Apr 2022 11:23:28 +0300 [thread overview]
Message-ID: <202204061608.ed0SVSJO-lkp@intel.com> (raw)
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
reply other threads:[~2022-04-06 8:27 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=202204061608.ed0SVSJO-lkp@intel.com \
--to=dan.carpenter@oracle.com \
--cc=kbuild-all@lists.01.org \
--cc=kbuild@lists.01.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=lkp@intel.com \
--cc=monstr@monstr.eu \
--cc=radhey.shyam.pandey@xilinx.com \
--cc=shubhrajyoti.datta@xilinx.com \
/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).