* [PATCH 1/2] PCI: export pci_match_device()
@ 2020-10-21 8:10 Zhenzhong Duan
2020-10-21 8:10 ` [PATCH 2/2] PCI: add support for dynamic ID when checking for duplicate IDs Zhenzhong Duan
2020-10-22 15:21 ` [PATCH 1/2] PCI: export pci_match_device() Christoph Hellwig
0 siblings, 2 replies; 4+ messages in thread
From: Zhenzhong Duan @ 2020-10-21 8:10 UTC (permalink / raw)
To: linux-kernel, linux-pci; +Cc: bhelgaas, Zhenzhong Duan
pci_match_id() is deprecated as it doesn't catch any dynamic ids that
a driver might want to check for.
Export pci_match_device() as a replacement which supports both dynamic
and static ids.
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@gmail.com>
---
drivers/pci/pci-driver.c | 3 ++-
include/linux/pci.h | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index d1b7169..bd9cfd1 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -250,7 +250,7 @@ const struct pci_device_id *pci_match_id(const struct pci_device_id *ids,
* system is in its list of supported devices. Returns the matching
* pci_device_id structure or %NULL if there is no match.
*/
-static const struct pci_device_id *pci_match_device(struct pci_driver *drv,
+const struct pci_device_id *pci_match_device(struct pci_driver *drv,
struct pci_dev *dev)
{
struct pci_dynid *dynid;
@@ -279,6 +279,7 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv,
return found_id;
}
+EXPORT_SYMBOL(pci_match_device);
struct drv_dev_and_id {
struct pci_driver *drv;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 8355306..6f947c4 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1406,6 +1406,8 @@ int pci_add_dynid(struct pci_driver *drv,
unsigned long driver_data);
const struct pci_device_id *pci_match_id(const struct pci_device_id *ids,
struct pci_dev *dev);
+const struct pci_device_id *pci_match_device(struct pci_driver *drv,
+ struct pci_dev *dev);
int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
int pass);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] PCI: add support for dynamic ID when checking for duplicate IDs
2020-10-21 8:10 [PATCH 1/2] PCI: export pci_match_device() Zhenzhong Duan
@ 2020-10-21 8:10 ` Zhenzhong Duan
2020-10-22 15:21 ` [PATCH 1/2] PCI: export pci_match_device() Christoph Hellwig
1 sibling, 0 replies; 4+ messages in thread
From: Zhenzhong Duan @ 2020-10-21 8:10 UTC (permalink / raw)
To: linux-kernel, linux-pci; +Cc: bhelgaas, Zhenzhong Duan
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@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] PCI: export pci_match_device()
2020-10-21 8:10 [PATCH 1/2] PCI: export pci_match_device() Zhenzhong Duan
2020-10-21 8:10 ` [PATCH 2/2] PCI: add support for dynamic ID when checking for duplicate IDs Zhenzhong Duan
@ 2020-10-22 15:21 ` Christoph Hellwig
2020-10-26 2:52 ` Zhenzhong Duan
1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2020-10-22 15:21 UTC (permalink / raw)
To: Zhenzhong Duan; +Cc: linux-kernel, linux-pci, bhelgaas
On Wed, Oct 21, 2020 at 04:10:29PM +0800, Zhenzhong Duan wrote:
> pci_match_id() is deprecated as it doesn't catch any dynamic ids that
> a driver might want to check for.
>
> Export pci_match_device() as a replacement which supports both dynamic
> and static ids.
You don't actually seems to add any user outside of the PCI core,
so I think you only need to drop the static specifier and add a
prototype.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] PCI: export pci_match_device()
2020-10-22 15:21 ` [PATCH 1/2] PCI: export pci_match_device() Christoph Hellwig
@ 2020-10-26 2:52 ` Zhenzhong Duan
0 siblings, 0 replies; 4+ messages in thread
From: Zhenzhong Duan @ 2020-10-26 2:52 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-kernel, linux-pci, Bjorn Helgaas
On Thu, Oct 22, 2020 at 11:21 PM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Wed, Oct 21, 2020 at 04:10:29PM +0800, Zhenzhong Duan wrote:
> > pci_match_id() is deprecated as it doesn't catch any dynamic ids that
> > a driver might want to check for.
> >
> > Export pci_match_device() as a replacement which supports both dynamic
> > and static ids.
>
> You don't actually seems to add any user outside of the PCI core,
> so I think you only need to drop the static specifier and add a
> prototype.
Thanks for review, will do it. I'll combine the two patches into one
if no need to export.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-10-26 2:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-21 8:10 [PATCH 1/2] PCI: export pci_match_device() Zhenzhong Duan
2020-10-21 8:10 ` [PATCH 2/2] PCI: add support for dynamic ID when checking for duplicate IDs Zhenzhong Duan
2020-10-22 15:21 ` [PATCH 1/2] PCI: export pci_match_device() Christoph Hellwig
2020-10-26 2:52 ` Zhenzhong Duan
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).