aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>2010-04-15 00:20:43 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2010-05-11 15:01:38 -0400
commit517cae3829ae8cc3033c24f60e64eb251b2f0d14 (patch)
tree90f54b8aa311e16e3549bda1e1d7148bd631ddd9 /drivers
parent4f7ccf6a6085eefd2517b8c7090608c64b01ab67 (diff)
PCI: aerdrv: rework find_aer_service
The structure find_aer_service_data is no longer useful. Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> Reviewed-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> Reviewed-by: Jin Dongming <jin.dongming@np.css.fujitsu.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/pcie/aer/aerdrv_core.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
index 8d458a03afc9..8fb14aeb74dd 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -373,21 +373,16 @@ static pci_ers_result_t broadcast_error_message(struct pci_dev *dev,
373 return result_data.result; 373 return result_data.result;
374} 374}
375 375
376struct find_aer_service_data {
377 struct pcie_port_service_driver *aer_driver;
378};
379
380static int find_aer_service_iter(struct device *device, void *data) 376static int find_aer_service_iter(struct device *device, void *data)
381{ 377{
382 struct pcie_port_service_driver *service_driver; 378 struct pcie_port_service_driver *service_driver, **drv;
383 struct find_aer_service_data *result;
384 379
385 result = (struct find_aer_service_data *) data; 380 drv = (struct pcie_port_service_driver **) data;
386 381
387 if (device->bus == &pcie_port_bus_type && device->driver) { 382 if (device->bus == &pcie_port_bus_type && device->driver) {
388 service_driver = to_service_driver(device->driver); 383 service_driver = to_service_driver(device->driver);
389 if (service_driver->service == PCIE_PORT_SERVICE_AER) { 384 if (service_driver->service == PCIE_PORT_SERVICE_AER) {
390 result->aer_driver = service_driver; 385 *drv = service_driver;
391 return 1; 386 return 1;
392 } 387 }
393 } 388 }
@@ -395,11 +390,13 @@ static int find_aer_service_iter(struct device *device, void *data)
395 return 0; 390 return 0;
396} 391}
397 392
398static void find_aer_service(struct pci_dev *dev, 393static struct pcie_port_service_driver *find_aer_service(struct pci_dev *dev)
399 struct find_aer_service_data *data)
400{ 394{
401 int retval; 395 struct pcie_port_service_driver *drv = NULL;
402 retval = device_for_each_child(&dev->dev, data, find_aer_service_iter); 396
397 device_for_each_child(&dev->dev, &drv, find_aer_service_iter);
398
399 return drv;
403} 400}
404 401
405static pci_ers_result_t reset_link(struct pcie_device *aerdev, 402static pci_ers_result_t reset_link(struct pcie_device *aerdev,
@@ -407,26 +404,24 @@ static pci_ers_result_t reset_link(struct pcie_device *aerdev,
407{ 404{
408 struct pci_dev *udev; 405 struct pci_dev *udev;
409 pci_ers_result_t status; 406 pci_ers_result_t status;
410 struct find_aer_service_data data; 407 struct pcie_port_service_driver *driver;
411 408
412 if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE) 409 if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE)
413 udev = dev; 410 udev = dev;
414 else 411 else
415 udev = dev->bus->self; 412 udev = dev->bus->self;
416 413
417 data.aer_driver = NULL; 414 /* Use the aer driver of the component firstly */
418 find_aer_service(udev, &data); 415 driver = find_aer_service(udev);
419 416
420 /* 417 /*
421 * Use the aer driver of the error agent firstly. 418 * If it hasn't the driver and is downstream port, use the root port's
422 * If it hasn't the aer driver, use the root port's
423 */ 419 */
424 if (!data.aer_driver || !data.aer_driver->reset_link) { 420 if (!driver || !driver->reset_link) {
425 if (udev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM && 421 if (udev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM &&
426 aerdev->device.driver && 422 aerdev->device.driver &&
427 to_service_driver(aerdev->device.driver)->reset_link) { 423 to_service_driver(aerdev->device.driver)->reset_link) {
428 data.aer_driver = 424 driver = to_service_driver(aerdev->device.driver);
429 to_service_driver(aerdev->device.driver);
430 } else { 425 } else {
431 dev_printk(KERN_DEBUG, &dev->dev, 426 dev_printk(KERN_DEBUG, &dev->dev,
432 "no link-reset support at upstream device %s\n", 427 "no link-reset support at upstream device %s\n",
@@ -435,7 +430,7 @@ static pci_ers_result_t reset_link(struct pcie_device *aerdev,
435 } 430 }
436 } 431 }
437 432
438 status = data.aer_driver->reset_link(udev); 433 status = driver->reset_link(udev);
439 if (status != PCI_ERS_RESULT_RECOVERED) { 434 if (status != PCI_ERS_RESULT_RECOVERED) {
440 dev_printk(KERN_DEBUG, &dev->dev, 435 dev_printk(KERN_DEBUG, &dev->dev,
441 "link reset at upstream device %s failed\n", 436 "link reset at upstream device %s failed\n",