drivers/net/ethernet/xilinx/ll_temac_main.c:1410:64: sparse: sparse: Using plain integer as NULL pointer
From: kernel test robot
Date: Thu Aug 06 2020 - 12:30:56 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 47ec5303d73ea344e84f46660fff693c57641386
commit: bd69058f50d5ffa659423bcfa6fe6280ce9c760a net: ll_temac: Use devm_platform_ioremap_resource_byname()
date: 7 days ago
config: sparc64-randconfig-s032-20200806 (attached as .config)
compiler: sparc64-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.2-117-g8c7aee71-dirty
git checkout bd69058f50d5ffa659423bcfa6fe6280ce9c760a
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=sparc64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
sparse warnings: (new ones prefixed by >>)
drivers/net/ethernet/xilinx/ll_temac_main.c:356:37: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] next @@ got restricted __be32 [usertype] @@
drivers/net/ethernet/xilinx/ll_temac_main.c:356:37: sparse: expected unsigned int [usertype] next
drivers/net/ethernet/xilinx/ll_temac_main.c:356:37: sparse: got restricted __be32 [usertype]
drivers/net/ethernet/xilinx/ll_temac_main.c:361:37: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] next @@ got restricted __be32 [usertype] @@
drivers/net/ethernet/xilinx/ll_temac_main.c:361:37: sparse: expected unsigned int [usertype] next
drivers/net/ethernet/xilinx/ll_temac_main.c:361:37: sparse: got restricted __be32 [usertype]
drivers/net/ethernet/xilinx/ll_temac_main.c:376:37: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] phys @@ got restricted __be32 [usertype] @@
drivers/net/ethernet/xilinx/ll_temac_main.c:376:37: sparse: expected unsigned int [usertype] phys
drivers/net/ethernet/xilinx/ll_temac_main.c:376:37: sparse: got restricted __be32 [usertype]
drivers/net/ethernet/xilinx/ll_temac_main.c:377:36: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] len @@ got restricted __be32 [usertype] @@
drivers/net/ethernet/xilinx/ll_temac_main.c:377:36: sparse: expected unsigned int [usertype] len
drivers/net/ethernet/xilinx/ll_temac_main.c:377:36: sparse: got restricted __be32 [usertype]
drivers/net/ethernet/xilinx/ll_temac_main.c:378:37: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] app0 @@ got restricted __be32 [usertype] @@
drivers/net/ethernet/xilinx/ll_temac_main.c:378:37: sparse: expected unsigned int [usertype] app0
drivers/net/ethernet/xilinx/ll_temac_main.c:378:37: sparse: got restricted __be32 [usertype]
drivers/net/ethernet/xilinx/ll_temac_main.c:774:16: sparse: sparse: cast to restricted __be32
drivers/net/ethernet/xilinx/ll_temac_main.c:777:17: sparse: sparse: cast to restricted __be32
drivers/net/ethernet/xilinx/ll_temac_main.c:777:17: sparse: sparse: cast to restricted __be32
drivers/net/ethernet/xilinx/ll_temac_main.c:789:41: sparse: sparse: cast to restricted __be32
drivers/net/ethernet/xilinx/ll_temac_main.c:796:24: sparse: sparse: cast to restricted __be32
drivers/net/ethernet/xilinx/ll_temac_main.c:863:29: sparse: sparse: invalid assignment: |=
drivers/net/ethernet/xilinx/ll_temac_main.c:863:29: sparse: left side has type unsigned int
drivers/net/ethernet/xilinx/ll_temac_main.c:863:29: sparse: right side has type restricted __be32
drivers/net/ethernet/xilinx/ll_temac_main.c:864:29: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] app1 @@ got restricted __be32 [usertype] @@
drivers/net/ethernet/xilinx/ll_temac_main.c:864:29: sparse: expected unsigned int [usertype] app1
drivers/net/ethernet/xilinx/ll_temac_main.c:864:29: sparse: got restricted __be32 [usertype]
drivers/net/ethernet/xilinx/ll_temac_main.c:869:21: sparse: sparse: invalid assignment: |=
drivers/net/ethernet/xilinx/ll_temac_main.c:869:21: sparse: left side has type unsigned int
drivers/net/ethernet/xilinx/ll_temac_main.c:869:21: sparse: right side has type restricted __be32
drivers/net/ethernet/xilinx/ll_temac_main.c:872:20: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] len @@ got restricted __be32 [usertype] @@
drivers/net/ethernet/xilinx/ll_temac_main.c:872:20: sparse: expected unsigned int [usertype] len
drivers/net/ethernet/xilinx/ll_temac_main.c:872:20: sparse: got restricted __be32 [usertype]
drivers/net/ethernet/xilinx/ll_temac_main.c:878:21: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] phys @@ got restricted __be32 [usertype] @@
drivers/net/ethernet/xilinx/ll_temac_main.c:878:21: sparse: expected unsigned int [usertype] phys
drivers/net/ethernet/xilinx/ll_temac_main.c:878:21: sparse: got restricted __be32 [usertype]
drivers/net/ethernet/xilinx/ll_temac_main.c:896:33: sparse: sparse: cast to restricted __be32
drivers/net/ethernet/xilinx/ll_temac_main.c:904:25: sparse: sparse: cast to restricted __be32
drivers/net/ethernet/xilinx/ll_temac_main.c:911:29: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] phys @@ got restricted __be32 [usertype] @@
drivers/net/ethernet/xilinx/ll_temac_main.c:911:29: sparse: expected unsigned int [usertype] phys
drivers/net/ethernet/xilinx/ll_temac_main.c:911:29: sparse: got restricted __be32 [usertype]
drivers/net/ethernet/xilinx/ll_temac_main.c:912:28: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] len @@ got restricted __be32 [usertype] @@
drivers/net/ethernet/xilinx/ll_temac_main.c:912:28: sparse: expected unsigned int [usertype] len
drivers/net/ethernet/xilinx/ll_temac_main.c:912:28: sparse: got restricted __be32 [usertype]
drivers/net/ethernet/xilinx/ll_temac_main.c:916:21: sparse: sparse: invalid assignment: |=
drivers/net/ethernet/xilinx/ll_temac_main.c:916:21: sparse: left side has type unsigned int
drivers/net/ethernet/xilinx/ll_temac_main.c:916:21: sparse: right side has type restricted __be32
drivers/net/ethernet/xilinx/ll_temac_main.c:961:39: sparse: sparse: cast to restricted __be32
drivers/net/ethernet/xilinx/ll_temac_main.c:975:17: sparse: sparse: cast to restricted __be32
drivers/net/ethernet/xilinx/ll_temac_main.c:981:26: sparse: sparse: cast to restricted __be32
drivers/net/ethernet/xilinx/ll_temac_main.c:996:37: sparse: sparse: cast to restricted __be32
drivers/net/ethernet/xilinx/ll_temac_main.c:996:35: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __wsum [usertype] csum @@ got restricted __be16 [usertype] @@
drivers/net/ethernet/xilinx/ll_temac_main.c:996:35: sparse: expected restricted __wsum [usertype] csum
drivers/net/ethernet/xilinx/ll_temac_main.c:996:35: sparse: got restricted __be16 [usertype]
drivers/net/ethernet/xilinx/ll_temac_main.c:1062:26: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] phys @@ got restricted __be32 [usertype] @@
drivers/net/ethernet/xilinx/ll_temac_main.c:1062:26: sparse: expected unsigned int [usertype] phys
drivers/net/ethernet/xilinx/ll_temac_main.c:1062:26: sparse: got restricted __be32 [usertype]
drivers/net/ethernet/xilinx/ll_temac_main.c:1063:25: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] len @@ got restricted __be32 [usertype] @@
drivers/net/ethernet/xilinx/ll_temac_main.c:1063:25: sparse: expected unsigned int [usertype] len
drivers/net/ethernet/xilinx/ll_temac_main.c:1063:25: sparse: got restricted __be32 [usertype]
drivers/net/ethernet/xilinx/ll_temac_main.c:1064:26: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] app0 @@ got restricted __be32 [usertype] @@
drivers/net/ethernet/xilinx/ll_temac_main.c:1064:26: sparse: expected unsigned int [usertype] app0
drivers/net/ethernet/xilinx/ll_temac_main.c:1064:26: sparse: got restricted __be32 [usertype]
>> drivers/net/ethernet/xilinx/ll_temac_main.c:1410:64: sparse: sparse: Using plain integer as NULL pointer
vim +1410 drivers/net/ethernet/xilinx/ll_temac_main.c
1383
1384 /* setup temac private info structure */
1385 lp = netdev_priv(ndev);
1386 lp->ndev = ndev;
1387 lp->dev = &pdev->dev;
1388 lp->options = XTE_OPTION_DEFAULTS;
1389 lp->rx_bd_num = RX_BD_NUM_DEFAULT;
1390 lp->tx_bd_num = TX_BD_NUM_DEFAULT;
1391 spin_lock_init(&lp->rx_lock);
1392 INIT_DELAYED_WORK(&lp->restart_work, ll_temac_restart_work_func);
1393
1394 /* Setup mutex for synchronization of indirect register access */
1395 if (pdata) {
1396 if (!pdata->indirect_lock) {
1397 dev_err(&pdev->dev,
1398 "indirect_lock missing in platform_data\n");
1399 return -EINVAL;
1400 }
1401 lp->indirect_lock = pdata->indirect_lock;
1402 } else {
1403 lp->indirect_lock = devm_kmalloc(&pdev->dev,
1404 sizeof(*lp->indirect_lock),
1405 GFP_KERNEL);
1406 spin_lock_init(lp->indirect_lock);
1407 }
1408
1409 /* map device registers */
> 1410 lp->regs = devm_platform_ioremap_resource_byname(pdev, 0);
1411 if (IS_ERR(lp->regs)) {
1412 dev_err(&pdev->dev, "could not map TEMAC registers\n");
1413 return -ENOMEM;
1414 }
1415
1416 /* Select register access functions with the specified
1417 * endianness mode. Default for OF devices is big-endian.
1418 */
1419 little_endian = false;
1420 if (temac_np) {
1421 if (of_get_property(temac_np, "little-endian", NULL))
1422 little_endian = true;
1423 } else if (pdata) {
1424 little_endian = pdata->reg_little_endian;
1425 }
1426 if (little_endian) {
1427 lp->temac_ior = _temac_ior_le;
1428 lp->temac_iow = _temac_iow_le;
1429 } else {
1430 lp->temac_ior = _temac_ior_be;
1431 lp->temac_iow = _temac_iow_be;
1432 }
1433
1434 /* Setup checksum offload, but default to off if not specified */
1435 lp->temac_features = 0;
1436 if (temac_np) {
1437 p = (__be32 *)of_get_property(temac_np, "xlnx,txcsum", NULL);
1438 if (p && be32_to_cpu(*p))
1439 lp->temac_features |= TEMAC_FEATURE_TX_CSUM;
1440 p = (__be32 *)of_get_property(temac_np, "xlnx,rxcsum", NULL);
1441 if (p && be32_to_cpu(*p))
1442 lp->temac_features |= TEMAC_FEATURE_RX_CSUM;
1443 } else if (pdata) {
1444 if (pdata->txcsum)
1445 lp->temac_features |= TEMAC_FEATURE_TX_CSUM;
1446 if (pdata->rxcsum)
1447 lp->temac_features |= TEMAC_FEATURE_RX_CSUM;
1448 }
1449 if (lp->temac_features & TEMAC_FEATURE_TX_CSUM)
1450 /* Can checksum TCP/UDP over IPv4. */
1451 ndev->features |= NETIF_F_IP_CSUM;
1452
1453 /* Defaults for IRQ delay/coalescing setup. These are
1454 * configuration values, so does not belong in device-tree.
1455 */
1456 lp->coalesce_delay_tx = 0x10;
1457 lp->coalesce_count_tx = 0x22;
1458 lp->coalesce_delay_rx = 0xff;
1459 lp->coalesce_count_rx = 0x07;
1460
1461 /* Setup LocalLink DMA */
1462 if (temac_np) {
1463 /* Find the DMA node, map the DMA registers, and
1464 * decode the DMA IRQs.
1465 */
1466 dma_np = of_parse_phandle(temac_np, "llink-connected", 0);
1467 if (!dma_np) {
1468 dev_err(&pdev->dev, "could not find DMA node\n");
1469 return -ENODEV;
1470 }
1471
1472 /* Setup the DMA register accesses, could be DCR or
1473 * memory mapped.
1474 */
1475 if (temac_dcr_setup(lp, pdev, dma_np)) {
1476 /* no DCR in the device tree, try non-DCR */
1477 lp->sdma_regs = devm_of_iomap(&pdev->dev, dma_np, 0,
1478 NULL);
1479 if (IS_ERR(lp->sdma_regs)) {
1480 dev_err(&pdev->dev,
1481 "unable to map DMA registers\n");
1482 of_node_put(dma_np);
1483 return PTR_ERR(lp->sdma_regs);
1484 }
1485 if (of_get_property(dma_np, "little-endian", NULL)) {
1486 lp->dma_in = temac_dma_in32_le;
1487 lp->dma_out = temac_dma_out32_le;
1488 } else {
1489 lp->dma_in = temac_dma_in32_be;
1490 lp->dma_out = temac_dma_out32_be;
1491 }
1492 dev_dbg(&pdev->dev, "MEM base: %p\n", lp->sdma_regs);
1493 }
1494
1495 /* Get DMA RX and TX interrupts */
1496 lp->rx_irq = irq_of_parse_and_map(dma_np, 0);
1497 lp->tx_irq = irq_of_parse_and_map(dma_np, 1);
1498
1499 /* Finished with the DMA node; drop the reference */
1500 of_node_put(dma_np);
1501 } else if (pdata) {
1502 /* 2nd memory resource specifies DMA registers */
1503 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1504 lp->sdma_regs = devm_ioremap(&pdev->dev, res->start,
1505 resource_size(res));
1506 if (!lp->sdma_regs) {
1507 dev_err(&pdev->dev,
1508 "could not map DMA registers\n");
1509 return -ENOMEM;
1510 }
1511 if (pdata->dma_little_endian) {
1512 lp->dma_in = temac_dma_in32_le;
1513 lp->dma_out = temac_dma_out32_le;
1514 } else {
1515 lp->dma_in = temac_dma_in32_be;
1516 lp->dma_out = temac_dma_out32_be;
1517 }
1518
1519 /* Get DMA RX and TX interrupts */
1520 lp->rx_irq = platform_get_irq(pdev, 0);
1521 lp->tx_irq = platform_get_irq(pdev, 1);
1522
1523 /* IRQ delay/coalescing setup */
1524 if (pdata->tx_irq_timeout || pdata->tx_irq_count) {
1525 lp->coalesce_delay_tx = pdata->tx_irq_timeout;
1526 lp->coalesce_count_tx = pdata->tx_irq_count;
1527 }
1528 if (pdata->rx_irq_timeout || pdata->rx_irq_count) {
1529 lp->coalesce_delay_rx = pdata->rx_irq_timeout;
1530 lp->coalesce_count_rx = pdata->rx_irq_count;
1531 }
1532 }
1533
1534 /* Error handle returned DMA RX and TX interrupts */
1535 if (lp->rx_irq < 0) {
1536 if (lp->rx_irq != -EPROBE_DEFER)
1537 dev_err(&pdev->dev, "could not get DMA RX irq\n");
1538 return lp->rx_irq;
1539 }
1540 if (lp->tx_irq < 0) {
1541 if (lp->tx_irq != -EPROBE_DEFER)
1542 dev_err(&pdev->dev, "could not get DMA TX irq\n");
1543 return lp->tx_irq;
1544 }
1545
1546 if (temac_np) {
1547 /* Retrieve the MAC address */
1548 addr = of_get_mac_address(temac_np);
1549 if (IS_ERR(addr)) {
1550 dev_err(&pdev->dev, "could not find MAC address\n");
1551 return -ENODEV;
1552 }
1553 temac_init_mac_address(ndev, addr);
1554 } else if (pdata) {
1555 temac_init_mac_address(ndev, pdata->mac_addr);
1556 }
1557
1558 rc = temac_mdio_setup(lp, pdev);
1559 if (rc)
1560 dev_warn(&pdev->dev, "error registering MDIO bus\n");
1561
1562 if (temac_np) {
1563 lp->phy_node = of_parse_phandle(temac_np, "phy-handle", 0);
1564 if (lp->phy_node)
1565 dev_dbg(lp->dev, "using PHY node %pOF\n", temac_np);
1566 } else if (pdata) {
1567 snprintf(lp->phy_name, sizeof(lp->phy_name),
1568 PHY_ID_FMT, lp->mii_bus->id, pdata->phy_addr);
1569 lp->phy_interface = pdata->phy_interface;
1570 }
1571
1572 /* Add the device attributes */
1573 rc = sysfs_create_group(&lp->dev->kobj, &temac_attr_group);
1574 if (rc) {
1575 dev_err(lp->dev, "Error creating sysfs files\n");
1576 goto err_sysfs_create;
1577 }
1578
1579 rc = register_netdev(lp->ndev);
1580 if (rc) {
1581 dev_err(lp->dev, "register_netdev() error (%i)\n", rc);
1582 goto err_register_ndev;
1583 }
1584
1585 return 0;
1586
1587 err_register_ndev:
1588 sysfs_remove_group(&lp->dev->kobj, &temac_attr_group);
1589 err_sysfs_create:
1590 if (lp->phy_node)
1591 of_node_put(lp->phy_node);
1592 temac_mdio_teardown(lp);
1593 return rc;
1594 }
1595
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip