Re: net2280 driver and gadgetfs?

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

 



On Tue, 3 Feb 2015, Mario Schuknecht wrote:

> I used gadgetfs with PLX3380 controler. I had the problem that was
> reported here:
> 
> http://thread.gmane.org/gmane.linux.usb.general/116872/focus=117488
> 
> Perphaps this is also your problem. The commit that caused the error
> is probably this:
> 
> commit 7f7f25e82d54870df24d415a7007fbd327da027b
> Author: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
> Date:   Tue Feb 11 17:49:24 2014 -0500
> 
>     replace checking for ->read/->aio_read presence with check in ->f_mode
> 
>     Since we are about to introduce new methods (read_iter/write_iter), the
>     tests in a bunch of places would have to grow inconveniently.  Check
>     once (at open() time) and store results in ->f_mode as FMODE_CAN_READ
>     and FMODE_CAN_WRITE resp.  It might end up being a temporary measure -
>     once everything switches from ->aio_{read,write} to ->{read,write}_iter
>     it might make sense to return to open-coded checks.  We'll see...
> 
>     Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
> 
> 
> If a driver register a read function, it is remembered in a flag in
> the open function.
> 
> 
> --- a/fs/open.c
> +++ b/fs/open.c
> @@ -725,6 +725,10 @@ static int do_dentry_open(struct file *f,
>         }
>         if ((f->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
>                 i_readcount_inc(inode);
> +       if ((f->f_mode & FMODE_READ) && likely(f->f_op->read ||
> f->f_op->aio_read))
> +               f->f_mode |= FMODE_CAN_READ;
> +       if ((f->f_mode & FMODE_WRITE) && likely(f->f_op->write ||
> f->f_op->aio_write))
> +               f->f_mode |= FMODE_CAN_WRITE;
> 
> 
> And if the file is read this flag is checked.
> 
> 
> --- a/fs/read_write.c
> +++ b/fs/read_write.c
> @@ -396,7 +396,7 @@ ssize_t vfs_read(struct file *file, char __user
> *buf, size_t count, loff_t *pos)
> 
>         if (!(file->f_mode & FMODE_READ))
>                 return -EBADF;
> -       if (!file->f_op->read && !file->f_op->aio_read)
> +       if (!(file->f_mode & FMODE_CAN_READ))
> 
> 
> 
> I have fixed the problem for myself. Setting FMODE_CAN_READ flag after
> change of file-pointer.
> 
> 
> diff --git a/drivers/usb/gadget/legacy/inode.c
> b/drivers/usb/gadget/legacy/inode.c
> index e96077b..1b56bee 100644
> --- a/drivers/usb/gadget/legacy/inode.c
> +++ b/drivers/usb/gadget/legacy/inode.c
> @@ -857,6 +857,7 @@ ep_config (struct file *fd, const char __user
> *buf, size_t len, loff_t *ptr)
>         }
>         if (value == 0) {
>                 fd->f_op = &ep_io_operations;
> +               fd->f_mode |= FMODE_CAN_READ;
>                 value = length;
>         }
>  gone:
> @@ -1926,6 +1927,7 @@ dev_config (struct file *fd, const char __user
> *buf, size_t len, loff_t *ptr)
>                  * kick in after the ep0 descriptor is closed.
>                  */
>                 fd->f_op = &ep0_io_operations;
> +               fd->f_mode |= FMODE_CAN_READ;
>                 value = len;
>         }
>         return value;
> --
> 
> It seems that there is no maintainer for the gadgetfs. It is located
> under the folder "legacy".
> Therefore I use the functionfs now, which has a similar functionality.
> 
> 
> I hope I could help you.
> 
> Mario

You should submit a patch with your changes so that they will be 
available to everybody.

Alan Stern

--
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