mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Teresa Gamez <t.gamez@phytec.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/2] commands: add of_display_timings
Date: Thu, 25 Sep 2014 13:22:03 +0200	[thread overview]
Message-ID: <1411644123.5887.28.camel@lws-gamez.phytec.de> (raw)
In-Reply-To: <20140925060732.GE4992@pengutronix.de>

Hello Sascha,

Am Donnerstag, den 25.09.2014, 08:07 +0200 schrieb Sascha Hauer:
> Hi Teresa,
> 
> On Wed, Sep 24, 2014 at 11:33:11AM +0200, Teresa Gámez wrote:
> > A lot of boards use display-timings nodes to define the timings of one or more
> > displays. This command makes it possible to list and select displays which are
> > defined in a device tree.
> 
> Nice idea.
> 
> > +static int of_display_timing(struct device_node *root, void *timingpath)
> > +{
> > +	int ret = 0;
> > +	struct device_node *display;
> > +
> > +	display = of_find_node_by_path_from(root, (char *) timingpath);
> 
> Unnecessary cast.

Removed it.
> 
> > +static int do_of_display_timings(int argc, char *argv[])
> > +{
> > +	int opt;
> > +	int list = 0;
> > +	int selected = 0;
> > +	int ret = 0;
> > +	struct device_node *root = NULL;
> > +	struct device_node *internal_root = NULL;
> > +	struct device_node *display = NULL;
> > +	struct device_node *timings = NULL;
> > +	char *timingpath = NULL;
> > +	char *dtbfile = NULL;
> > +
> > +	while ((opt = getopt(argc, argv, "sS:lf:")) > 0) {
> > +		switch (opt) {
> > +		case 'l':
> > +			list = 1;
> > +			break;
> > +		case 'f':
> > +			dtbfile = optarg;
> > +			break;
> 
> Do we really need this option? It can only be used for showing display
> timings in an external dtb, not for manipulating it. If I plan to use
> the external tree I can still do a oftree -f / oftree -l dtb to exchange
> the internal tree.

Well, it just gives the same feature like of_dump has. It is not that 
necessary, but it makes it more handy. 

> 
> > +		case 's':
> > +			selected = 1;
> > +			break;
> > +		case 'S':
> > +			timingpath = xzalloc(strlen(optarg) + 1);
> > +			strcpy(timingpath, optarg);
> 
> You never free timingpath. But why are you making a copy of the string?
> This shouldn't be necessary.

I need to save the string for later usage in the fixup function. This is
called after the command has finished. I think the optarg pointer to
argv is not longer vaild then.

The fixup can be called multiple times (canceled boot, of_dump -F,..).
I don't see a save place to free timingpath.

Teresa

> 
> > +			break;
> > +		default:
> > +			return COMMAND_ERROR_USAGE;
> > +		}
> > +	}
> > +
> > +	/* Check if external dtb given */
> > +	if (dtbfile) {
> > +		void *fdt;
> > +		size_t size;
> > +
> > +		fdt = read_file(dtbfile, &size);
> > +		if (!fdt) {
> > +			pr_err("unable to read %s: %s\n", dtbfile,
> > +				strerror(errno));
> > +			return -errno;
> > +		}
> > +
> > +		if (file_detect_type(fdt, size) != filetype_oftree) {
> > +			pr_err("%s is not a oftree file.\n", dtbfile);
> > +			return -EINVAL;
> 
> Here you lose memory.
> 
> > +		}
> > +
> > +		root = of_unflatten_dtb(fdt);
> 
> This must be freed after use with of_delete_node().
> 
> Sascha
> 
> 



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

      reply	other threads:[~2014-09-25 11:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-24  9:33 [PATCH 1/2] of: Added of_set_property_to_child_phandle Teresa Gámez
2014-09-24  9:33 ` [PATCH 2/2] commands: add of_display_timings Teresa Gámez
2014-09-25  6:07   ` Sascha Hauer
2014-09-25 11:22     ` Teresa Gamez [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=1411644123.5887.28.camel@lws-gamez.phytec.de \
    --to=t.gamez@phytec.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@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