Search code examples
clinuxlinux-device-driverembedded-linuxusbserial

which function is responsible to receive data in linux "usbserial" driver?


I went through usb-serial.c, which is a source file in the usbserial module in the Linux kernel. I would like to implement some customization in this driver, e.g., blinking LED when a communication (Tx/Rx) happens. However, I am having trouble finding the functions which are responsible for that communication. I was able to find serial_write but was not able to find a serial_read, serial_receive, or similar. Does anyone know about the receive data function in this driver? Thanks in advance..!


Solution

  • Try usb_serial_generic_read_bulk_callback (from drivers/usb/serial/generic.c). I think the line in this function that has port->read_urbs is basically when the USB read is starting from.

    So if you make your own version of that function you can put it in usb_serial_operations_init in place of usb_serial_generic_read_bulk_callback