Search code examples
cserial-portlinux-device-driverembedded-linuxuart

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.


Solution

  • @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/