diff mbox series

[v4,43/44] dm: core: Tweak device_is_on_pci_bus() for code size

Message ID 20230926141514.2101787-44-sjg@chromium.org
State Accepted
Commit 61fc132051740e0378a5e71f3db6cb1581e970fe
Delegated to: Tom Rini
Headers show
Series spl: Preparation for Universal Payload | expand

Commit Message

Simon Glass Sept. 26, 2023, 2:14 p.m. UTC
This function cannot return true if PCI is not enabled, since no PCI
devices will have been bound. Add a check for this to reduce code size
where it is used.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v4:
- Add new patch to tweak device_is_on_pci_bus() for code size

 include/dm/device.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/include/dm/device.h b/include/dm/device.h
index e54cb6bca415..add67f9ec06f 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -1005,7 +1005,8 @@  int dev_enable_by_path(const char *path);
  */
 static inline bool device_is_on_pci_bus(const struct udevice *dev)
 {
-	return dev->parent && device_get_uclass_id(dev->parent) == UCLASS_PCI;
+	return CONFIG_IS_ENABLED(PCI) && dev->parent &&
+		device_get_uclass_id(dev->parent) == UCLASS_PCI;
 }
 
 /**