From: Aleksey Makarov <aleksey.makarov@linaro.org> To: linux-acpi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Aleksey Makarov <aleksey.makarov@linaro.org>, Graeme Gregory <graeme.gregory@linaro.org>, Russell King <linux@arm.linux.org.uk>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Rafael J . Wysocki" <rjw@rjwysocki.net>, Shannon Zhao <shannon.zhao@linaro.org>, Andy Shevchenko <andy.shevchenko@gmail.com>, Vladimir Zapolskiy <vz@mleia.com>, Len Brown <lenb@kernel.org> Subject: [PATCH v6 1/2] ACPI: introduce a function to find the first physical device Date: Wed, 20 Jan 2016 20:29:26 +0600 [thread overview] Message-ID: <1453300171-25473-2-git-send-email-aleksey.makarov@linaro.org> (raw) In-Reply-To: <1453300171-25473-1-git-send-email-aleksey.makarov@linaro.org> Factor out the code that finds the first physical device of a given ACPI device. It is used in several places. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Aleksey Makarov <aleksey.makarov@linaro.org> --- drivers/acpi/acpi_platform.c | 19 ++----------------- drivers/acpi/bus.c | 33 ++++++++++++++++++++++----------- drivers/acpi/internal.h | 1 + 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c index 296b7a1..c3af108 100644 --- a/drivers/acpi/acpi_platform.c +++ b/drivers/acpi/acpi_platform.c @@ -43,7 +43,6 @@ static const struct acpi_device_id forbidden_id_list[] = { struct platform_device *acpi_create_platform_device(struct acpi_device *adev) { struct platform_device *pdev = NULL; - struct acpi_device *acpi_parent; struct platform_device_info pdevinfo; struct resource_entry *rentry; struct list_head resource_list; @@ -82,22 +81,8 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev) * attached to it, that physical device should be the parent of the * platform device we are about to create. */ - pdevinfo.parent = NULL; - acpi_parent = adev->parent; - if (acpi_parent) { - struct acpi_device_physical_node *entry; - struct list_head *list; - - mutex_lock(&acpi_parent->physical_node_lock); - list = &acpi_parent->physical_node_list; - if (!list_empty(list)) { - entry = list_first_entry(list, - struct acpi_device_physical_node, - node); - pdevinfo.parent = entry->dev; - } - mutex_unlock(&acpi_parent->physical_node_lock); - } + pdevinfo.parent = adev->parent ? + acpi_get_first_physical_node(adev->parent) : NULL; pdevinfo.name = dev_name(&adev->dev); pdevinfo.id = -1; pdevinfo.res = resources; diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index a212cef..832b26d 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -478,24 +478,35 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device) Device Matching -------------------------------------------------------------------------- */ -static struct acpi_device *acpi_primary_dev_companion(struct acpi_device *adev, - const struct device *dev) +/** + * acpi_device_fix_parent - Get first physical node of an ACPI device + * @adev: ACPI device in question + */ +struct device *acpi_get_first_physical_node(struct acpi_device *adev) { struct mutex *physical_node_lock = &adev->physical_node_lock; + struct device *node = NULL; mutex_lock(physical_node_lock); - if (list_empty(&adev->physical_node_list)) { - adev = NULL; - } else { - const struct acpi_device_physical_node *node; + if (!list_empty(&adev->physical_node_list)) node = list_first_entry(&adev->physical_node_list, - struct acpi_device_physical_node, node); - if (node->dev != dev) - adev = NULL; - } + struct acpi_device_physical_node, node)->dev; + mutex_unlock(physical_node_lock); - return adev; + + return node; +} + +static struct acpi_device *acpi_primary_dev_companion(struct acpi_device *adev, + const struct device *dev) +{ + const struct device *node = acpi_get_first_physical_node(adev); + + if (node && node == dev) + return adev; + + return NULL; } /** diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 11d87bf..ee9312ba 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -98,6 +98,7 @@ bool acpi_device_is_present(struct acpi_device *adev); bool acpi_device_is_battery(struct acpi_device *adev); bool acpi_device_is_first_physical_node(struct acpi_device *adev, const struct device *dev); +struct device *acpi_get_first_physical_node(struct acpi_device *adev); /* -------------------------------------------------------------------------- Device Matching and Notification -- 2.7.0
WARNING: multiple messages have this Message-ID (diff)
From: aleksey.makarov@linaro.org (Aleksey Makarov) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 1/2] ACPI: introduce a function to find the first physical device Date: Wed, 20 Jan 2016 20:29:26 +0600 [thread overview] Message-ID: <1453300171-25473-2-git-send-email-aleksey.makarov@linaro.org> (raw) In-Reply-To: <1453300171-25473-1-git-send-email-aleksey.makarov@linaro.org> Factor out the code that finds the first physical device of a given ACPI device. It is used in several places. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Aleksey Makarov <aleksey.makarov@linaro.org> --- drivers/acpi/acpi_platform.c | 19 ++----------------- drivers/acpi/bus.c | 33 ++++++++++++++++++++++----------- drivers/acpi/internal.h | 1 + 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c index 296b7a1..c3af108 100644 --- a/drivers/acpi/acpi_platform.c +++ b/drivers/acpi/acpi_platform.c @@ -43,7 +43,6 @@ static const struct acpi_device_id forbidden_id_list[] = { struct platform_device *acpi_create_platform_device(struct acpi_device *adev) { struct platform_device *pdev = NULL; - struct acpi_device *acpi_parent; struct platform_device_info pdevinfo; struct resource_entry *rentry; struct list_head resource_list; @@ -82,22 +81,8 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev) * attached to it, that physical device should be the parent of the * platform device we are about to create. */ - pdevinfo.parent = NULL; - acpi_parent = adev->parent; - if (acpi_parent) { - struct acpi_device_physical_node *entry; - struct list_head *list; - - mutex_lock(&acpi_parent->physical_node_lock); - list = &acpi_parent->physical_node_list; - if (!list_empty(list)) { - entry = list_first_entry(list, - struct acpi_device_physical_node, - node); - pdevinfo.parent = entry->dev; - } - mutex_unlock(&acpi_parent->physical_node_lock); - } + pdevinfo.parent = adev->parent ? + acpi_get_first_physical_node(adev->parent) : NULL; pdevinfo.name = dev_name(&adev->dev); pdevinfo.id = -1; pdevinfo.res = resources; diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index a212cef..832b26d 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -478,24 +478,35 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device) Device Matching -------------------------------------------------------------------------- */ -static struct acpi_device *acpi_primary_dev_companion(struct acpi_device *adev, - const struct device *dev) +/** + * acpi_device_fix_parent - Get first physical node of an ACPI device + * @adev: ACPI device in question + */ +struct device *acpi_get_first_physical_node(struct acpi_device *adev) { struct mutex *physical_node_lock = &adev->physical_node_lock; + struct device *node = NULL; mutex_lock(physical_node_lock); - if (list_empty(&adev->physical_node_list)) { - adev = NULL; - } else { - const struct acpi_device_physical_node *node; + if (!list_empty(&adev->physical_node_list)) node = list_first_entry(&adev->physical_node_list, - struct acpi_device_physical_node, node); - if (node->dev != dev) - adev = NULL; - } + struct acpi_device_physical_node, node)->dev; + mutex_unlock(physical_node_lock); - return adev; + + return node; +} + +static struct acpi_device *acpi_primary_dev_companion(struct acpi_device *adev, + const struct device *dev) +{ + const struct device *node = acpi_get_first_physical_node(adev); + + if (node && node == dev) + return adev; + + return NULL; } /** diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 11d87bf..ee9312ba 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -98,6 +98,7 @@ bool acpi_device_is_present(struct acpi_device *adev); bool acpi_device_is_battery(struct acpi_device *adev); bool acpi_device_is_first_physical_node(struct acpi_device *adev, const struct device *dev); +struct device *acpi_get_first_physical_node(struct acpi_device *adev); /* -------------------------------------------------------------------------- Device Matching and Notification -- 2.7.0
next prev parent reply other threads:[~2016-01-20 14:29 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-01-20 14:29 [PATCH v6 0/2] Add AMBA bus probing support to ACPI Aleksey Makarov 2016-01-20 14:29 ` Aleksey Makarov 2016-01-20 14:29 ` Aleksey Makarov [this message] 2016-01-20 14:29 ` [PATCH v6 1/2] ACPI: introduce a function to find the first physical device Aleksey Makarov 2016-01-20 15:12 ` Andy Shevchenko 2016-01-20 15:12 ` Andy Shevchenko 2016-01-20 15:12 ` Andy Shevchenko 2016-01-20 17:00 ` Aleksey Makarov 2016-01-20 17:00 ` Aleksey Makarov 2016-01-20 17:00 ` Aleksey Makarov 2016-01-20 17:25 ` Andy Shevchenko 2016-01-20 17:25 ` Andy Shevchenko 2016-01-20 17:25 ` Andy Shevchenko 2016-02-16 1:21 ` Rafael J. Wysocki 2016-02-16 1:21 ` Rafael J. Wysocki 2016-02-16 1:21 ` Rafael J. Wysocki 2016-02-16 1:20 ` Rafael J. Wysocki 2016-02-16 1:20 ` Rafael J. Wysocki 2016-02-16 12:52 ` Aleksey Makarov 2016-02-16 12:52 ` Aleksey Makarov 2016-02-16 19:20 ` Rafael J. Wysocki 2016-02-16 19:20 ` Rafael J. Wysocki 2016-01-20 14:29 ` [PATCH v6 2/2] ACPI: amba bus probing support Aleksey Makarov 2016-01-20 14:29 ` Aleksey Makarov 2016-02-16 1:23 ` Rafael J. Wysocki 2016-02-16 1:23 ` 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=1453300171-25473-2-git-send-email-aleksey.makarov@linaro.org \ --to=aleksey.makarov@linaro.org \ --cc=andy.shevchenko@gmail.com \ --cc=graeme.gregory@linaro.org \ --cc=gregkh@linuxfoundation.org \ --cc=lenb@kernel.org \ --cc=linux-acpi@vger.kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux@arm.linux.org.uk \ --cc=rjw@rjwysocki.net \ --cc=shannon.zhao@linaro.org \ --cc=vz@mleia.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: linkBe 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.