Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
Mock Turtle
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Mock Turtle
Commits
f3c4ef08
Commit
f3c4ef08
authored
Jul 30, 2015
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel: save a couple of memcpy in user space
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
ad922622
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
15 deletions
+10
-15
wrnc-hmq.c
kernel/wrnc-hmq.c
+8
-10
wrnc-user.h
kernel/wrnc-user.h
+1
-1
libwrnc.c
lib/libwrnc.c
+1
-4
No files found.
kernel/wrnc-hmq.c
View file @
f3c4ef08
...
...
@@ -539,7 +539,7 @@ static struct wrnc_msg *wrnc_message_pop(struct wrnc_hmq *hmq)
static
int
wrnc_ioctl_msg_sync
(
struct
wrnc_hmq
*
hmq
,
void
__user
*
uarg
)
{
struct
wrnc_dev
*
wrnc
=
to_wrnc_dev
(
hmq
->
dev
.
parent
);
struct
wrnc_msg
msg_ans
;
struct
wrnc_msg
msg_ans
,
msg_req
;
struct
wrnc_msg_sync
msg
;
struct
wrnc_hmq
*
hmq_out
;
unsigned
long
flags
;
...
...
@@ -548,6 +548,9 @@ static int wrnc_ioctl_msg_sync(struct wrnc_hmq *hmq, void __user *uarg)
/* Copy the message from user space*/
err
=
copy_from_user
(
&
msg
,
uarg
,
sizeof
(
struct
wrnc_msg_sync
));
if
(
err
)
return
err
;
err
=
copy_from_user
(
&
msg_req
,
msg
.
msg
,
sizeof
(
struct
wrnc_msg
));
if
(
err
)
return
err
;
...
...
@@ -569,7 +572,7 @@ static int wrnc_ioctl_msg_sync(struct wrnc_hmq *hmq, void __user *uarg)
/* Send the message */
spin_lock_irqsave
(
&
hmq
->
lock
,
flags
);
seq
=
wrnc_message_push
(
hmq
,
&
msg
.
msg
);
seq
=
wrnc_message_push
(
hmq
,
&
msg
_req
);
spin_unlock_irqrestore
(
&
hmq
->
lock
,
flags
);
/* Set message sequance to wait */
...
...
@@ -594,15 +597,10 @@ static int wrnc_ioctl_msg_sync(struct wrnc_hmq *hmq, void __user *uarg)
if
(
to
==
0
)
dev_err
(
&
hmq
->
dev
,
"The real time application is taking too much time to answer. Something is broken
\n
"
);
memset
(
&
msg
.
msg
,
0
,
sizeof
(
struct
wrnc_msg
));
goto
out_sync
;
memset
(
&
msg_ans
,
0
,
sizeof
(
struct
wrnc_msg
));
}
/* Copy the answer message back to user space */
memcpy
(
&
msg
.
msg
,
&
msg_ans
,
sizeof
(
struct
wrnc_msg
));
out_sync:
return
copy_to_user
(
uarg
,
&
msg
,
sizeof
(
struct
wrnc_msg_sync
));
return
copy_to_user
(
msg
.
msg
,
&
msg_ans
,
sizeof
(
struct
wrnc_msg
));
}
...
...
@@ -692,7 +690,7 @@ static long wrnc_hmq_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
wrnc_ioctl_msg_filter_clean
(
user
,
uarg
);
break
;
default:
pr_warn
(
"
ual
: invalid ioctl command %d
\n
"
,
cmd
);
pr_warn
(
"
wrnc
: invalid ioctl command %d
\n
"
,
cmd
);
return
-
EINVAL
;
}
...
...
kernel/wrnc-user.h
View file @
f3c4ef08
...
...
@@ -57,7 +57,7 @@ struct wrnc_msg {
* Message descriptor used to send synchronous messages
*/
struct
wrnc_msg_sync
{
struct
wrnc_msg
msg
;
/**< the message to send. It will be overwritten by
struct
wrnc_msg
*
msg
;
/**< the message to send. It will be overwritten by
the synchronous answer */
uint16_t
index_in
;
/**< where write the message */
uint16_t
index_out
;
/**< where we expect the synchronous answer */
...
...
lib/libwrnc.c
View file @
f3c4ef08
...
...
@@ -735,16 +735,13 @@ int wrnc_hmq_send_and_receive_sync(struct wrnc_hmq *hmq,
smsg
.
index_in
=
hmq
->
index
;
smsg
.
index_out
=
index_out
;
smsg
.
timeout_ms
=
timeout_ms
;
memcpy
(
&
smsg
.
msg
,
msg
,
sizeof
(
struct
wrnc_msg
))
;
smsg
.
msg
=
msg
;
/* Send the message */
err
=
ioctl
(
hmq
->
fd
,
WRNC_IOCTL_MSG_SYNC
,
&
smsg
);
if
(
err
)
return
-
1
;
/* Copy the answer */
memcpy
(
msg
,
&
smsg
.
msg
,
sizeof
(
struct
wrnc_msg
));
msg
->
error
=
0
;
msg
->
offset
=
0
;
msg
->
direction
=
WRNC_MSG_DIR_RECEIVE
;
...
...
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