@@ -934,31 +934,44 @@ static ssize_t __ffs_epfile_read_data(struct ffs_epfile *epfile,
934
934
return ret ;
935
935
}
936
936
937
- static ssize_t ffs_epfile_io ( struct file * file , struct ffs_io_data * io_data )
937
+ static struct ffs_ep * ffs_epfile_wait_ep ( struct file * file )
938
938
{
939
939
struct ffs_epfile * epfile = file -> private_data ;
940
- struct usb_request * req ;
941
940
struct ffs_ep * ep ;
942
- char * data = NULL ;
943
- ssize_t ret , data_len = - EINVAL ;
944
- int halt ;
945
-
946
- /* Are we still active? */
947
- if (WARN_ON (epfile -> ffs -> state != FFS_ACTIVE ))
948
- return - ENODEV ;
941
+ int ret ;
949
942
950
943
/* Wait for endpoint to be enabled */
951
944
ep = epfile -> ep ;
952
945
if (!ep ) {
953
946
if (file -> f_flags & O_NONBLOCK )
954
- return - EAGAIN ;
947
+ return ERR_PTR ( - EAGAIN ) ;
955
948
956
949
ret = wait_event_interruptible (
957
950
epfile -> ffs -> wait , (ep = epfile -> ep ));
958
951
if (ret )
959
- return - EINTR ;
952
+ return ERR_PTR ( - EINTR ) ;
960
953
}
961
954
955
+ return ep ;
956
+ }
957
+
958
+ static ssize_t ffs_epfile_io (struct file * file , struct ffs_io_data * io_data )
959
+ {
960
+ struct ffs_epfile * epfile = file -> private_data ;
961
+ struct usb_request * req ;
962
+ struct ffs_ep * ep ;
963
+ char * data = NULL ;
964
+ ssize_t ret , data_len = - EINVAL ;
965
+ int halt ;
966
+
967
+ /* Are we still active? */
968
+ if (WARN_ON (epfile -> ffs -> state != FFS_ACTIVE ))
969
+ return - ENODEV ;
970
+
971
+ ep = ffs_epfile_wait_ep (file );
972
+ if (IS_ERR (ep ))
973
+ return PTR_ERR (ep );
974
+
962
975
/* Do we halt? */
963
976
halt = (!io_data -> read == !epfile -> in );
964
977
if (halt && epfile -> isoc )
@@ -1280,16 +1293,9 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code,
1280
1293
return - ENODEV ;
1281
1294
1282
1295
/* Wait for endpoint to be enabled */
1283
- ep = epfile -> ep ;
1284
- if (!ep ) {
1285
- if (file -> f_flags & O_NONBLOCK )
1286
- return - EAGAIN ;
1287
-
1288
- ret = wait_event_interruptible (
1289
- epfile -> ffs -> wait , (ep = epfile -> ep ));
1290
- if (ret )
1291
- return - EINTR ;
1292
- }
1296
+ ep = ffs_epfile_wait_ep (file );
1297
+ if (IS_ERR (ep ))
1298
+ return PTR_ERR (ep );
1293
1299
1294
1300
spin_lock_irq (& epfile -> ffs -> eps_lock );
1295
1301
0 commit comments