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
3941dae1
Commit
3941dae1
authored
Apr 20, 2017
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
drm_dp_aux_dev: switch to read_iter/write_iter
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
2ea659a9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
63 deletions
+46
-63
drivers/gpu/drm/drm_dp_aux_dev.c
drivers/gpu/drm/drm_dp_aux_dev.c
+46
-63
No files found.
drivers/gpu/drm/drm_dp_aux_dev.c
View file @
3941dae1
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
#include <linux/kernel.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/module.h>
#include <linux/uaccess.h>
#include <linux/uaccess.h>
#include <linux/uio.h>
#include <drm/drm_dp_helper.h>
#include <drm/drm_dp_helper.h>
#include <drm/drm_crtc.h>
#include <drm/drm_crtc.h>
#include <drm/drmP.h>
#include <drm/drmP.h>
...
@@ -140,101 +141,83 @@ static loff_t auxdev_llseek(struct file *file, loff_t offset, int whence)
...
@@ -140,101 +141,83 @@ static loff_t auxdev_llseek(struct file *file, loff_t offset, int whence)
return
fixed_size_llseek
(
file
,
offset
,
whence
,
AUX_MAX_OFFSET
);
return
fixed_size_llseek
(
file
,
offset
,
whence
,
AUX_MAX_OFFSET
);
}
}
static
ssize_t
auxdev_read
(
struct
file
*
file
,
char
__user
*
buf
,
size_t
count
,
static
ssize_t
auxdev_read_iter
(
struct
kiocb
*
iocb
,
struct
iov_iter
*
to
)
loff_t
*
offset
)
{
{
s
ize_t
bytes_pending
,
num_bytes_processed
=
0
;
s
truct
drm_dp_aux_dev
*
aux_dev
=
iocb
->
ki_filp
->
private_data
;
struct
drm_dp_aux_dev
*
aux_dev
=
file
->
private_data
;
loff_t
pos
=
iocb
->
ki_pos
;
ssize_t
res
=
0
;
ssize_t
res
=
0
;
if
(
!
atomic_inc_not_zero
(
&
aux_dev
->
usecount
))
if
(
!
atomic_inc_not_zero
(
&
aux_dev
->
usecount
))
return
-
ENODEV
;
return
-
ENODEV
;
bytes_pending
=
min
((
loff_t
)
count
,
AUX_MAX_OFFSET
-
(
*
offset
));
iov_iter_truncate
(
to
,
AUX_MAX_OFFSET
-
pos
);
if
(
!
access_ok
(
VERIFY_WRITE
,
buf
,
bytes_pending
))
{
res
=
-
EFAULT
;
goto
out
;
}
while
(
bytes_pending
>
0
)
{
while
(
iov_iter_count
(
to
)
)
{
uint8_t
local
buf
[
DP_AUX_MAX_PAYLOAD_BYTES
];
uint8_t
buf
[
DP_AUX_MAX_PAYLOAD_BYTES
];
ssize_t
todo
=
min
_t
(
size_t
,
bytes_pending
,
sizeof
(
local
buf
));
ssize_t
todo
=
min
(
iov_iter_count
(
to
),
sizeof
(
buf
));
if
(
signal_pending
(
current
))
{
if
(
signal_pending
(
current
))
{
res
=
num_bytes_processed
?
res
=
-
ERESTARTSYS
;
num_bytes_processed
:
-
ERESTARTSYS
;
break
;
goto
out
;
}
}
res
=
drm_dp_dpcd_read
(
aux_dev
->
aux
,
*
offset
,
localbuf
,
todo
);
res
=
drm_dp_dpcd_read
(
aux_dev
->
aux
,
pos
,
buf
,
todo
);
if
(
res
<=
0
)
{
if
(
res
<=
0
)
res
=
num_bytes_processed
?
num_bytes_processed
:
res
;
break
;
goto
out
;
}
if
(
copy_to_iter
(
buf
,
res
,
to
)
!=
res
)
{
if
(
__copy_to_user
(
buf
+
num_bytes_processed
,
localbuf
,
res
))
{
res
=
-
EFAULT
;
res
=
num_bytes_processed
?
break
;
num_bytes_processed
:
-
EFAULT
;
goto
out
;
}
}
bytes_pending
-=
res
;
*
offset
+=
res
;
pos
+=
res
;
num_bytes_processed
+=
res
;
res
=
num_bytes_processed
;
}
}
out:
if
(
pos
!=
iocb
->
ki_pos
)
res
=
pos
-
iocb
->
ki_pos
;
iocb
->
ki_pos
=
pos
;
atomic_dec
(
&
aux_dev
->
usecount
);
atomic_dec
(
&
aux_dev
->
usecount
);
wake_up_atomic_t
(
&
aux_dev
->
usecount
);
wake_up_atomic_t
(
&
aux_dev
->
usecount
);
return
res
;
return
res
;
}
}
static
ssize_t
auxdev_write
(
struct
file
*
file
,
const
char
__user
*
buf
,
static
ssize_t
auxdev_write_iter
(
struct
kiocb
*
iocb
,
struct
iov_iter
*
from
)
size_t
count
,
loff_t
*
offset
)
{
{
s
ize_t
bytes_pending
,
num_bytes_processed
=
0
;
s
truct
drm_dp_aux_dev
*
aux_dev
=
iocb
->
ki_filp
->
private_data
;
struct
drm_dp_aux_dev
*
aux_dev
=
file
->
private_data
;
loff_t
pos
=
iocb
->
ki_pos
;
ssize_t
res
=
0
;
ssize_t
res
=
0
;
if
(
!
atomic_inc_not_zero
(
&
aux_dev
->
usecount
))
if
(
!
atomic_inc_not_zero
(
&
aux_dev
->
usecount
))
return
-
ENODEV
;
return
-
ENODEV
;
bytes_pending
=
min
((
loff_t
)
count
,
AUX_MAX_OFFSET
-
*
offset
);
iov_iter_truncate
(
from
,
AUX_MAX_OFFSET
-
pos
);
if
(
!
access_ok
(
VERIFY_READ
,
buf
,
bytes_pending
))
{
res
=
-
EFAULT
;
goto
out
;
}
while
(
bytes_pending
>
0
)
{
while
(
iov_iter_count
(
from
)
)
{
uint8_t
local
buf
[
DP_AUX_MAX_PAYLOAD_BYTES
];
uint8_t
buf
[
DP_AUX_MAX_PAYLOAD_BYTES
];
ssize_t
todo
=
min
_t
(
size_t
,
bytes_pending
,
sizeof
(
local
buf
));
ssize_t
todo
=
min
(
iov_iter_count
(
from
),
sizeof
(
buf
));
if
(
signal_pending
(
current
))
{
if
(
signal_pending
(
current
))
{
res
=
num_bytes_processed
?
res
=
-
ERESTARTSYS
;
num_bytes_processed
:
-
ERESTARTSYS
;
break
;
goto
out
;
}
}
if
(
__copy_from_user
(
localbuf
,
if
(
!
copy_from_iter_full
(
buf
,
todo
,
from
))
{
buf
+
num_bytes_processed
,
todo
))
{
res
=
-
EFAULT
;
res
=
num_bytes_processed
?
break
;
num_bytes_processed
:
-
EFAULT
;
goto
out
;
}
}
res
=
drm_dp_dpcd_write
(
aux_dev
->
aux
,
*
offset
,
localbuf
,
todo
);
res
=
drm_dp_dpcd_write
(
aux_dev
->
aux
,
pos
,
buf
,
todo
);
if
(
res
<=
0
)
{
if
(
res
<=
0
)
res
=
num_bytes_processed
?
num_bytes_processed
:
res
;
break
;
goto
out
;
}
pos
+=
res
;
bytes_pending
-=
res
;
*
offset
+=
res
;
num_bytes_processed
+=
res
;
res
=
num_bytes_processed
;
}
}
out:
if
(
pos
!=
iocb
->
ki_pos
)
res
=
pos
-
iocb
->
ki_pos
;
iocb
->
ki_pos
=
pos
;
atomic_dec
(
&
aux_dev
->
usecount
);
atomic_dec
(
&
aux_dev
->
usecount
);
wake_up_atomic_t
(
&
aux_dev
->
usecount
);
wake_up_atomic_t
(
&
aux_dev
->
usecount
);
return
res
;
return
res
;
...
@@ -251,8 +234,8 @@ static int auxdev_release(struct inode *inode, struct file *file)
...
@@ -251,8 +234,8 @@ static int auxdev_release(struct inode *inode, struct file *file)
static
const
struct
file_operations
auxdev_fops
=
{
static
const
struct
file_operations
auxdev_fops
=
{
.
owner
=
THIS_MODULE
,
.
owner
=
THIS_MODULE
,
.
llseek
=
auxdev_llseek
,
.
llseek
=
auxdev_llseek
,
.
read
=
auxdev_read
,
.
read
_iter
=
auxdev_read_iter
,
.
write
=
auxdev_write
,
.
write
_iter
=
auxdev_write_iter
,
.
open
=
auxdev_open
,
.
open
=
auxdev_open
,
.
release
=
auxdev_release
,
.
release
=
auxdev_release
,
};
};
...
...
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