]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/usb/misc/usbtest.c
slabinfo: fall back from /sys/kernel/slab to /sys/slab
[linux-2.6-omap-h63xx.git] / drivers / usb / misc / usbtest.c
index e901d31e051b3d579e3dcebdf1e66f161e2a31ba..da922dfc0dccfefa3c308d35301580fe1e39d82f 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/scatterlist.h>
+#include <linux/mutex.h>
 
 #include <linux/usb.h>
 
@@ -64,7 +65,7 @@ struct usbtest_dev {
        int                     in_iso_pipe;
        int                     out_iso_pipe;
        struct usb_endpoint_descriptor  *iso_in, *iso_out;
-       struct semaphore        sem;
+       struct mutex            lock;
 
 #define TBUF_SIZE      256
        u8                      *buf;
@@ -360,9 +361,9 @@ static void free_sglist (struct scatterlist *sg, int nents)
        if (!sg)
                return;
        for (i = 0; i < nents; i++) {
-               if (!sg [i].page)
+               if (!sg_page(&sg[i]))
                        continue;
-               kfree (page_address (sg [i].page) + sg [i].offset);
+               kfree (sg_virt(&sg[i]));
        }
        kfree (sg);
 }
@@ -1151,6 +1152,7 @@ static int verify_halted (int ep, struct urb *urb)
                dbg ("ep %02x couldn't get halt status, %d", ep, retval);
                return retval;
        }
+       le16_to_cpus(&status);
        if (status != 1) {
                dbg ("ep %02x bogus status: %04x != 1", ep, status);
                return -EINVAL;
@@ -1310,7 +1312,7 @@ static int ctrl_out (struct usbtest_dev *dev,
                len += vary;
 
                /* [real world] the "zero bytes IN" case isn't really used.
-                * hardware can easily trip up in this wierd case, since its
+                * hardware can easily trip up in this weird case, since its
                 * status stage is IN, not OUT like other ep0in transfers.
                 */
                if (len > length)
@@ -1558,11 +1560,11 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
                        || param->sglen < 0 || param->vary < 0)
                return -EINVAL;
 
-       if (down_interruptible (&dev->sem))
+       if (mutex_lock_interruptible(&dev->lock))
                return -ERESTARTSYS;
 
        if (intf->dev.power.power_state.event != PM_EVENT_ON) {
-               up (&dev->sem);
+               mutex_unlock(&dev->lock);
                return -EHOSTUNREACH;
        }
 
@@ -1574,7 +1576,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
                int     res;
 
                if (intf->altsetting->desc.bInterfaceNumber) {
-                       up (&dev->sem);
+                       mutex_unlock(&dev->lock);
                        return -ENODEV;
                }
                res = set_altsetting (dev, dev->info->alt);
@@ -1582,7 +1584,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
                        dev_err (&intf->dev,
                                        "set altsetting to %d failed, %d\n",
                                        dev->info->alt, res);
-                       up (&dev->sem);
+                       mutex_unlock(&dev->lock);
                        return res;
                }
        }
@@ -1855,7 +1857,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
                param->duration.tv_usec += 1000 * 1000;
                param->duration.tv_sec -= 1;
        }
-       up (&dev->sem);
+       mutex_unlock(&dev->lock);
        return retval;
 }
 
@@ -1905,7 +1907,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
                return -ENOMEM;
        info = (struct usbtest_info *) id->driver_info;
        dev->info = info;
-       init_MUTEX (&dev->sem);
+       mutex_init(&dev->lock);
 
        dev->intf = intf;
 
@@ -1990,8 +1992,6 @@ static void usbtest_disconnect (struct usb_interface *intf)
 {
        struct usbtest_dev      *dev = usb_get_intfdata (intf);
 
-       down (&dev->sem);
-
        usb_set_intfdata (intf, NULL);
        dev_dbg (&intf->dev, "disconnect\n");
        kfree (dev);