Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: Remove pci_bus_b() and use list_for_each_entry() directly

Replace list_for_each() with list_for_each_entry(), which means we no
longer need pci_bus_b() and can remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Yijing Wang and committed by
Bjorn Helgaas
94e6a9b9 560698e9

+8 -9
+3 -3
drivers/pci/pci.c
··· 108 108 */ 109 109 unsigned char pci_bus_max_busnr(struct pci_bus* bus) 110 110 { 111 - struct list_head *tmp; 111 + struct pci_bus *tmp; 112 112 unsigned char max, n; 113 113 114 114 max = bus->busn_res.end; 115 - list_for_each(tmp, &bus->children) { 116 - n = pci_bus_max_busnr(pci_bus_b(tmp)); 115 + list_for_each_entry(tmp, &bus->children, node) { 116 + n = pci_bus_max_busnr(tmp); 117 117 if(n > max) 118 118 max = n; 119 119 }
+5 -5
drivers/pci/search.c
··· 54 54 55 55 static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr) 56 56 { 57 - struct pci_bus* child; 58 - struct list_head *tmp; 57 + struct pci_bus *child; 58 + struct pci_bus *tmp; 59 59 60 60 if(bus->number == busnr) 61 61 return bus; 62 62 63 - list_for_each(tmp, &bus->children) { 64 - child = pci_do_find_bus(pci_bus_b(tmp), busnr); 63 + list_for_each_entry(tmp, &bus->children, node) { 64 + child = pci_do_find_bus(tmp, busnr); 65 65 if(child) 66 66 return child; 67 67 } ··· 111 111 down_read(&pci_bus_sem); 112 112 n = from ? from->node.next : pci_root_buses.next; 113 113 if (n != &pci_root_buses) 114 - b = pci_bus_b(n); 114 + b = list_entry(n, struct pci_bus, node); 115 115 up_read(&pci_bus_sem); 116 116 return b; 117 117 }
-1
include/linux/pci.h
··· 461 461 unsigned int is_added:1; 462 462 }; 463 463 464 - #define pci_bus_b(n) list_entry(n, struct pci_bus, node) 465 464 #define to_pci_bus(n) container_of(n, struct pci_bus, dev) 466 465 467 466 /*