提交 694f88ef 编写于 作者: K Kenji Kaneshige 提交者: Jesse Barnes

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: NKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
上级 40717c39
...@@ -53,7 +53,7 @@ static struct pci_error_handlers aer_error_handlers = { ...@@ -53,7 +53,7 @@ static struct pci_error_handlers aer_error_handlers = {
static struct pcie_port_service_driver aerdriver = { static struct pcie_port_service_driver aerdriver = {
.name = "aer", .name = "aer",
.port_type = PCIE_RC_PORT, .port_type = PCI_EXP_TYPE_ROOT_PORT,
.service = PCIE_PORT_SERVICE_AER, .service = PCIE_PORT_SERVICE_AER,
.probe = aer_probe, .probe = aer_probe,
......
...@@ -123,9 +123,9 @@ static int set_device_error_reporting(struct pci_dev *dev, void *data) ...@@ -123,9 +123,9 @@ static int set_device_error_reporting(struct pci_dev *dev, void *data)
{ {
bool enable = *((bool *)data); bool enable = *((bool *)data);
if (dev->pcie_type == PCIE_RC_PORT || if ((dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) ||
dev->pcie_type == PCIE_SW_UPSTREAM_PORT || (dev->pcie_type == PCI_EXP_TYPE_UPSTREAM) ||
dev->pcie_type == PCIE_SW_DOWNSTREAM_PORT) { (dev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM)) {
if (enable) if (enable)
pci_enable_pcie_error_reporting(dev); pci_enable_pcie_error_reporting(dev);
else else
...@@ -437,10 +437,9 @@ static int find_aer_service_iter(struct device *device, void *data) ...@@ -437,10 +437,9 @@ static int find_aer_service_iter(struct device *device, void *data)
result = (struct find_aer_service_data *) data; result = (struct find_aer_service_data *) data;
if (device->bus == &pcie_port_bus_type) { if (device->bus == &pcie_port_bus_type) {
struct pcie_port_data *port_data; struct pcie_device *pcie = to_pcie_device(device);
port_data = pci_get_drvdata(to_pcie_device(device)->port); if (pcie->port->pcie_type == PCI_EXP_TYPE_DOWNSTREAM)
if (port_data->port_type == PCIE_SW_DOWNSTREAM_PORT)
result->is_downstream = 1; result->is_downstream = 1;
driver = device->driver; driver = device->driver;
......
...@@ -26,7 +26,6 @@ EXPORT_SYMBOL_GPL(pcie_port_bus_type); ...@@ -26,7 +26,6 @@ EXPORT_SYMBOL_GPL(pcie_port_bus_type);
static int pcie_port_bus_match(struct device *dev, struct device_driver *drv) static int pcie_port_bus_match(struct device *dev, struct device_driver *drv)
{ {
struct pcie_device *pciedev; struct pcie_device *pciedev;
struct pcie_port_data *port_data;
struct pcie_port_service_driver *driver; struct pcie_port_service_driver *driver;
if (drv->bus != &pcie_port_bus_type || dev->bus != &pcie_port_bus_type) if (drv->bus != &pcie_port_bus_type || dev->bus != &pcie_port_bus_type)
...@@ -38,10 +37,8 @@ static int pcie_port_bus_match(struct device *dev, struct device_driver *drv) ...@@ -38,10 +37,8 @@ static int pcie_port_bus_match(struct device *dev, struct device_driver *drv)
if (driver->service != pciedev->service) if (driver->service != pciedev->service)
return 0; return 0;
port_data = pci_get_drvdata(pciedev->port); if ((driver->port_type != PCIE_ANY_PORT) &&
(driver->port_type != pciedev->port->pcie_type))
if (driver->port_type != PCIE_ANY_PORT
&& driver->port_type != port_data->port_type)
return 0; return 0;
return 1; return 1;
......
...@@ -296,7 +296,6 @@ static int pcie_device_init(struct pci_dev *pdev, int service, int irq) ...@@ -296,7 +296,6 @@ static int pcie_device_init(struct pci_dev *pdev, int service, int irq)
*/ */
int pcie_port_device_register(struct pci_dev *dev) int pcie_port_device_register(struct pci_dev *dev)
{ {
struct pcie_port_data *port_data;
int status, capabilities, i, nr_service; int status, capabilities, i, nr_service;
int irqs[PCIE_PORT_DEVICE_MAXSERVICES]; int irqs[PCIE_PORT_DEVICE_MAXSERVICES];
...@@ -305,17 +304,10 @@ int pcie_port_device_register(struct pci_dev *dev) ...@@ -305,17 +304,10 @@ int pcie_port_device_register(struct pci_dev *dev)
if (!capabilities) if (!capabilities)
return -ENODEV; return -ENODEV;
/* Allocate driver data for port device */
port_data = kzalloc(sizeof(*port_data), GFP_KERNEL);
if (!port_data)
return -ENOMEM;
port_data->port_type = dev->pcie_type;
pci_set_drvdata(dev, port_data);
/* Enable PCI Express port device */ /* Enable PCI Express port device */
status = pci_enable_device(dev); status = pci_enable_device(dev);
if (status) if (status)
goto error_kfree; return status;
pci_set_master(dev); pci_set_master(dev);
/* /*
* Initialize service irqs. Don't use service devices that * Initialize service irqs. Don't use service devices that
...@@ -347,8 +339,6 @@ int pcie_port_device_register(struct pci_dev *dev) ...@@ -347,8 +339,6 @@ int pcie_port_device_register(struct pci_dev *dev)
cleanup_service_irqs(dev); cleanup_service_irqs(dev);
error_disable: error_disable:
pci_disable_device(dev); pci_disable_device(dev);
error_kfree:
kfree(port_data);
return status; return status;
} }
...@@ -416,12 +406,9 @@ static int remove_iter(struct device *dev, void *data) ...@@ -416,12 +406,9 @@ static int remove_iter(struct device *dev, void *data)
*/ */
void pcie_port_device_remove(struct pci_dev *dev) void pcie_port_device_remove(struct pci_dev *dev)
{ {
struct pcie_port_data *port_data = pci_get_drvdata(dev);
device_for_each_child(&dev->dev, NULL, remove_iter); device_for_each_child(&dev->dev, NULL, remove_iter);
cleanup_service_irqs(dev); cleanup_service_irqs(dev);
pci_disable_device(dev); pci_disable_device(dev);
kfree(port_data);
} }
/** /**
......
...@@ -10,10 +10,7 @@ ...@@ -10,10 +10,7 @@
#define _PCIEPORT_IF_H_ #define _PCIEPORT_IF_H_
/* Port Type */ /* Port Type */
#define PCIE_RC_PORT 4 /* Root port of RC */ #define PCIE_ANY_PORT (~0)
#define PCIE_SW_UPSTREAM_PORT 5 /* Upstream port of Switch */
#define PCIE_SW_DOWNSTREAM_PORT 6 /* Downstream port of Switch */
#define PCIE_ANY_PORT 7
/* Service Type */ /* Service Type */
#define PCIE_PORT_SERVICE_PME_SHIFT 0 /* Power Management Event */ #define PCIE_PORT_SERVICE_PME_SHIFT 0 /* Power Management Event */
...@@ -25,10 +22,6 @@ ...@@ -25,10 +22,6 @@
#define PCIE_PORT_SERVICE_VC_SHIFT 3 /* Virtual Channel */ #define PCIE_PORT_SERVICE_VC_SHIFT 3 /* Virtual Channel */
#define PCIE_PORT_SERVICE_VC (1 << PCIE_PORT_SERVICE_VC_SHIFT) #define PCIE_PORT_SERVICE_VC (1 << PCIE_PORT_SERVICE_VC_SHIFT)
struct pcie_port_data {
int port_type; /* Type of the port */
};
struct pcie_device { struct pcie_device {
int irq; /* Service IRQ/MSI/MSI-X Vector */ int irq; /* Service IRQ/MSI/MSI-X Vector */
struct pci_dev *port; /* Root/Upstream/Downstream Port */ struct pci_dev *port; /* Root/Upstream/Downstream Port */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册