Lines Matching defs:epfile
119 struct usb_request *req; /* P: epfile->mutex */
126 int status; /* P: epfile->mutex */
149 * can never run concurrently (they are synchronised by epfile->mutex)
866 static void __ffs_epfile_read_buffer_free(struct ffs_epfile *epfile)
872 struct ffs_buffer *buf = xchg(&epfile->read_buffer, READ_BUFFER_DROP);
877 /* Assumes epfile->mutex is held. */
878 static ssize_t __ffs_epfile_read_buffered(struct ffs_epfile *epfile,
882 * Null out epfile->read_buffer so ffs_func_eps_disable does not free
886 struct ffs_buffer *buf = xchg(&epfile->read_buffer, NULL);
904 if (cmpxchg(&epfile->read_buffer, NULL, buf))
910 /* Assumes epfile->mutex is held. */
911 static ssize_t __ffs_epfile_read_data(struct ffs_epfile *epfile,
942 if (unlikely(cmpxchg(&epfile->read_buffer, NULL, buf)))
950 struct ffs_epfile *epfile = file->private_data;
958 if (WARN_ON(epfile->ffs->state != FFS_ACTIVE))
962 ep = epfile->ep;
968 epfile->ffs->wait, (ep = epfile->ep));
974 halt = (!io_data->read == !epfile->in);
975 if (halt && epfile->isoc)
979 ret = ffs_mutex_lock(&epfile->mutex, file->f_flags & O_NONBLOCK);
995 ret = __ffs_epfile_read_buffered(epfile, &io_data->data);
1001 * if we _do_ wait above, the epfile->ffs->gadget might be NULL
1005 gadget = epfile->ffs->gadget;
1007 spin_lock_irq(&epfile->ffs->eps_lock);
1009 if (epfile->ep != ep) {
1022 spin_unlock_irq(&epfile->ffs->eps_lock);
1036 spin_lock_irq(&epfile->ffs->eps_lock);
1038 if (epfile->ep != ep) {
1083 spin_unlock_irq(&epfile->ffs->eps_lock);
1100 ret = __ffs_epfile_read_data(epfile, data, ep->status,
1121 io_data->ffs = epfile->ffs;
1142 spin_unlock_irq(&epfile->ffs->eps_lock);
1144 mutex_unlock(&epfile->mutex);
1154 struct ffs_epfile *epfile = inode->i_private;
1158 if (WARN_ON(epfile->ffs->state != FFS_ACTIVE))
1161 file->private_data = epfile;
1162 ffs_data_opened(epfile->ffs);
1170 struct ffs_epfile *epfile = kiocb->ki_filp->private_data;
1176 spin_lock_irqsave(&epfile->ffs->eps_lock, flags);
1183 spin_unlock_irqrestore(&epfile->ffs->eps_lock, flags);
1277 struct ffs_epfile *epfile = inode->i_private;
1281 __ffs_epfile_read_buffer_free(epfile);
1282 ffs_data_closed(epfile->ffs);
1290 struct ffs_epfile *epfile = file->private_data;
1296 if (WARN_ON(epfile->ffs->state != FFS_ACTIVE))
1300 ep = epfile->ep;
1306 epfile->ffs->wait, (ep = epfile->ep));
1311 spin_lock_irq(&epfile->ffs->eps_lock);
1314 if (epfile->ep != ep) {
1315 spin_unlock_irq(&epfile->ffs->eps_lock);
1321 ret = usb_ep_fifo_status(epfile->ep->ep);
1324 usb_ep_fifo_flush(epfile->ep->ep);
1328 ret = usb_ep_clear_halt(epfile->ep->ep);
1331 ret = epfile->ep->num;
1338 switch (epfile->ffs->gadget->speed) {
1350 desc = epfile->ep->descs[desc_idx];
1353 spin_unlock_irq(&epfile->ffs->eps_lock);
1362 spin_unlock_irq(&epfile->ffs->eps_lock);
1803 * copy of epfile will save us from use-after-free.
1907 struct ffs_epfile *epfile, *epfiles;
1917 epfile = epfiles;
1918 for (i = 1; i <= count; ++i, ++epfile) {
1919 epfile->ffs = ffs;
1920 mutex_init(&epfile->mutex);
1922 sprintf(epfile->name, "ep%02x", ffs->eps_addrmap[i]);
1924 sprintf(epfile->name, "ep%u", i);
1925 epfile->dentry = ffs_sb_create_file(ffs->sb, epfile->name,
1926 epfile,
1928 if (unlikely(!epfile->dentry)) {
1940 struct ffs_epfile *epfile = epfiles;
1944 for (; count; --count, ++epfile) {
1945 BUG_ON(mutex_is_locked(&epfile->mutex));
1946 if (epfile->dentry) {
1947 d_delete(epfile->dentry);
1948 dput(epfile->dentry);
1949 epfile->dentry = NULL;
1959 struct ffs_epfile *epfile;
1965 epfile = func->ffs->epfiles;
1973 if (epfile) {
1974 epfile->ep = NULL;
1975 __ffs_epfile_read_buffer_free(epfile);
1976 ++epfile;
1986 struct ffs_epfile *epfile;
1994 epfile = ffs->epfiles;
2008 epfile->ep = ep;
2009 epfile->in = usb_endpoint_dir_in(ep->ep->desc);
2010 epfile->isoc = usb_endpoint_xfer_isoc(ep->ep->desc);
2016 ++epfile;