Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
577 views
in Technique[技术] by (71.8m points)

c - Difference between device_register and driver_register

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);

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().

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

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.

Is uart_register_driver related with device_driver()?.

Please explain.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

driver_register: Adds this driver to the bus' list of drivers.

device_register: Bus' list of drivers is iterated to find the driver that supports this device and then this device is added to the bus' list of devices.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...