platform device as parent of a miscdevice

Martin Kaiser lists at kaiser.cx
Tue Mar 30 15:27:17 EDT 2021


Hi Greg and all,

Thus wrote Greg KH (greg at kroah.com):

> Not at all, this is what you should be done, and is what many misc
> devices do, that's why the parent pointer is there :)

thanks for the confirmation.

> What in-kernel misc drivers do not do that that you feel should?

My misunderstanding was that quite a few drivers set the parent pointer
but hardly anyone uses the parent pointer in the file_operations.

It seems that most drivers have their miscdevice as part of their global
structure and use container_of in the file_operations, e.g. ipmb_read in
drivers/char/ipmi/ipmb_dev_int.c.

Best regards,
Martin



More information about the Kernelnewbies mailing list