Re: [PATCH v3 03/11] platform/x86/intel/ifs: Create device for Intel IFS (In Field Scan)

Greg KH
2022-04-20T18:04:32Z

On Wed, Apr 20, 2022 at 05:57:04PM +0000, Luck, Tony wrote:
> >> ifs_class = class_create(THIS_MODULE, "intel_ifs");
> >
> > Why do you need a class? Why not just use a misc device? Saves you
> > loads of boilerplate code that is sometimes tricky to get correct.
>
> It didn't feel like a "ton" of boiler plate. Just class_create()/class_destroy()
> for the class itself. And
>
> class_for_each_device(ifs_class, NULL, NULL, ifs_device_unregister);
>
> to clean up devices on exit (or error cleanup in init()).
>
>
> I thought I needed a class to make a directory for my per-test directories to live in:
>
> $ ls -l /sys/devices/virtual/intel_ifs
> total 0
> drwxr-xr-x 3 root root 0 Apr 20 13:36 ifs0
> drwxr-xr-x 3 root root 0 Apr 20 13:36 ifs1
>
> Can I do that with a misc device?
>
> Or is it ok for them all to sit at the top level of /sys/devices/virtual?

How many do you have?

And why is a directory needed for just one tiny driver type?

thanks,

greg k-h