--- linux-2.6.0-test1/net/bluetooth/rfcomm/tty.c.orig 2003-07-15 00:39:01.000000000 +0200 +++ linux-2.6.0-test1/net/bluetooth/rfcomm/tty.c 2003-07-18 19:54:41.686614720 +0200 @@ -668,40 +668,8 @@ return room; } -static int rfcomm_tty_set_modem_status(uint cmd, struct rfcomm_dlc *dlc, uint status) -{ - u8 v24_sig, mask; - - BT_DBG("dlc %p cmd 0x%02x", dlc, cmd); - - if (cmd == TIOCMSET) - v24_sig = 0; - else - rfcomm_dlc_get_modem_status(dlc, &v24_sig); - - mask = ((status & TIOCM_DSR) ? RFCOMM_V24_RTC : 0) | - ((status & TIOCM_DTR) ? RFCOMM_V24_RTC : 0) | - ((status & TIOCM_RTS) ? RFCOMM_V24_RTR : 0) | - ((status & TIOCM_CTS) ? RFCOMM_V24_RTR : 0) | - ((status & TIOCM_RI) ? RFCOMM_V24_IC : 0) | - ((status & TIOCM_CD) ? RFCOMM_V24_DV : 0); - - if (cmd == TIOCMBIC) - v24_sig &= ~mask; - else - v24_sig |= mask; - - rfcomm_dlc_set_modem_status(dlc, v24_sig); - return 0; -} - static int rfcomm_tty_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, unsigned long arg) { - struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; - struct rfcomm_dlc *dlc = dev->dlc; - uint status; - int err; - BT_DBG("tty %p cmd 0x%02x", tty, cmd); switch (cmd) { @@ -713,18 +681,6 @@ BT_DBG("TCSETS is not supported"); return -ENOIOCTLCMD; - case TIOCMGET: - BT_DBG("TIOCMGET"); - - return put_user(dev->modem_status, (unsigned int *)arg); - - case TIOCMSET: /* Turns on and off the lines as specified by the mask */ - case TIOCMBIS: /* Turns on the lines as specified by the mask */ - case TIOCMBIC: /* Turns off the lines as specified by the mask */ - if ((err = get_user(status, (unsigned int *)arg))) - return err; - return rfcomm_tty_set_modem_status(cmd, dlc, status); - case TIOCMIWAIT: BT_DBG("TIOCMIWAIT"); break; @@ -851,6 +807,44 @@ return 0; } +static int rfcomm_tty_tiocmget(struct tty_struct *tty, struct file *file) +{ + struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; + + return dev->modem_status; +} + +static int rfcomm_tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) +{ + struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; + struct rfcomm_dlc *dlc = dev->dlc; + u8 v24_sig; + + BT_DBG("dlc %p tiocmset(%x,%x)", dlc, set, clear); + + rfcomm_dlc_get_modem_status(dlc, &v24_sig); + + if (set & TIOCM_DSR || set & TIOCM_DTR) + v24_sig |= RFCOMM_V24_RTC; + if (set & TIOCM_RTS || set & TIOCM_CTS) + v24_sig |= RFCOMM_V24_RTR; + if (set & TIOCM_RI) + v24_sig |= RFCOMM_V24_IC; + if (set & TIOCM_CD) + v24_sig |= RFCOMM_V24_DV; + if (clear & TIOCM_DSR || clear & TIOCM_DTR) + v24_sig &= ~RFCOMM_V24_RTC; + if (clear & TIOCM_RTS || clear & TIOCM_CTS) + v24_sig &= ~RFCOMM_V24_RTR; + if (clear & TIOCM_RI) + v24_sig &= ~RFCOMM_V24_IC; + if (clear & TIOCM_CD) + v24_sig &= ~RFCOMM_V24_DV; + + rfcomm_dlc_set_modem_status(dlc, v24_sig); + return 0; +} + /* ---- TTY structure ---- */ static struct tty_driver *rfcomm_tty_driver; @@ -870,6 +864,8 @@ .hangup = rfcomm_tty_hangup, .wait_until_sent = rfcomm_tty_wait_until_sent, .read_proc = rfcomm_tty_read_proc, + .tiocmget = rfcomm_tty_tiocmget, + .tiocmset = rfcomm_tty_tiocmset, }; int rfcomm_init_ttys(void)