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

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>

authored by

Kenji Kaneshige and committed by
Jesse Barnes
694f88ef 40717c39

+10 -34
+1 -1
drivers/pci/pcie/aer/aerdrv.c
··· 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,
+5 -6
drivers/pci/pcie/aer/aerdrv_core.c
··· 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 ··· 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;
+2 -5
drivers/pci/pcie/portdrv_bus.c
··· 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) ··· 37 38 if (driver->service != pciedev->service) 38 39 return 0; 39 40 40 - port_data = pci_get_drvdata(pciedev->port); 41 - 42 - if (driver->port_type != PCIE_ANY_PORT 43 - && driver->port_type != port_data->port_type) 41 + if ((driver->port_type != PCIE_ANY_PORT) && 42 + (driver->port_type != pciedev->port->pcie_type)) 44 43 return 0; 45 44 46 45 return 1;
+1 -14
drivers/pci/pcie/portdrv_core.c
··· 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 ··· 304 305 if (!capabilities) 305 306 return -ENODEV; 306 307 307 - /* Allocate driver data for port device */ 308 - port_data = kzalloc(sizeof(*port_data), GFP_KERNEL); 309 - if (!port_data) 310 - return -ENOMEM; 311 - port_data->port_type = dev->pcie_type; 312 - pci_set_drvdata(dev, port_data); 313 - 314 308 /* Enable PCI Express port device */ 315 309 status = pci_enable_device(dev); 316 310 if (status) 317 - goto error_kfree; 311 + return status; 318 312 pci_set_master(dev); 319 313 /* 320 314 * Initialize service irqs. Don't use service devices that ··· 339 347 cleanup_service_irqs(dev); 340 348 error_disable: 341 349 pci_disable_device(dev); 342 - error_kfree: 343 - kfree(port_data); 344 350 return status; 345 351 } 346 352 ··· 406 416 */ 407 417 void pcie_port_device_remove(struct pci_dev *dev) 408 418 { 409 - struct pcie_port_data *port_data = pci_get_drvdata(dev); 410 - 411 419 device_for_each_child(&dev->dev, NULL, remove_iter); 412 420 cleanup_service_irqs(dev); 413 421 pci_disable_device(dev); 414 - kfree(port_data); 415 422 } 416 423 417 424 /**
+1 -8
include/linux/pcieport_if.h
··· 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 */ ··· 21 24 #define PCIE_PORT_SERVICE_HP (1 << PCIE_PORT_SERVICE_HP_SHIFT) 22 25 #define PCIE_PORT_SERVICE_VC_SHIFT 3 /* Virtual Channel */ 23 26 #define PCIE_PORT_SERVICE_VC (1 << PCIE_PORT_SERVICE_VC_SHIFT) 24 - 25 - struct pcie_port_data { 26 - int port_type; /* Type of the port */ 27 - }; 28 27 29 28 struct pcie_device { 30 29 int irq; /* Service IRQ/MSI/MSI-X Vector */