Commit 171d149c authored by Bjorn Helgaas's avatar Bjorn Helgaas

PCI/ERR: Factor out common dev->driver expressions

Save the struct pci_driver pointer from pdev->driver instead of repeating
it several times.  No functional change.
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent ae232f09
...@@ -49,14 +49,16 @@ static int report_error_detected(struct pci_dev *dev, ...@@ -49,14 +49,16 @@ static int report_error_detected(struct pci_dev *dev,
pci_channel_state_t state, pci_channel_state_t state,
enum pci_ers_result *result) enum pci_ers_result *result)
{ {
struct pci_driver *pdrv;
pci_ers_result_t vote; pci_ers_result_t vote;
const struct pci_error_handlers *err_handler; const struct pci_error_handlers *err_handler;
device_lock(&dev->dev); device_lock(&dev->dev);
pdrv = dev->driver;
if (!pci_dev_set_io_state(dev, state) || if (!pci_dev_set_io_state(dev, state) ||
!dev->driver || !pdrv ||
!dev->driver->err_handler || !pdrv->err_handler ||
!dev->driver->err_handler->error_detected) { !pdrv->err_handler->error_detected) {
/* /*
* If any device in the subtree does not have an error_detected * If any device in the subtree does not have an error_detected
* callback, PCI_ERS_RESULT_NO_AER_DRIVER prevents subsequent * callback, PCI_ERS_RESULT_NO_AER_DRIVER prevents subsequent
...@@ -70,7 +72,7 @@ static int report_error_detected(struct pci_dev *dev, ...@@ -70,7 +72,7 @@ static int report_error_detected(struct pci_dev *dev,
vote = PCI_ERS_RESULT_NONE; vote = PCI_ERS_RESULT_NONE;
} }
} else { } else {
err_handler = dev->driver->err_handler; err_handler = pdrv->err_handler;
vote = err_handler->error_detected(dev, state); vote = err_handler->error_detected(dev, state);
} }
pci_uevent_ers(dev, vote); pci_uevent_ers(dev, vote);
...@@ -91,16 +93,18 @@ static int report_normal_detected(struct pci_dev *dev, void *data) ...@@ -91,16 +93,18 @@ static int report_normal_detected(struct pci_dev *dev, void *data)
static int report_mmio_enabled(struct pci_dev *dev, void *data) static int report_mmio_enabled(struct pci_dev *dev, void *data)
{ {
struct pci_driver *pdrv;
pci_ers_result_t vote, *result = data; pci_ers_result_t vote, *result = data;
const struct pci_error_handlers *err_handler; const struct pci_error_handlers *err_handler;
device_lock(&dev->dev); device_lock(&dev->dev);
if (!dev->driver || pdrv = dev->driver;
!dev->driver->err_handler || if (!pdrv ||
!dev->driver->err_handler->mmio_enabled) !pdrv->err_handler ||
!pdrv->err_handler->mmio_enabled)
goto out; goto out;
err_handler = dev->driver->err_handler; err_handler = pdrv->err_handler;
vote = err_handler->mmio_enabled(dev); vote = err_handler->mmio_enabled(dev);
*result = merge_result(*result, vote); *result = merge_result(*result, vote);
out: out:
...@@ -110,16 +114,18 @@ static int report_mmio_enabled(struct pci_dev *dev, void *data) ...@@ -110,16 +114,18 @@ static int report_mmio_enabled(struct pci_dev *dev, void *data)
static int report_slot_reset(struct pci_dev *dev, void *data) static int report_slot_reset(struct pci_dev *dev, void *data)
{ {
struct pci_driver *pdrv;
pci_ers_result_t vote, *result = data; pci_ers_result_t vote, *result = data;
const struct pci_error_handlers *err_handler; const struct pci_error_handlers *err_handler;
device_lock(&dev->dev); device_lock(&dev->dev);
if (!dev->driver || pdrv = dev->driver;
!dev->driver->err_handler || if (!pdrv ||
!dev->driver->err_handler->slot_reset) !pdrv->err_handler ||
!pdrv->err_handler->slot_reset)
goto out; goto out;
err_handler = dev->driver->err_handler; err_handler = pdrv->err_handler;
vote = err_handler->slot_reset(dev); vote = err_handler->slot_reset(dev);
*result = merge_result(*result, vote); *result = merge_result(*result, vote);
out: out:
...@@ -129,16 +135,18 @@ static int report_slot_reset(struct pci_dev *dev, void *data) ...@@ -129,16 +135,18 @@ static int report_slot_reset(struct pci_dev *dev, void *data)
static int report_resume(struct pci_dev *dev, void *data) static int report_resume(struct pci_dev *dev, void *data)
{ {
struct pci_driver *pdrv;
const struct pci_error_handlers *err_handler; const struct pci_error_handlers *err_handler;
device_lock(&dev->dev); device_lock(&dev->dev);
pdrv = dev->driver;
if (!pci_dev_set_io_state(dev, pci_channel_io_normal) || if (!pci_dev_set_io_state(dev, pci_channel_io_normal) ||
!dev->driver || !pdrv ||
!dev->driver->err_handler || !pdrv->err_handler ||
!dev->driver->err_handler->resume) !pdrv->err_handler->resume)
goto out; goto out;
err_handler = dev->driver->err_handler; err_handler = pdrv->err_handler;
err_handler->resume(dev); err_handler->resume(dev);
out: out:
pci_uevent_ers(dev, PCI_ERS_RESULT_RECOVERED); pci_uevent_ers(dev, PCI_ERS_RESULT_RECOVERED);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment