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)
...
@@ -864,38 +864,6 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
return
ret
;
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
static
int
ffs_epfile_open
(
struct
inode
*
inode
,
struct
file
*
file
)
ffs_epfile_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
{
...
@@ -932,72 +900,84 @@ static int ffs_aio_cancel(struct kiocb *kiocb)
...
@@ -932,72 +900,84 @@ static int ffs_aio_cancel(struct kiocb *kiocb)
return
value
;
return
value
;
}
}
static
ssize_t
ffs_epfile_aio_write
(
struct
kiocb
*
kiocb
,
static
ssize_t
ffs_epfile_write_iter
(
struct
kiocb
*
kiocb
,
struct
iov_iter
*
from
)
const
struct
iovec
*
iovec
,
unsigned
long
nr_segs
,
loff_t
loff
)
{
{
struct
ffs_io_data
*
io_data
;
struct
ffs_io_data
io_data
,
*
p
=
&
io_data
;
ssize_t
res
;
ssize_t
res
;
ENTER
();
ENTER
();
io_data
=
kmalloc
(
sizeof
(
*
io_data
),
GFP_KERNEL
);
if
(
!
is_sync_kiocb
(
kiocb
))
{
if
(
unlikely
(
!
io_data
))
p
=
kmalloc
(
sizeof
(
io_data
),
GFP_KERNEL
);
return
-
ENOMEM
;
if
(
unlikely
(
!
p
))
return
-
ENOMEM
;
p
->
aio
=
true
;
}
else
{
p
->
aio
=
false
;
}
io_data
->
aio
=
true
;
p
->
read
=
false
;
io_data
->
read
=
false
;
p
->
kiocb
=
kiocb
;
io_data
->
kiocb
=
kiocb
;
p
->
data
=
*
from
;
iov_iter_init
(
&
io_data
->
data
,
WRITE
,
iovec
,
nr_segs
,
kiocb
->
ki_nbytes
);
p
->
mm
=
current
->
mm
;
io_data
->
mm
=
current
->
mm
;
kiocb
->
private
=
io_data
;
kiocb
->
private
=
p
;
kiocb_set_cancel_fn
(
kiocb
,
ffs_aio_cancel
);
kiocb_set_cancel_fn
(
kiocb
,
ffs_aio_cancel
);
res
=
ffs_epfile_io
(
kiocb
->
ki_filp
,
io_data
);
res
=
ffs_epfile_io
(
kiocb
->
ki_filp
,
p
);
if
(
res
!=
-
EIOCBQUEUED
)
if
(
res
==
-
EIOCBQUEUED
)
kfree
(
io_data
);
return
res
;
if
(
p
->
aio
)
kfree
(
p
);
else
*
from
=
p
->
data
;
return
res
;
return
res
;
}
}
static
ssize_t
ffs_epfile_aio_read
(
struct
kiocb
*
kiocb
,
static
ssize_t
ffs_epfile_read_iter
(
struct
kiocb
*
kiocb
,
struct
iov_iter
*
to
)
const
struct
iovec
*
iovec
,
unsigned
long
nr_segs
,
loff_t
loff
)
{
{
struct
ffs_io_data
*
io_data
;
struct
ffs_io_data
io_data
,
*
p
=
&
io_data
;
struct
iovec
*
iovec_copy
;
ssize_t
res
;
ssize_t
res
;
ENTER
();
ENTER
();
iovec_copy
=
kmalloc_array
(
nr_segs
,
sizeof
(
*
iovec_copy
),
GFP_KERNEL
);
if
(
!
is_sync_kiocb
(
kiocb
))
{
if
(
unlikely
(
!
iovec_copy
))
p
=
kmalloc
(
sizeof
(
io_data
),
GFP_KERNEL
);
return
-
ENOMEM
;
if
(
unlikely
(
!
p
))
return
-
ENOMEM
;
memcpy
(
iovec_copy
,
iovec
,
sizeof
(
struct
iovec
)
*
nr_segs
);
p
->
aio
=
true
;
}
else
{
io_data
=
kmalloc
(
sizeof
(
*
io_data
),
GFP_KERNEL
);
p
->
aio
=
false
;
if
(
unlikely
(
!
io_data
))
{
kfree
(
iovec_copy
);
return
-
ENOMEM
;
}
}
io_data
->
aio
=
true
;
p
->
read
=
true
;
io_data
->
read
=
true
;
p
->
kiocb
=
kiocb
;
io_data
->
kiocb
=
kiocb
;
if
(
p
->
aio
)
{
io_data
->
to_free
=
iovec_copy
;
p
->
to_free
=
dup_iter
(
&
p
->
data
,
to
,
GFP_KERNEL
);
iov_iter_init
(
&
io_data
->
data
,
READ
,
iovec_copy
,
nr_segs
,
kiocb
->
ki_nbytes
);
if
(
!
p
->
to_free
)
{
io_data
->
mm
=
current
->
mm
;
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
);
kiocb_set_cancel_fn
(
kiocb
,
ffs_aio_cancel
);
res
=
ffs_epfile_io
(
kiocb
->
ki_filp
,
io_data
);
res
=
ffs_epfile_io
(
kiocb
->
ki_filp
,
p
);
if
(
res
!=
-
EIOCBQUEUED
)
{
if
(
res
==
-
EIOCBQUEUED
)
kfree
(
io_data
->
to_free
);
return
res
;
kfree
(
io_data
);
if
(
p
->
aio
)
{
kfree
(
p
->
to_free
);
kfree
(
p
);
}
else
{
*
to
=
p
->
data
;
}
}
return
res
;
return
res
;
}
}
...
@@ -1079,10 +1059,10 @@ static const struct file_operations ffs_epfile_operations = {
...
@@ -1079,10 +1059,10 @@ static const struct file_operations ffs_epfile_operations = {
.
llseek
=
no_llseek
,
.
llseek
=
no_llseek
,
.
open
=
ffs_epfile_open
,
.
open
=
ffs_epfile_open
,
.
write
=
ffs_epfile
_write
,
.
write
=
new_sync
_write
,
.
read
=
ffs_epfile
_read
,
.
read
=
new_sync
_read
,
.
aio_write
=
ffs_epfile_aio_write
,
.
write_iter
=
ffs_epfile_write_iter
,
.
aio_read
=
ffs_epfile_aio_read
,
.
read_iter
=
ffs_epfile_read_iter
,
.
release
=
ffs_epfile_release
,
.
release
=
ffs_epfile_release
,
.
unlocked_ioctl
=
ffs_epfile_ioctl
,
.
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