[PATCH] driver core: make kobj_to_dev() take a const pointer

From: Greg Kroah-Hartman
Date: Sat Oct 01 2022 - 12:52:58 EST

Doing pointer math does not modify the pointer itself, so it is safe to
say that the kobject passed into kobj_to_dev() is const. Now the
pointer passed out of it does loose the const capability, but for now
that's ok, we are allowing this so that const kobjects can call this
function successfully.

Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
include/linux/device.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/device.h b/include/linux/device.h
index 424b55df0272..b855b2e74cd3 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -680,7 +680,7 @@ struct device_link {
bool supplier_preactivated; /* Owned by consumer probe. */

-static inline struct device *kobj_to_dev(struct kobject *kobj)
+static inline struct device *kobj_to_dev(const struct kobject *kobj)
return container_of(kobj, struct device, kobj);