All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: xen-devel@lists.xenproject.org, tim@xen.org,
	stefano.stabellini@citrix.com, patches@linaro.org
Subject: Re: [RFC for-4.5 05/12] xen/dts: Add dt_parse_phandle_with_args and dt_parse_phandle
Date: Wed, 19 Feb 2014 16:17:40 +0000	[thread overview]
Message-ID: <5304D924.4090504@linaro.org> (raw)
In-Reply-To: <1392813280.29739.43.camel@kazak.uk.xensource.com>

Hello Ian,

On 02/19/2014 12:34 PM, Ian Campbell wrote:
> On Fri, 2014-02-07 at 17:43 +0000, Julien Grall wrote:
>> Code adapted from linux drivers/of/base.c (commit ef42c58).
> 
> On that basis I only took a cursory glance through that monster
> function.
> 
>>
>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
>> diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
>> index 7c075d9..d429e60 100644
>> --- a/xen/include/xen/device_tree.h
>> +++ b/xen/include/xen/device_tree.h
>> @@ -112,6 +112,13 @@ struct dt_device_node {
>>  
>>  };
>>  
>> +#define MAX_PHANDLE_ARGS 16
>> +struct dt_phandle_args {
>> +    struct dt_device_node *np;
>> +    int args_count;
>> +    uint32_t args[MAX_PHANDLE_ARGS];
>> +};
>> +
>>  /**
>>   * IRQ line type.
>>   *
>> @@ -621,6 +628,53 @@ void dt_set_range(__be32 **cellp, const struct dt_device_node *np,
>>  void dt_get_range(const __be32 **cellp, const struct dt_device_node *np,
>>                    u64 *address, u64 *size);
>>  
>> +/**
>> + * dt_parse_phandle - Resolve a phandle property to a device_node pointer
>> + * @np: Pointer to device node holding phandle property
>> + * @phandle_name: Name of property holding a phandle value
>> + * @index: For properties holding a table of phandles, this is the index into
>> + *         the table
> 
> Otherwise it is -1 or something else?

Even with one element, the property contains a table of phandles. So,
the first index is always 0.

> 
>> + *
>> + * Returns the device_node pointer.
>> + */
>> +struct dt_device_node *dt_parse_phandle(const struct dt_device_node *np,
>> +				                        const char *phandle_name,
> 
> Stray hard tabs?

Oops, I forgot to check the hard tabs on this function. I will fix it.

>> +                                        int index);
>> +
>> +/**
>> + * dt_parse_phandle_with_args() - Find a node pointed by phandle in a list
>> + * @np:	pointer to a device tree node containing a list
>> + * @list_name: property name that contains a list
>> + * @cells_name: property name that specifies phandles' arguments count
>> + * @index: index of a phandle to parse out
>> + * @out_args: optional pointer to output arguments structure (will be filled)
>> + *
>> + * This function is useful to parse lists of phandles and their arguments.
>> + * Returns 0 on success and fills out_args, on error returns appropriate
>> + * errno value.
>> + *
>> + * Example:
>> + *
>> + * phandle1: node1 {
>> + * 	#list-cells = <2>;
>> + * }
>> + *
>> + * phandle2: node2 {
>> + * 	#list-cells = <1>;
>> + * }
>> + *
>> + * node3 {
>> + * 	list = <&phandle1 1 2 &phandle2 3>;
>> + * }
>> + *
>> + * To get a device_node of the `node2' node you may call this:
>> + * dt_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
> 
> Wow, what an exciting function!
> 
> How do I decide the correct size for out_args?

out_args is a structure dt_phandle_args which contains the node and an
array of arguments.

The function is designed to parse one phandle by one phandle. So
out_args is either NULL (we don't want to get the info) or contains a
pointer to the structure to fill.

The description of out_args seems clear to me. Does it miss something?

Cheers,

-- 
Julien Grall

  reply	other threads:[~2014-02-19 16:17 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-07 17:42 [RFC for-4.5 00/12] IOMMU support for ARM Julien Grall
2014-02-07 17:43 ` [RFC for-4.5 01/12] xen/common: grant-table: only call IOMMU if paging mode translate is disabled Julien Grall
2014-02-10  8:02   ` Jan Beulich
2014-02-19 12:25   ` Ian Campbell
2014-02-07 17:43 ` [RFC for-4.5 02/12] xen/passthrough: vtd: Don't export iommu_domain_teardown Julien Grall
2014-02-19 12:26   ` Ian Campbell
2014-02-07 17:43 ` [RFC for-4.5 03/12] xen/passthrough: vtd: Don't export iommu_set_pgd Julien Grall
2014-02-10  8:04   ` Jan Beulich
2014-02-10  8:07     ` Zhang, Xiantao
2014-02-19 12:27   ` Ian Campbell
2014-02-07 17:43 ` [RFC for-4.5 04/12] xen/dts: Add dt_property_read_bool Julien Grall
2014-02-19 12:28   ` Ian Campbell
2014-02-19 14:57     ` Julien Grall
2014-02-07 17:43 ` [RFC for-4.5 05/12] xen/dts: Add dt_parse_phandle_with_args and dt_parse_phandle Julien Grall
2014-02-19 12:34   ` Ian Campbell
2014-02-19 16:17     ` Julien Grall [this message]
2014-02-19 16:26       ` Ian Campbell
2014-02-19 16:52         ` Julien Grall
2014-02-19 16:57           ` Ian Campbell
2014-02-07 17:43 ` [RFC for-4.5 06/12] xen/passthrough: rework dom0_pvh_reqs to use it also on ARM Julien Grall
2014-02-10  8:07   ` Jan Beulich
2014-02-10 11:42     ` Julien Grall
2014-02-10 16:10   ` Julien Grall
2014-02-10 16:35     ` Jan Beulich
2014-02-10 17:42       ` Julien Grall
2014-02-11  7:47         ` Jan Beulich
2014-02-07 17:43 ` [RFC for-4.5 07/12] xen/passthrough: iommu: Don't need to map dom0 page when the PT is shared Julien Grall
2014-02-10  8:11   ` Jan Beulich
2014-02-19 12:37   ` Ian Campbell
2014-02-07 17:43 ` [RFC for-4.5 08/12] xen/passthrough: iommu: Split generic IOMMU code Julien Grall
2014-02-10  8:22   ` Jan Beulich
2014-02-10 11:52     ` Julien Grall
2014-02-19 12:39   ` Ian Campbell
2014-02-19 16:23     ` Julien Grall
2014-02-07 17:43 ` [RFC for-4.5 09/12] xen/passthrough: iommu: Introduce arch specific code Julien Grall
2014-02-19 12:40   ` Ian Campbell
2014-02-19 16:25     ` Julien Grall
2014-02-07 17:43 ` [RFC for-4.5 10/12] xen/passthrough: Introduce IOMMU ARM architure Julien Grall
2014-02-19 12:49   ` Ian Campbell
2014-02-19 16:50     ` Julien Grall
2014-02-07 17:43 ` [RFC for-4.5 11/12] MAINTAINERS: Add drivers/passthrough/arm Julien Grall
2014-02-19 12:49   ` Ian Campbell
2014-02-07 17:43 ` [RFC for-4.5 12/12] drivers/passthrough: arm: Add support for SMMU drivers Julien Grall
2014-02-19 14:15   ` Ian Campbell
2014-02-19 17:21     ` Julien Grall
2014-02-19 17:27       ` Ian Campbell
2014-02-19 17:31         ` Julien Grall
2014-02-20  8:11           ` Jan Beulich
2014-02-20 11:05             ` Julien Grall
2014-02-19 17:23     ` Julien Grall
2014-02-07 17:51 ` [RFC for-4.5 00/12] IOMMU support for ARM Julien Grall

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=5304D924.4090504@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=Ian.Campbell@citrix.com \
    --cc=patches@linaro.org \
    --cc=stefano.stabellini@citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.