From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>
Subject: [PATCH 13/21] driver core: bus: clean up bus_sort_breadthfirst()
Date: Wed, 8 Feb 2023 12:13:22 +0100 [thread overview]
Message-ID: <20230208111330.439504-14-gregkh@linuxfoundation.org> (raw)
In-Reply-To: <20230208111330.439504-1-gregkh@linuxfoundation.org>
Convert the bus_sort_breadthfirst() function to use bus_to_subsys() and
not use the back-pointer to the private structure.
This also allows us to get rid of bus_get_device_klist() which was only
being used by this one internal function.
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/base/bus.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index c007524151d2..87e21aafe6e6 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -1006,11 +1006,6 @@ struct kset *bus_get_kset(struct bus_type *bus)
}
EXPORT_SYMBOL_GPL(bus_get_kset);
-static struct klist *bus_get_device_klist(struct bus_type *bus)
-{
- return &bus->p->klist_devices;
-}
-
/*
* Yes, this forcibly breaks the klist abstraction temporarily. It
* just wants to sort the klist, not change reference counts and
@@ -1042,13 +1037,16 @@ void bus_sort_breadthfirst(struct bus_type *bus,
int (*compare)(const struct device *a,
const struct device *b))
{
+ struct subsys_private *sp = bus_to_subsys(bus);
LIST_HEAD(sorted_devices);
struct klist_node *n, *tmp;
struct device_private *dev_prv;
struct device *dev;
struct klist *device_klist;
- device_klist = bus_get_device_klist(bus);
+ if (!sp)
+ return;
+ device_klist = &sp->klist_devices;
spin_lock(&device_klist->k_lock);
list_for_each_entry_safe(n, tmp, &device_klist->k_list, n_node) {
@@ -1058,6 +1056,7 @@ void bus_sort_breadthfirst(struct bus_type *bus,
}
list_splice(&sorted_devices, &device_klist->k_list);
spin_unlock(&device_klist->k_lock);
+ subsys_put(sp);
}
EXPORT_SYMBOL_GPL(bus_sort_breadthfirst);
--
2.39.1
next prev parent reply other threads:[~2023-02-08 11:14 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-08 11:13 [PATCH 00/21] driver core: bus: remove private "backpointer" from struct bus_type Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 01/21] driver core: add local subsys_get and subsys_put functions Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 02/21] driver core: bus: implement bus_get/put() without the private pointer Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 03/21] driver core: bus: constantify the bus_find_* functions Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 04/21] driver core: bus: convert bus_create/remove_file to be constant Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 05/21] driver core: bus: sysfs function cleanups Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 06/21] driver core: bus: bus_add/probe/remove_device() cleanups Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 07/21] driver core: bus: bus_register/unregister() cleanups Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 08/21] driver core: bus: subsys_interface_register/unregister() cleanups Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 09/21] driver core: bus: bus_get_kset() cleanup Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 10/21] driver core: bus: bus_register/unregister_notifier() cleanups Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 11/21] driver core: bus: bus_add/remove_driver() cleanups Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 12/21] driver core: bus: bus iterator cleanups Greg Kroah-Hartman
2023-02-21 12:54 ` Geert Uytterhoeven
2023-02-08 11:13 ` Greg Kroah-Hartman [this message]
2023-02-08 11:13 ` [PATCH 14/21] driver core: move driver_find() to bus.c Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 15/21] driver core: bus: clean up driver_find() Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 16/21] driver core: create bus_is_registered() Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 17/21] driver core: remove private pointer from struct bus_type Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 18/21] driver core: bus: constify bus_register/unregister_notifier() Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 19/21] driver core: bus: constify bus_get_kset() Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 20/21] driver core: bus: constify some internal functions Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 21/21] driver core: bus: constify bus_unregister() Greg Kroah-Hartman
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=20230208111330.439504-14-gregkh@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.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