mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Yunus Bas <y.bas@phytec.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] commands: of_property: Extend command usage on external dtb
Date: Fri, 25 Jun 2021 09:50:20 +0200	[thread overview]
Message-ID: <20210625075020.GE9782@pengutronix.de> (raw)
In-Reply-To: <20210624152810.3385526-1-y.bas@phytec.de>

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 ;)

> +	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.

>  
> -	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
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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


  reply	other threads:[~2021-06-25  8:15 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 [this message]
2021-06-25 10:30   ` Yunus Bas

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=20210625075020.GE9782@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=y.bas@phytec.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