device_register和driver_register的区别 [英] Difference between device_register and driver_register

查看:1611
本文介绍了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().

我碰到来到uart_register_driver() platform_driver_register()在OMAP-serial.c。

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

我可以在 driver_register platform_driver_register() uart_register_driver 映射以tty相关function.Since我是一个初学者,我不希望使用的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_driver 的device_driver()

Is uart_register_driver related with device_driver()?.

请解释一下。

推荐答案

@Dino,按我的理解device_register:无非是注册新设备添加到系统和链接,你可以通过的 https://www.kernel.org/doc/htmldocs/device-drivers/API-设备register.html 。 driver_register:注册一个​​平台驱动程序,该驱动程序支持基于在平台驱动结构中指定的。名称和.of_match_table器件。 。名称结构的platform_driver和姓名platform_device应该匹配,那么唯一的设备被绑定到驱动器和探头函数被调用。请通过链接 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的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆