diff options
-rw-r--r-- | arch/powerpc/include/asm/hvsi.h | 16 | ||||
-rw-r--r-- | drivers/tty/hvc/hvsi.c | 66 |
2 files changed, 37 insertions, 45 deletions
diff --git a/arch/powerpc/include/asm/hvsi.h b/arch/powerpc/include/asm/hvsi.h index f13125a0cb3a..ab2ddd76c2e0 100644 --- a/arch/powerpc/include/asm/hvsi.h +++ b/arch/powerpc/include/asm/hvsi.h | |||
@@ -29,16 +29,12 @@ struct hvsi_header { | |||
29 | } __attribute__((packed)); | 29 | } __attribute__((packed)); |
30 | 30 | ||
31 | struct hvsi_data { | 31 | struct hvsi_data { |
32 | uint8_t type; | 32 | struct hvsi_header hdr; |
33 | uint8_t len; | ||
34 | uint16_t seqno; | ||
35 | uint8_t data[HVSI_MAX_OUTGOING_DATA]; | 33 | uint8_t data[HVSI_MAX_OUTGOING_DATA]; |
36 | } __attribute__((packed)); | 34 | } __attribute__((packed)); |
37 | 35 | ||
38 | struct hvsi_control { | 36 | struct hvsi_control { |
39 | uint8_t type; | 37 | struct hvsi_header hdr; |
40 | uint8_t len; | ||
41 | uint16_t seqno; | ||
42 | uint16_t verb; | 38 | uint16_t verb; |
43 | /* optional depending on verb: */ | 39 | /* optional depending on verb: */ |
44 | uint32_t word; | 40 | uint32_t word; |
@@ -46,16 +42,12 @@ struct hvsi_control { | |||
46 | } __attribute__((packed)); | 42 | } __attribute__((packed)); |
47 | 43 | ||
48 | struct hvsi_query { | 44 | struct hvsi_query { |
49 | uint8_t type; | 45 | struct hvsi_header hdr; |
50 | uint8_t len; | ||
51 | uint16_t seqno; | ||
52 | uint16_t verb; | 46 | uint16_t verb; |
53 | } __attribute__((packed)); | 47 | } __attribute__((packed)); |
54 | 48 | ||
55 | struct hvsi_query_response { | 49 | struct hvsi_query_response { |
56 | uint8_t type; | 50 | struct hvsi_header hdr; |
57 | uint8_t len; | ||
58 | uint16_t seqno; | ||
59 | uint16_t verb; | 51 | uint16_t verb; |
60 | uint16_t query_seqno; | 52 | uint16_t query_seqno; |
61 | union { | 53 | union { |
diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c index 0b35793de1fa..c94e2f5853d8 100644 --- a/drivers/tty/hvc/hvsi.c +++ b/drivers/tty/hvc/hvsi.c | |||
@@ -295,18 +295,18 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno) | |||
295 | struct hvsi_query_response packet __ALIGNED__; | 295 | struct hvsi_query_response packet __ALIGNED__; |
296 | int wrote; | 296 | int wrote; |
297 | 297 | ||
298 | packet.type = VS_QUERY_RESPONSE_PACKET_HEADER; | 298 | packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER; |
299 | packet.len = sizeof(struct hvsi_query_response); | 299 | packet.hdr.len = sizeof(struct hvsi_query_response); |
300 | packet.seqno = atomic_inc_return(&hp->seqno); | 300 | packet.hdr.seqno = atomic_inc_return(&hp->seqno); |
301 | packet.verb = VSV_SEND_VERSION_NUMBER; | 301 | packet.verb = VSV_SEND_VERSION_NUMBER; |
302 | packet.u.version = HVSI_VERSION; | 302 | packet.u.version = HVSI_VERSION; |
303 | packet.query_seqno = query_seqno+1; | 303 | packet.query_seqno = query_seqno+1; |
304 | 304 | ||
305 | pr_debug("%s: sending %i bytes\n", __func__, packet.len); | 305 | pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); |
306 | dbg_dump_hex((uint8_t*)&packet, packet.len); | 306 | dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); |
307 | 307 | ||
308 | wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len); | 308 | wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); |
309 | if (wrote != packet.len) { | 309 | if (wrote != packet.hdr.len) { |
310 | printk(KERN_ERR "hvsi%i: couldn't send query response!\n", | 310 | printk(KERN_ERR "hvsi%i: couldn't send query response!\n", |
311 | hp->index); | 311 | hp->index); |
312 | return -EIO; | 312 | return -EIO; |
@@ -321,7 +321,7 @@ static void hvsi_recv_query(struct hvsi_struct *hp, uint8_t *packet) | |||
321 | 321 | ||
322 | switch (hp->state) { | 322 | switch (hp->state) { |
323 | case HVSI_WAIT_FOR_VER_QUERY: | 323 | case HVSI_WAIT_FOR_VER_QUERY: |
324 | hvsi_version_respond(hp, query->seqno); | 324 | hvsi_version_respond(hp, query->hdr.seqno); |
325 | __set_state(hp, HVSI_OPEN); | 325 | __set_state(hp, HVSI_OPEN); |
326 | break; | 326 | break; |
327 | default: | 327 | default: |
@@ -579,16 +579,16 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb) | |||
579 | struct hvsi_query packet __ALIGNED__; | 579 | struct hvsi_query packet __ALIGNED__; |
580 | int wrote; | 580 | int wrote; |
581 | 581 | ||
582 | packet.type = VS_QUERY_PACKET_HEADER; | 582 | packet.hdr.type = VS_QUERY_PACKET_HEADER; |
583 | packet.len = sizeof(struct hvsi_query); | 583 | packet.hdr.len = sizeof(struct hvsi_query); |
584 | packet.seqno = atomic_inc_return(&hp->seqno); | 584 | packet.hdr.seqno = atomic_inc_return(&hp->seqno); |
585 | packet.verb = verb; | 585 | packet.verb = verb; |
586 | 586 | ||
587 | pr_debug("%s: sending %i bytes\n", __func__, packet.len); | 587 | pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); |
588 | dbg_dump_hex((uint8_t*)&packet, packet.len); | 588 | dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); |
589 | 589 | ||
590 | wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len); | 590 | wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); |
591 | if (wrote != packet.len) { | 591 | if (wrote != packet.hdr.len) { |
592 | printk(KERN_ERR "hvsi%i: couldn't send query (%i)!\n", hp->index, | 592 | printk(KERN_ERR "hvsi%i: couldn't send query (%i)!\n", hp->index, |
593 | wrote); | 593 | wrote); |
594 | return -EIO; | 594 | return -EIO; |
@@ -622,20 +622,20 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl) | |||
622 | struct hvsi_control packet __ALIGNED__; | 622 | struct hvsi_control packet __ALIGNED__; |
623 | int wrote; | 623 | int wrote; |
624 | 624 | ||
625 | packet.type = VS_CONTROL_PACKET_HEADER, | 625 | packet.hdr.type = VS_CONTROL_PACKET_HEADER, |
626 | packet.seqno = atomic_inc_return(&hp->seqno); | 626 | packet.hdr.seqno = atomic_inc_return(&hp->seqno); |
627 | packet.len = sizeof(struct hvsi_control); | 627 | packet.hdr.len = sizeof(struct hvsi_control); |
628 | packet.verb = VSV_SET_MODEM_CTL; | 628 | packet.verb = VSV_SET_MODEM_CTL; |
629 | packet.mask = HVSI_TSDTR; | 629 | packet.mask = HVSI_TSDTR; |
630 | 630 | ||
631 | if (mctrl & TIOCM_DTR) | 631 | if (mctrl & TIOCM_DTR) |
632 | packet.word = HVSI_TSDTR; | 632 | packet.word = HVSI_TSDTR; |
633 | 633 | ||
634 | pr_debug("%s: sending %i bytes\n", __func__, packet.len); | 634 | pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); |
635 | dbg_dump_hex((uint8_t*)&packet, packet.len); | 635 | dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); |
636 | 636 | ||
637 | wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len); | 637 | wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); |
638 | if (wrote != packet.len) { | 638 | if (wrote != packet.hdr.len) { |
639 | printk(KERN_ERR "hvsi%i: couldn't set DTR!\n", hp->index); | 639 | printk(KERN_ERR "hvsi%i: couldn't set DTR!\n", hp->index); |
640 | return -EIO; | 640 | return -EIO; |
641 | } | 641 | } |
@@ -705,13 +705,13 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count) | |||
705 | 705 | ||
706 | BUG_ON(count > HVSI_MAX_OUTGOING_DATA); | 706 | BUG_ON(count > HVSI_MAX_OUTGOING_DATA); |
707 | 707 | ||
708 | packet.type = VS_DATA_PACKET_HEADER; | 708 | packet.hdr.type = VS_DATA_PACKET_HEADER; |
709 | packet.seqno = atomic_inc_return(&hp->seqno); | 709 | packet.hdr.seqno = atomic_inc_return(&hp->seqno); |
710 | packet.len = count + sizeof(struct hvsi_header); | 710 | packet.hdr.len = count + sizeof(struct hvsi_header); |
711 | memcpy(&packet.data, buf, count); | 711 | memcpy(&packet.data, buf, count); |
712 | 712 | ||
713 | ret = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len); | 713 | ret = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); |
714 | if (ret == packet.len) { | 714 | if (ret == packet.hdr.len) { |
715 | /* return the number of chars written, not the packet length */ | 715 | /* return the number of chars written, not the packet length */ |
716 | return count; | 716 | return count; |
717 | } | 717 | } |
@@ -722,15 +722,15 @@ static void hvsi_close_protocol(struct hvsi_struct *hp) | |||
722 | { | 722 | { |
723 | struct hvsi_control packet __ALIGNED__; | 723 | struct hvsi_control packet __ALIGNED__; |
724 | 724 | ||
725 | packet.type = VS_CONTROL_PACKET_HEADER; | 725 | packet.hdr.type = VS_CONTROL_PACKET_HEADER; |
726 | packet.seqno = atomic_inc_return(&hp->seqno); | 726 | packet.hdr.seqno = atomic_inc_return(&hp->seqno); |
727 | packet.len = 6; | 727 | packet.hdr.len = 6; |
728 | packet.verb = VSV_CLOSE_PROTOCOL; | 728 | packet.verb = VSV_CLOSE_PROTOCOL; |
729 | 729 | ||
730 | pr_debug("%s: sending %i bytes\n", __func__, packet.len); | 730 | pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); |
731 | dbg_dump_hex((uint8_t*)&packet, packet.len); | 731 | dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); |
732 | 732 | ||
733 | hvc_put_chars(hp->vtermno, (char *)&packet, packet.len); | 733 | hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); |
734 | } | 734 | } |
735 | 735 | ||
736 | static int hvsi_open(struct tty_struct *tty, struct file *filp) | 736 | static int hvsi_open(struct tty_struct *tty, struct file *filp) |