diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2013-06-15 09:36:01 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-23 19:47:07 -0400 |
commit | 1fc359fc3ea72314cc3ebdfa94c60e020c152cd2 (patch) | |
tree | 302ccb5a8cd9dee3c5affe1407e1413b66e8a207 | |
parent | f0f947c124e05ec977019b974b12dfe171dd7148 (diff) |
tty: Compute flip buffer ptrs
The char_buf_ptr and flag_buf_ptr values are trivially derived from
the .data field offset; compute values as needed.
Fixes a long-standing type-mismatch with the char and flag ptrs.
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/tty_buffer.c | 22 | ||||
-rw-r--r-- | include/linux/tty.h | 12 | ||||
-rw-r--r-- | include/linux/tty_flip.h | 4 |
3 files changed, 22 insertions, 16 deletions
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index ff1b2e37c3ca..170674cb68fc 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c | |||
@@ -71,8 +71,6 @@ static struct tty_buffer *tty_buffer_alloc(struct tty_port *port, size_t size) | |||
71 | p->next = NULL; | 71 | p->next = NULL; |
72 | p->commit = 0; | 72 | p->commit = 0; |
73 | p->read = 0; | 73 | p->read = 0; |
74 | p->char_buf_ptr = (char *)(p->data); | ||
75 | p->flag_buf_ptr = (unsigned char *)p->char_buf_ptr + size; | ||
76 | port->buf.memory_used += size; | 74 | port->buf.memory_used += size; |
77 | return p; | 75 | return p; |
78 | } | 76 | } |
@@ -265,8 +263,8 @@ int tty_insert_flip_string_fixed_flag(struct tty_port *port, | |||
265 | if (unlikely(space == 0)) { | 263 | if (unlikely(space == 0)) { |
266 | break; | 264 | break; |
267 | } | 265 | } |
268 | memcpy(tb->char_buf_ptr + tb->used, chars, space); | 266 | memcpy(char_buf_ptr(tb, tb->used), chars, space); |
269 | memset(tb->flag_buf_ptr + tb->used, flag, space); | 267 | memset(flag_buf_ptr(tb, tb->used), flag, space); |
270 | tb->used += space; | 268 | tb->used += space; |
271 | copied += space; | 269 | copied += space; |
272 | chars += space; | 270 | chars += space; |
@@ -303,8 +301,8 @@ int tty_insert_flip_string_flags(struct tty_port *port, | |||
303 | if (unlikely(space == 0)) { | 301 | if (unlikely(space == 0)) { |
304 | break; | 302 | break; |
305 | } | 303 | } |
306 | memcpy(tb->char_buf_ptr + tb->used, chars, space); | 304 | memcpy(char_buf_ptr(tb, tb->used), chars, space); |
307 | memcpy(tb->flag_buf_ptr + tb->used, flags, space); | 305 | memcpy(flag_buf_ptr(tb, tb->used), flags, space); |
308 | tb->used += space; | 306 | tb->used += space; |
309 | copied += space; | 307 | copied += space; |
310 | chars += space; | 308 | chars += space; |
@@ -364,8 +362,8 @@ int tty_prepare_flip_string(struct tty_port *port, unsigned char **chars, | |||
364 | int space = tty_buffer_request_room(port, size); | 362 | int space = tty_buffer_request_room(port, size); |
365 | if (likely(space)) { | 363 | if (likely(space)) { |
366 | struct tty_buffer *tb = port->buf.tail; | 364 | struct tty_buffer *tb = port->buf.tail; |
367 | *chars = tb->char_buf_ptr + tb->used; | 365 | *chars = char_buf_ptr(tb, tb->used); |
368 | memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space); | 366 | memset(flag_buf_ptr(tb, tb->used), TTY_NORMAL, space); |
369 | tb->used += space; | 367 | tb->used += space; |
370 | } | 368 | } |
371 | return space; | 369 | return space; |
@@ -394,8 +392,8 @@ int tty_prepare_flip_string_flags(struct tty_port *port, | |||
394 | int space = tty_buffer_request_room(port, size); | 392 | int space = tty_buffer_request_room(port, size); |
395 | if (likely(space)) { | 393 | if (likely(space)) { |
396 | struct tty_buffer *tb = port->buf.tail; | 394 | struct tty_buffer *tb = port->buf.tail; |
397 | *chars = tb->char_buf_ptr + tb->used; | 395 | *chars = char_buf_ptr(tb, tb->used); |
398 | *flags = tb->flag_buf_ptr + tb->used; | 396 | *flags = flag_buf_ptr(tb, tb->used); |
399 | tb->used += space; | 397 | tb->used += space; |
400 | } | 398 | } |
401 | return space; | 399 | return space; |
@@ -407,8 +405,8 @@ static int | |||
407 | receive_buf(struct tty_struct *tty, struct tty_buffer *head, int count) | 405 | receive_buf(struct tty_struct *tty, struct tty_buffer *head, int count) |
408 | { | 406 | { |
409 | struct tty_ldisc *disc = tty->ldisc; | 407 | struct tty_ldisc *disc = tty->ldisc; |
410 | char *p = head->char_buf_ptr + head->read; | 408 | unsigned char *p = char_buf_ptr(head, head->read); |
411 | unsigned char *f = head->flag_buf_ptr + head->read; | 409 | char *f = flag_buf_ptr(head, head->read); |
412 | 410 | ||
413 | if (disc->ops->receive_buf2) | 411 | if (disc->ops->receive_buf2) |
414 | count = disc->ops->receive_buf2(tty, p, f, count); | 412 | count = disc->ops->receive_buf2(tty, p, f, count); |
diff --git a/include/linux/tty.h b/include/linux/tty.h index 57a70d1d0412..87bbaa31ebf5 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h | |||
@@ -31,8 +31,6 @@ | |||
31 | 31 | ||
32 | struct tty_buffer { | 32 | struct tty_buffer { |
33 | struct tty_buffer *next; | 33 | struct tty_buffer *next; |
34 | char *char_buf_ptr; | ||
35 | unsigned char *flag_buf_ptr; | ||
36 | int used; | 34 | int used; |
37 | int size; | 35 | int size; |
38 | int commit; | 36 | int commit; |
@@ -41,6 +39,16 @@ struct tty_buffer { | |||
41 | unsigned long data[0]; | 39 | unsigned long data[0]; |
42 | }; | 40 | }; |
43 | 41 | ||
42 | static inline unsigned char *char_buf_ptr(struct tty_buffer *b, int ofs) | ||
43 | { | ||
44 | return ((unsigned char *)b->data) + ofs; | ||
45 | } | ||
46 | |||
47 | static inline char *flag_buf_ptr(struct tty_buffer *b, int ofs) | ||
48 | { | ||
49 | return (char *)char_buf_ptr(b, ofs) + b->size; | ||
50 | } | ||
51 | |||
44 | /* | 52 | /* |
45 | * We default to dicing tty buffer allocations to this many characters | 53 | * We default to dicing tty buffer allocations to this many characters |
46 | * in order to avoid multiple page allocations. We know the size of | 54 | * in order to avoid multiple page allocations. We know the size of |
diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h index e0f252633b47..ad0303994c32 100644 --- a/include/linux/tty_flip.h +++ b/include/linux/tty_flip.h | |||
@@ -18,8 +18,8 @@ static inline int tty_insert_flip_char(struct tty_port *port, | |||
18 | { | 18 | { |
19 | struct tty_buffer *tb = port->buf.tail; | 19 | struct tty_buffer *tb = port->buf.tail; |
20 | if (tb && tb->used < tb->size) { | 20 | if (tb && tb->used < tb->size) { |
21 | tb->flag_buf_ptr[tb->used] = flag; | 21 | *flag_buf_ptr(tb, tb->used) = flag; |
22 | tb->char_buf_ptr[tb->used++] = ch; | 22 | *char_buf_ptr(tb, tb->used++) = ch; |
23 | return 1; | 23 | return 1; |
24 | } | 24 | } |
25 | return tty_insert_flip_string_flags(port, &ch, &flag, 1); | 25 | return tty_insert_flip_string_flags(port, &ch, &flag, 1); |