Merge master.kernel.org:/home/rmk/linux-2.6-arm
[sfrench/cifs-2.6.git] / drivers / usb / usb-skeleton.c
index 719d23a4ac51644fde1464131f20c8421dd9d291..4de9fb56ebfc02294636e65b1ca92303286e2b4e 100644 (file)
@@ -166,7 +166,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou
        int retval = 0;
        struct urb *urb = NULL;
        char *buf = NULL;
-       size_t writesize = max(count, MAX_TRANSFER);
+       size_t writesize = min(count, (size_t)MAX_TRANSFER);
 
        dev = (struct usb_skel *)file->private_data;
 
@@ -175,7 +175,10 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou
                goto exit;
 
        /* limit the number of URBs in flight to stop a user from using up all RAM */
-       down (&dev->limit_sem);
+       if (down_interruptible(&dev->limit_sem)) {
+               retval = -ERESTARTSYS;
+               goto exit;
+       }
 
        /* create a urb, and a buffer for it, and copy the data to the urb */
        urb = usb_alloc_urb(0, GFP_KERNEL);
@@ -231,7 +234,7 @@ static struct file_operations skel_fops = {
 
 /* 
  * usb class driver info in order to get a minor number from the usb core,
- * and to have the device registered with devfs and the driver core
+ * and to have the device registered with the driver core
  */
 static struct usb_class_driver skel_class = {
        .name =         "skel%d",