On 6/7/21 13:05, David Gibson wrote:
On Fri, Jun 04, 2021 at 03:50:28PM +0200, BALATON Zoltan wrote:
On Fri, 4 Jun 2021, David Gibson wrote:
On Sun, May 30, 2021 at 07:33:01PM +0200, BALATON Zoltan wrote:
[snip]
MorphOS checks the name property of the root node ("/") to decide what
platform it runs on so we may need to be able to set this property on /
where it should return "bplan,Pegasos2", therefore the above maybe should do
getprop first and only generate name property if it's not set (or at least
check if we're on the root node and allow setting name property there). (On
Macs the root node is named "device-tree" and this was before found to be
needed for MorphOS.)

Ah.  Hrm.  Have to think about what to do about that.

This is easy to fix, this seems to allow setting a name property or return a
default:

diff --git a/hw/ppc/vof.c b/hw/ppc/vof.c
index b47bbd509d..746842593e 100644
--- a/hw/ppc/vof.c
+++ b/hw/ppc/vof.c
@@ -163,14 +163,14 @@ static uint32_t vof_finddevice(const void *fdt,
uint32_t nodeaddr)
  static const void *getprop(const void *fdt, int nodeoff, const char *propname,
                             int *proplen, bool *write0)
  {
-    const char *unit, *prop;
+    const char *unit, *prop = fdt_getprop(fdt, nodeoff, propname, proplen);

      /*
       * The "name" property is not actually stored as a property in the FDT,
       * we emulate it by returning a pointer to the node's name and adjust
       * proplen to include only the name but not the unit.
       */
-    if (strcmp(propname, "name") == 0) {
+    if (!prop && strcmp(propname, "name") == 0) {
          prop = fdt_get_name(fdt, nodeoff, proplen);
          if (!prop) {
              *proplen = 0;
@@ -196,7 +196,7 @@ static const void *getprop(const void *fdt, int nodeoff, 
const char *propname,
      if (write0) {
          *write0 = false;
      }
-    return fdt_getprop(fdt, nodeoff, propname, proplen);
+    return prop;
  }

Kind of a hack, but it'll do for now.


oops missed this subthread but I ended up doing it anyway, just tiny bit different.



--
Alexey

Reply via email to