简体   繁体   中英

Problems when calling USB bulk send message inside USB device Linux Kernel module

I have a kernel module in which I deal with USB devices.

It happens that I can successfully send a USB bulk message to a device, but that operation is being made under the callback of a binary attribute.

However, there is a specific operation that I need to do when something happens. When that happens, I need to send a bulk message to the device. The place in which that occurs is the own device data income callback. If I send the bulk message in that place I get a kernel panic.

Can someone tell me why?

If that is not a proper place to do such operation, where can I safely do it? How can I signal the operation to be done in another place? A Timer?

Please advice regarding this specific problem.

I managed to solve the problem I was facing with the following approach:

  • Created a work task
  • Placed the processing that was being made into a work task routine
  • I schedule that work task every time I have enough data to process what I need.

I think this approach leads to a better design since the time spent in the interruption handle is thus reduced.

I can now invoke usb_bulk_msg(...) peacefully since I'm not in an interrupt context anymore. That was indeed the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM