@@ -154,7 +154,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
154154 acpi_handle tmp ;
155155 acpi_status status = AE_OK ;
156156 unsigned long long adr , sun ;
157- int device , function , retval ;
157+ int device , function , retval , found = 0 ;
158158 struct pci_bus * pbus = bridge -> pci_bus ;
159159 struct pci_dev * pdev ;
160160 u32 val ;
@@ -208,14 +208,15 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
208208 }
209209
210210 /* search for objects that share the same slot */
211- for (slot = bridge -> slots ; slot ; slot = slot -> next )
211+ list_for_each_entry (slot , & bridge -> slots , node )
212212 if (slot -> device == device ) {
213213 if (slot -> sun != sun )
214214 warn ("sibling found, but _SUN doesn't match!\n" );
215+ found = 1 ;
215216 break ;
216217 }
217218
218- if (!slot ) {
219+ if (!found ) {
219220 slot = kzalloc (sizeof (struct acpiphp_slot ), GFP_KERNEL );
220221 if (!slot ) {
221222 kfree (newfunc );
@@ -228,9 +229,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
228229 INIT_LIST_HEAD (& slot -> funcs );
229230 mutex_init (& slot -> crit_sect );
230231
231- slot -> next = bridge -> slots ;
232- bridge -> slots = slot ;
233-
232+ list_add_tail (& slot -> node , & bridge -> slots );
234233 bridge -> nr_slots ++ ;
235234
236235 dbg ("found ACPI PCI Hotplug slot %llu at PCI %04x:%02x:%02x\n" ,
@@ -289,7 +288,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
289288
290289 err_exit :
291290 bridge -> nr_slots -- ;
292- bridge -> slots = slot -> next ;
291+ list_del ( & slot -> node ) ;
293292 kfree (slot );
294293 kfree (newfunc );
295294
@@ -353,7 +352,7 @@ static struct acpiphp_func *acpiphp_bridge_handle_to_function(acpi_handle handle
353352 struct acpiphp_func * func ;
354353
355354 list_for_each_entry (bridge , & bridge_list , list ) {
356- for (slot = bridge -> slots ; slot ; slot = slot -> next ) {
355+ list_for_each_entry (slot , & bridge -> slots , node ) {
357356 list_for_each_entry (func , & slot -> funcs , sibling ) {
358357 if (func -> handle == handle )
359358 return func ;
@@ -400,9 +399,7 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
400399 err ("failed to install interrupt notify handler\n" );
401400 }
402401
403- slot = bridge -> slots ;
404- while (slot ) {
405- next = slot -> next ;
402+ list_for_each_entry_safe (slot , next , & bridge -> slots , node ) {
406403 list_for_each_entry_safe (func , tmp , & slot -> funcs , sibling ) {
407404 if (is_dock_device (func -> handle )) {
408405 unregister_hotplug_dock_device (func -> handle );
@@ -421,7 +418,6 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
421418 acpiphp_unregister_hotplug_slot (slot );
422419 list_del (& slot -> funcs );
423420 kfree (slot );
424- slot = next ;
425421 }
426422
427423 put_device (& bridge -> pci_bus -> dev );
@@ -820,7 +816,7 @@ static int acpiphp_check_bridge(struct acpiphp_bridge *bridge)
820816
821817 enabled = disabled = 0 ;
822818
823- for (slot = bridge -> slots ; slot ; slot = slot -> next ) {
819+ list_for_each_entry (slot , & bridge -> slots , node ) {
824820 unsigned int status = get_slot_status (slot );
825821 if (slot -> flags & SLOT_ENABLED ) {
826822 if (status == ACPI_STA_ALL )
@@ -1098,6 +1094,7 @@ void acpiphp_enumerate_slots(struct pci_bus *bus, acpi_handle handle)
10981094 return ;
10991095 }
11001096
1097+ INIT_LIST_HEAD (& bridge -> slots );
11011098 bridge -> handle = handle ;
11021099 bridge -> pci_dev = pci_dev_get (bus -> self );
11031100 bridge -> pci_bus = bus ;
0 commit comments