devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <dwg-8fk3Idey6ehBDgjK7y7TUQ@public.gmane.org>
To: Srinivas KANDAGATLA <srinivas.kandagatla-qxv4g6HH51o@public.gmane.org>
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Subject: Re: [PATCH] fdtput: expand fdt if value does not fit.
Date: Fri, 19 Apr 2013 10:56:30 +1000	[thread overview]
Message-ID: <20130419005630.GM16400@truffula.fritz.box> (raw)
In-Reply-To: <1366007810-17881-1-git-send-email-srinivas.kandagatla-qxv4g6HH51o@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 1711 bytes --]

On Mon, Apr 15, 2013 at 07:36:50AM +0100, Srinivas KANDAGATLA wrote:
> From: Srinivas Kandagatla <srinivas.kandagatla-qxv4g6HH51o@public.gmane.org>
> 
> If you try to insert a new node or extend a property with large value,
> using fdtput you will notice that it always fails.
> 
> example:
> fdtput -v -p -ts ./tst.dtb "/node-1" "property-1" "value-1
> Error at 'node-1': FDT_ERR_NOSPACE
> 
> or
> 
> fdtput -v -c ./tst.dtb "/node-1"
> Error at 'node-1': FDT_ERR_NOSPACE
> 
> or
> 
> fdtput -v  -ts ./tst.dtb "/node" "property" "very big value"
> Decoding value:
> 	string: 'very big value'
> Value size 15
> Error at 'property': FDT_ERR_NOSPACE
> 
> All these error are returned from libfdt, as the size of the fdt passed
> has no space to accomdate these new properties.
> 
> This patch adds realloc functions in fdtput to allocate new space in fdt
> when it detects a shortage in space for new value or node. With this
> patch, fdtput can insert a new node or property or extend a property
> with new value greater than original size.
> 
> Without this patch fdtput tool complains with FDT_ERR_NOSPACE when we
> try to add a node/property or extend the value of a property.
> 
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla-qxv4g6HH51o@public.gmane.org>

Your realloc functions could overestimate the required size in some
cases, so you should put an fdt_pack() before you write the final blob
out to clean up any extra padding.

Other than that, looks good.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 192 bytes --]

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

  parent reply	other threads:[~2013-04-19  0:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-15  6:36 [PATCH] fdtput: expand fdt if value does not fit Srinivas KANDAGATLA
     [not found] ` <1366007810-17881-1-git-send-email-srinivas.kandagatla-qxv4g6HH51o@public.gmane.org>
2013-04-19  0:56   ` David Gibson [this message]
     [not found]     ` <20130419005630.GM16400-W9XWwYn+TF0XU02nzanrWNbf9cGiqdzd@public.gmane.org>
2013-04-19  8:33       ` Srinivas KANDAGATLA

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=20130419005630.GM16400@truffula.fritz.box \
    --to=dwg-8fk3idey6ehbdgjk7y7tuq@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=srinivas.kandagatla-qxv4g6HH51o@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).