Re: Creating URB in completion callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jul 4, 2009 at 1:20 AM, Alan Stern<stern@xxxxxxxxxxxxxxxxxxx> wrote:
> On Sat, 4 Jul 2009, Ramya Desai wrote:
>
>> Dear Experts,
>>
>> I am trying to create a new URB in the completion call back.
>> Here I am giving the code that I am using.
>>
>> void my_usb_stor_blocking_completion(struct urb *urb)
>> {
>>
>> struct urb *rr_urb ;
>>
>> //
>> //
>> //
>>
>>       rr_urb = (struct urb*)kmalloc(sizeof(struct urb), GFP_KERNEL);
>
> Don't use kmalloc to allocate URBs; use usb_alloc_urb.
>
> You must not use GFP_KERNEL in a completion routine.  Use GFP_ATOMIC
> instead.
>
>>                 if( NULL == rr_urb)
>>                    return -ENOMEM;
>
> You can't return -ENOMEM because this function returns void.
>
>>                 memcpy(rr_urb, urb, sizeof(struct urb));
>
> Why do the memcpy?  usb_fill_bulk_urb will just overwrite the data.
>
>>                 usb_fill_bulk_urb(rr_urb,
>> current_urb_context->pusb_dev, current_urb_context->stat_bulkin_pipe,
>> prd_ready, 4,
>>                                       my_usb_stor_blocking_completion,(void*)current_urb_context);
>>
>> //
>> //
>> //
>>
>> }
>>
>> With this code, the system is going to hanging.
>> Is there any thing I need to do while creating a URB ?
>
> Fix those mistakes.  No other special action is needed.
>
> In fact, you might not have to create a new URB at all.  You might be
> able to re-use the URB that was passed to
> my_usb_stor_blocking_completion().
>
> Alan Stern

Good. Now urb creation is working with these changes.
Thanks for help.

Regards,
RD
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux