rockchip: rk3328: rock64 - fix gen3 SPL hang
[oweals/u-boot.git] / drivers / w1 / w1-uclass.c
index aecf7fec77cf7bcc90e4d7f34fb4cbe919f9c16f..9478c93e9b0c9aecefdc45fd01f3bb15efe71ed6 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <log.h>
 #include <w1.h>
 #include <w1-eeprom.h>
 
@@ -84,10 +85,6 @@ static int w1_enumerate(struct udevice *bus)
                        rn |= (tmp64 << i);
                }
 
-               /* last device or error, aborting here */
-               if ((triplet_ret & 0x03) == 0x03)
-                       last_device = true;
-
                if ((triplet_ret & 0x03) != 0x03) {
                        if (desc_bit == last_zero || last_zero < 0) {
                                last_device = 1;
@@ -115,17 +112,19 @@ int w1_get_bus(int busnum, struct udevice **busp)
        struct udevice *dev;
 
        for (ret = uclass_first_device(UCLASS_W1, &dev);
-            !ret;
-            uclass_next_device(&dev), i++) {
-               if (ret) {
-                       debug("Cannot find w1 bus %d\n", busnum);
-                       return ret;
-               }
+            dev && !ret;
+            ret = uclass_next_device(&dev), i++) {
                if (i == busnum) {
                        *busp = dev;
                        return 0;
                }
        }
+
+       if (!ret) {
+               debug("Cannot find w1 bus %d\n", busnum);
+               ret = -ENODEV;
+       }
+
        return ret;
 }