Re: [PATCH] usb: usbtest: update wait routine to set a timeout

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

 



On Fri, May 30, 2014 at 10:25:40AM -0400, Alan Stern wrote:
> On Fri, 30 May 2014, Huang Rui wrote:
> 
> 
> Ugh, don't make a copy of the existing code.  Use the facilities the 
> way they are meant to be used.  Like the patch below.
> 

Looks good to me, thank you to improve it. Will you send this format
patch later or I would update it as you refined?

Thanks,
Rui

> 
> 
> 
> Index: usb-3.15/drivers/usb/misc/usbtest.c
> ===================================================================
> --- usb-3.15.orig/drivers/usb/misc/usbtest.c
> +++ usb-3.15/drivers/usb/misc/usbtest.c
> @@ -7,7 +7,7 @@
>  #include <linux/moduleparam.h>
>  #include <linux/scatterlist.h>
>  #include <linux/mutex.h>
> -
> +#include <linux/timer.h>
>  #include <linux/usb.h>
>  
>  #define SIMPLE_IO_TIMEOUT	10000	/* in milliseconds */
> @@ -484,6 +484,13 @@ alloc_sglist(int nents, int max, int var
>  	return sg;
>  }
>  
> +static void sg_timeout(unsigned long _req)
> +{
> +	struct usb_sg_request	*req = (struct usb_sg_request *) _req;
> +
> +	usb_sg_cancel(req);
> +}
> +
>  static int perform_sglist(
>  	struct usbtest_dev	*tdev,
>  	unsigned		iterations,
> @@ -495,6 +502,9 @@ static int perform_sglist(
>  {
>  	struct usb_device	*udev = testdev_to_usbdev(tdev);
>  	int			retval = 0;
> +	struct timer_list	sg_timer;
> +
> +	setup_timer_on_stack(&sg_timer, sg_timeout, (unsigned long) req);
>  
>  	while (retval == 0 && iterations-- > 0) {
>  		retval = usb_sg_init(req, udev, pipe,
> @@ -505,7 +515,10 @@ static int perform_sglist(
>  
>  		if (retval)
>  			break;
> +		mod_timer(&sg_timer, jiffies +
> +				msecs_to_jiffies(SIMPLE_IO_TIMEOUT));
>  		usb_sg_wait(req);
> +		del_timer_sync(&sg_timer);
>  		retval = req->status;
>  
>  		/* FIXME check resulting data pattern */
> 
> 
--
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