Skip to content

Commit

Permalink
PCI: endpoint: Add an API to get matching "pci_epf_device_id"
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Kishon Vijay Abraham I authored and Bjorn Helgaas committed Aug 18, 2017
1 parent 64c1a02 commit f01f969
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions drivers/pci/endpoint/pci-epf-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,22 @@ struct pci_epf *pci_epf_create(const char *name)
}
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);
Expand Down
2 changes: 2 additions & 0 deletions include/linux/pci-epf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f01f969

Please sign in to comment.