summaryrefslogtreecommitdiffstats
path: root/drivers/pci/pcie
diff options
context:
space:
mode:
authorGeliang Tang <geliangtang@163.com>2016-01-22 22:50:19 +0800
committerBjorn Helgaas <bhelgaas@google.com>2016-02-04 16:03:53 -0600
commit0e6053dc6e7a42c8ba9ce6e81adb3350c7df4bc8 (patch)
treec7f492c0ee6ad434231f524176a9ee33b0678563 /drivers/pci/pcie
parent7e8fbdc628760857369af05636ed4ddc4fc8569b (diff)
downloadlinux-0e6053dc6e7a42c8ba9ce6e81adb3350c7df4bc8.tar.bz2
PCI/AER: Use list_first_entry_or_null() to simplify code
Use list_first_entry_or_null() instead of list_empty() + list_entry() to simplify the code. Signed-off-by: Geliang Tang <geliangtang@163.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/pcie')
-rw-r--r--drivers/pci/pcie/aer/aer_inject.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/pci/pcie/aer/aer_inject.c b/drivers/pci/pcie/aer/aer_inject.c
index 79a5e112711a..e2760a39a98a 100644
--- a/drivers/pci/pcie/aer/aer_inject.c
+++ b/drivers/pci/pcie/aer/aer_inject.c
@@ -124,16 +124,13 @@ static struct pci_ops *__find_pci_bus_ops(struct pci_bus *bus)
static struct pci_bus_ops *pci_bus_ops_pop(void)
{
unsigned long flags;
- struct pci_bus_ops *bus_ops = NULL;
+ struct pci_bus_ops *bus_ops;
spin_lock_irqsave(&inject_lock, flags);
- if (list_empty(&pci_bus_ops_list))
- bus_ops = NULL;
- else {
- struct list_head *lh = pci_bus_ops_list.next;
- list_del(lh);
- bus_ops = list_entry(lh, struct pci_bus_ops, list);
- }
+ bus_ops = list_first_entry_or_null(&pci_bus_ops_list,
+ struct pci_bus_ops, list);
+ if (bus_ops)
+ list_del(&bus_ops->list);
spin_unlock_irqrestore(&inject_lock, flags);
return bus_ops;
}