本文介绍了device_register 和 driver_register 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个 UART 驱动程序.我在第 14.Linux 设备模型章节中遇到了这两个函数.

I am writing a UART driver. I came across the two functions in the chapter 14.Linux Device Model.

int device_register(struct device *dev);
int driver_register(struct device_driver *drv);

由于 UART 是一个字符驱动程序,我使用 (alloc_chrdev_region) 动态创建了主编号,并使用 cdevadd() 将设备添加到内核.

Since UART is a char driver I have dynamically created the major number using (alloc_chrdev_region) and added the device to kernel by using cdevadd().

我在 omap-serial.c 中遇到了 uart_register_driver()platform_driver_register().

I came across uart_register_driver() and platform_driver_register() in omap-serial.c.

我可以将 driver_register 映射到 platform_driver_register()uart_register_driver 映射到 tty 相关函数.因为我是初学者我不想使用tty相关的功能.

I could map the driver_register with the platform_driver_register() but the uart_register_driver is mapped with tty related function.Since I am a beginner i do not want to use the tty related functions.

uart_register_driverdevice_driver()有关系吗?

请解释一下.

推荐答案

@Dino,据我了解 device_register: 只不过是注册一个新设备到系统和链接,你可以通过 https://www.kernel.org/doc/htmldocs/device-drivers/API-设备注册.html.driver_register:注册平台驱动,该驱动支持基于平台驱动结构中指定的.name"和.of_match_table"的设备.结构平台驱动程序中的.name"和平台设备中的名称应该匹配,然后只有设备绑定到驱动程序并调用探测函数.请通过链接http://lwn.net/Articles/448499/

@Dino, as per my understanding device_register: is nothing but registering a new device to the system and link which you can go through https://www.kernel.org/doc/htmldocs/device-drivers/API-device-register.html. driver_register: registering a platform driver, this driver supports devices based on the ".name" and ".of_match_table" specified in the platform driver structure. ".name" in structure platform_driver and name in the platform_device should match then only device gets bind to driver and probe function is called. Please go through the link http://lwn.net/Articles/448499/

这篇关于device_register 和 driver_register 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-19 01:44