@@ -640,22 +640,13 @@ static ssize_t ffs_ep0_read(struct file *file, char __user *buf,
640640
641641static int ffs_ep0_open (struct inode * inode , struct file * file )
642642{
643- struct ffs_data * ffs = inode -> i_sb -> s_fs_info ;
644- int ret ;
643+ struct ffs_data * ffs = inode -> i_private ;
645644
646- /* Acquire mutex */
647- ret = ffs_mutex_lock (& ffs -> mutex , file -> f_flags & O_NONBLOCK );
648- if (ret < 0 )
649- return ret ;
650-
651- ffs_data_opened (ffs );
652- if (ffs -> state == FFS_CLOSING ) {
653- ffs_data_closed (ffs );
654- mutex_unlock (& ffs -> mutex );
645+ if (ffs -> state == FFS_CLOSING )
655646 return - EBUSY ;
656- }
657- mutex_unlock (& ffs -> mutex );
647+
658648 file -> private_data = ffs ;
649+ ffs_data_opened (ffs );
659650
660651 return stream_open (inode , file );
661652}
@@ -1202,33 +1193,14 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
12021193static int
12031194ffs_epfile_open (struct inode * inode , struct file * file )
12041195{
1205- struct ffs_data * ffs = inode -> i_sb -> s_fs_info ;
1206- struct ffs_epfile * epfile ;
1207- int ret ;
1196+ struct ffs_epfile * epfile = inode -> i_private ;
12081197
1209- /* Acquire mutex */
1210- ret = ffs_mutex_lock (& ffs -> mutex , file -> f_flags & O_NONBLOCK );
1211- if (ret < 0 )
1212- return ret ;
1213-
1214- if (!atomic_inc_not_zero (& ffs -> opened )) {
1215- mutex_unlock (& ffs -> mutex );
1216- return - ENODEV ;
1217- }
1218- /*
1219- * we want the state to be FFS_ACTIVE; FFS_ACTIVE alone is
1220- * not enough, though - we might have been through FFS_CLOSING
1221- * and back to FFS_ACTIVE, with our file already removed.
1222- */
1223- epfile = smp_load_acquire (& inode -> i_private );
1224- if (unlikely (ffs -> state != FFS_ACTIVE || !epfile )) {
1225- mutex_unlock (& ffs -> mutex );
1226- ffs_data_closed (ffs );
1198+ if (WARN_ON (epfile -> ffs -> state != FFS_ACTIVE ))
12271199 return - ENODEV ;
1228- }
1229- mutex_unlock (& ffs -> mutex );
12301200
12311201 file -> private_data = epfile ;
1202+ ffs_data_opened (epfile -> ffs );
1203+
12321204 return stream_open (inode , file );
12331205}
12341206
@@ -1360,7 +1332,7 @@ static void ffs_dmabuf_put(struct dma_buf_attachment *attach)
13601332static int
13611333ffs_epfile_release (struct inode * inode , struct file * file )
13621334{
1363- struct ffs_epfile * epfile = file -> private_data ;
1335+ struct ffs_epfile * epfile = inode -> i_private ;
13641336 struct ffs_dmabuf_priv * priv , * tmp ;
13651337 struct ffs_data * ffs = epfile -> ffs ;
13661338
@@ -2380,19 +2352,14 @@ static int ffs_epfiles_create(struct ffs_data *ffs)
23802352 return 0 ;
23812353}
23822354
2383- static void clear_one (struct dentry * dentry )
2384- {
2385- smp_store_release (& dentry -> d_inode -> i_private , NULL );
2386- }
2387-
23882355static void ffs_epfiles_destroy (struct ffs_epfile * epfiles , unsigned count )
23892356{
23902357 struct ffs_epfile * epfile = epfiles ;
23912358
23922359 for (; count ; -- count , ++ epfile ) {
23932360 BUG_ON (mutex_is_locked (& epfile -> mutex ));
23942361 if (epfile -> dentry ) {
2395- simple_recursive_removal (epfile -> dentry , clear_one );
2362+ simple_recursive_removal (epfile -> dentry , NULL );
23962363 epfile -> dentry = NULL ;
23972364 }
23982365 }
0 commit comments