Platform device driver code example

In this example code, we will create a dummy platform device and register the device with the kernel. Later on, in the same driver code , we will register the driver and make the kernel invoke the “probe” function for the driver. the sample code is provided below

Sample platform device driver code

The dmesg output of loading and unloading of the device driver above is shown below. It can be seen that the kernel invoked the “probe” function after the driver was registered. The device was earlier registered using platform_device_register API. On unregistering the device and driver, the release and remove callbacks were invoked for the device and driver respectively.

Understanding network device drivers in Linux kernel

Comments

  1. Pingback: Platform device drivers in the Linux Kernel | Hitch Hiker's Guide to Learning

Leave a Reply

Your email address will not be published. Required fields are marked *