Re: strange problem with "usb_submit_urb"

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

 



On Thu, Oct 08, 2009 at 08:42:11PM +0530, aditya uttam wrote:
> > And what does the code look like for the whole driver?
> 
> Here I am pasting the callback and related code.

That's not exactly the whole driver :(

Any reason for not posting that?

> Please find the code execution path in which usb_submit_urb() is failing.
> 
> common_callback()->common_check_for_fail_status()->usb_stor_clear_halt()->usb_stor_control_msg()->my_usb_stor_msg_common()->usb_submit_urb().

Are you overflowing the interrupt stack?  Be careful about that.

> //Main call back routine
> void common_callback(struct urb *urb)
> {
> 	if(urb->status == 0)
> 	{
> 
> 		doProcessCallBack(urb);
> 	}
> 	else
> 	{      //This is the path whare usb_submit_urb();is failing
>                //submission has been failed retry submitting urb
> 		common_check_for_fail_status(urb);
> 	}	

The kernel follows a common coding style for a very good reason, our
brains.  Please be kind and post code in our coding style if you wish us
to review it, otherwise it is much more difficult.

Seriously, it matters, lots of studies have proven it.

> }
> 
> void common_check_for_fail_status(struct urb *urb)
> {
> 	struct urb_context *current_urb_context = NULL;
> 	int result = 0;
> 
> 	current_urb_context = (struct urb_context*)urb->context;

Cast is not needed

> 
> 	result =  usb_interpret_urb_result(current_urb_context->stat_bulkin_pipe,
> 						USB_BULK_LEN, urb->status,	urb->actual_length);

What is this function?

> 
> 	if(result == USB_STOR_CLEAR_HALT)
> 	{
> 		//This is the path whare usb_submit_urb();is failing		
> 		usb_stor_clear_halt(urb, current_urb_context->stat_bulkin_pipe);
> 
> 		return ;
> 	}
> 
> 	if(result == USB_STOR_XFER_SHORT && urb->actual_length == 0)
> 	{		
> 		PRINTK("in:Received 0-length ; retrying...\n");
> 
> 		usb_fill_bulk_urb(urb, current_urb_context->pusb_dev,
> current_urb_context->stat_bulkin_pipe, urb->transfer_buffer,
> 				USB_BULK_LEN,	common_callback,(void*)current_urb_context);
> 
> 		result = my_usb_stor_msg_common(urb);
> 					
> 		return ;
> 	}
> 	else if(result == USB_STOR_XFER_STALLED)
> 	{	
> 		PRINTK("in:Attempting to get (2nd try)...\n");
> 
> 		usb_fill_bulk_urb(urb, current_urb_context->pusb_dev,
> current_urb_context->stat_bulkin_pipe, urb->transfer_buffer,
> 				USB_BULK_LEN,	common_callback,(void*)current_urb_context);
> 
> 		result = my_usb_stor_msg_common(urb);
> 			
> 		return ;
> 	}

What about the other failures you could have?  How are you handling
them?

> }
> 
> int usb_stor_clear_halt(struct urb *urb, unsigned int pipe)
> {
> 	int result;
> 	
> 	struct urb_context *current_urb_context = (struct urb_context*)urb->context;
> 	int endp = usb_pipeendpoint(pipe);
> 
> 	if (usb_pipein (pipe))
> 		endp |= USB_DIR_IN;
> 
> 	//This is the path whare usb_submit_urb();is failing
> 	result = usb_stor_control_msg(urb, current_urb_context->send_ctrl_pipe,
> 		USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT,
> 		USB_ENDPOINT_HALT, endp,
> 		NULL, 0, 3*HZ);
> 
> 	return result;
> 	
> }

This seems like a duplicate of the existing call of the same name in the
usb-storage driver.

Odd.  One would think that you are writing another usb-storage driver,
why not just patch the existing one to add whatever functionality you
need?

confused,

greg k-h
--
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