Re: [PATCH] commands: of_property: Extend command usage on external dtb

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Sascha,

Am Freitag, dem 25.06.2021 um 09:50 +0200 schrieb Sascha Hauer:
> Hi,
> 
> On Thu, Jun 24, 2021 at 05:28:10PM +0200, Yunus Bas wrote:
> > @@ -314,6 +320,9 @@ static int do_of_property(int argc, char
> > *argv[])
> >                 case 'f':
> >                         fixup = 1;
> >                         break;
> > +               case 'e':
> > +                       dtbfile = optarg;
> > +                       break;
> >                 default:
> >                         return COMMAND_ERROR_USAGE;
> >                 }
> > @@ -327,8 +336,22 @@ static int do_of_property(int argc, char
> > *argv[])
> >  
> >         debug("path: %s propname: %s\n", path, propname);
> >  
> > +       if ( !(set || delete))
> > +               return COMMAND_ERROR_USAGE;
> > +
> > +       if (dtbfile) {
> > +               fdt = read_file(dtbfile, &size);
> > +               if (!fdt) {
> > +                       printf("unable to read %s: %s\n", dtbfile,
> > strerror(errno));
> 
> We have %m now as a shortcut for "%s", strerror(errno) and you could
> be
> the first user ;)

Thank you for the advice. That's a nice feature.

> 
> > +       if (root && !fixup) {
> > +               fdt = of_get_fixed_tree(root);
> > +
> > +               ret = write_file(dtbfile, fdt, fdt32_to_cpu(fdt-
> > >totalsize));
> > +
> > +               free(fdt);
> >         }
> 
> Are you sure you want to save the fixed tree? I would rather expect
> that
> the saved tree has only the desired property changed.

You're right, we don't need to apply the fixup's here. I'll send an
update on this.

Regards,
Yunus
> 
> >  
> > -       return COMMAND_ERROR_USAGE;
> > +out:
> > +
> > +       if (root)
> > +               of_delete_node(root);
> > +
> > +       return ret;
> >  }
> >  
> >  BAREBOX_CMD_HELP_START(of_property)
> > @@ -373,6 +412,7 @@ BAREBOX_CMD_HELP_TEXT("Options:")
> >  BAREBOX_CMD_HELP_OPT ("-s",  "set property to value")
> >  BAREBOX_CMD_HELP_OPT ("-d",  "delete property")
> >  BAREBOX_CMD_HELP_OPT ("-f",  "set/delete as a fixup (defer the
> > action until booting)")
> > +BAREBOX_CMD_HELP_OPT ("-e dtb",  "set/delete/fixup from external
> > dtb")
> >  BAREBOX_CMD_HELP_TEXT("")
> >  BAREBOX_CMD_HELP_TEXT("Valid formats for values:")
> >  BAREBOX_CMD_HELP_TEXT("<0x00112233 4 05> - an array of cells.
> > cells not beginning with a digit are")
> > @@ -384,8 +424,8 @@ BAREBOX_CMD_HELP_END
> >  BAREBOX_CMD_START(of_property)
> >         .cmd            = do_of_property,
> >         BAREBOX_CMD_DESC("handle device tree properties")
> > -       BAREBOX_CMD_OPTS("[-sd] [-f] NODE [PROPERTY] [VALUES]")
> > +       BAREBOX_CMD_OPTS("[-sd] [-e] [-f] NODE [PROPERTY]
> > [VALUES]")
> >         BAREBOX_CMD_GROUP(CMD_GRP_MISC)
> > -       BAREBOX_CMD_COMPLETE(devicetree_complete)
> > +       BAREBOX_CMD_COMPLETE(devicetree_file_complete)
> >         BAREBOX_CMD_HELP(cmd_of_property_help)
> >  BAREBOX_CMD_END
> > -- 
> > 2.30.0
> > 
> > 
> > _______________________________________________
> > barebox mailing list
> > barebox@xxxxxxxxxxxxxxxxxxx
> > http://lists.infradead.org/mailman/listinfo/barebox
> > 
> 

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux