Re: [PATCH] fdtput: add delete node and property function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Hi Wang,

On 13 January 2015 at 21:25, long.wanglong <long.wanglong@xxxxxxxxxx> wrote:
> On 2015/1/14 12:07, Simon Glass wrote:
>> Hi Wang,
>>
>> On 13 January 2015 at 19:53, Wang Long <long.wanglong@xxxxxxxxxx> wrote:
>>> add the delete node and property function for fdtput.
>>>
>>> usage:
>>> 1) delete a node
>>>  # fdtput test.dtb -d node /chosen/son
>>> 2) delete a property
>>>  # fdtput test.dtb -d prop /chosen/ prop_name
>>
>> This is a great addition!
>>
>> I know David is keen on single character flags. But would it be better
>> to have a separate delete option, e.g.
>>
>> -r to remove a node
>> -d to delete a property
>>
> ok
>
> i will use single character flags in next version of the patch.

You might want to wait to see if David has some comments before
sending the next version.

>
>>>
>>> Signed-off-by: Wang Long <long.wanglong@xxxxxxxxxx>
>>> ---
>>>  fdtput.c           | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
>>>  tests/run_tests.sh | 17 ++++++++++
>>>  2 files changed, 108 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/fdtput.c b/fdtput.c
>>> index 2a8d674..28e1f55 100644
>>> --- a/fdtput.c
>>> +++ b/fdtput.c
>>> @@ -32,6 +32,8 @@
>>>  enum oper_type {
>>>         OPER_WRITE_PROP,                /* Write a property in a node */
>>>         OPER_CREATE_NODE,               /* Create a new node */
>>> +       OPER_DELETE_NODE,               /* Delete a node */
>>> +       OPER_DELETE_PROP,               /* Delete a property in a node */
>>>  };
>>>
>>>  struct display_info {
>>> @@ -270,6 +272,60 @@ static int create_node(char **blob, const char *node_name)
>>>         return 0;
>>>  }
>>>
>>> +/**
>>> + * Delete a property of a node in the fdt.
>>> + *
>>> + * @param blob         FDT blob to write into
>>> + * @param node_name    Name of node which the delete property belongs to
>>> + * @param prop_name    Name of property to delete
>>> + * @return 0 on success, or -1 on failure
>>> + */
>>> +static int delete_prop(char **blob, const char *node_name, const char *prop_name)
>>
>> Can you just pass char *blob? Why the double pointer? Same with the
>> next function.
>>
> hi,Simon
>
> the function create_paths and create_node use the double pointer.
>
>  static int create_paths(char **blob, const char *in_path)
>  static int create_node(char **blob, const char *node_name)
>
> In order to maintain a consistent coding style, i use char **blob instead of char *blob.
> should we update char **blob  to char *blob in all functions?

When expanding the tree (e.g. by adding nodes or properties) we might
need to relocate it. But since you are deleting things, that isn't
necessary.

Regards
Simon
--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux