1. tcflush implementation is wrong for HAVE_ASM_TERMBITS_H, please check and use appropriate flags for PURGE_RXABORT & PURGE_RXCLEAR. 2. In some cases both termios and termios2 cases return SUCCESS, you can put it out of the ifdef's 3. Also in some functions you need not keep the separate ifdefs for declaring the variables and actual functionality, you can put them in in one ifdef. for eg: get_hand_flow, get_line_control, get_special_chars, set_line_control, set_special_chars