DTS parsing improvement for phandle-array created by #define

This commit is contained in:
Ken Van Hoeylandt 2026-02-10 23:07:56 +01:00
parent f491a86064
commit e960cd93c3

View File

@ -77,6 +77,20 @@ def property_to_string(property: DeviceProperty, devices: list[Device]) -> str:
return "{ " + ",".join(value_list) + " }" return "{ " + ",".join(value_list) + " }"
elif type == "phandle": elif type == "phandle":
return find_phandle(devices, property.value) return find_phandle(devices, property.value)
elif type == "phandle-array":
value_list = list()
if isinstance(property.value, list):
for item in property.value:
if isinstance(item, PropertyValue):
value_list.append(property_to_string(DeviceProperty(name="", type=item.type, value=item.value), devices))
else:
value_list.append(str(item))
return "{ " + ",".join(value_list) + " }"
elif isinstance(property.value, str):
# If it's a string, assume it's a #define and show it as-is
return property.value
else:
raise Exception(f"Unsupported phandle-array type for {property.value}")
else: else:
raise DevicetreeException(f"property_to_string() has an unsupported type: {type}") raise DevicetreeException(f"property_to_string() has an unsupported type: {type}")