Skip to contentSkip to conversation

driver core: make kobj_to_dev() take a const pointer

PATCH Superseded Greg Kroah-Hartman 1 participant 1 message Oct 1, 2022 Driver core

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

PATCH 1/1 driver core: make kobj_to_dev() take a const pointer

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.

---
 include/linux/device.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/device.h +1 -1
index 424b55df0272..b855b2e74cd3 100644
@@ -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);
 }
Signature · 1 line
2.37.3