Commit b4abdfa4fbf4afaa7540ddaf814236e7844935ff

Authored by aurel32
1 parent 77f0435e

fix use of host serial port

Signed-off-by: David Ahern <daahern@cisco.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6556 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 19 additions and 8 deletions
qemu-char.c
... ... @@ -1047,17 +1047,17 @@ static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg)
1047 1047 int *targ = (int *)arg;
1048 1048 ioctl(s->fd_in, TIOCMGET, &sarg);
1049 1049 *targ = 0;
1050   - if (sarg | TIOCM_CTS)
  1050 + if (sarg & TIOCM_CTS)
1051 1051 *targ |= CHR_TIOCM_CTS;
1052   - if (sarg | TIOCM_CAR)
  1052 + if (sarg & TIOCM_CAR)
1053 1053 *targ |= CHR_TIOCM_CAR;
1054   - if (sarg | TIOCM_DSR)
  1054 + if (sarg & TIOCM_DSR)
1055 1055 *targ |= CHR_TIOCM_DSR;
1056   - if (sarg | TIOCM_RI)
  1056 + if (sarg & TIOCM_RI)
1057 1057 *targ |= CHR_TIOCM_RI;
1058   - if (sarg | TIOCM_DTR)
  1058 + if (sarg & TIOCM_DTR)
1059 1059 *targ |= CHR_TIOCM_DTR;
1060   - if (sarg | TIOCM_RTS)
  1060 + if (sarg & TIOCM_RTS)
1061 1061 *targ |= CHR_TIOCM_RTS;
1062 1062 }
1063 1063 break;
... ... @@ -1065,9 +1065,20 @@ static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg)
1065 1065 {
1066 1066 int sarg = *(int *)arg;
1067 1067 int targ = 0;
1068   - if (sarg | CHR_TIOCM_DTR)
  1068 + ioctl(s->fd_in, TIOCMGET, &targ);
  1069 + targ &= ~(CHR_TIOCM_CTS | CHR_TIOCM_CAR | CHR_TIOCM_DSR
  1070 + | CHR_TIOCM_RI | CHR_TIOCM_DTR | CHR_TIOCM_RTS);
  1071 + if (sarg & CHR_TIOCM_CTS)
  1072 + targ |= TIOCM_CTS;
  1073 + if (sarg & CHR_TIOCM_CAR)
  1074 + targ |= TIOCM_CAR;
  1075 + if (sarg & CHR_TIOCM_DSR)
  1076 + targ |= TIOCM_DSR;
  1077 + if (sarg & CHR_TIOCM_RI)
  1078 + targ |= TIOCM_RI;
  1079 + if (sarg & CHR_TIOCM_DTR)
1069 1080 targ |= TIOCM_DTR;
1070   - if (sarg | CHR_TIOCM_RTS)
  1081 + if (sarg & CHR_TIOCM_RTS)
1071 1082 targ |= TIOCM_RTS;
1072 1083 ioctl(s->fd_in, TIOCMSET, &targ);
1073 1084 }
... ...