Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 174826
b: refs/heads/master
c: 52a0f24
h: refs/heads/master
v: v3
  • Loading branch information
Kenji Kaneshige authored and Jesse Barnes committed Dec 4, 2009
1 parent 933d27b commit 2fe2441
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 52 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 898294c97500b1cdff6edce52fd34e024eb070ec
refs/heads/master: 52a0f24beabe9e89223e367c65a0156dff17265c
77 changes: 26 additions & 51 deletions trunk/drivers/pci/pcie/portdrv_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,54 +246,39 @@ static int get_port_device_capability(struct pci_dev *dev)
}

/**
* pcie_device_init - initialize PCI Express port service device
* @dev: Port service device to initialize
* @parent: PCI Express port to associate the service device with
* @port_type: Type of the port
* @service_type: Type of service to associate with the service device
* pcie_device_init - allocate and initialize PCI Express port service device
* @pdev: PCI Express port to associate the service device with
* @service: Type of service to associate with the service device
* @irq: Interrupt vector to associate with the service device
*/
static void pcie_device_init(struct pci_dev *parent, struct pcie_device *dev,
int service_type, int irq)
static int pcie_device_init(struct pci_dev *pdev, int service, int irq)
{
struct pcie_port_data *port_data = pci_get_drvdata(parent);
int retval;
struct pcie_device *pcie;
struct device *device;
int port_type = port_data->port_type;

dev->port = parent;
dev->irq = irq;
dev->service = service_type;
pcie = kzalloc(sizeof(*pcie), GFP_KERNEL);
if (!pcie)
return -ENOMEM;
pcie->port = pdev;
pcie->irq = irq;
pcie->service = service;

/* Initialize generic device interface */
device = &dev->device;
memset(device, 0, sizeof(struct device));
device = &pcie->device;
device->bus = &pcie_port_bus_type;
device->driver = NULL;
dev_set_drvdata(device, NULL);
device->release = release_pcie_device; /* callback to free pcie dev */
dev_set_name(device, "%s:pcie%02x",
pci_name(parent), get_descriptor_id(port_type, service_type));
device->parent = &parent->dev;
}

/**
* alloc_pcie_device - allocate PCI Express port service device structure
* @parent: PCI Express port to associate the service device with
* @port_type: Type of the port
* @service_type: Type of service to associate with the service device
* @irq: Interrupt vector to associate with the service device
*/
static struct pcie_device* alloc_pcie_device(struct pci_dev *parent,
int service_type, int irq)
{
struct pcie_device *device;

device = kzalloc(sizeof(struct pcie_device), GFP_KERNEL);
if (!device)
return NULL;

pcie_device_init(parent, device, service_type, irq);
return device;
pci_name(pdev),
get_descriptor_id(pdev->pcie_type, service));
device->parent = &pdev->dev;

retval = device_register(device);
if (retval)
kfree(pcie);
else
get_device(device);
return retval;
}

/**
Expand Down Expand Up @@ -346,24 +331,14 @@ int pcie_port_device_register(struct pci_dev *dev)

/* Allocate child services if any */
for (i = 0, nr_serv = 0; i < PCIE_PORT_DEVICE_MAXSERVICES; i++) {
struct pcie_device *child;
int service = 1 << i;

if (!(capabilities & service))
continue;

child = alloc_pcie_device(dev, service, vectors[i]);
if (!child)
continue;

status = device_register(&child->device);
if (status) {
kfree(child);
continue;
}

get_device(&child->device);
nr_serv++;
status = pcie_device_init(dev, service, vectors[i]);
if (!status)
nr_serv++;
}
if (!nr_serv) {
pci_disable_device(dev);
Expand Down

0 comments on commit 2fe2441

Please sign in to comment.