#include <common.h>
#include <dm.h>
+#include <errno.h>
#include <log.h>
#include <w1.h>
#include <w1-eeprom.h>
int w1_get_bus(int busnum, struct udevice **busp)
{
int ret, i = 0;
-
struct udevice *dev;
- for (ret = uclass_first_device(UCLASS_W1, &dev);
- dev && !ret;
- ret = uclass_next_device(&dev), i++) {
+ for (ret = uclass_first_device_check(UCLASS_W1, &dev);
+ dev;
+ ret = uclass_next_device_check(&dev), i++) {
if (i == busnum) {
+ if (ret) {
+ debug("Cannot probe w1 bus %d: %d (%s)\n",
+ busnum, ret, errno_str(ret));
+ return ret;
+ }
*busp = dev;
return 0;
}
}
- if (!ret) {
- debug("Cannot find w1 bus %d\n", busnum);
- ret = -ENODEV;
- }
+ debug("Cannot find w1 bus %d\n", busnum);
- return ret;
+ return -ENODEV;
}
u8 w1_get_device_family(struct udevice *dev)