Feature #7913
openUrb completion callbacks specification required
0%
Description
Brief description with some details missed.
@complete: Completion handler. This URB is passed as the parameter to the completion function. The completion function may then do what it likes with the URB, including resubmitting or freeing it. Completion Callbacks: The completion callback is made in_interrupt(), and one of the first things that a completion handler should do is check the status field. The status field is provided for all URBs. It is used to report unlinked URBs, and status for all non-ISO transfers. It should not be examined before the URB is returned to the completion handler. The context field is normally used to link URBs back to the relevant driver or request state. When the completion callback is invoked for non-isochronous URBs, the actual_length field tells how many bytes were transferred. This field is updated even when the URB terminated with an error or was unlinked.
void usb_fill_control_urb() and Company
{
urb->complete = complete_fn;
}
---------------------------------------------> Register URB completion process (urb, complete_fn)
int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
If the submission is successful, the complete() callback from the URB will be called exactly once, when the USB core and Host Controller Driver (HCD) are finished with the URB. When the completion function is called, control of the URB is returned to the device driver which issued the request. The completion handler may then immediately free or reuse that URB.
usb_submit_urb()
---------------------------------------------> Activate URB completion process(urb)
after that URB completion process can call completion callback (in_interrupt) once and deactivates itself
if completion callback did not call usb_submit_urb() to reactivate itself.
There can be several URB completion processes identified by 'urb*'.
Updated by Evgeny Novikov almost 8 years ago
Please, specify where and why is it necessary. Also the issue description looks a bit strange, e.g. "void usb_fill_control_urb() and Company". I suddenly found some nice documentation here.
Updated by Alexey Khoroshilov almost 8 years ago
Evgeny Novikov wrote:
Please, specify where and why is it necessary.
First of all, it is required to make reachable code of urb completion callbacks.
Also there were false alarms by this reason:
On 05/30/2013 12:28 PM, Evgeny Novikov wrote:
Попалась еще пара аналогичных случаев. Все немного сложнее оказалось, чем казалось: usb_fill_bulk_urb помещает в структуру указатель на функцию > lcd_write_bulk_callback (которая освобождает DMA-буффер). Эта функция вызывается по указателю при успешном вызове usb_submit_urb (см. комментарий http://lxr.free-electrons.com/source/drivers/usb/core/urb.c#L202). В случае ошибки usb_submit_urb драйвер самостоятельно освобождает DMA-буффер.
As far as I remember, we had some "model" in 144 rule, but actually it is required for any rule.