devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Stone <ahs3-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: "Rafael J. Wysocki" <rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.org>,
	Sakari Ailus
	<sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org
Cc: linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	sudeep.holla-5wv7dgnIgG8@public.gmane.org,
	lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org,
	rafael-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	mark.rutland-5wv7dgnIgG8@public.gmane.org,
	broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Subject: Re: [PATCH v2 15/16] device property: Add fwnode_get_next_parent()
Date: Wed, 8 Feb 2017 09:49:09 -0700	[thread overview]
Message-ID: <cbeeac53-a4e7-56b4-b69c-e2106671c721@redhat.com> (raw)
In-Reply-To: <7605668.5ZxNsBFnEG-yvgW3jdyMHm1GS7QM15AGw@public.gmane.org>

On 02/08/2017 05:19 AM, Rafael J. Wysocki wrote:
> On Wednesday, February 08, 2017 12:50:25 PM Rafael J. Wysocki wrote:
>> On Tuesday, February 07, 2017 11:57:55 AM Al Stone wrote:
>>> On 02/02/2017 09:22 AM, Sakari Ailus wrote:
>>>> In order to differentiate the functionality between dropping a reference
>>>> to the node (or not) for the benefit of OF, introduce
>>>> fwnode_get_next_parent().
>>>>
>>>> Signed-off-by: Sakari Ailus <sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
>>>> ---
>>>>  drivers/base/property.c  | 29 +++++++++++++++++++++++++++++
>>>>  include/linux/property.h |  1 +
>>>>  2 files changed, 30 insertions(+)
>>>>
>>>> diff --git a/drivers/base/property.c b/drivers/base/property.c
>>>> index 28125a5..8e4398f 100644
>>>> --- a/drivers/base/property.c
>>>> +++ b/drivers/base/property.c
>>>> @@ -868,6 +868,35 @@ int device_add_properties(struct device *dev, struct property_entry *properties)
>>>>  EXPORT_SYMBOL_GPL(device_add_properties);
>>>>  
>>>>  /**
>>>> + * fwnode_get_next_parent - Iterate to the node's parent
>>>> + * @fwnode: Firmware whose parent is retrieved
>>>> + *
>>>> + * This is like fwnode_get_parent() except that it drops the refcount
>>>> + * on the passed node, making it suitable for iterating through a
>>>> + * node's parents.
>>>> + *
>>>> + * Returns a node pointer with refcount incremented, use
>>>> + * fwnode_handle_node() on it when done.
>>>> + */
>>>> +struct fwnode_handle *fwnode_get_next_parent(struct fwnode_handle *fwnode)
>>>> +{
>>>> +	struct fwnode_handle *parent = NULL;
>>>> +
>>>> +	if (is_of_node(fwnode)) {
>>>> +		struct device_node *node;
>>>> +
>>>> +		node = of_get_next_parent(to_of_node(fwnode));
>>>> +		if (node)
>>>> +			parent = &node->fwnode;
>>>> +	} else if (is_acpi_node(fwnode)) {
>>>> +		parent = acpi_node_get_parent(fwnode);
>>>> +	}
>>>> +
>>>> +	return parent;
>>>> +}
>>>> +EXPORT_SYMBOL_GPL(fwnode_get_next_parent);
>>>
>>> I think I agree with Rob's prior comments about making an ops struct for DT
>>> vs ACPI.  Out of the 16 patches, 2/16, 3/16, 5/16 (multiple times), and this
>>> patch all end up using the same construct.  Maybe it needs to be a separate
>>> refactoring effort, but if it's happening this often just in this patch set,
>>> it seems like it's getting time to clean things up.
>>
>> As long as there are two cases only (ACPI vs DT), an ops struct wouldn't
>> really make things simpler and it would make the code more difficult to
>> follow.
>>
>> But we do have a third case (static or built-in properties) and it doesn't
>> seem to be covered at all.
> 
> That said the ops struct could be introduced on top of this series just fine.
> It even might be cleaner to do it this way, so I'm not asking for a redesign
> here.

Right.  I don't think it necessarily needs to be covered in this series, but it
sure does feel like the time has come.  The number of "if (dt) then x else if
(acpi) then y;" really stood out for me in this series.

> I'd like the built-in properties to be covered too, however.

Yeah, good point.  I was focused on ACPI and DT, and forgot about those.

Not sure if I have time, but I can start looking into this.

-- 
ciao,
al
-----------------------------------
Al Stone
Software Engineer
Red Hat, Inc.
ahs3-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
-----------------------------------
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-02-08 16:49 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-02 16:22 [PATCH v2 00/16] ACPI graph support Sakari Ailus
2017-02-02 16:22 ` [PATCH v2 01/16] ACPI / property: Add possiblity to retrieve parent firmware node Sakari Ailus
2017-02-02 16:22 ` [PATCH v2 02/16] device property: Add fwnode_get_parent() Sakari Ailus
2017-02-02 16:22 ` [PATCH v2 03/16] ACPI / property: Add fwnode_get_next_child_node() Sakari Ailus
2017-02-02 16:22 ` [PATCH v2 04/16] device property: Add fwnode_get_named_child_node() Sakari Ailus
2017-02-02 16:22 ` [PATCH v2 05/16] ACPI / property: Add support for remote endpoints Sakari Ailus
2017-02-02 16:22 ` [PATCH v2 06/16] device " Sakari Ailus
2017-02-02 16:22 ` [PATCH v2 08/16] of: Add of_fwnode_handle() to convert device nodes to fwnode_handle Sakari Ailus
     [not found] ` <1486052546-19257-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-02-02 16:22   ` [PATCH v2 07/16] device property: Add fwnode_handle_get() Sakari Ailus
2017-02-02 16:22   ` [PATCH v2 09/16] driver core: Arrange headers alphabetically Sakari Ailus
2017-02-02 16:22   ` [PATCH v2 11/16] of: No need to include linux/property.h, linux/fwnode.h is sufficient Sakari Ailus
2017-02-20 10:37     ` [PATCH v2.1 " Sakari Ailus
2017-02-02 16:22 ` [PATCH v2 10/16] irqchip/gic: Add missing forward declaration for struct device Sakari Ailus
2017-02-02 16:22 ` [PATCH v2 12/16] device property: Obtain device's fwnode independently of FW type Sakari Ailus
2017-02-02 16:22 ` [PATCH v2 13/16] device property: Get endpoint index from the ACPI tables Sakari Ailus
2017-02-02 16:22 ` [PATCH v2 14/16] of: Add nop implementation of of_get_next_parent() Sakari Ailus
2017-02-02 16:22 ` [PATCH v2 15/16] device property: Add fwnode_get_next_parent() Sakari Ailus
2017-02-07 18:57   ` Al Stone
     [not found]     ` <9a481aec-92e6-ac01-b825-167bf73dfb11-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-02-08 11:50       ` Rafael J. Wysocki
     [not found]         ` <6293579.fEEljmGD4Z-yvgW3jdyMHm1GS7QM15AGw@public.gmane.org>
2017-02-08 12:19           ` Rafael J. Wysocki
     [not found]             ` <7605668.5ZxNsBFnEG-yvgW3jdyMHm1GS7QM15AGw@public.gmane.org>
2017-02-08 16:49               ` Al Stone [this message]
2017-02-14  8:01                 ` Sakari Ailus
2017-02-14 17:09                   ` Al Stone
2017-02-21  8:17             ` Sakari Ailus
     [not found]               ` <20170221081749.GC16975-S+BSfZ9RZZmRSg0ZkenSGLdO1Tsj/99ntUK59QYPAWc@public.gmane.org>
2017-02-21 23:00                 ` Rafael J. Wysocki
2017-02-22 13:12                   ` Sakari Ailus
2017-02-23 17:01               ` Sakari Ailus
2017-02-02 16:22 ` [PATCH v2 16/16] ACPI / DSD: Document references, ports and endpoints Sakari Ailus

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=cbeeac53-a4e7-56b4-b69c-e2106671c721@redhat.com \
    --to=ahs3-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=rafael-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.org \
    --cc=robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=sudeep.holla-5wv7dgnIgG8@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).