dm: pci: Fix device PCI iteration
When there is no PCI bus uclass_first_device will return no bus and no
error which will result in pci_find_first_device calling
skip_to_next_device with no bus, and the bus is only checked at the end
of the while cycle, not the beginning.
Fixes: 76c3fbcd3d ("dm: pci: Add a way to iterate through all PCI devices")
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
			
			
This commit is contained in:
		
							parent
							
								
									c0648b7b9d
								
							
						
					
					
						commit
						5afe93a18c
					
				| 
						 | 
					@ -1217,7 +1217,7 @@ static int skip_to_next_device(struct udevice *bus, struct udevice **devp)
 | 
				
			||||||
	 * Scan through all the PCI controllers. On x86 there will only be one
 | 
						 * Scan through all the PCI controllers. On x86 there will only be one
 | 
				
			||||||
	 * but that is not necessarily true on other hardware.
 | 
						 * but that is not necessarily true on other hardware.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	do {
 | 
						while (bus) {
 | 
				
			||||||
		device_find_first_child(bus, &dev);
 | 
							device_find_first_child(bus, &dev);
 | 
				
			||||||
		if (dev) {
 | 
							if (dev) {
 | 
				
			||||||
			*devp = dev;
 | 
								*devp = dev;
 | 
				
			||||||
| 
						 | 
					@ -1226,7 +1226,7 @@ static int skip_to_next_device(struct udevice *bus, struct udevice **devp)
 | 
				
			||||||
		ret = uclass_next_device(&bus);
 | 
							ret = uclass_next_device(&bus);
 | 
				
			||||||
		if (ret)
 | 
							if (ret)
 | 
				
			||||||
			return ret;
 | 
								return ret;
 | 
				
			||||||
	} while (bus);
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue