- ret = uclass_find_device_by_of_offset(UCLASS_DISPLAY, offset, &disp);
- if (ret) {
- debug("%s: device '%s' display not found (ret=%d)\n", __func__,
- dev->name, ret);
- return ret;
- }
+ /*
+ * The remote-endpoint references into a subnode of the encoder
+ * (i.e. HDMI, MIPI, etc.) with the DTS looking something like
+ * the following (assume 'hdmi_in_vopl' to be referenced):
+ *
+ * hdmi: hdmi@ff940000 {
+ * ports {
+ * hdmi_in: port {
+ * hdmi_in_vopb: endpoint@0 { ... };
+ * hdmi_in_vopl: endpoint@1 { ... };
+ * }
+ * }
+ * }
+ *
+ * The original code had 3 steps of "walking the parent", but
+ * a much better (as in: less likely to break if the DTS
+ * changes) way of doing this is to "find the enclosing device
+ * of UCLASS_DISPLAY".
+ */
+ while (ofnode_valid(remote)) {
+ remote = ofnode_get_parent(remote);
+ if (!ofnode_valid(remote)) {
+ debug("%s(%s): no UCLASS_DISPLAY for remote-endpoint\n",
+ __func__, dev_read_name(dev));
+ return -EINVAL;
+ }
+
+ uclass_find_device_by_ofnode(UCLASS_DISPLAY, remote, &disp);
+ if (disp)
+ break;
+ };