summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-07-28 17:57:01 +0100
committerMark Brown <broonie@kernel.org>2026-07-28 17:57:01 +0100
commit289c6bb5293f761646256f7646a6aef24ece88a6 (patch)
treed507fc0510c7f7cc8d69336287c5f30a676a2e4f /include
parentd9e848dbb0f71892e211838ab44cabcf18c78b8f (diff)
parent0e6f8ccd4618afdb504d5c56fe2fea1a2cd5d86a (diff)
downloadlinux-next-289c6bb5293f761646256f7646a6aef24ece88a6.tar.gz
linux-next-289c6bb5293f761646256f7646a6aef24ece88a6.zip
Merge branch 'driver-core-next' of https://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git
# Conflicts: # drivers/gpu/drm/xe/xe_i2c.c # drivers/gpu/nova-core/gpu.rs # include/linux/platform_device.h
Diffstat (limited to 'include')
-rw-r--r--include/kunit/fwnode.h29
-rw-r--r--include/linux/container_of.h5
-rw-r--r--include/linux/kobject.h75
-rw-r--r--include/linux/platform_device.h8
4 files changed, 110 insertions, 7 deletions
diff --git a/include/kunit/fwnode.h b/include/kunit/fwnode.h
new file mode 100644
index 000000000000..e250bb87e144
--- /dev/null
+++ b/include/kunit/fwnode.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * KUnit resource management helpers for firmware nodes.
+ *
+ * Copyright (C) Qualcomm Technologies, Inc. and/or its subsidiaries
+ */
+
+#ifndef _KUNIT_FWNODE_H
+#define _KUNIT_FWNODE_H
+
+struct device;
+struct fwnode_handle;
+struct kunit;
+struct property_entry;
+struct software_node;
+
+struct fwnode_handle *
+kunit_fwnode_create_software_node(struct kunit *test,
+ const struct property_entry *properties,
+ const struct fwnode_handle *parent);
+struct fwnode_handle *
+kunit_software_node_register(struct kunit *test,
+ const struct software_node *node);
+int kunit_software_node_register_node_group(struct kunit *test,
+ const struct software_node *const *nodes);
+int kunit_device_add_software_node(struct kunit *test, struct device *dev,
+ const struct software_node *node);
+
+#endif /* _KUNIT_FWNODE_H */
diff --git a/include/linux/container_of.h b/include/linux/container_of.h
index 1f6ebf27d962..28db38e9ee3e 100644
--- a/include/linux/container_of.h
+++ b/include/linux/container_of.h
@@ -17,11 +17,10 @@
* Do not use container_of() in new code.
*/
#define container_of(ptr, type, member) ({ \
- void *__mptr = (void *)(ptr); \
- static_assert(__same_type(*(ptr), ((type *)0)->member) || \
+ static_assert(__same_type(*(ptr), typeof_member(type, member)) || \
__same_type(*(ptr), void), \
"pointer type mismatch in container_of()"); \
- ((type *)(__mptr - offsetof(type, member))); })
+ (type *)((void *)(ptr) - offsetof(type, member)); })
/**
* container_of_const - cast a member of a structure out to the containing
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index bcb5d4e32001..55e37a5d405e 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -138,12 +138,79 @@ struct kset_uevent_ops {
struct kobj_attribute {
struct attribute attr;
- ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
- char *buf);
- ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
- const char *buf, size_t count);
+ __SYSFS_FUNCTION_ALTERNATIVE(
+ ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr, char *buf);
+ ssize_t (*show_const)(struct kobject *kobj, const struct kobj_attribute *attr,
+ char *buf);
+ );
+ __SYSFS_FUNCTION_ALTERNATIVE(
+ ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
+ const char *buf, size_t count);
+ ssize_t (*store_const)(struct kobject *kobj, const struct kobj_attribute *attr,
+ const char *buf, size_t count);
+ );
};
+typedef ssize_t __kobj_show_handler_const(struct kobject *kobj, const struct kobj_attribute *attr,
+ char *buf);
+typedef ssize_t __kobj_store_handler_const(struct kobject *kobj, const struct kobj_attribute *attr,
+ const char *buf, size_t count);
+
+#ifdef CONFIG_CFI
+
+#define __KOBJ_ATTR_SHOW_STORE(_show, _store) \
+ .show = _Generic(_show, \
+ __kobj_show_handler_const * : NULL, \
+ default : _show \
+ ), \
+ .show_const = _Generic(_show, \
+ __kobj_show_handler_const * : _show, \
+ default : NULL \
+ ), \
+ .store = _Generic(_store, \
+ __kobj_store_handler_const * : NULL, \
+ default : _store \
+ ), \
+ .store_const = _Generic(_store, \
+ __kobj_store_handler_const * : _store, \
+ default : NULL \
+ ),
+
+#else
+
+#define __KOBJ_ATTR_SHOW_STORE(_show, _store) \
+ .show = _Generic(_show, \
+ __kobj_show_handler_const * : (void *)_show, \
+ default : _show \
+ ), \
+ .store = _Generic(_store, \
+ __kobj_store_handler_const * : (void *)_store, \
+ default : _store \
+ ), \
+
+#endif
+
+#define __KOBJ_ATTR(_name, _mode, _show, _store) { \
+ .attr = { .name = __stringify(_name), \
+ .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \
+ __KOBJ_ATTR_SHOW_STORE(_show, _store) \
+}
+
+#define __KOBJ_ATTR_RO_MODE(_name, _mode) \
+ __KOBJ_ATTR(_name, _mode, _name##_show, NULL)
+
+#define __KOBJ_ATTR_RO(_name) \
+ __KOBJ_ATTR_RO_MODE(_name, 0444)
+
+#define __KOBJ_ATTR_RW_MODE(_name, _mode) \
+ __KOBJ_ATTR(_name, _mode, _name##_show, _name##_store)
+
+#define __KOBJ_ATTR_WO(_name) \
+ __KOBJ_ATTR(_name, 0200, NULL, _name##_store)
+
+#define __KOBJ_ATTR_RW(_name) \
+ __KOBJ_ATTR(_name, 0644, _name##_show, _name##_store)
+
extern const struct sysfs_ops kobj_sysfs_ops;
struct sock;
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 8c566f09d04e..3d5bbcbae730 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -19,6 +19,8 @@
struct irq_affinity;
struct mfd_cell;
struct property_entry;
+struct device_node;
+struct fwnode_handle;
struct platform_device {
const char *name;
@@ -262,6 +264,12 @@ extern int platform_device_add_resources(struct platform_device *pdev,
unsigned int num);
extern int platform_device_add_data(struct platform_device *pdev,
const void *data, size_t size);
+void platform_device_set_of_node(struct platform_device *pdev,
+ struct device_node *np);
+void platform_device_set_fwnode(struct platform_device *pdev,
+ struct fwnode_handle *fwnode);
+void platform_device_set_of_node_from_dev(struct platform_device *pdev,
+ const struct device *dev2);
extern int platform_device_add(struct platform_device *pdev);
extern void platform_device_del(struct platform_device *pdev);
extern void platform_device_put(struct platform_device *pdev);