From: Kishon Vijay Abraham I Date: Fri, 18 Aug 2017 14:57:54 +0000 (+0530) Subject: PCI: endpoint: Add an API to get matching "pci_epf_device_id" X-Git-Tag: v4.14-rc1~87^2~11^2~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f01f969e25ecc6f88844bcdd63f1f27610418bbc;p=platform%2Fkernel%2Flinux-rpi3.git PCI: endpoint: Add an API to get matching "pci_epf_device_id" Add an API to get "pci_epf_device_id" matching the EPF name. This can be used by the EPF driver to get the driver data corresponding to the EPF device name. Signed-off-by: Kishon Vijay Abraham I [bhelgaas: folded in "while" loop termination fix from Colin Ian King ] Signed-off-by: Bjorn Helgaas --- diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index 6877d6a..f14e2be 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -267,6 +267,22 @@ err_ret: } EXPORT_SYMBOL_GPL(pci_epf_create); +const struct pci_epf_device_id * +pci_epf_match_device(const struct pci_epf_device_id *id, struct pci_epf *epf) +{ + if (!id || !epf) + return NULL; + + while (*id->name) { + if (strcmp(epf->name, id->name) == 0) + return id; + id++; + } + + return NULL; +} +EXPORT_SYMBOL_GPL(pci_epf_match_device); + static void pci_epf_dev_release(struct device *dev) { struct pci_epf *epf = to_pci_epf(dev); diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index 0d529cb..6ed63b5e 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -149,6 +149,8 @@ static inline void *epf_get_drvdata(struct pci_epf *epf) return dev_get_drvdata(&epf->dev); } +const struct pci_epf_device_id * +pci_epf_match_device(const struct pci_epf_device_id *id, struct pci_epf *epf); struct pci_epf *pci_epf_create(const char *name); void pci_epf_destroy(struct pci_epf *epf); int __pci_epf_register_driver(struct pci_epf_driver *driver,