ktypes vs. devices classes (struct class)

Richard richard_siegfried at systemli.org
Sun Oct 1 17:22:46 EDT 2023


>>
>>> Is it possible that one device belongs to several classes?
>>
>> No.
> 
> Oops, well yes.  Depends on what you are thinking is a "device" here.
> 
> In the kernel, yes, a 'struct device' on a bus can then register itself
> with multiple subsystems that handle different classes, and then
> individual 'struct device' are created for those classes that have a
> parent of the original 'struct device' on the bus.
> 
> But within a 'struct class', there can only be one "struct device" for
> that class for that specific class type (we used to call them "struct
> class_device" but that got removed a long time ago as the objects really
> all did the same thing.)

Oki, thanks for explaining

> 
> It's a bit confusing, yes, sorry, but creating a unified object model of
> all devices in the system turns out to be complex due to the huge range
> of devices that an operating system needs to manage, which is probably
> why most other operating systems have never attempted to do such a
> thing.

 From what I've heard Windows has tried the same with WDF but it's so 
abstract and elegant it only plays with the "nice" devices so only 
around 50%, for all other devices you still need the old device model. 
So in the end every driver developer has to learn both models :D

> 
> When Pat and I created it, we were young and naive and thought "this
> should be simple!"  Famous last words...

:D

> 
> thanks,
> 
> greg k-h

Thank you!,
Richard



More information about the Kernelnewbies mailing list