[Linux-stm32] [bug report] stmmac: pci: Add dwmac support for Loongson

Dan Carpenter dan.carpenter at oracle.com
Tue Jun 22 11:06:43 UTC 2021


Hello Qing Zhang,

The patch 30bba69d7db4: "stmmac: pci: Add dwmac support for Loongson"
from Jun 18, 2021, leads to the following static checker warning:

	drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c:111 loongson_dwmac_probe()
	warn: unsigned 'plat->phy_interface' is never less than zero.

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
    97          /* Get the base address of device */
    98          for (i = 0; i < PCI_STD_NUM_BARS; i++) {
    99                  if (pci_resource_len(pdev, i) == 0)
   100                          continue;
   101                  ret = pcim_iomap_regions(pdev, BIT(0), pci_name(pdev));
   102                  if (ret)
   103                          return ret;
   104                  break;
   105          }
   106  
   107          plat->bus_id = of_alias_get_id(np, "ethernet");
   108          if (plat->bus_id < 0)

plat->bus_id is unsigned so this can't be true.

   109                  plat->bus_id = pci_dev_id(pdev);
   110  
   111          plat->phy_interface = device_get_phy_mode(&pdev->dev);
   112          if (plat->phy_interface < 0)
   113                  dev_err(&pdev->dev, "phy_mode not found\n");
   114  
   115          plat->interface = PHY_INTERFACE_MODE_GMII;
   116  
   117          pci_set_master(pdev);
   118  
   119          loongson_default_data(plat);
   120          pci_enable_msi(pdev);

regards,
dan carpenter



More information about the Linux-stm32 mailing list