Since the c_ispeed and c_ospeed fields are marked unused, and since I don't see
how one could actually apply different speeds, make cf{set|get}{i|o}speed() use the c_cflag field with the CBAUD mask instead. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42160 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
aa2a6e33cb
commit
75a4759d33
@ -103,7 +103,7 @@ tcsendbreak(int fd, int duration)
|
||||
speed_t
|
||||
cfgetispeed(const struct termios *termios)
|
||||
{
|
||||
return termios->c_ispeed;
|
||||
return termios->c_cflag & CBAUD;
|
||||
}
|
||||
|
||||
|
||||
@ -115,12 +115,13 @@ cfsetispeed(struct termios *termios, speed_t speed)
|
||||
the maximum value defined in termios.h
|
||||
Note that errors from hardware device are detected only
|
||||
until the tcsetattr() function is called */
|
||||
if (speed > B230400) {
|
||||
if (speed > B230400 || (speed & CBAUD) != speed) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
termios->c_ispeed = speed;
|
||||
termios->c_cflag &= ~CBAUD;
|
||||
termios->c_cflag |= speed;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -128,7 +129,7 @@ cfsetispeed(struct termios *termios, speed_t speed)
|
||||
speed_t
|
||||
cfgetospeed(const struct termios *termios)
|
||||
{
|
||||
return termios->c_ospeed;
|
||||
return termios->c_cflag & CBAUD;
|
||||
}
|
||||
|
||||
|
||||
@ -136,11 +137,12 @@ int
|
||||
cfsetospeed(struct termios *termios, speed_t speed)
|
||||
{
|
||||
/* Check for unaccepted speed values (see above) */
|
||||
if (speed > B230400) {
|
||||
if (speed > B230400 || (speed & CBAUD) != speed) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
termios->c_ospeed = speed;
|
||||
termios->c_cflag &= ~CBAUD;
|
||||
termios->c_cflag |= speed;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user