On 04.12.2024 19:17, Greg Kroah-Hartman wrote: > On Wed, Dec 04, 2024 at 06:04:32PM +0100, Heiner Kallweit wrote: >> On 04.12.2024 10:33, Greg Kroah-Hartman wrote: >>> On Tue, Dec 03, 2024 at 09:10:05PM +0100, Heiner Kallweit wrote: >>>> 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); >>> >>> I see the goal here, but let's not continue on and create fake kobjects >>> in places where there should NOT be any kobjects. Also, you might get >>> in trouble when removing this kobject as it thinks it is a 'struct >>> class' but yet it isn't, right? Did you test that? >>> >> >> It's removed using kobject_put(), same as what class_compat_unregister() does. >> I only compile-tested the changes. > > I would not be able to take these unless someone actually runs them as > the kobject removal here might be getting confused a bit. > Understood. Maybe Alex/Kirti can test. > thanks, > > greg k-h