+int uclass_get_device_by_ofnode(enum uclass_id id, ofnode node,
+ struct udevice **devp)
+{
+ struct udevice *dev;
+ int ret;
+
+ log(LOGC_DM, LOGL_DEBUG, "Looking for %s\n", ofnode_get_name(node));
+ *devp = NULL;
+ ret = uclass_find_device_by_ofnode(id, node, &dev);
+ log(LOGC_DM, LOGL_DEBUG, " - result for %s: %s (ret=%d)\n",
+ ofnode_get_name(node), dev ? dev->name : "(none)", ret);
+
+ return uclass_get_device_tail(dev, ret, devp);
+}
+
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+int uclass_get_device_by_phandle_id(enum uclass_id id, uint phandle_id,
+ struct udevice **devp)
+{
+ struct udevice *dev;
+ struct uclass *uc;
+ int ret;
+
+ *devp = NULL;
+ ret = uclass_get(id, &uc);
+ if (ret)
+ return ret;
+
+ uclass_foreach_dev(dev, uc) {
+ uint phandle;
+
+ phandle = dev_read_phandle(dev);
+
+ if (phandle == phandle_id) {
+ *devp = dev;
+ return uclass_get_device_tail(dev, ret, devp);
+ }
+ }
+
+ return -ENODEV;
+}
+