devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Srinivas KANDAGATLA <srinivas.kandagatla-qxv4g6HH51o@public.gmane.org>
To: David Gibson <dwg-8fk3Idey6ehBDgjK7y7TUQ@public.gmane.org>
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Subject: Re: [RFC 0/2]  Add node and property realloc functions.
Date: Thu, 11 Apr 2013 07:52:40 +0100	[thread overview]
Message-ID: <51665DB8.6050304@st.com> (raw)
In-Reply-To: <20130411014439.GN8165-W9XWwYn+TF0XU02nzanrWNbf9cGiqdzd@public.gmane.org>

On 11/04/13 02:44, David Gibson wrote:
> On Wed, Apr 10, 2013 at 03:31:18PM +0100, Srinivas KANDAGATLA wrote:
>> 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" "str10"
>> Error at 'node-1': FDT_ERR_NOSPACE
>>
>> or
>>
>> fdtput -v -c ./tst.dtb "/node-1"
>> Error at 'node-1': FDT_ERR_NOSPACE
>>
>>
>> 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 not space to accomdate these new properties.
>>
>> However,
>> libfdt has code to add new property or node or extend a property to an
>> arbitary value, however it cannot be used because all the library
>> functions take preallocated fdt pointer limted to a size.
>>
>> Adding realloc function into libfdt can help tools like fdtput to insert
>> nodes or properties or extend a property.
> Nack.
>
> libfdt deliberately does not use an allocator, to permit embedding in
> weird and limited environments such as bootloaders.
>
> I've thought about adding an optional layer of allocator aware
> functions, but it's not quite as straightforward as you'd think
> because you need to be clear about what the assumptions are on the
> allocation of the given blob - there's no place to put extra context
> to indicate whether it is malloc()ed or part of a larger structure,
> for example.  At the very lease allocating functions would need to
> move to a separate source file from the existing functions.
>
> I think the correct fix in this case is to make fdtput handle the
> FDT_ERR_NOSPACE by reallocating itself, using fdt_open_into() and
> retrying.
Thanks for the comment, I will try to fix fdtput with fdt_open_into.
>
>
>
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss

      parent reply	other threads:[~2013-04-11  6:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-10 14:31 [RFC 0/2] Add node and property realloc functions Srinivas KANDAGATLA
     [not found] ` <1365604278-17956-1-git-send-email-srinivas.kandagatla-qxv4g6HH51o@public.gmane.org>
2013-04-10 14:33   ` [RFC 1/2] libfdt: " Srinivas KANDAGATLA
     [not found]     ` <1365604398-18064-1-git-send-email-srinivas.kandagatla-qxv4g6HH51o@public.gmane.org>
2013-04-11  1:46       ` David Gibson
2013-04-10 14:33   ` [RFC 2/2] fdtput: use libfdt " Srinivas KANDAGATLA
2013-04-11  1:44   ` [RFC 0/2] Add node and property " David Gibson
     [not found]     ` <20130411014439.GN8165-W9XWwYn+TF0XU02nzanrWNbf9cGiqdzd@public.gmane.org>
2013-04-11  6:52       ` Srinivas KANDAGATLA [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=51665DB8.6050304@st.com \
    --to=srinivas.kandagatla-qxv4g6hh51o@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=dwg-8fk3Idey6ehBDgjK7y7TUQ@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).