[PATCH 2/2] PCI: add support for dynamic ID when checking for duplicate IDs

From: Zhenzhong Duan
Date: Wed Oct 21 2020 - 04:10:53 EST


When a device ID data is writen to /sys/bus/pci/drivers/.../new_id,
only static ID table is checked for duplicate and multiple dynamic id
entries of same kind are allowed to be dynamically linked.

Fix it by calling pci_match_device() which checks both dynamic and static IDs.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@xxxxxxxxx>
---
drivers/pci/pci-driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index bd9cfd1..751c605 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -125,7 +125,7 @@ static ssize_t new_id_store(struct device_driver *driver, const char *buf,
pdev->subsystem_device = subdevice;
pdev->class = class;

- if (pci_match_id(pdrv->id_table, pdev))
+ if (pci_match_device(pdrv, pdev))
retval = -EEXIST;

kfree(pdev);
--
1.8.3.1