In preparation of removing class_compat support, add a helper for creating a pseudo class in sysfs. This way we can keep class_kset private to driver core. This helper will be used by vfio/mdev, replacing the call to class_compat_create(). Signed-off-by: Heiner Kallweit <hkallweit1@xxxxxxxxx> --- drivers/base/class.c | 14 ++++++++++++++ include/linux/device/class.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/base/class.c b/drivers/base/class.c index 582b5a02a..f812236e2 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -578,6 +578,20 @@ struct class_compat *class_compat_register(const char *name) } EXPORT_SYMBOL_GPL(class_compat_register); +/** + * class_pseudo_register - create a pseudo class entry in sysfs + * @name: the name of the child + * + * Helper for creating a pseudo class in sysfs, keeps class_kset private + * + * Returns: the created kobject + */ +struct kobject *class_pseudo_register(const char *name) +{ + return kobject_create_and_add(name, &class_kset->kobj); +} +EXPORT_SYMBOL_GPL(class_pseudo_register); + /** * class_compat_unregister - unregister a compatibility class * @cls: the class to unregister diff --git a/include/linux/device/class.h b/include/linux/device/class.h index 518c9c83d..8b6e890c7 100644 --- a/include/linux/device/class.h +++ b/include/linux/device/class.h @@ -86,6 +86,7 @@ int class_compat_create_link(struct class_compat *cls, struct device *dev, struct device *device_link); void class_compat_remove_link(struct class_compat *cls, struct device *dev, struct device *device_link); +struct kobject *class_pseudo_register(const char *name); void class_dev_iter_init(struct class_dev_iter *iter, const struct class *class, const struct device *start, const struct device_type *type); -- 2.47.1