Module in linux driver_ platform_ Learning driver macro

Linux driver module_platform_driver macro learning

It is common to see this macro module_platform_driver on Linux devices. The following figure shows a character device driver. Today we’re going to learn about this macro.

2, the macro is in kernel/include/Linux/platform_device. H defined inside. We find that this calls another macro, module_driver.

. So where is the module_driver macro defined?For once, the macro is in kernel/include/Linux/device. The definition of h.

The macro module_platform_driver can be used to write much less code. The purpose of the macro is to define the platform driver registration function and the platform driver unregistration function with the specified name, and to register and unregister the platform driver within the function body with the functions platform_driver_register() and Platform_driver_unregister (), respectively.

static int x_init(void)
return platform_driver_register(& xxx);
static void __exit xxx_init(void)
return platform_driver_unregister(& xxx);

Read More: