Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <kishon@ti.com>
[bhelgaas: folded in "while" loop termination fix from Colin Ian King
<colin.king@canonical.com>]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Kishon Vijay Abraham I and committed by
Bjorn Helgaas
f01f969e 64c1a02a

+18
+16
drivers/pci/endpoint/pci-epf-core.c
··· 267 267 } 268 268 EXPORT_SYMBOL_GPL(pci_epf_create); 269 269 270 + const struct pci_epf_device_id * 271 + pci_epf_match_device(const struct pci_epf_device_id *id, struct pci_epf *epf) 272 + { 273 + if (!id || !epf) 274 + return NULL; 275 + 276 + while (*id->name) { 277 + if (strcmp(epf->name, id->name) == 0) 278 + return id; 279 + id++; 280 + } 281 + 282 + return NULL; 283 + } 284 + EXPORT_SYMBOL_GPL(pci_epf_match_device); 285 + 270 286 static void pci_epf_dev_release(struct device *dev) 271 287 { 272 288 struct pci_epf *epf = to_pci_epf(dev);
+2
include/linux/pci-epf.h
··· 149 149 return dev_get_drvdata(&epf->dev); 150 150 } 151 151 152 + const struct pci_epf_device_id * 153 + pci_epf_match_device(const struct pci_epf_device_id *id, struct pci_epf *epf); 152 154 struct pci_epf *pci_epf_create(const char *name); 153 155 void pci_epf_destroy(struct pci_epf *epf); 154 156 int __pci_epf_register_driver(struct pci_epf_driver *driver,