diff options
author | Geliang Tang <geliangtang@163.com> | 2016-01-22 09:50:19 -0500 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2016-02-04 17:03:53 -0500 |
commit | 0e6053dc6e7a42c8ba9ce6e81adb3350c7df4bc8 (patch) | |
tree | c7f492c0ee6ad434231f524176a9ee33b0678563 /drivers/pci/pcie | |
parent | 7e8fbdc628760857369af05636ed4ddc4fc8569b (diff) |
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.c | 13 |
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) | |||
124 | static struct pci_bus_ops *pci_bus_ops_pop(void) | 124 | static struct pci_bus_ops *pci_bus_ops_pop(void) |
125 | { | 125 | { |
126 | unsigned long flags; | 126 | unsigned long flags; |
127 | struct pci_bus_ops *bus_ops = NULL; | 127 | struct pci_bus_ops *bus_ops; |
128 | 128 | ||
129 | spin_lock_irqsave(&inject_lock, flags); | 129 | spin_lock_irqsave(&inject_lock, flags); |
130 | if (list_empty(&pci_bus_ops_list)) | 130 | bus_ops = list_first_entry_or_null(&pci_bus_ops_list, |
131 | bus_ops = NULL; | 131 | struct pci_bus_ops, list); |
132 | else { | 132 | if (bus_ops) |
133 | struct list_head *lh = pci_bus_ops_list.next; | 133 | list_del(&bus_ops->list); |
134 | list_del(lh); | ||
135 | bus_ops = list_entry(lh, struct pci_bus_ops, list); | ||
136 | } | ||
137 | spin_unlock_irqrestore(&inject_lock, flags); | 134 | spin_unlock_irqrestore(&inject_lock, flags); |
138 | return bus_ops; | 135 | return bus_ops; |
139 | } | 136 | } |