dm: core: Switch uclass_*_device_err to use uclass_*_device_check
authorMichal Suchanek <msuchanek@suse.de>
Sun, 25 Sep 2022 11:08:16 +0000 (13:08 +0200)
committerSimon Glass <sjg@chromium.org>
Sat, 29 Oct 2022 13:36:33 +0000 (07:36 -0600)
Clarify documentation, fix a few more cases that could be broken by the
change.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
drivers/pci/pci-uclass.c
drivers/sysinfo/sysinfo-uclass.c
include/dm/uclass.h

index 5cff81a..6dd1965 100644 (file)
@@ -1777,10 +1777,9 @@ int pci_sriov_init(struct udevice *pdev, int vf_en)
 
        bdf = dm_pci_get_bdf(pdev);
 
-       pci_get_bus(PCI_BUS(bdf), &bus);
-
-       if (!bus)
-               return -ENODEV;
+       ret = pci_get_bus(PCI_BUS(bdf), &bus);
+       if (ret)
+               return ret;
 
        bdf += PCI_BDF(0, 0, vf_offset);
 
index c5cc3cb..10194d0 100644 (file)
@@ -16,7 +16,15 @@ struct sysinfo_priv {
 
 int sysinfo_get(struct udevice **devp)
 {
-       return uclass_first_device_err(UCLASS_SYSINFO, devp);
+       int ret = uclass_first_device_err(UCLASS_SYSINFO, devp);
+
+       /*
+        * There is some very dodgy error handling in gazerbeam,
+        * do not return a device on error.
+        */
+       if (ret)
+               *devp = NULL;
+       return ret;
 }
 
 int sysinfo_detect(struct udevice *dev)
index 823a165..b1c016e 100644 (file)
@@ -350,7 +350,8 @@ int uclass_next_device(struct udevice **devp);
 /**
  * uclass_first_device_err() - Get the first device in a uclass
  *
- * The device returned is probed if necessary, and ready for use
+ * The device returned is probed if necessary, and ready for use if no error is
+ * returned
  *
  * @id: Uclass ID to look up
  * @devp: Returns pointer to the first device in that uclass, or NULL if none
@@ -361,7 +362,8 @@ int uclass_first_device_err(enum uclass_id id, struct udevice **devp);
 /**
  * uclass_next_device_err() - Get the next device in a uclass
  *
- * The device returned is probed if necessary, and ready for use
+ * The device returned is probed if necessary, and ready for use if no error is
+ * returned
  *
  * @devp: On entry, pointer to device to lookup. On exit, returns pointer
  * to the next device in the uclass if no error occurred, or NULL if
@@ -373,7 +375,8 @@ int uclass_next_device_err(struct udevice **devp);
 /**
  * uclass_first_device_check() - Get the first device in a uclass
  *
- * The device returned is probed if necessary, and ready for use
+ * The device returned is probed if necessary, and ready for use if no error is
+ * returned
  *
  * This function is useful to start iterating through a list of devices which
  * are functioning correctly and can be probed.
@@ -389,7 +392,8 @@ int uclass_first_device_check(enum uclass_id id, struct udevice **devp);
 /**
  * uclass_next_device_check() - Get the next device in a uclass
  *
- * The device returned is probed if necessary, and ready for use
+ * The device returned is probed if necessary, and ready for use if no error is
+ * returned
  *
  * This function is useful to start iterating through a list of devices which
  * are functioning correctly and can be probed.