Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / drivers / usb / gadget / inode.c
index 084fe62..0eb010a 100644 (file)
@@ -342,7 +342,7 @@ fail:
 static ssize_t
 ep_io (struct ep_data *epdata, void *buf, unsigned len)
 {
-       DECLARE_COMPLETION_ONSTACK (done);
+       DECLARE_COMPLETION (done);
        int value;
 
        spin_lock_irq (&epdata->dev->lock);
@@ -528,7 +528,7 @@ struct kiocb_priv {
        struct usb_request      *req;
        struct ep_data          *epdata;
        void                    *buf;
-       char __user             *ubuf;          /* NULL for writes */
+       char __user             *ubuf;
        unsigned                actual;
 };
 
@@ -566,6 +566,7 @@ static ssize_t ep_aio_read_retry(struct kiocb *iocb)
                status = priv->actual;
        kfree(priv->buf);
        kfree(priv);
+       aio_put_req(iocb);
        return status;
 }
 
@@ -579,8 +580,8 @@ static void ep_aio_complete(struct usb_ep *ep, struct usb_request *req)
        spin_lock(&epdata->dev->lock);
        priv->req = NULL;
        priv->epdata = NULL;
-       if (priv->ubuf == NULL
-                       || unlikely(req->actual == 0)
+       if (NULL == iocb->ki_retry
+                       || unlikely(0 == req->actual)
                        || unlikely(kiocbIsCancelled(iocb))) {
                kfree(req->buf);
                kfree(priv);
@@ -617,7 +618,7 @@ ep_aio_rwtail(
        char __user     *ubuf
 )
 {
-       struct kiocb_priv       *priv;
+       struct kiocb_priv       *priv = (void *) &iocb->private;
        struct usb_request      *req;
        ssize_t                 value;
 
@@ -669,7 +670,7 @@ fail:
                kfree(priv);
                put_ep(epdata);
        } else
-               value = (ubuf ? -EIOCBRETRY : -EIOCBQUEUED);
+               value = -EIOCBQUEUED;
        return value;
 }
 
@@ -844,7 +845,7 @@ fail1:
 static int
 ep_open (struct inode *inode, struct file *fd)
 {
-       struct ep_data          *data = inode->i_private;
+       struct ep_data          *data = inode->u.generic_ip;
        int                     value = -EBUSY;
 
        if (down_interruptible (&data->lock) != 0)
@@ -1038,7 +1039,7 @@ scan:
                /* ep0 can't deliver events when STATE_SETUP */
                for (i = 0; i < n; i++) {
                        if (dev->event [i].type == GADGETFS_SETUP) {
-                               len = i + 1;
+                               len = n = i + 1;
                                len *= sizeof (struct usb_gadgetfs_event);
                                n = 0;
                                break;
@@ -1586,13 +1587,13 @@ gadgetfs_create_file (struct super_block *sb, char const *name,
 static int activate_ep_files (struct dev_data *dev)
 {
        struct usb_ep   *ep;
-       struct ep_data  *data;
 
        gadget_for_each_ep (ep, dev->gadget) {
+               struct ep_data  *data;
 
                data = kzalloc(sizeof(*data), GFP_KERNEL);
                if (!data)
-                       goto enomem0;
+                       goto enomem;
                data->state = STATE_EP_DISABLED;
                init_MUTEX (&data->lock);
                init_waitqueue_head (&data->wait);
@@ -1607,23 +1608,21 @@ static int activate_ep_files (struct dev_data *dev)
 
                data->req = usb_ep_alloc_request (ep, GFP_KERNEL);
                if (!data->req)
-                       goto enomem1;
+                       goto enomem;
 
                data->inode = gadgetfs_create_file (dev->sb, data->name,
                                data, &ep_config_operations,
                                &data->dentry);
-               if (!data->inode)
-                       goto enomem2;
+               if (!data->inode) {
+                       usb_ep_free_request(ep, data->req);
+                       kfree (data);
+                       goto enomem;
+               }
                list_add_tail (&data->epfiles, &dev->epfiles);
        }
        return 0;
 
-enomem2:
-       usb_ep_free_request (ep, data->req);
-enomem1:
-       put_dev (dev);
-       kfree (data);
-enomem0:
+enomem:
        DBG (dev, "%s enomem\n", __FUNCTION__);
        destroy_ep_files (dev);
        return -ENOMEM;
@@ -1794,7 +1793,7 @@ static struct usb_gadget_driver probe_driver = {
  *
  * After initialization, the device stays active for as long as that
  * $CHIP file is open.  Events may then be read from that descriptor,
- * such as configuration notifications.  More complex drivers will handle
+ * such configuration notifications.  More complex drivers will handle
  * some control requests in user space.
  */
 
@@ -1909,7 +1908,7 @@ fail:
 static int
 dev_open (struct inode *inode, struct file *fd)
 {
-       struct dev_data         *dev = inode->i_private;
+       struct dev_data         *dev = inode->u.generic_ip;
        int                     value = -EBUSY;
 
        if (dev->state == STATE_DEV_DISABLED) {
@@ -1966,10 +1965,11 @@ gadgetfs_make_inode (struct super_block *sb,
                inode->i_mode = mode;
                inode->i_uid = default_uid;
                inode->i_gid = default_gid;
+               inode->i_blksize = PAGE_CACHE_SIZE;
                inode->i_blocks = 0;
                inode->i_atime = inode->i_mtime = inode->i_ctime
                                = CURRENT_TIME;
-               inode->i_private = data;
+               inode->u.generic_ip = data;
                inode->i_fop = fops;
        }
        return inode;
@@ -2033,10 +2033,12 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
                        NULL, &simple_dir_operations,
                        S_IFDIR | S_IRUGO | S_IXUGO);
        if (!inode)
-               goto enomem0;
+               return -ENOMEM;
        inode->i_op = &simple_dir_inode_operations;
-       if (!(d = d_alloc_root (inode)))
-               goto enomem1;
+       if (!(d = d_alloc_root (inode))) {
+               iput (inode);
+               return -ENOMEM;
+       }
        sb->s_root = d;
 
        /* the ep0 file is named after the controller we expect;
@@ -2044,36 +2046,29 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
         */
        dev = dev_new ();
        if (!dev)
-               goto enomem2;
+               return -ENOMEM;
 
        dev->sb = sb;
-       if (!gadgetfs_create_file (sb, CHIP,
+       if (!(inode = gadgetfs_create_file (sb, CHIP,
                                dev, &dev_init_operations,
-                               &dev->dentry))
-               goto enomem3;
+                               &dev->dentry))) {
+               put_dev(dev);
+               return -ENOMEM;
+       }
 
        /* other endpoint files are available after hardware setup,
         * from binding to a controller.
         */
        the_device = dev;
        return 0;
-
-enomem3:
-       put_dev (dev);
-enomem2:
-       dput (d);
-enomem1:
-       iput (inode);
-enomem0:
-       return -ENOMEM;
 }
 
 /* "mount -t gadgetfs path /dev/gadget" ends up here */
-static int
+static struct super_block *
 gadgetfs_get_sb (struct file_system_type *t, int flags,
-               const char *path, void *opts, struct vfsmount *mnt)
+               const char *path, void *opts)
 {
-       return get_sb_single (t, flags, opts, gadgetfs_fill_super, mnt);
+       return get_sb_single (t, flags, opts, gadgetfs_fill_super);
 }
 
 static void