我正在尝试借助pci_rescan_bus()
内核功能重新扫描我自己的内核驱动程序中的 PCI 总线,但我看不到它的功能相同。
如果我尝试通过运行以下命令从用户空间执行相同操作,我会看到重新扫描发生:
echo 1 > /sys/devices/pci0000:00/0000:00:14.1/rescan
我正在尝试重新初始化位于 PCI 总线上的以太网端口。下面是我现在使用的代码:
struct pci_dev *pci_eth_dev01, *pci_eth_dev02 = NULL;
pci_eth_dev01 = pci_get_device(0x10ec, 0x8168, NULL);
if (pci_eth_dev01 != NULL)
dev_info(&info->client->dev, "class - %2X\tbus number - %d\n", pci_eth_dev01->class, pci_eth_dev01->bus->number);
else
dev_info(&info->client->dev, "Error retreiving pci device\n");
pci_eth_dev02 = pci_get_device(0x10ec, 0x8168, pci_eth_dev01);
if (pci_eth_dev02 != NULL)
dev_info(&info->client->dev, "class - %2X\tbus number - %d\n", pci_eth_dev02->class, pci_eth_dev02->bus->number);
else
dev_info(&info->client->dev, "Error retreiving pci device\n");
pci_stop_and_remove_bus_device(pci_eth_dev02);
pci_remove_bus(pci_eth_dev02->bus);
unsigned int ret = 0;
pci_lock_rescan_remove();
ret = pci_rescan_bus(pci_eth_dev02->bus);
pci_unlock_rescan_remove();
dev_info(&info->client->dev, "ret from pci_rescan_bus - %d\n", ret);
我从函数调用中得到2
一个返回值。pci_rescan_bus()
我在这里做错什么了吗?