Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
70e60d91
Commit
70e60d91
authored
Jan 31, 2015
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gadget/function/f_fs.c: switch to ->{read,write}_iter()
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
c993c39b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
78 deletions
+58
-78
drivers/usb/gadget/function/f_fs.c
drivers/usb/gadget/function/f_fs.c
+58
-78
No files found.
drivers/usb/gadget/function/f_fs.c
View file @
70e60d91
...
...
@@ -864,38 +864,6 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
return
ret
;
}
static
ssize_t
ffs_epfile_write
(
struct
file
*
file
,
const
char
__user
*
buf
,
size_t
len
,
loff_t
*
ptr
)
{
struct
ffs_io_data
io_data
;
struct
iovec
iov
=
{.
iov_base
=
buf
,
.
iov_len
=
len
};
ENTER
();
io_data
.
aio
=
false
;
io_data
.
read
=
false
;
iov_iter_init
(
&
io_data
.
data
,
WRITE
,
&
iov
,
1
,
len
);
return
ffs_epfile_io
(
file
,
&
io_data
);
}
static
ssize_t
ffs_epfile_read
(
struct
file
*
file
,
char
__user
*
buf
,
size_t
len
,
loff_t
*
ptr
)
{
struct
ffs_io_data
io_data
;
struct
iovec
iov
=
{.
iov_base
=
buf
,
.
iov_len
=
len
};
ENTER
();
io_data
.
aio
=
false
;
io_data
.
read
=
true
;
io_data
.
to_free
=
NULL
;
iov_iter_init
(
&
io_data
.
data
,
READ
,
&
iov
,
1
,
len
);
return
ffs_epfile_io
(
file
,
&
io_data
);
}
static
int
ffs_epfile_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
...
...
@@ -932,72 +900,84 @@ static int ffs_aio_cancel(struct kiocb *kiocb)
return
value
;
}
static
ssize_t
ffs_epfile_aio_write
(
struct
kiocb
*
kiocb
,
const
struct
iovec
*
iovec
,
unsigned
long
nr_segs
,
loff_t
loff
)
static
ssize_t
ffs_epfile_write_iter
(
struct
kiocb
*
kiocb
,
struct
iov_iter
*
from
)
{
struct
ffs_io_data
*
io_data
;
struct
ffs_io_data
io_data
,
*
p
=
&
io_data
;
ssize_t
res
;
ENTER
();
io_data
=
kmalloc
(
sizeof
(
*
io_data
),
GFP_KERNEL
);
if
(
unlikely
(
!
io_data
))
return
-
ENOMEM
;
if
(
!
is_sync_kiocb
(
kiocb
))
{
p
=
kmalloc
(
sizeof
(
io_data
),
GFP_KERNEL
);
if
(
unlikely
(
!
p
))
return
-
ENOMEM
;
p
->
aio
=
true
;
}
else
{
p
->
aio
=
false
;
}
io_data
->
aio
=
true
;
io_data
->
read
=
false
;
io_data
->
kiocb
=
kiocb
;
iov_iter_init
(
&
io_data
->
data
,
WRITE
,
iovec
,
nr_segs
,
kiocb
->
ki_nbytes
);
io_data
->
mm
=
current
->
mm
;
p
->
read
=
false
;
p
->
kiocb
=
kiocb
;
p
->
data
=
*
from
;
p
->
mm
=
current
->
mm
;
kiocb
->
private
=
io_data
;
kiocb
->
private
=
p
;
kiocb_set_cancel_fn
(
kiocb
,
ffs_aio_cancel
);
res
=
ffs_epfile_io
(
kiocb
->
ki_filp
,
io_data
);
if
(
res
!=
-
EIOCBQUEUED
)
kfree
(
io_data
);
res
=
ffs_epfile_io
(
kiocb
->
ki_filp
,
p
);
if
(
res
==
-
EIOCBQUEUED
)
return
res
;
if
(
p
->
aio
)
kfree
(
p
);
else
*
from
=
p
->
data
;
return
res
;
}
static
ssize_t
ffs_epfile_aio_read
(
struct
kiocb
*
kiocb
,
const
struct
iovec
*
iovec
,
unsigned
long
nr_segs
,
loff_t
loff
)
static
ssize_t
ffs_epfile_read_iter
(
struct
kiocb
*
kiocb
,
struct
iov_iter
*
to
)
{
struct
ffs_io_data
*
io_data
;
struct
iovec
*
iovec_copy
;
struct
ffs_io_data
io_data
,
*
p
=
&
io_data
;
ssize_t
res
;
ENTER
();
iovec_copy
=
kmalloc_array
(
nr_segs
,
sizeof
(
*
iovec_copy
),
GFP_KERNEL
);
if
(
unlikely
(
!
iovec_copy
))
return
-
ENOMEM
;
memcpy
(
iovec_copy
,
iovec
,
sizeof
(
struct
iovec
)
*
nr_segs
);
io_data
=
kmalloc
(
sizeof
(
*
io_data
),
GFP_KERNEL
);
if
(
unlikely
(
!
io_data
))
{
kfree
(
iovec_copy
);
return
-
ENOMEM
;
if
(
!
is_sync_kiocb
(
kiocb
))
{
p
=
kmalloc
(
sizeof
(
io_data
),
GFP_KERNEL
);
if
(
unlikely
(
!
p
))
return
-
ENOMEM
;
p
->
aio
=
true
;
}
else
{
p
->
aio
=
false
;
}
io_data
->
aio
=
true
;
io_data
->
read
=
true
;
io_data
->
kiocb
=
kiocb
;
io_data
->
to_free
=
iovec_copy
;
iov_iter_init
(
&
io_data
->
data
,
READ
,
iovec_copy
,
nr_segs
,
kiocb
->
ki_nbytes
);
io_data
->
mm
=
current
->
mm
;
p
->
read
=
true
;
p
->
kiocb
=
kiocb
;
if
(
p
->
aio
)
{
p
->
to_free
=
dup_iter
(
&
p
->
data
,
to
,
GFP_KERNEL
);
if
(
!
p
->
to_free
)
{
kfree
(
p
);
return
-
ENOMEM
;
}
}
else
{
p
->
data
=
*
to
;
p
->
to_free
=
NULL
;
}
p
->
mm
=
current
->
mm
;
kiocb
->
private
=
io_data
;
kiocb
->
private
=
p
;
kiocb_set_cancel_fn
(
kiocb
,
ffs_aio_cancel
);
res
=
ffs_epfile_io
(
kiocb
->
ki_filp
,
io_data
);
if
(
res
!=
-
EIOCBQUEUED
)
{
kfree
(
io_data
->
to_free
);
kfree
(
io_data
);
res
=
ffs_epfile_io
(
kiocb
->
ki_filp
,
p
);
if
(
res
==
-
EIOCBQUEUED
)
return
res
;
if
(
p
->
aio
)
{
kfree
(
p
->
to_free
);
kfree
(
p
);
}
else
{
*
to
=
p
->
data
;
}
return
res
;
}
...
...
@@ -1079,10 +1059,10 @@ static const struct file_operations ffs_epfile_operations = {
.
llseek
=
no_llseek
,
.
open
=
ffs_epfile_open
,
.
write
=
ffs_epfile
_write
,
.
read
=
ffs_epfile
_read
,
.
aio_write
=
ffs_epfile_aio_write
,
.
aio_read
=
ffs_epfile_aio_read
,
.
write
=
new_sync
_write
,
.
read
=
new_sync
_read
,
.
write_iter
=
ffs_epfile_write_iter
,
.
read_iter
=
ffs_epfile_read_iter
,
.
release
=
ffs_epfile_release
,
.
unlocked_ioctl
=
ffs_epfile_ioctl
,
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment