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

Greg Kroah-Hartman posted 1 patch 1 year, 6 months ago
include/linux/device.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] driver core: make kobj_to_dev() take a const pointer
Posted by Greg Kroah-Hartman 1 year, 6 months ago
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@linuxfoundation.org>
---
 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);
 }
-- 
2.37.3