mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 22:02:02 +00:00
tty: ehv_bytecha: use memcpy_and_pad() in local_ev_byte_channel_send()
There is a helper for memcpy(buffer)+memset(the_rest). Use it for simplicity. And add a comment why we are doing the copy in the first place. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com> Cc: linuxppc-dev@lists.ozlabs.org Link: https://lore.kernel.org/r/20231121092258.9334-8-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
73b2ed3675
commit
9d3e3301ae
1 changed files with 5 additions and 2 deletions
|
@ -143,9 +143,12 @@ static unsigned int local_ev_byte_channel_send(unsigned int handle,
|
|||
char buffer[EV_BYTE_CHANNEL_MAX_BYTES];
|
||||
unsigned int c = *count;
|
||||
|
||||
/*
|
||||
* ev_byte_channel_send() expects at least EV_BYTE_CHANNEL_MAX_BYTES
|
||||
* (16 B) in the buffer. Fake it using a local buffer if needed.
|
||||
*/
|
||||
if (c < sizeof(buffer)) {
|
||||
memcpy(buffer, p, c);
|
||||
memset(&buffer[c], 0, sizeof(buffer) - c);
|
||||
memcpy_and_pad(buffer, sizeof(buffer), p, c, 0);
|
||||
p = buffer;
|
||||
}
|
||||
return ev_byte_channel_send(handle, count, p);
|
||||
|
|
Loading…
Reference in a new issue