From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: linux-kernel@vger.kernel.org, Mark Brown <broonie@kernel.org>,
Len Brown <lenb@kernel.org>,
linux-acpi@vger.kernel.org, Robert Moore <robert.moore@intel.com>,
Lv Zheng <lv.zheng@intel.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@acpica.org
Subject: Re: [PATCH v1 04/10] device property: add fwnode_get_parent()
Date: Thu, 02 Jul 2015 01:38 +0200 [thread overview]
Message-ID: <2793969.faR48RUkvm@vostro.rjw.lan> (raw)
In-Reply-To: <1435676108-20590-5-git-send-email-tomeu.vizoso@collabora.com>
On Tuesday, June 30, 2015 04:55:02 PM Tomeu Vizoso wrote:
> So we can query the parent of a fwnode without having to resort to API
> that is specific to a firmware data format.
>
> Also adds a acpi_get_parent_dev() function to retrieve the parent
> of an acpi_device. acpi_get_parent() already existed but it works with
> acpi_handles.
>
> The interface covers both ACPI and Device Trees.
>
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
This one looks good to me.
> ---
>
> drivers/base/property.c | 23 +++++++++++++++++++++++
> include/acpi/acpi_bus.h | 5 +++++
> include/linux/acpi.h | 5 +++++
> include/linux/property.h | 2 ++
> 4 files changed, 35 insertions(+)
>
> diff --git a/drivers/base/property.c b/drivers/base/property.c
> index f3f6d16..a7fb46b 100644
> --- a/drivers/base/property.c
> +++ b/drivers/base/property.c
> @@ -533,3 +533,26 @@ bool device_dma_is_coherent(struct device *dev)
> return coherent;
> }
> EXPORT_SYMBOL_GPL(device_dma_is_coherent);
> +
> +/**
> + * fwnode_get_parent - return the parent node of a device node
> + * @fwnode: Device node to find the parent node of
> + */
> +struct fwnode_handle *fwnode_get_parent(struct fwnode_handle *fwnode)
> +{
> + if (is_of_node(fwnode)) {
> + struct device_node *node = to_of_node(fwnode);
> +
> + if (node->parent)
> + return &node->parent->fwnode;
> + } else if (is_acpi_node(fwnode)) {
> + struct acpi_device *node;
> +
> + node = acpi_get_parent_dev(to_acpi_node(fwnode));
> + if (node)
> + return acpi_fwnode_handle(node);
> + }
> +
> + return NULL;
> +}
> +EXPORT_SYMBOL_GPL(fwnode_get_parent);
> diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
> index 83061ca..93c42a6 100644
> --- a/include/acpi/acpi_bus.h
> +++ b/include/acpi/acpi_bus.h
> @@ -436,6 +436,11 @@ static inline void *acpi_driver_data(struct acpi_device *d)
> return d->driver_data;
> }
>
> +static inline struct acpi_device *acpi_get_parent_dev(struct acpi_device *adev)
> +{
> + return adev->parent;
> +}
> +
> #define to_acpi_device(d) container_of(d, struct acpi_device, dev)
> #define to_acpi_driver(d) container_of(d, struct acpi_driver, drv)
>
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index ed79b06..fc84e42 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -804,6 +804,11 @@ static inline struct acpi_device *acpi_get_next_child(struct device *dev,
> return NULL;
> }
>
> +static inline struct acpi_device *acpi_get_parent_dev(struct acpi_device *adev)
> +{
> + return NULL;
> +}
> +
> #endif
>
> #endif /*_LINUX_ACPI_H*/
> diff --git a/include/linux/property.h b/include/linux/property.h
> index 76ebde9..f47092d 100644
> --- a/include/linux/property.h
> +++ b/include/linux/property.h
> @@ -63,6 +63,8 @@ int fwnode_property_read_string(struct fwnode_handle *fwnode,
> struct fwnode_handle *device_get_next_child_node(struct device *dev,
> struct fwnode_handle *child);
>
> +struct fwnode_handle *fwnode_get_parent(struct fwnode_handle *fwnode);
> +
> #define device_for_each_child_node(dev, child) \
> for (child = device_get_next_child_node(dev, NULL); child; \
> child = device_get_next_child_node(dev, child))
>
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
next prev parent reply other threads:[~2015-07-01 23:11 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-30 14:54 [PATCH v1 0/10] Fixes and API additions for firmware nodes Tomeu Vizoso
2015-06-30 14:54 ` [PATCH v1 01/10] of/platform: Set fwnode field for new devices Tomeu Vizoso
2015-06-30 18:24 ` Grant Likely
2015-07-01 23:32 ` Rafael J. Wysocki
2015-06-30 14:55 ` [PATCH v1 02/10] i2c: core: Have clients point to their firmware nodes Tomeu Vizoso
2015-07-31 10:36 ` Wolfram Sang
2015-08-06 14:17 ` Tomeu Vizoso
2015-08-06 21:06 ` Wolfram Sang
2015-06-30 14:55 ` [PATCH v1 03/10] mfd: Have child devices " Tomeu Vizoso
2015-06-30 18:24 ` Grant Likely
2015-07-01 7:36 ` Lee Jones
2015-07-01 23:33 ` Rafael J. Wysocki
2015-06-30 14:55 ` [PATCH v1 04/10] device property: add fwnode_get_parent() Tomeu Vizoso
2015-07-01 23:38 ` Rafael J. Wysocki [this message]
2015-06-30 14:55 ` [PATCH v1 05/10] device property: add fwnode_get_name() Tomeu Vizoso
2015-06-30 18:26 ` Grant Likely
2015-07-01 23:38 ` Rafael J. Wysocki
2015-07-22 11:53 ` Tomeu Vizoso
2015-06-30 14:55 ` [PATCH v1 06/10] ACPI / scan: Add acpi_dev_get_next_child() Tomeu Vizoso
2015-07-01 23:39 ` Rafael J. Wysocki
2015-06-30 14:55 ` [PATCH v1 07/10] device property: Add fwnode_get_next_child_node() Tomeu Vizoso
2015-07-01 23:40 ` Rafael J. Wysocki
2015-06-30 14:55 ` [PATCH v1 08/10] device property: add fwnode_is_compatible() Tomeu Vizoso
2015-06-30 18:28 ` Grant Likely
2015-07-01 23:44 ` Rafael J. Wysocki
2015-06-30 14:55 ` [PATCH v1 09/10] device: property: add fwnode_driver_match_device() Tomeu Vizoso
2015-06-30 18:32 ` Grant Likely
2015-07-01 23:45 ` Rafael J. Wysocki
2015-06-30 14:55 ` [PATCH v1 10/10] core: platform: use fwnode_driver_match_device() Tomeu Vizoso
2015-07-01 23:46 ` Rafael J. Wysocki
2015-07-10 12:53 ` Tomeu Vizoso
2015-07-11 2:47 ` Rafael J. Wysocki
2015-07-13 6:55 ` Tomeu Vizoso
2015-06-30 15:32 ` [PATCH v1 0/10] Fixes and API additions for firmware nodes Rafael J. Wysocki
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=2793969.faR48RUkvm@vostro.rjw.lan \
--to=rjw@rjwysocki.net \
--cc=broonie@kernel.org \
--cc=devel@acpica.org \
--cc=gregkh@linuxfoundation.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lv.zheng@intel.com \
--cc=rafael.j.wysocki@intel.com \
--cc=robert.moore@intel.com \
--cc=tomeu.vizoso@collabora.com \
/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
Powered by JetHome