Skip to content

Commit

Permalink
core/pci: Use cached vendor/device IDs in quirks
Browse files Browse the repository at this point in the history
The PCI device vendor/device IDs have been cached to pd->vdid, no
need to pass them in pci_handle_quirk(). This also introduces two
macros to extract vendor/device fields and they are useful afterwards.
No logical changes introduced.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
Gavin Shan authored and stewartsmith committed Jun 15, 2017
1 parent e835c2f commit 2b841bf
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
9 changes: 3 additions & 6 deletions core/pci-quirk.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,14 @@ static const struct pci_quirk quirk_table[] = {
{NULL}
};

void pci_handle_quirk(struct phb *phb,
struct pci_device *pd,
uint16_t vendor_id,
uint16_t device_id)
void pci_handle_quirk(struct phb *phb, struct pci_device *pd)
{
const struct pci_quirk *quirks = quirk_table;

while (quirks->vendor_id) {
if (vendor_id == quirks->vendor_id &&
if (quirks->vendor_id == PCI_VENDOR_ID(pd->vdid) &&
(quirks->device_id == PCI_ANY_ID ||
device_id == quirks->device_id))
quirks->device_id == PCI_DEVICE_ID(pd->vdid)))
quirks->fixup(phb, pd);
quirks++;
}
Expand Down
2 changes: 1 addition & 1 deletion core/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ static void pci_add_one_device_node(struct phb *phb,
if (intpin)
dt_add_property_cells(np, "interrupts", intpin);

pci_handle_quirk(phb, pd, vdid & 0xffff, vdid >> 16);
pci_handle_quirk(phb, pd);

/* XXX FIXME: Add a few missing ones such as
*
Expand Down
5 changes: 1 addition & 4 deletions include/pci-quirk.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ struct pci_quirk {
uint16_t device_id;
};

void pci_handle_quirk(struct phb *phb,
struct pci_device *pd,
uint16_t vendor_id,
uint16_t device_id);
void pci_handle_quirk(struct phb *phb, struct pci_device *pd);

#endif /* __PCI_QUIRK_H */
2 changes: 2 additions & 0 deletions include/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ struct pci_device {

uint32_t vdid;
uint32_t sub_vdid;
#define PCI_VENDOR_ID(x) ((x) & 0xFFFF)
#define PCI_DEVICE_ID(x) ((x) >> 8)
uint32_t class;
uint64_t cap_list;
struct {
Expand Down

0 comments on commit 2b841bf

Please sign in to comment.