Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b20f9ce6 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "USB: f_fs: Allow epfile to be opened only once"

parents c7a3b625 270a7f2a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ struct ffs_epfile {
	unsigned char			isoc;	/* P: ffs->eps_lock */

	unsigned char			_pad;
	atomic_t			opened;
};

/*  ffs_io_data structure ***************************************************/
@@ -1012,6 +1013,13 @@ ffs_epfile_open(struct inode *inode, struct file *file)
	if (WARN_ON(epfile->ffs->state != FFS_ACTIVE))
		return -ENODEV;

	if (atomic_read(&epfile->opened)) {
		pr_err("%s(): ep(%s) is already opened.\n",
					__func__, epfile->name);
		return -EBUSY;
	}

	atomic_set(&epfile->opened, 1);
	file->private_data = epfile;
	ffs_data_opened(epfile->ffs);
	atomic_set(&epfile->error, 0);
@@ -1109,6 +1117,7 @@ ffs_epfile_release(struct inode *inode, struct file *file)

	ENTER();

	atomic_set(&epfile->opened, 0);
	atomic_set(&epfile->error, 1);
	ffs_data_closed(epfile->ffs);
	file->private_data = NULL;
@@ -1681,6 +1690,7 @@ static int ffs_epfiles_create(struct ffs_data *ffs)
		epfile->ffs = ffs;
		mutex_init(&epfile->mutex);
		init_waitqueue_head(&epfile->wait);
		atomic_set(&epfile->opened, 0);
		if (ffs->user_flags & FUNCTIONFS_VIRTUAL_ADDR)
			sprintf(epfiles->name, "ep%02x", ffs->eps_addrmap[i]);
		else