To allow HVC backends to set the I/O buffer sizes to values
that are most efficient for the backend, change the macro
definitions where the buffer sizes are set to be conditional
on whether or not the macros are already defined.  Also,
rename the macros from N_OUTBUF to HVC_N_OUBUF and from
N_INBUF to HVC_N_INBUF.

Typical usage in the backend source file would be:

 #define HVC_N_OUTBUF 32
 #define HVC_N_INBUF 32
 #include "hvc_console.h"

Signed-off-by: Geoff Levand <ge...@infradead.org>
---
 drivers/tty/hvc/hvc_console.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 436cc51c92c3..2928bad057fc 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -42,12 +42,15 @@
 #define HVC_CLOSE_WAIT (HZ/100) /* 1/10 of a second */
 
 /*
- * These sizes are most efficient for vio, because they are the
- * native transfer size. We could make them selectable in the
- * future to better deal with backends that want other buffer sizes.
+ * These default sizes are most efficient for vio, because they are
+ * the native transfer size.
  */
-#define N_OUTBUF       16
-#define N_INBUF                16
+#if !defined(HVC_N_OUTBUF)
+# define HVC_N_OUTBUF  16
+#endif
+#if !defined(HVC_N_INBUF)
+# define HVC_N_INBUF   16
+#endif
 
 #define __ALIGNED__ __attribute__((__aligned__(sizeof(long))))
 
@@ -151,7 +154,7 @@ static uint32_t vtermnos[MAX_NR_HVC_CONSOLES] =
 static void hvc_console_print(struct console *co, const char *b,
                              unsigned count)
 {
-       char c[N_OUTBUF] __ALIGNED__;
+       char c[HVC_N_OUTBUF] __ALIGNED__;
        unsigned i = 0, n = 0;
        int r, donecr = 0, index = co->index;
 
@@ -640,7 +643,7 @@ static int __hvc_poll(struct hvc_struct *hp, bool may_sleep)
 {
        struct tty_struct *tty;
        int i, n, count, poll_mask = 0;
-       char buf[N_INBUF] __ALIGNED__;
+       char buf[HVC_N_INBUF] __ALIGNED__;
        unsigned long flags;
        int read_total = 0;
        int written_total = 0;
@@ -681,7 +684,7 @@ static int __hvc_poll(struct hvc_struct *hp, bool may_sleep)
 
  read_again:
        /* Read data if any */
-       count = tty_buffer_request_room(&hp->port, N_INBUF);
+       count = tty_buffer_request_room(&hp->port, HVC_N_INBUF);
 
        /* If flip is full, just reschedule a later read */
        if (count == 0) {
-- 
2.20.1

Reply via email to