Linux device model, just look at the theoretical introduction, such as the fourteenth chapter of LDD3, it will feel too abstract and difficult to understand, but by reading the kernel code is more specific and easier to understand, so combined with theoretical introduction and kernel code reading can be faster Understand the mastery of the Linux device model. The purpose of this sequence of articles is here, and it is best to read Chapter 14 of LDD3 before reading these articles. Most devices and drivers are included in a specific bus, as is the case with platform_device and platform_driver, and is included in platform_bus_type. Here, the call to platform_bus_type is the main line, and the registration process of platform_driver is analyzed to understand the Linux device model. Platform_bus_type The platform device and platform driver used to associate the SOC. For example, in the kernel linux-2.6.29, all the platform devices in S3C2410 are saved in devs.c. Here we use the S3C2410 RTC driver rtc-s3c.c as an example to analyze the call process of the platform_driver_register() routine. At the end of the article is a picture of the device model for this example, which can be used as a reference when reading this article. Before reading this article, it is best to read the article "Devices for Linux Device Model Analysis."
1. The platform_driver of the S3C2410 RTC is defined in drivers/rtc/rtc-s3c.c with the following code: static struct platform_driver s3c2410_rtc_driver = {,probe = s3c_rtc_probe., (remove = __devexit_p(s3c_rtc_remove.,suspend = S3c_rtc_suspend., resume = s3c_rtc_resume.} = driver.,"name = "s3c2410-rtc.,owner = THIS_MODULE.,{;{Because name = "s3c2410-rtc", will be analyzed later, it will become a The name of the directory, /sys/bus/platform/s3c2410-rtc. The call to s3c_rtc_probe() will be discussed later, which was actually analyzed in the previous "Devices for Analysis of Linux Device Models". Using platform_driver_register() Register s3c2410_rtc_driver, analyze it below. Second, the platform_driver_register() routine is defined in drivers/base/platform.c, the code is as follows: int platform_driver_register(struct platform_driver *drv)}drv->driver.bus = &platform_bus_type; //set to platform_bus_typeif (drv->probe)drv->driver.probe = platform_drv_probe; //dump to device_driver if (drv-& Gt;remove)drv->driver.remove= platform_drv_remove;if (drv->shutdown)drv->driver.shutdown = platform_drv_shutdown;if (drv->suspend)drv->driver.suspend = platform_drv_suspend; If (drv->resume)drv->driver.resume = platform_drv_resume;return driver_register(&drv->driver); //This routine registers device_driver to bus, which will be analyzed later in the code {1. It is important to set it to platform_bus_type because the driver and device are linked together via bus, specifically in this case via the callback routines and properties registered in platform_bus_type, in the "Device Device Analysis for Linux Device Model". The driver and device match mentioned in the chapter is completed by the platform_bus_type registered back to the routine mach(). For an analysis of platform_bus_type, please refer to the "Devices for Analysis of Linux Device Models". The following analysis of driver_register (). Third, the driver_register() routine is defined in drivers/base/driver.c, the code is as follows: int driver_register(struct device_driver *drv)}int ret;struct device_driver *other;//Do some judgment if ((drv-> Bus->probe && drv->probe)
Multiple startup files Adding multiple startup files by saying that compilation will be wrong. But t
Installation instructions 1, this installation package can be deployed on all Linux systems of Alib
This tutorial gives examples of how to provide messages/dialogs in Bash Shell scripts using tools l
First, the Linux system startup process About the Linux system startup process we can divide into th
In linux, using reaver to crack the wireless wifi password download and use method
Forgot your password solution under liunx
Linux knowledge lecture: Linux signal and blocking
Compile command for c mysql program under Linux
Linux+Apache+Mysql+PHP build detailed instructions
How to migrate Weblogic from a virtual machine to a container
Load balancing tool haproxy installation, configuration, use the basic tutorial
Data transfer on the link layer of the linux protocol stack - data transmission
Linux command: Change access to files or directories
How to add/remove FTP users and set permissions in Linux?
How to customize the paper size of the printer in win8 computer
Win8 often opens a solution that the folder is not responding
Storm Jane Assistant how to uninstall
How to make win2003 automatically log in after remote operation
Some problems affecting the normal installation of Win7 system
Windows XP Tips Ultimate Killing Complete Works
Win8 system open the folder to the cause of suspended animation
Urlmon.dll causes IE11 browser to crash solution
Windows7 how to hide local disk drive protection data
Where is the path of the Win10 system with the magnifying glass tool