Commit 694f88ef7ada0d99e304f687ba92e268a594358b

Authored by Kenji Kaneshige
Committed by Jesse Barnes
1 parent 40717c39b1

PCI: portdrv: remove unnecessary struct pcie_port_data

Remove 'port_type' field in struct pcie_port_data(), because we can
get port type information from struct pci_dev. With this change, this
patch also does followings:

 - Remove struct pcie_port_data because it no longer has any field.
 - Remove portdrv private definitions about port type (PCIE_RC_PORT,
   PCIE_SW_UPSTREAM_PORT and PCIE_SW_DOWNSTREAM_PORT), and use generic
   definitions instead.

Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>

Showing 5 changed files with 10 additions and 34 deletions Side-by-side Diff

drivers/pci/pcie/aer/aerdrv.c
... ... @@ -53,7 +53,7 @@
53 53  
54 54 static struct pcie_port_service_driver aerdriver = {
55 55 .name = "aer",
56   - .port_type = PCIE_RC_PORT,
  56 + .port_type = PCI_EXP_TYPE_ROOT_PORT,
57 57 .service = PCIE_PORT_SERVICE_AER,
58 58  
59 59 .probe = aer_probe,
drivers/pci/pcie/aer/aerdrv_core.c
... ... @@ -123,9 +123,9 @@
123 123 {
124 124 bool enable = *((bool *)data);
125 125  
126   - if (dev->pcie_type == PCIE_RC_PORT ||
127   - dev->pcie_type == PCIE_SW_UPSTREAM_PORT ||
128   - dev->pcie_type == PCIE_SW_DOWNSTREAM_PORT) {
  126 + if ((dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) ||
  127 + (dev->pcie_type == PCI_EXP_TYPE_UPSTREAM) ||
  128 + (dev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM)) {
129 129 if (enable)
130 130 pci_enable_pcie_error_reporting(dev);
131 131 else
132 132  
... ... @@ -437,10 +437,9 @@
437 437 result = (struct find_aer_service_data *) data;
438 438  
439 439 if (device->bus == &pcie_port_bus_type) {
440   - struct pcie_port_data *port_data;
  440 + struct pcie_device *pcie = to_pcie_device(device);
441 441  
442   - port_data = pci_get_drvdata(to_pcie_device(device)->port);
443   - if (port_data->port_type == PCIE_SW_DOWNSTREAM_PORT)
  442 + if (pcie->port->pcie_type == PCI_EXP_TYPE_DOWNSTREAM)
444 443 result->is_downstream = 1;
445 444  
446 445 driver = device->driver;
drivers/pci/pcie/portdrv_bus.c
... ... @@ -26,7 +26,6 @@
26 26 static int pcie_port_bus_match(struct device *dev, struct device_driver *drv)
27 27 {
28 28 struct pcie_device *pciedev;
29   - struct pcie_port_data *port_data;
30 29 struct pcie_port_service_driver *driver;
31 30  
32 31 if (drv->bus != &pcie_port_bus_type || dev->bus != &pcie_port_bus_type)
... ... @@ -38,10 +37,8 @@
38 37 if (driver->service != pciedev->service)
39 38 return 0;
40 39  
41   - port_data = pci_get_drvdata(pciedev->port);
42   -
43   - if (driver->port_type != PCIE_ANY_PORT
44   - && driver->port_type != port_data->port_type)
  40 + if ((driver->port_type != PCIE_ANY_PORT) &&
  41 + (driver->port_type != pciedev->port->pcie_type))
45 42 return 0;
46 43  
47 44 return 1;
drivers/pci/pcie/portdrv_core.c
... ... @@ -296,7 +296,6 @@
296 296 */
297 297 int pcie_port_device_register(struct pci_dev *dev)
298 298 {
299   - struct pcie_port_data *port_data;
300 299 int status, capabilities, i, nr_service;
301 300 int irqs[PCIE_PORT_DEVICE_MAXSERVICES];
302 301  
303 302  
... ... @@ -305,17 +304,10 @@
305 304 if (!capabilities)
306 305 return -ENODEV;
307 306  
308   - /* Allocate driver data for port device */
309   - port_data = kzalloc(sizeof(*port_data), GFP_KERNEL);
310   - if (!port_data)
311   - return -ENOMEM;
312   - port_data->port_type = dev->pcie_type;
313   - pci_set_drvdata(dev, port_data);
314   -
315 307 /* Enable PCI Express port device */
316 308 status = pci_enable_device(dev);
317 309 if (status)
318   - goto error_kfree;
  310 + return status;
319 311 pci_set_master(dev);
320 312 /*
321 313 * Initialize service irqs. Don't use service devices that
... ... @@ -347,8 +339,6 @@
347 339 cleanup_service_irqs(dev);
348 340 error_disable:
349 341 pci_disable_device(dev);
350   -error_kfree:
351   - kfree(port_data);
352 342 return status;
353 343 }
354 344  
355 345  
... ... @@ -416,12 +406,9 @@
416 406 */
417 407 void pcie_port_device_remove(struct pci_dev *dev)
418 408 {
419   - struct pcie_port_data *port_data = pci_get_drvdata(dev);
420   -
421 409 device_for_each_child(&dev->dev, NULL, remove_iter);
422 410 cleanup_service_irqs(dev);
423 411 pci_disable_device(dev);
424   - kfree(port_data);
425 412 }
426 413  
427 414 /**
include/linux/pcieport_if.h
... ... @@ -10,10 +10,7 @@
10 10 #define _PCIEPORT_IF_H_
11 11  
12 12 /* Port Type */
13   -#define PCIE_RC_PORT 4 /* Root port of RC */
14   -#define PCIE_SW_UPSTREAM_PORT 5 /* Upstream port of Switch */
15   -#define PCIE_SW_DOWNSTREAM_PORT 6 /* Downstream port of Switch */
16   -#define PCIE_ANY_PORT 7
  13 +#define PCIE_ANY_PORT (~0)
17 14  
18 15 /* Service Type */
19 16 #define PCIE_PORT_SERVICE_PME_SHIFT 0 /* Power Management Event */
... ... @@ -24,10 +21,6 @@
24 21 #define PCIE_PORT_SERVICE_HP (1 << PCIE_PORT_SERVICE_HP_SHIFT)
25 22 #define PCIE_PORT_SERVICE_VC_SHIFT 3 /* Virtual Channel */
26 23 #define PCIE_PORT_SERVICE_VC (1 << PCIE_PORT_SERVICE_VC_SHIFT)
27   -
28   -struct pcie_port_data {
29   - int port_type; /* Type of the port */
30   -};
31 24  
32 25 struct pcie_device {
33 26 int irq; /* Service IRQ/MSI/MSI-X Vector */