mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Yunus Bas <Y.Bas@phytec.de>
To: "sha@pengutronix.de" <sha@pengutronix.de>
Cc: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: Re: [PATCH] commands: of_property: Extend command usage on external dtb
Date: Fri, 25 Jun 2021 10:30:42 +0000	[thread overview]
Message-ID: <0b7bc05838d98c3e81d97e5f0afe6464ef1529e4.camel@phytec.de> (raw)
In-Reply-To: <20210625075020.GE9782@pengutronix.de>

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@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
> > 
> 

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

      reply	other threads:[~2021-06-25 10:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-24 15:28 Yunus Bas
2021-06-25  7:50 ` Sascha Hauer
2021-06-25 10:30   ` Yunus Bas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0b7bc05838d98c3e81d97e5f0afe6464ef1529e4.camel@phytec.de \
    --to=y.bas@phytec.de \
    --cc=barebox@lists.infradead.org \
    --cc=sha@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox