summaryrefslogtreecommitdiff
path: root/include/linux/device.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/device.h')
-rw-r--r--include/linux/device.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index 424b55df0272..84ae52de6746 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -680,11 +680,27 @@ 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(struct kobject *kobj)
{
return container_of(kobj, struct device, kobj);
}
+static inline const struct device *__kobj_to_dev_const(const struct kobject *kobj)
+{
+ return container_of(kobj, const struct device, kobj);
+}
+
+/*
+ * container_of() will happily take a const * and spit back a non-const * as it
+ * is just doing pointer math. But we want to be a bit more careful in the
+ * driver code, so manually force any const * of a kobject to also be a const *
+ * to a device.
+ */
+#define kobj_to_dev(kobj) \
+ _Generic((kobj), \
+ const struct kobject *: __kobj_to_dev_const, \
+ struct kobject *: __kobj_to_dev)(kobj)
+
/**
* device_iommu_mapped - Returns true when the device DMA is translated
* by an IOMMU
@@ -1046,12 +1062,8 @@ static inline void device_remove_group(struct device *dev,
int __must_check devm_device_add_groups(struct device *dev,
const struct attribute_group **groups);
-void devm_device_remove_groups(struct device *dev,
- const struct attribute_group **groups);
int __must_check devm_device_add_group(struct device *dev,
const struct attribute_group *grp);
-void devm_device_remove_group(struct device *dev,
- const struct attribute_group *grp);
/*
* Platform "fixup" functions - allow the platform to have their say