All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hisi_lpc: Use acpi_dev_for_each_child()
@ 2022-06-29 12:55 Rafael J. Wysocki
  2022-06-29 13:33 ` John Garry
  2022-06-29 13:47 ` [PATCH v2] " Rafael J. Wysocki
  0 siblings, 2 replies; 28+ messages in thread
From: Rafael J. Wysocki @ 2022-06-29 12:55 UTC (permalink / raw)
  To: Linux ACPI; +Cc: LKML, Andy Shevchenko, john.garry, Greg Kroah-Hartman

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Instead of walking the list of children of an ACPI device directly,
use acpi_dev_for_each_child() to carry out an action for all of
the given ACPI device's children.

This will help to eliminate the children list head from struct
acpi_device as it is redundant and it is used in questionable ways
in some places (in particular, locking is needed for walking the
list pointed to it safely, but it is often missing).

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/bus/hisi_lpc.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Index: linux-pm/drivers/bus/hisi_lpc.c
===================================================================
--- linux-pm.orig/drivers/bus/hisi_lpc.c
+++ linux-pm/drivers/bus/hisi_lpc.c
@@ -471,6 +471,12 @@ static int hisi_lpc_acpi_remove_subdev(s
 	return 0;
 }
 
+static int hisi_lpc_acpi_clear_enumerated(struct acpi_device *adev, void *not_used)
+{
+	acpi_device_clear_enumerated(adev);
+	return 0;
+}
+
 struct hisi_lpc_acpi_cell {
 	const char *hid;
 	const char *name;
@@ -480,13 +486,11 @@ struct hisi_lpc_acpi_cell {
 
 static void hisi_lpc_acpi_remove(struct device *hostdev)
 {
-	struct acpi_device *adev = ACPI_COMPANION(hostdev);
 	struct acpi_device *child;
 
 	device_for_each_child(hostdev, NULL, hisi_lpc_acpi_remove_subdev);
-
-	list_for_each_entry(child, &adev->children, node)
-		acpi_device_clear_enumerated(child);
+	acpi_dev_for_each_child(ACPI_COMPANION(hostdev),
+				hisi_lpc_acpi_clear_enumerated, NULL);
 }
 
 /*




^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2022-08-09 10:35 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-29 12:55 [PATCH] hisi_lpc: Use acpi_dev_for_each_child() Rafael J. Wysocki
2022-06-29 13:33 ` John Garry
2022-06-29 13:38   ` Rafael J. Wysocki
2022-06-29 13:47 ` [PATCH v2] " Rafael J. Wysocki
2022-06-30 12:48   ` Rafael J. Wysocki
2022-06-30 13:37     ` John Garry
2022-06-30 13:40       ` Rafael J. Wysocki
2022-06-30 18:13   ` [PATCH v3] " Rafael J. Wysocki
2022-07-01  8:34     ` Greg Kroah-Hartman
2022-07-01 10:49     ` John Garry
2022-07-01 11:06       ` Andy Shevchenko
2022-07-01 11:07         ` Andy Shevchenko
2022-07-01 11:54           ` John Garry
2022-07-01 12:05             ` Andy Shevchenko
2022-07-01 12:18               ` John Garry
2022-07-04 19:02                 ` Rafael J. Wysocki
2022-07-05  8:37                   ` John Garry
2022-07-05  9:38                     ` Andy Shevchenko
2022-07-05  9:39                       ` Andy Shevchenko
2022-07-05 10:16                         ` John Garry
2022-07-05 10:29                           ` Andy Shevchenko
2022-07-05 13:54                           ` Rafael J. Wysocki
2022-07-05 15:16                             ` John Garry
2022-07-05 15:34                               ` Rafael J. Wysocki
2022-08-09 10:35                             ` John Garry
2022-07-05 15:08                     ` Rafael J. Wysocki
2022-07-01 18:16               ` Rafael J. Wysocki
2022-07-01 18:19       ` Rafael J. Wysocki

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.