Skip to contentSkip to conversation

driver core: make bus_get_device_klist() static

PATCH In review Greg Kroah-Hartman 2 participants 13 messages Jan 9, 2023 – Jan 10, 2023 Driver core

lore
Share & tools
lore
author maintainer
#1 lore raw

PATCH 2/6 driver core: remove subsys_find_device_by_id()

In reply to Greg Kroah-Hartman

This function has not been called by any code in the kernel tree in many many years so remove it as it is unused.

Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/base/bus.c         | 41 --------------------------------------
 include/linux/device/bus.h |  2 --
 2 files changed, 43 deletions(-)
drivers/base/bus.c +0 -41
index 4e6fdb65a157..45aa8d996f0a 100644
@@ -363,47 +363,6 @@ struct device *bus_find_device(struct bus_type *bus,
 }
 EXPORT_SYMBOL_GPL(bus_find_device);
 
-/**
- * subsys_find_device_by_id - find a device with a specific enumeration number
- * @subsys: subsystem
- * @id: index 'id' in struct device
- * @hint: device to check first
- *
- * Check the hint's next object and if it is a match return it directly,
- * otherwise, fall back to a full list search. Either way a reference for
- * the returned object is taken.
- */
-struct device *subsys_find_device_by_id(struct bus_type *subsys, unsigned int id,
-					struct device *hint)
-{
-	struct klist_iter i;
-	struct device *dev;
-
-	if (!subsys)
-		return NULL;
-
-	if (hint) {
-		klist_iter_init_node(&subsys->p->klist_devices, &i, &hint->p->knode_bus);
-		dev = next_device(&i);
-		if (dev && dev->id == id && get_device(dev)) {
-			klist_iter_exit(&i);
-			return dev;
-		}
-		klist_iter_exit(&i);
-	}
-
-	klist_iter_init_node(&subsys->p->klist_devices, &i, NULL);
-	while ((dev = next_device(&i))) {
-		if (dev->id == id && get_device(dev)) {
-			klist_iter_exit(&i);
-			return dev;
-		}
-	}
-	klist_iter_exit(&i);
-	return NULL;
-}
-EXPORT_SYMBOL_GPL(subsys_find_device_by_id);
-
 static struct device_driver *next_driver(struct klist_iter *i)
 {
 	struct klist_node *n = klist_next(i);
include/linux/device/bus.h +0 -2
index 0699b3970344..d865440d8c02 100644
@@ -250,8 +250,6 @@ bus_find_device_by_acpi_dev(struct bus_type *bus, const void *adev)
 }
 #endif
 
-struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id,
-					struct device *hint);
 int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
 		     void *data, int (*fn)(struct device_driver *, void *));
 void bus_sort_breadthfirst(struct bus_type *bus,
Signature · 1 line
2.39.0

Greg Kroah-Hartman

author maintainer
#0 lore raw

PATCH 1/6 driver core: make bus_get_device_klist() static

No one calls this function outside of drivers/base/bus.c so make it static so it does not need to be exported anymore.

Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/base/bus.c         | 3 +--
 include/linux/device/bus.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/base/bus.c +1 -2
index e1bf741063e0..4e6fdb65a157 100644
@@ -927,11 +927,10 @@ struct kset *bus_get_kset(struct bus_type *bus)
 }
 EXPORT_SYMBOL_GPL(bus_get_kset);
 
-struct klist *bus_get_device_klist(struct bus_type *bus)
+static struct klist *bus_get_device_klist(struct bus_type *bus)
 {
 	return &bus->p->klist_devices;
 }
-EXPORT_SYMBOL_GPL(bus_get_device_klist);
 
 /*
  * Yes, this forcibly breaks the klist abstraction temporarily.  It
include/linux/device/bus.h +0 -1
index f2cf7c4ddd20..0699b3970344 100644
@@ -287,6 +287,5 @@ extern int bus_unregister_notifier(struct bus_type *bus,
 #define BUS_NOTIFY_DRIVER_NOT_BOUND	0x00000008 /* driver fails to be bound */
 
 extern struct kset *bus_get_kset(struct bus_type *bus);
-extern struct klist *bus_get_device_klist(struct bus_type *bus);
 
 #endif
Signature · 1 line
2.39.0
author maintainer
#7 lore raw

PATCH 5/6 driver core: make subsys_dev_iter_exit() static

The function subsys_dev_iter_exit() is not used outside of drivers/base/bus.c so make it static to that file and remove the global export.

Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/base/bus.c         | 3 +--
 include/linux/device/bus.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/base/bus.c +1 -2
index 4be73f58d0ad..e0fe07872a74 100644
@@ -998,11 +998,10 @@ static struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter)
  * Finish an iteration.  Always call this function after iteration is
  * complete whether the iteration ran till the end or not.
  */
-void subsys_dev_iter_exit(struct subsys_dev_iter *iter)
+static void subsys_dev_iter_exit(struct subsys_dev_iter *iter)
 {
 	klist_iter_exit(&iter->ki);
 }
-EXPORT_SYMBOL_GPL(subsys_dev_iter_exit);
 
 int subsys_interface_register(struct subsys_interface *sif)
 {
include/linux/device/bus.h +0 -1
index 5a7590bc7913..ffa562f2d975 100644
@@ -154,7 +154,6 @@ struct subsys_dev_iter {
 	struct klist_iter		ki;
 	const struct device_type	*type;
 };
-void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
 
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 		     int (*fn)(struct device *dev, void *data));
Signature · 1 line
2.39.0
author maintainer
#9 lore raw

PATCH 6/6 driver core: move struct subsys_dev_iter to a local file

In reply to Greg Kroah-Hartman

struct subsys_dev_iter is not used by any code outside of drivers/base/bus.c so move it into that file and out of the global bus.h file.

Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/base/bus.c         | 5 +++++
 include/linux/device/bus.h | 5 -----
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/base/bus.c +5 -0
index e0fe07872a74..e0953656d5ac 100644
@@ -941,6 +941,11 @@ void bus_sort_breadthfirst(struct bus_type *bus,
 }
 EXPORT_SYMBOL_GPL(bus_sort_breadthfirst);
 
+struct subsys_dev_iter {
+	struct klist_iter		ki;
+	const struct device_type	*type;
+};
+
 /**
  * subsys_dev_iter_init - initialize subsys device iterator
  * @iter: subsys iterator to initialize
include/linux/device/bus.h +0 -5
index ffa562f2d975..53e3cdf18bae 100644
@@ -150,11 +150,6 @@ int device_match_acpi_handle(struct device *dev, const void *handle);
 int device_match_any(struct device *dev, const void *unused);
 
 /* iterator helpers for buses */
-struct subsys_dev_iter {
-	struct klist_iter		ki;
-	const struct device_type	*type;
-};
-
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 		     int (*fn)(struct device *dev, void *data));
 struct device *bus_find_device(struct bus_type *bus, struct device *start,
Signature · 1 line
2.39.0
author maintainer
#3 lore raw

PATCH 3/6 driver core: make subsys_dev_iter_init() static

In reply to Greg Kroah-Hartman

No one outside of drivers/base/bus.c calls this function so make it static and remove the exported symbol.

Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/base/bus.c         | 5 ++---
 include/linux/device/bus.h | 4 ----
 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/base/bus.c +2 -3
index 45aa8d996f0a..a375305a11dd 100644
@@ -953,8 +953,8 @@ EXPORT_SYMBOL_GPL(bus_sort_breadthfirst);
  * otherwise if it is NULL, the iteration starts at the beginning of
  * the list.
  */
-void subsys_dev_iter_init(struct subsys_dev_iter *iter, struct bus_type *subsys,
-			  struct device *start, const struct device_type *type)
+static void subsys_dev_iter_init(struct subsys_dev_iter *iter, struct bus_type *subsys,
+				 struct device *start, const struct device_type *type)
 {
 	struct klist_node *start_knode = NULL;
 
@@ -963,7 +963,6 @@ void subsys_dev_iter_init(struct subsys_dev_iter *iter, struct bus_type *subsys,
 	klist_iter_init_node(&subsys->p->klist_devices, &iter->ki, start_knode);
 	iter->type = type;
 }
-EXPORT_SYMBOL_GPL(subsys_dev_iter_init);
 
 /**
  * subsys_dev_iter_next - iterate to the next device
include/linux/device/bus.h +0 -4
index d865440d8c02..a1da2f8647af 100644
@@ -154,10 +154,6 @@ struct subsys_dev_iter {
 	struct klist_iter		ki;
 	const struct device_type	*type;
 };
-void subsys_dev_iter_init(struct subsys_dev_iter *iter,
-			 struct bus_type *subsys,
-			 struct device *start,
-			 const struct device_type *type);
 struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter);
 void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
 
Signature · 1 line
2.39.0
author maintainer
#5 lore raw

PATCH 4/6 driver core: make subsys_dev_iter_next() static

In reply to Greg Kroah-Hartman

The function subsys_dev_iter_next() is only used in drivers/base/bus.c so make it static to that file and remove the global export.

Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/base/bus.c         | 3 +--
 include/linux/device/bus.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/base/bus.c +1 -2
index a375305a11dd..4be73f58d0ad 100644
@@ -976,7 +976,7 @@ static void subsys_dev_iter_init(struct subsys_dev_iter *iter, struct bus_type *
  * free to do whatever it wants to do with the device including
  * calling back into subsys code.
  */
-struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter)
+static struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter)
 {
 	struct klist_node *knode;
 	struct device *dev;
@@ -990,7 +990,6 @@ struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter)
 			return dev;
 	}
 }
-EXPORT_SYMBOL_GPL(subsys_dev_iter_next);
 
 /**
  * subsys_dev_iter_exit - finish iteration
include/linux/device/bus.h +0 -1
index a1da2f8647af..5a7590bc7913 100644
@@ -154,7 +154,6 @@ struct subsys_dev_iter {
 	struct klist_iter		ki;
 	const struct device_type	*type;
 };
-struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter);
 void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
 
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
Signature · 1 line
2.39.0
maintainer Reviewed-by on v1 1/6
#11 lore raw
In reply to Greg Kroah-Hartman
Quoted 6 lines · Greg Kroah-Hartman

No one calls this function outside of drivers/base/bus.c so make it static so it does not need to be exported anymore.

Cc "Rafael J. Wysocki" <[email protected]>
Quoted 36 lines
---
 drivers/base/bus.c         | 3 +--
 include/linux/device/bus.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/base/bus.c +1 -2
index e1bf741063e0..4e6fdb65a157 100644
@@ -927,11 +927,10 @@ struct kset *bus_get_kset(struct bus_type *bus)
 }
 EXPORT_SYMBOL_GPL(bus_get_kset);
 
-struct klist *bus_get_device_klist(struct bus_type *bus)
+static struct klist *bus_get_device_klist(struct bus_type *bus)
 {
        return &bus->p->klist_devices;
 }
-EXPORT_SYMBOL_GPL(bus_get_device_klist);
 
 /*
  * Yes, this forcibly breaks the klist abstraction temporarily.  It
include/linux/device/bus.h +0 -2
index f2cf7c4ddd20..0699b3970344 100644
@@ -287,6 +287,5 @@ extern int bus_unregister_notifier(struct bus_type *bus,
 #define BUS_NOTIFY_DRIVER_NOT_BOUND    0x00000008 /* driver fails to be bound */
 
 extern struct kset *bus_get_kset(struct bus_type *bus);
-extern struct klist *bus_get_device_klist(struct bus_type *bus);
 
 #endif
--

2.39.0

maintainer Reviewed-by on v1 2/6
#2 lore raw

Re: [PATCH 2/6] driver core: remove subsys_find_device_by_id()

In reply to Greg Kroah-Hartman
Quoted 6 lines · Greg Kroah-Hartman

This function has not been called by any code in the kernel tree in many many years so remove it as it is unused.

Cc "Rafael J. Wysocki" <[email protected]>
Quoted 73 lines
---
 drivers/base/bus.c         | 41 --------------------------------------
 include/linux/device/bus.h |  2 --
 2 files changed, 43 deletions(-)
drivers/base/bus.c +0 -41
index 4e6fdb65a157..45aa8d996f0a 100644
@@ -363,47 +363,6 @@ struct device *bus_find_device(struct bus_type *bus,
 }
 EXPORT_SYMBOL_GPL(bus_find_device);
 
-/**
- * subsys_find_device_by_id - find a device with a specific enumeration number
- * @subsys: subsystem
- * @id: index 'id' in struct device
- * @hint: device to check first
- *
- * Check the hint's next object and if it is a match return it directly,
- * otherwise, fall back to a full list search. Either way a reference for
- * the returned object is taken.
- */
-struct device *subsys_find_device_by_id(struct bus_type *subsys, unsigned int id,
-                                       struct device *hint)
-{
-       struct klist_iter i;
-       struct device *dev;
-
-       if (!subsys)
-               return NULL;
-
-       if (hint) {
-               klist_iter_init_node(&subsys->p->klist_devices, &i, &hint->p->knode_bus);
-               dev = next_device(&i);
-               if (dev && dev->id == id && get_device(dev)) {
-                       klist_iter_exit(&i);
-                       return dev;
-               }
-               klist_iter_exit(&i);
-       }
-
-       klist_iter_init_node(&subsys->p->klist_devices, &i, NULL);
-       while ((dev = next_device(&i))) {
-               if (dev->id == id && get_device(dev)) {
-                       klist_iter_exit(&i);
-                       return dev;
-               }
-       }
-       klist_iter_exit(&i);
-       return NULL;
-}
-EXPORT_SYMBOL_GPL(subsys_find_device_by_id);
-
 static struct device_driver *next_driver(struct klist_iter *i)
 {
        struct klist_node *n = klist_next(i);
include/linux/device/bus.h +0 -3
index 0699b3970344..d865440d8c02 100644
@@ -250,8 +250,6 @@ bus_find_device_by_acpi_dev(struct bus_type *bus, const void *adev)
 }
 #endif
 
-struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id,
-                                       struct device *hint);
 int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
                     void *data, int (*fn)(struct device_driver *, void *));
 void bus_sort_breadthfirst(struct bus_type *bus,
--

2.39.0

maintainer Reviewed-by on v1 3/6
#4 lore raw

Re: [PATCH 3/6] driver core: make subsys_dev_iter_init() static

In reply to Greg Kroah-Hartman
Quoted 6 lines · Greg Kroah-Hartman

No one outside of drivers/base/bus.c calls this function so make it static and remove the exported symbol.

Cc "Rafael J. Wysocki" <[email protected]>
Quoted 46 lines
---
 drivers/base/bus.c         | 5 ++---
 include/linux/device/bus.h | 4 ----
 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/base/bus.c +2 -3
index 45aa8d996f0a..a375305a11dd 100644
@@ -953,8 +953,8 @@ EXPORT_SYMBOL_GPL(bus_sort_breadthfirst);
  * otherwise if it is NULL, the iteration starts at the beginning of
  * the list.
  */
-void subsys_dev_iter_init(struct subsys_dev_iter *iter, struct bus_type *subsys,
-                         struct device *start, const struct device_type *type)
+static void subsys_dev_iter_init(struct subsys_dev_iter *iter, struct bus_type *subsys,
+                                struct device *start, const struct device_type *type)
 {
        struct klist_node *start_knode = NULL;
 
@@ -963,7 +963,6 @@ void subsys_dev_iter_init(struct subsys_dev_iter *iter, struct bus_type *subsys,
        klist_iter_init_node(&subsys->p->klist_devices, &iter->ki, start_knode);
        iter->type = type;
 }
-EXPORT_SYMBOL_GPL(subsys_dev_iter_init);
 
 /**
  * subsys_dev_iter_next - iterate to the next device
include/linux/device/bus.h +0 -5
index d865440d8c02..a1da2f8647af 100644
@@ -154,10 +154,6 @@ struct subsys_dev_iter {
        struct klist_iter               ki;
        const struct device_type        *type;
 };
-void subsys_dev_iter_init(struct subsys_dev_iter *iter,
-                        struct bus_type *subsys,
-                        struct device *start,
-                        const struct device_type *type);
 struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter);
 void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
 
--

2.39.0

maintainer Reviewed-by on v1 4/6
#6 lore raw

Re: [PATCH 4/6] driver core: make subsys_dev_iter_next() static

In reply to Greg Kroah-Hartman
Quoted 6 lines · Greg Kroah-Hartman

The function subsys_dev_iter_next() is only used in drivers/base/bus.c so make it static to that file and remove the global export.

Cc "Rafael J. Wysocki" <[email protected]>
Quoted 41 lines
---
 drivers/base/bus.c         | 3 +--
 include/linux/device/bus.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/base/bus.c +1 -2
index a375305a11dd..4be73f58d0ad 100644
@@ -976,7 +976,7 @@ static void subsys_dev_iter_init(struct subsys_dev_iter *iter, struct bus_type *
  * free to do whatever it wants to do with the device including
  * calling back into subsys code.
  */
-struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter)
+static struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter)
 {
        struct klist_node *knode;
        struct device *dev;
@@ -990,7 +990,6 @@ struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter)
                        return dev;
        }
 }
-EXPORT_SYMBOL_GPL(subsys_dev_iter_next);
 
 /**
  * subsys_dev_iter_exit - finish iteration
include/linux/device/bus.h +0 -2
index a1da2f8647af..5a7590bc7913 100644
@@ -154,7 +154,6 @@ struct subsys_dev_iter {
        struct klist_iter               ki;
        const struct device_type        *type;
 };
-struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter);
 void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
 
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
--

2.39.0

maintainer Reviewed-by on v1 5/6
#8 lore raw

Re: [PATCH 5/6] driver core: make subsys_dev_iter_exit() static

In reply to Greg Kroah-Hartman
Quoted 7 lines · Greg Kroah-Hartman

The function subsys_dev_iter_exit() is not used outside of drivers/base/bus.c so make it static to that file and remove the global export.

Cc "Rafael J. Wysocki" <[email protected]>
Quoted 37 lines
---
 drivers/base/bus.c         | 3 +--
 include/linux/device/bus.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/base/bus.c +1 -2
index 4be73f58d0ad..e0fe07872a74 100644
@@ -998,11 +998,10 @@ static struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter)
  * Finish an iteration.  Always call this function after iteration is
  * complete whether the iteration ran till the end or not.
  */
-void subsys_dev_iter_exit(struct subsys_dev_iter *iter)
+static void subsys_dev_iter_exit(struct subsys_dev_iter *iter)
 {
        klist_iter_exit(&iter->ki);
 }
-EXPORT_SYMBOL_GPL(subsys_dev_iter_exit);
 
 int subsys_interface_register(struct subsys_interface *sif)
 {
include/linux/device/bus.h +0 -2
index 5a7590bc7913..ffa562f2d975 100644
@@ -154,7 +154,6 @@ struct subsys_dev_iter {
        struct klist_iter               ki;
        const struct device_type        *type;
 };
-void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
 
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
                     int (*fn)(struct device *dev, void *data));
--

2.39.0

maintainer Reviewed-by on v1 6/6
#10 lore raw

Re: [PATCH 6/6] driver core: move struct subsys_dev_iter to a local file

In reply to Greg Kroah-Hartman
Quoted 7 lines · Greg Kroah-Hartman

struct subsys_dev_iter is not used by any code outside of drivers/base/bus.c so move it into that file and out of the global bus.h file.

Cc "Rafael J. Wysocki" <[email protected]>
Quoted 40 lines
---
 drivers/base/bus.c         | 5 +++++
 include/linux/device/bus.h | 5 -----
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/base/bus.c +5 -0
index e0fe07872a74..e0953656d5ac 100644
@@ -941,6 +941,11 @@ void bus_sort_breadthfirst(struct bus_type *bus,
 }
 EXPORT_SYMBOL_GPL(bus_sort_breadthfirst);
 
+struct subsys_dev_iter {
+       struct klist_iter               ki;
+       const struct device_type        *type;
+};
+
 /**
  * subsys_dev_iter_init - initialize subsys device iterator
  * @iter: subsys iterator to initialize
include/linux/device/bus.h +0 -6
index ffa562f2d975..53e3cdf18bae 100644
@@ -150,11 +150,6 @@ int device_match_acpi_handle(struct device *dev, const void *handle);
 int device_match_any(struct device *dev, const void *unused);
 
 /* iterator helpers for buses */
-struct subsys_dev_iter {
-       struct klist_iter               ki;
-       const struct device_type        *type;
-};
-
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
                     int (*fn)(struct device *dev, void *data));
 struct device *bus_find_device(struct bus_type *bus, struct device *start,
--

2.39.0