From f8bd8b97bea9273d166efdc06c3a6a54fc24ffdb Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 13 Aug 2017 16:48:27 -0400 Subject: command: Don't pass max_size to command_encodef() The command_encodef() can read the max_size parameter directly from the 'struct command_encoder' passed into it. Also, there is no need to check that a message will fit in a buffer if the buffer is declared to be MESSAGE_MAX in size. Signed-off-by: Kevin O'Connor --- src/pru/internal.h | 3 ++- src/pru/main.c | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/pru') diff --git a/src/pru/internal.h b/src/pru/internal.h index 980c1d61..abbc9e40 100644 --- a/src/pru/internal.h +++ b/src/pru/internal.h @@ -3,6 +3,7 @@ // Local definitions for PRU code #include // uint32_t +#include "command.h" // MESSAGE_MAX #define IEP_EVENT 7 #define KICK_ARM_EVENT 16 @@ -24,7 +25,7 @@ // Layout of shared memory struct shared_response_buffer { uint32_t count; - char data[64]; + char data[MESSAGE_MAX]; }; struct shared_mem { uint32_t signal; diff --git a/src/pru/main.c b/src/pru/main.c index 45eb8274..6eed82e3 100644 --- a/src/pru/main.c +++ b/src/pru/main.c @@ -135,14 +135,13 @@ void console_sendf(const struct command_encoder *ce, va_list args) { // Verify space for message - uint32_t max_size = ce->max_size; uint32_t send_push_pos = SHARED_MEM->send_push_pos; struct shared_response_buffer *s = &SHARED_MEM->send_data[send_push_pos]; - if (max_size > sizeof(s->data) || readl(&s->count)) + if (readl(&s->count)) return; // Generate message - uint32_t msglen = command_encodef(s->data, max_size, ce, args); + uint32_t msglen = command_encodef(s->data, ce, args); // Signal PRU0 to transmit message writel(&s->count, msglen); -- cgit v1.2.3-70-g09d2