diff mbox

[v3,1/2] device property: Add fwnode_graph_get_port_parent

Message ID cce043f797174561fe49350a66b56ce07059716c.1495473356.git-series.kieran.bingham+renesas@ideasonboard.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kieran Bingham May 22, 2017, 5:36 p.m. UTC
From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

Provide a helper to obtain the parent device fwnode without first
parsing the remote-endpoint as per fwnode_graph_get_remote_port_parent.

Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

---
v2:
 - Rebase on top of Sakari's acpi-graph-clean branch and simplify

v3:
 - Fix up kerneldoc
 - Get the 'port' of the endpoint to find the parent of the port

 drivers/base/property.c  | 15 +++++++++++++++
 include/linux/property.h |  2 ++
 2 files changed, 17 insertions(+)

Comments

Sakari Ailus May 23, 2017, 12:58 p.m. UTC | #1
Hi Kieran,

On Mon, May 22, 2017 at 06:36:37PM +0100, Kieran Bingham wrote:
> From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> 
> Provide a helper to obtain the parent device fwnode without first
> parsing the remote-endpoint as per fwnode_graph_get_remote_port_parent.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> 
> ---
> v2:
>  - Rebase on top of Sakari's acpi-graph-clean branch and simplify
> 
> v3:
>  - Fix up kerneldoc
>  - Get the 'port' of the endpoint to find the parent of the port
> 
>  drivers/base/property.c  | 15 +++++++++++++++
>  include/linux/property.h |  2 ++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/drivers/base/property.c b/drivers/base/property.c
> index b311a6fa7d0c..fdbc644fd743 100644
> --- a/drivers/base/property.c
> +++ b/drivers/base/property.c
> @@ -1169,6 +1169,21 @@ fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode,
>  EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);
>  
>  /**
> + * fwnode_graph_get_port_parent - Return the device fwnode of a port endpoint
> + * @endpoint: Endpoint firmware node of the port
> + *
> + * Return: the firmware node of the device the @endpoint belongs to.
> + */
> +struct fwnode_handle *
> +fwnode_graph_get_port_parent(struct fwnode_handle *endpoint)
> +{
> +	struct fwnode_handle *port = fwnode_get_next_parent(endpoint);
> +
> +	return fwnode_call_ptr_op(port, graph_get_port_parent);

I missed one thing: the reference to port obtained in
fwnode_get_next_parent() needs to be released.

I can do the change while applying the patch on top of the set if you're ok
with that.

> +}
> +EXPORT_SYMBOL_GPL(fwnode_graph_get_port_parent);
> +
> +/**
>   * fwnode_graph_get_remote_port_parent - Return fwnode of a remote device
>   * @fwnode: Endpoint firmware node pointing to the remote endpoint
>   *
> diff --git a/include/linux/property.h b/include/linux/property.h
> index b9f4838d9882..af95d5d84192 100644
> --- a/include/linux/property.h
> +++ b/include/linux/property.h
> @@ -275,6 +275,8 @@ void *device_get_mac_address(struct device *dev, char *addr, int alen);
>  
>  struct fwnode_handle *fwnode_graph_get_next_endpoint(
>  	struct fwnode_handle *fwnode, struct fwnode_handle *prev);
> +struct fwnode_handle *fwnode_graph_get_port_parent(
> +	struct fwnode_handle *fwnode);
>  struct fwnode_handle *fwnode_graph_get_remote_port_parent(
>  	struct fwnode_handle *fwnode);
>  struct fwnode_handle *fwnode_graph_get_remote_port(
Kieran Bingham May 23, 2017, 5:15 p.m. UTC | #2
On 23/05/17 13:58, Sakari Ailus wrote:
> Hi Kieran,
> 
> On Mon, May 22, 2017 at 06:36:37PM +0100, Kieran Bingham wrote:
>> From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
>>
>> Provide a helper to obtain the parent device fwnode without first
>> parsing the remote-endpoint as per fwnode_graph_get_remote_port_parent.
>>
>> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
>>
>> ---
>> v2:
>>  - Rebase on top of Sakari's acpi-graph-clean branch and simplify
>>
>> v3:
>>  - Fix up kerneldoc
>>  - Get the 'port' of the endpoint to find the parent of the port
>>
>>  drivers/base/property.c  | 15 +++++++++++++++
>>  include/linux/property.h |  2 ++
>>  2 files changed, 17 insertions(+)
>>
>> diff --git a/drivers/base/property.c b/drivers/base/property.c
>> index b311a6fa7d0c..fdbc644fd743 100644
>> --- a/drivers/base/property.c
>> +++ b/drivers/base/property.c
>> @@ -1169,6 +1169,21 @@ fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode,
>>  EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);
>>  
>>  /**
>> + * fwnode_graph_get_port_parent - Return the device fwnode of a port endpoint
>> + * @endpoint: Endpoint firmware node of the port
>> + *
>> + * Return: the firmware node of the device the @endpoint belongs to.
>> + */
>> +struct fwnode_handle *
>> +fwnode_graph_get_port_parent(struct fwnode_handle *endpoint)
>> +{
>> +	struct fwnode_handle *port = fwnode_get_next_parent(endpoint);
>> +
>> +	return fwnode_call_ptr_op(port, graph_get_port_parent);
> 
> I missed one thing: the reference to port obtained in
> fwnode_get_next_parent() needs to be released.
> 
> I can do the change while applying the patch on top of the set if you're ok
> with that.

Yes, that would be great thanks.

--
Kieran

> 
>> +}
>> +EXPORT_SYMBOL_GPL(fwnode_graph_get_port_parent);
>> +
>> +/**
>>   * fwnode_graph_get_remote_port_parent - Return fwnode of a remote device
>>   * @fwnode: Endpoint firmware node pointing to the remote endpoint
>>   *
>> diff --git a/include/linux/property.h b/include/linux/property.h
>> index b9f4838d9882..af95d5d84192 100644
>> --- a/include/linux/property.h
>> +++ b/include/linux/property.h
>> @@ -275,6 +275,8 @@ void *device_get_mac_address(struct device *dev, char *addr, int alen);
>>  
>>  struct fwnode_handle *fwnode_graph_get_next_endpoint(
>>  	struct fwnode_handle *fwnode, struct fwnode_handle *prev);
>> +struct fwnode_handle *fwnode_graph_get_port_parent(
>> +	struct fwnode_handle *fwnode);
>>  struct fwnode_handle *fwnode_graph_get_remote_port_parent(
>>  	struct fwnode_handle *fwnode);
>>  struct fwnode_handle *fwnode_graph_get_remote_port(
>
Sakari Ailus May 23, 2017, 9:37 p.m. UTC | #3
Hi Kieran,

On Tue, May 23, 2017 at 06:15:42PM +0100, Kieran Bingham wrote:
> 
> 
> On 23/05/17 13:58, Sakari Ailus wrote:
> > Hi Kieran,
> > 
> > On Mon, May 22, 2017 at 06:36:37PM +0100, Kieran Bingham wrote:
> >> From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> >>
> >> Provide a helper to obtain the parent device fwnode without first
> >> parsing the remote-endpoint as per fwnode_graph_get_remote_port_parent.
> >>
> >> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> >>
> >> ---
> >> v2:
> >>  - Rebase on top of Sakari's acpi-graph-clean branch and simplify
> >>
> >> v3:
> >>  - Fix up kerneldoc
> >>  - Get the 'port' of the endpoint to find the parent of the port
> >>
> >>  drivers/base/property.c  | 15 +++++++++++++++
> >>  include/linux/property.h |  2 ++
> >>  2 files changed, 17 insertions(+)
> >>
> >> diff --git a/drivers/base/property.c b/drivers/base/property.c
> >> index b311a6fa7d0c..fdbc644fd743 100644
> >> --- a/drivers/base/property.c
> >> +++ b/drivers/base/property.c
> >> @@ -1169,6 +1169,21 @@ fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode,
> >>  EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);
> >>  
> >>  /**
> >> + * fwnode_graph_get_port_parent - Return the device fwnode of a port endpoint
> >> + * @endpoint: Endpoint firmware node of the port
> >> + *
> >> + * Return: the firmware node of the device the @endpoint belongs to.
> >> + */
> >> +struct fwnode_handle *
> >> +fwnode_graph_get_port_parent(struct fwnode_handle *endpoint)
> >> +{
> >> +	struct fwnode_handle *port = fwnode_get_next_parent(endpoint);
> >> +
> >> +	return fwnode_call_ptr_op(port, graph_get_port_parent);
> > 
> > I missed one thing: the reference to port obtained in
> > fwnode_get_next_parent() needs to be released.
> > 
> > I can do the change while applying the patch on top of the set if you're ok
> > with that.
> 
> Yes, that would be great thanks.

Thanks! The patch actually came out in this form:

<URL:https://git.linuxtv.org/sailus/media_tree.git/commit/?h=acpi-graph-cleaned&id=6c9e58006e73de03441337f3ca6247afed28cf0a>

I'll post it to list once I've rebased the set again, I hope you're ok with
that. :-)
Kieran Bingham May 23, 2017, 9:50 p.m. UTC | #4
Hi Sakari,

On 23/05/17 22:37, Sakari Ailus wrote:
> Hi Kieran,
> 
> On Tue, May 23, 2017 at 06:15:42PM +0100, Kieran Bingham wrote:
>>
>>
>> On 23/05/17 13:58, Sakari Ailus wrote:
>>> Hi Kieran,
>>>
>>> On Mon, May 22, 2017 at 06:36:37PM +0100, Kieran Bingham wrote:
>>>> From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
>>>>
>>>> Provide a helper to obtain the parent device fwnode without first
>>>> parsing the remote-endpoint as per fwnode_graph_get_remote_port_parent.
>>>>
>>>> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
>>>>
>>>> ---
>>>> v2:
>>>>  - Rebase on top of Sakari's acpi-graph-clean branch and simplify
>>>>
>>>> v3:
>>>>  - Fix up kerneldoc
>>>>  - Get the 'port' of the endpoint to find the parent of the port
>>>>
>>>>  drivers/base/property.c  | 15 +++++++++++++++
>>>>  include/linux/property.h |  2 ++
>>>>  2 files changed, 17 insertions(+)
>>>>
>>>> diff --git a/drivers/base/property.c b/drivers/base/property.c
>>>> index b311a6fa7d0c..fdbc644fd743 100644
>>>> --- a/drivers/base/property.c
>>>> +++ b/drivers/base/property.c
>>>> @@ -1169,6 +1169,21 @@ fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode,
>>>>  EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);
>>>>  
>>>>  /**
>>>> + * fwnode_graph_get_port_parent - Return the device fwnode of a port endpoint
>>>> + * @endpoint: Endpoint firmware node of the port
>>>> + *
>>>> + * Return: the firmware node of the device the @endpoint belongs to.
>>>> + */
>>>> +struct fwnode_handle *
>>>> +fwnode_graph_get_port_parent(struct fwnode_handle *endpoint)
>>>> +{
>>>> +	struct fwnode_handle *port = fwnode_get_next_parent(endpoint);
>>>> +
>>>> +	return fwnode_call_ptr_op(port, graph_get_port_parent);
>>>
>>> I missed one thing: the reference to port obtained in
>>> fwnode_get_next_parent() needs to be released.
>>>
>>> I can do the change while applying the patch on top of the set if you're ok
>>> with that.
>>
>> Yes, that would be great thanks.
> 
> Thanks! The patch actually came out in this form:
> 
> <URL:https://git.linuxtv.org/sailus/media_tree.git/commit/?h=acpi-graph-cleaned&id=6c9e58006e73de03441337f3ca6247afed28cf0a>
> 
> I'll post it to list once I've rebased the set again, I hope you're ok with
> that. :-)

That looks great.

Thanks
--
Kieran
diff mbox

Patch

diff --git a/drivers/base/property.c b/drivers/base/property.c
index b311a6fa7d0c..fdbc644fd743 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -1169,6 +1169,21 @@  fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode,
 EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);
 
 /**
+ * fwnode_graph_get_port_parent - Return the device fwnode of a port endpoint
+ * @endpoint: Endpoint firmware node of the port
+ *
+ * Return: the firmware node of the device the @endpoint belongs to.
+ */
+struct fwnode_handle *
+fwnode_graph_get_port_parent(struct fwnode_handle *endpoint)
+{
+	struct fwnode_handle *port = fwnode_get_next_parent(endpoint);
+
+	return fwnode_call_ptr_op(port, graph_get_port_parent);
+}
+EXPORT_SYMBOL_GPL(fwnode_graph_get_port_parent);
+
+/**
  * fwnode_graph_get_remote_port_parent - Return fwnode of a remote device
  * @fwnode: Endpoint firmware node pointing to the remote endpoint
  *
diff --git a/include/linux/property.h b/include/linux/property.h
index b9f4838d9882..af95d5d84192 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -275,6 +275,8 @@  void *device_get_mac_address(struct device *dev, char *addr, int alen);
 
 struct fwnode_handle *fwnode_graph_get_next_endpoint(
 	struct fwnode_handle *fwnode, struct fwnode_handle *prev);
+struct fwnode_handle *fwnode_graph_get_port_parent(
+	struct fwnode_handle *fwnode);
 struct fwnode_handle *fwnode_graph_get_remote_port_parent(
 	struct fwnode_handle *fwnode);
 struct fwnode_handle *fwnode_graph_get_remote_port(