Re: [PATCH 1/3] driver core: class: add class_pseudo_register

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

thanks,

greg k-h




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux