aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2011-06-16 11:08:24 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2011-06-29 03:48:30 -0400
commit048bee7718bb3532aa96d0ce8572cced2ea951e6 (patch)
treed29b370d9d467a541b510f60f6316e0f7636bd1a /drivers/tty
parent725e789f228641fdfafcd65458f0ac78b87acc5a (diff)
powerpc/pseries: Factor HVSI header struct in packet definitions
Embed the struct hvsi_header in the various packet definitions rather than open coding it multiple times. Will help provide stronger type checking. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/hvc/hvsi.c66
1 files changed, 33 insertions, 33 deletions
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
736static int hvsi_open(struct tty_struct *tty, struct file *filp) 736static int hvsi_open(struct tty_struct *tty, struct file *filp)