PCI/ERR: Factor out common dev->driver expressions
authorBjorn Helgaas <bhelgaas@google.com>
Tue, 12 Oct 2021 22:20:06 +0000 (17:20 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 12 Oct 2021 22:37:15 +0000 (17:37 -0500)
Save the struct pci_driver pointer from pdev->driver instead of repeating
it several times.  No functional change.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pcie/err.c

index b576aa890c76ba2a486a809a39f5ed5c0a351f38..0c5a143025af435e9728ef319185915562d831b2 100644 (file)
@@ -49,14 +49,16 @@ static int report_error_detected(struct pci_dev *dev,
                                 pci_channel_state_t state,
                                 enum pci_ers_result *result)
 {
+       struct pci_driver *pdrv;
        pci_ers_result_t vote;
        const struct pci_error_handlers *err_handler;
 
        device_lock(&dev->dev);
+       pdrv = dev->driver;
        if (!pci_dev_set_io_state(dev, state) ||
-               !dev->driver ||
-               !dev->driver->err_handler ||
-               !dev->driver->err_handler->error_detected) {
+               !pdrv ||
+               !pdrv->err_handler ||
+               !pdrv->err_handler->error_detected) {
                /*
                 * If any device in the subtree does not have an error_detected
                 * callback, PCI_ERS_RESULT_NO_AER_DRIVER prevents subsequent
@@ -70,7 +72,7 @@ static int report_error_detected(struct pci_dev *dev,
                        vote = PCI_ERS_RESULT_NONE;
                }
        } else {
-               err_handler = dev->driver->err_handler;
+               err_handler = pdrv->err_handler;
                vote = err_handler->error_detected(dev, state);
        }
        pci_uevent_ers(dev, vote);
@@ -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)
 {
+       struct pci_driver *pdrv;
        pci_ers_result_t vote, *result = data;
        const struct pci_error_handlers *err_handler;
 
        device_lock(&dev->dev);
-       if (!dev->driver ||
-               !dev->driver->err_handler ||
-               !dev->driver->err_handler->mmio_enabled)
+       pdrv = dev->driver;
+       if (!pdrv ||
+               !pdrv->err_handler ||
+               !pdrv->err_handler->mmio_enabled)
                goto out;
 
-       err_handler = dev->driver->err_handler;
+       err_handler = pdrv->err_handler;
        vote = err_handler->mmio_enabled(dev);
        *result = merge_result(*result, vote);
 out:
@@ -110,16 +114,18 @@ out:
 
 static int report_slot_reset(struct pci_dev *dev, void *data)
 {
+       struct pci_driver *pdrv;
        pci_ers_result_t vote, *result = data;
        const struct pci_error_handlers *err_handler;
 
        device_lock(&dev->dev);
-       if (!dev->driver ||
-               !dev->driver->err_handler ||
-               !dev->driver->err_handler->slot_reset)
+       pdrv = dev->driver;
+       if (!pdrv ||
+               !pdrv->err_handler ||
+               !pdrv->err_handler->slot_reset)
                goto out;
 
-       err_handler = dev->driver->err_handler;
+       err_handler = pdrv->err_handler;
        vote = err_handler->slot_reset(dev);
        *result = merge_result(*result, vote);
 out:
@@ -129,16 +135,18 @@ out:
 
 static int report_resume(struct pci_dev *dev, void *data)
 {
+       struct pci_driver *pdrv;
        const struct pci_error_handlers *err_handler;
 
        device_lock(&dev->dev);
+       pdrv = dev->driver;
        if (!pci_dev_set_io_state(dev, pci_channel_io_normal) ||
-               !dev->driver ||
-               !dev->driver->err_handler ||
-               !dev->driver->err_handler->resume)
+               !pdrv ||
+               !pdrv->err_handler ||
+               !pdrv->err_handler->resume)
                goto out;
 
-       err_handler = dev->driver->err_handler;
+       err_handler = pdrv->err_handler;
        err_handler->resume(dev);
 out:
        pci_uevent_ers(dev, PCI_ERS_RESULT_RECOVERED);