On Wed, 21 Dec 2005, Oliver Neukum wrote:

> Hi,
> 
> this introduces limits whose lack in the skeleton driver someone recently
> complained about.
> 
>       Regards
>               Oliver
> 
> Signed-off-by: Oliver Neukum <[EMAIL PROTECTED]>
> 
> --- a/drivers/usb/usb-skeleton.c      2005-12-04 06:10:42.000000000 +0100
> +++ b/drivers/usb/usb-skeleton.c      2005-12-17 23:31:43.000000000 +0100
> @@ -39,10 +39,15 @@
>  /* Get a minor range for your devices from the usb maintainer */
>  #define USB_SKEL_MINOR_BASE  192
>  
> +/* our private defines. if this grows any larger, use your own .h file */
> +#define MAX_TRANSFER         ( PAGE_SIZE - 512 )
> +#define WRITES_IN_FLIGHT     8
> +
>  /* Structure to hold all of our device specific stuff */
>  struct usb_skel {
>       struct usb_device *     udev;                   /* the usb device for 
> this device */
>       struct usb_interface *  interface;              /* the interface for 
> this device */
> +     struct semaphore        limit_sem;              /* limiting the number 
> of writes in progress */
>       unsigned char *         bulk_in_buffer;         /* the buffer to 
> receive data */
>       size_t                  bulk_in_size;           /* the size of the 
> receive buffer */
>       __u8                    bulk_in_endpointAddr;   /* the address of the 
> bulk in endpoint */
> @@ -152,6 +157,7 @@
>       /* free up our allocated buffer */
>       usb_buffer_free(urb->dev, urb->transfer_buffer_length, 
>                       urb->transfer_buffer, urb->transfer_dma);
> +     up(&dev->limit_sem);
>  }
>  
>  static ssize_t skel_write(struct file *file, const char *user_buffer, size_t 
> count, loff_t *ppos)
> @@ -160,6 +166,7 @@
>       int retval = 0;
>       struct urb *urb = NULL;
>       char *buf = NULL;
> +     size_t writesize = max(count, MAX_TRANSFER);

Shouldn't here be min() instead?

Olav


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to