Linux – How do I register callbacks on hang in Linux drivers?

How do I register callbacks on hang in Linux drivers?… here is a solution to the problem.

How do I register callbacks on hang in Linux drivers?

I’m writing a linux driver and I want to register a callback function to call when the system goes to sleep. What is the API to do this?

Thank you.

Solution

It depends on what kind of driver you have. For example, if you have a driver registered with platform_device_register(), struct platform_driver contains a .suspend member for device suspension to hit back. For PCI devices, the struct pci_driver that you pass to pci_register_driver() also contains a .suspend member.

Most device classes should provide a similar mechanism.

Related Problems and Solutions