diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2009-01-13 08:46:46 -0500 |
---|---|---|
committer | Jesse Barnes <jbarnes@hobbes.lan> | 2009-03-19 22:29:23 -0400 |
commit | 22106368c999246c414610dcaacd485e741605b1 (patch) | |
tree | 2c74166b9967118e863012e6c81e03f9c7345bfd /drivers/pci/pcie | |
parent | 0516c8bcd25293f438573101c439ce25a18916ad (diff) |
PCI: PCIe portdrv: Remove struct pcie_port_service_id
The PCI Express port driver uses 'struct pcie_port_service_id' for
matching port service devices and drivers, but this structure
contains fields that duplicate information from the port device
itself (vendor, device, subvendor, subdevice) and fields that are not
used by any existing port service driver (class, class_mask,
drvier_data). Also, both existing port service drivers (AER and
PCIe HP) don't even use the vendor and device fields for device
matching. Therefore 'struct pcie_port_service_id' can be removed
altogether and the only useful members of it (port_type, service) can
be introduced directly into the port service device and port service
driver structures. That simplifies the code quite a bit and reduces
its size.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/pcie')
-rw-r--r-- | drivers/pci/pcie/aer/aerdrv.c | 16 | ||||
-rw-r--r-- | drivers/pci/pcie/aer/aerdrv_core.c | 10 | ||||
-rw-r--r-- | drivers/pci/pcie/portdrv.h | 5 | ||||
-rw-r--r-- | drivers/pci/pcie/portdrv_bus.c | 18 | ||||
-rw-r--r-- | drivers/pci/pcie/portdrv_core.c | 5 |
5 files changed, 18 insertions, 36 deletions
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c index 57c41204c549..e11c03194063 100644 --- a/drivers/pci/pcie/aer/aerdrv.c +++ b/drivers/pci/pcie/aer/aerdrv.c | |||
@@ -48,19 +48,6 @@ static pci_ers_result_t aer_error_detected(struct pci_dev *dev, | |||
48 | static void aer_error_resume(struct pci_dev *dev); | 48 | static void aer_error_resume(struct pci_dev *dev); |
49 | static pci_ers_result_t aer_root_reset(struct pci_dev *dev); | 49 | static pci_ers_result_t aer_root_reset(struct pci_dev *dev); |
50 | 50 | ||
51 | /* | ||
52 | * PCI Express bus's AER Root service driver data structure | ||
53 | */ | ||
54 | static struct pcie_port_service_id aer_id[] = { | ||
55 | { | ||
56 | .vendor = PCI_ANY_ID, | ||
57 | .device = PCI_ANY_ID, | ||
58 | .port_type = PCIE_RC_PORT, | ||
59 | .service_type = PCIE_PORT_SERVICE_AER, | ||
60 | }, | ||
61 | { /* end: all zeroes */ } | ||
62 | }; | ||
63 | |||
64 | static struct pci_error_handlers aer_error_handlers = { | 51 | static struct pci_error_handlers aer_error_handlers = { |
65 | .error_detected = aer_error_detected, | 52 | .error_detected = aer_error_detected, |
66 | .resume = aer_error_resume, | 53 | .resume = aer_error_resume, |
@@ -68,7 +55,8 @@ static struct pci_error_handlers aer_error_handlers = { | |||
68 | 55 | ||
69 | static struct pcie_port_service_driver aerdriver = { | 56 | static struct pcie_port_service_driver aerdriver = { |
70 | .name = "aer", | 57 | .name = "aer", |
71 | .id_table = &aer_id[0], | 58 | .port_type = PCIE_ANY_PORT, |
59 | .service = PCIE_PORT_SERVICE_AER, | ||
72 | 60 | ||
73 | .probe = aer_probe, | 61 | .probe = aer_probe, |
74 | .remove = aer_remove, | 62 | .remove = aer_remove, |
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c index 382575007382..307452f30035 100644 --- a/drivers/pci/pcie/aer/aerdrv_core.c +++ b/drivers/pci/pcie/aer/aerdrv_core.c | |||
@@ -351,21 +351,21 @@ static int find_aer_service_iter(struct device *device, void *data) | |||
351 | { | 351 | { |
352 | struct device_driver *driver; | 352 | struct device_driver *driver; |
353 | struct pcie_port_service_driver *service_driver; | 353 | struct pcie_port_service_driver *service_driver; |
354 | struct pcie_device *pcie_dev; | ||
355 | struct find_aer_service_data *result; | 354 | struct find_aer_service_data *result; |
356 | 355 | ||
357 | result = (struct find_aer_service_data *) data; | 356 | result = (struct find_aer_service_data *) data; |
358 | 357 | ||
359 | if (device->bus == &pcie_port_bus_type) { | 358 | if (device->bus == &pcie_port_bus_type) { |
360 | pcie_dev = to_pcie_device(device); | 359 | struct pcie_port_data *port_data; |
361 | if (pcie_dev->id.port_type == PCIE_SW_DOWNSTREAM_PORT) | 360 | |
361 | port_data = pci_get_drvdata(to_pcie_device(device)->port); | ||
362 | if (port_data->port_type == PCIE_SW_DOWNSTREAM_PORT) | ||
362 | result->is_downstream = 1; | 363 | result->is_downstream = 1; |
363 | 364 | ||
364 | driver = device->driver; | 365 | driver = device->driver; |
365 | if (driver) { | 366 | if (driver) { |
366 | service_driver = to_service_driver(driver); | 367 | service_driver = to_service_driver(driver); |
367 | if (service_driver->id_table->service_type == | 368 | if (service_driver->service == PCIE_PORT_SERVICE_AER) { |
368 | PCIE_PORT_SERVICE_AER) { | ||
369 | result->aer_driver = service_driver; | 369 | result->aer_driver = service_driver; |
370 | return 1; | 370 | return 1; |
371 | } | 371 | } |
diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h index b0dcbc73415e..ad4d082a0344 100644 --- a/drivers/pci/pcie/portdrv.h +++ b/drivers/pci/pcie/portdrv.h | |||
@@ -28,11 +28,6 @@ | |||
28 | 28 | ||
29 | #define get_descriptor_id(type, service) (((type - 4) << 4) | service) | 29 | #define get_descriptor_id(type, service) (((type - 4) << 4) | service) |
30 | 30 | ||
31 | struct pcie_port_data { | ||
32 | int port_type; /* Type of the port */ | ||
33 | int port_irq_mode; /* [0:INTx | 1:MSI | 2:MSI-X] */ | ||
34 | }; | ||
35 | |||
36 | extern struct bus_type pcie_port_bus_type; | 31 | extern struct bus_type pcie_port_bus_type; |
37 | extern int pcie_port_device_probe(struct pci_dev *dev); | 32 | extern int pcie_port_device_probe(struct pci_dev *dev); |
38 | extern int pcie_port_device_register(struct pci_dev *dev); | 33 | extern int pcie_port_device_register(struct pci_dev *dev); |
diff --git a/drivers/pci/pcie/portdrv_bus.c b/drivers/pci/pcie/portdrv_bus.c index eec89b767f9f..ef3a4eeaebb4 100644 --- a/drivers/pci/pcie/portdrv_bus.c +++ b/drivers/pci/pcie/portdrv_bus.c | |||
@@ -26,20 +26,22 @@ EXPORT_SYMBOL_GPL(pcie_port_bus_type); | |||
26 | static int pcie_port_bus_match(struct device *dev, struct device_driver *drv) | 26 | static int pcie_port_bus_match(struct device *dev, struct device_driver *drv) |
27 | { | 27 | { |
28 | struct pcie_device *pciedev; | 28 | struct pcie_device *pciedev; |
29 | struct pcie_port_data *port_data; | ||
29 | struct pcie_port_service_driver *driver; | 30 | struct pcie_port_service_driver *driver; |
30 | 31 | ||
31 | if (drv->bus != &pcie_port_bus_type || dev->bus != &pcie_port_bus_type) | 32 | if (drv->bus != &pcie_port_bus_type || dev->bus != &pcie_port_bus_type) |
32 | return 0; | 33 | return 0; |
33 | 34 | ||
34 | pciedev = to_pcie_device(dev); | 35 | pciedev = to_pcie_device(dev); |
35 | driver = to_service_driver(drv); | 36 | driver = to_service_driver(drv); |
36 | if ( (driver->id_table->vendor != PCI_ANY_ID && | 37 | |
37 | driver->id_table->vendor != pciedev->id.vendor) || | 38 | if (driver->service != pciedev->service) |
38 | (driver->id_table->device != PCI_ANY_ID && | 39 | return 0; |
39 | driver->id_table->device != pciedev->id.device) || | 40 | |
40 | (driver->id_table->port_type != PCIE_ANY_PORT && | 41 | port_data = pci_get_drvdata(pciedev->port); |
41 | driver->id_table->port_type != pciedev->id.port_type) || | 42 | |
42 | driver->id_table->service_type != pciedev->id.service_type ) | 43 | if (driver->port_type != PCIE_ANY_PORT |
44 | && driver->port_type != port_data->port_type) | ||
43 | return 0; | 45 | return 0; |
44 | 46 | ||
45 | return 1; | 47 | return 1; |
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index 682524b0c93a..843d9e30dd3b 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c | |||
@@ -140,10 +140,7 @@ static void pcie_device_init(struct pci_dev *parent, struct pcie_device *dev, | |||
140 | 140 | ||
141 | dev->port = parent; | 141 | dev->port = parent; |
142 | dev->irq = irq; | 142 | dev->irq = irq; |
143 | dev->id.vendor = parent->vendor; | 143 | dev->service = service_type; |
144 | dev->id.device = parent->device; | ||
145 | dev->id.port_type = port_type; | ||
146 | dev->id.service_type = service_type; | ||
147 | 144 | ||
148 | /* Initialize generic device interface */ | 145 | /* Initialize generic device interface */ |
149 | device = &dev->device; | 146 | device = &dev->device; |