Lines Matching +full:odd +full:- +full:parity

78 /* ---- Device functions ---- */
83 struct rfcomm_dlc *dlc = dev->dlc; in rfcomm_dev_destruct()
89 if (dlc->owner == dev) in rfcomm_dev_destruct()
90 dlc->owner = NULL; in rfcomm_dev_destruct()
95 if (dev->tty_dev) in rfcomm_dev_destruct()
96 tty_unregister_device(rfcomm_tty_driver, dev->id); in rfcomm_dev_destruct()
99 list_del(&dev->list); in rfcomm_dev_destruct()
109 /* device-specific initialization: open the dlc */
115 err = rfcomm_dlc_open(dev->dlc, &dev->src, &dev->dst, dev->channel); in rfcomm_dev_activate()
117 set_bit(TTY_IO_ERROR, &tty->flags); in rfcomm_dev_activate()
121 /* we block the open until the dlc->state becomes BT_CONNECTED */
126 return (dev->dlc->state == BT_CONNECTED); in rfcomm_dev_carrier_raised()
129 /* device-specific cleanup: close the dlc */
134 if (dev->tty_dev->parent) in rfcomm_dev_shutdown()
135 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST); in rfcomm_dev_shutdown()
138 rfcomm_dlc_close(dev->dlc, 0); in rfcomm_dev_shutdown()
153 if (dev->id == id) in __rfcomm_dev_lookup()
167 if (dev && !tty_port_get(&dev->port)) in rfcomm_dev_get()
180 hdev = hci_get_route(&dev->dst, &dev->src, BDADDR_BREDR); in rfcomm_reparent_device()
188 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &dev->dst); in rfcomm_reparent_device()
193 if (conn && device_is_registered(&conn->dev)) in rfcomm_reparent_device()
194 device_move(dev->tty_dev, &conn->dev, DPM_ORDER_DEV_AFTER_PARENT); in rfcomm_reparent_device()
204 return sprintf(buf, "%pMR\n", &dev->dst); in address_show()
211 return sprintf(buf, "%d\n", dev->channel); in channel_show()
226 return ERR_PTR(-ENOMEM); in __rfcomm_dev_add()
230 if (req->dev_id < 0) { in __rfcomm_dev_add()
231 dev->id = 0; in __rfcomm_dev_add()
234 if (entry->id != dev->id) in __rfcomm_dev_add()
237 dev->id++; in __rfcomm_dev_add()
238 head = &entry->list; in __rfcomm_dev_add()
241 dev->id = req->dev_id; in __rfcomm_dev_add()
244 if (entry->id == dev->id) { in __rfcomm_dev_add()
245 err = -EADDRINUSE; in __rfcomm_dev_add()
249 if (entry->id > dev->id - 1) in __rfcomm_dev_add()
252 head = &entry->list; in __rfcomm_dev_add()
256 if ((dev->id < 0) || (dev->id > RFCOMM_MAX_DEV - 1)) { in __rfcomm_dev_add()
257 err = -ENFILE; in __rfcomm_dev_add()
261 sprintf(dev->name, "rfcomm%d", dev->id); in __rfcomm_dev_add()
263 list_add(&dev->list, head); in __rfcomm_dev_add()
265 bacpy(&dev->src, &req->src); in __rfcomm_dev_add()
266 bacpy(&dev->dst, &req->dst); in __rfcomm_dev_add()
267 dev->channel = req->channel; in __rfcomm_dev_add()
269 dev->flags = req->flags & in __rfcomm_dev_add()
272 tty_port_init(&dev->port); in __rfcomm_dev_add()
273 dev->port.ops = &rfcomm_port_ops; in __rfcomm_dev_add()
275 skb_queue_head_init(&dev->pending); in __rfcomm_dev_add()
279 if (req->flags & (1 << RFCOMM_REUSE_DLC)) { in __rfcomm_dev_add()
280 struct sock *sk = dlc->owner; in __rfcomm_dev_add()
287 while ((skb = skb_dequeue(&sk->sk_receive_queue))) { in __rfcomm_dev_add()
289 skb_queue_tail(&dev->pending, skb); in __rfcomm_dev_add()
290 atomic_sub(skb->len, &sk->sk_rmem_alloc); in __rfcomm_dev_add()
294 dlc->data_ready = rfcomm_dev_data_ready; in __rfcomm_dev_add()
295 dlc->state_change = rfcomm_dev_state_change; in __rfcomm_dev_add()
296 dlc->modem_status = rfcomm_dev_modem_status; in __rfcomm_dev_add()
298 dlc->owner = dev; in __rfcomm_dev_add()
299 dev->dlc = dlc; in __rfcomm_dev_add()
301 rfcomm_dev_modem_status(dlc, dlc->remote_v24_sig); in __rfcomm_dev_add()
323 BT_DBG("id %d channel %d", req->dev_id, req->channel); in rfcomm_dev_add()
331 tty = tty_port_register_device(&dev->port, rfcomm_tty_driver, in rfcomm_dev_add()
332 dev->id, NULL); in rfcomm_dev_add()
334 tty_port_put(&dev->port); in rfcomm_dev_add()
338 dev->tty_dev = tty; in rfcomm_dev_add()
340 dev_set_drvdata(dev->tty_dev, dev); in rfcomm_dev_add()
342 if (device_create_file(dev->tty_dev, &dev_attr_address) < 0) in rfcomm_dev_add()
345 if (device_create_file(dev->tty_dev, &dev_attr_channel) < 0) in rfcomm_dev_add()
348 return dev->id; in rfcomm_dev_add()
351 /* ---- Send buffer ---- */
354 struct rfcomm_dlc *dlc = dev->dlc; in rfcomm_room()
357 int pending = 40 - atomic_read(&dev->wmem_alloc); in rfcomm_room()
359 return max(0, pending) * dlc->mtu; in rfcomm_room()
364 struct rfcomm_dev *dev = (void *) skb->sk; in rfcomm_wfree()
365 atomic_dec(&dev->wmem_alloc); in rfcomm_wfree()
366 if (test_bit(RFCOMM_TTY_ATTACHED, &dev->flags)) in rfcomm_wfree()
367 tty_port_tty_wakeup(&dev->port); in rfcomm_wfree()
368 tty_port_put(&dev->port); in rfcomm_wfree()
373 tty_port_get(&dev->port); in rfcomm_set_owner_w()
374 atomic_inc(&dev->wmem_alloc); in rfcomm_set_owner_w()
375 skb->sk = (void *) dev; in rfcomm_set_owner_w()
376 skb->destructor = rfcomm_wfree; in rfcomm_set_owner_w()
387 /* ---- Device IOCTLs ---- */
398 return -EFAULT; in __rfcomm_create_dev()
403 return -EPERM; in __rfcomm_create_dev()
407 if (sk->sk_state != BT_CONNECTED) in __rfcomm_create_dev()
408 return -EBADFD; in __rfcomm_create_dev()
410 dlc = rfcomm_pi(sk)->dlc; in __rfcomm_create_dev()
418 return -EBUSY; in __rfcomm_create_dev()
421 return -ENOMEM; in __rfcomm_create_dev()
431 sk->sk_state = BT_CLOSED; in __rfcomm_create_dev()
444 return -EFAULT; in __rfcomm_release_dev()
450 return -ENODEV; in __rfcomm_release_dev()
452 if (dev->flags != NOCAP_FLAGS && !capable(CAP_NET_ADMIN)) { in __rfcomm_release_dev()
453 tty_port_put(&dev->port); in __rfcomm_release_dev()
454 return -EPERM; in __rfcomm_release_dev()
458 if (test_and_set_bit(RFCOMM_DEV_RELEASED, &dev->status)) { in __rfcomm_release_dev()
459 tty_port_put(&dev->port); in __rfcomm_release_dev()
460 return -EALREADY; in __rfcomm_release_dev()
464 rfcomm_dlc_close(dev->dlc, 0); in __rfcomm_release_dev()
467 tty = tty_port_tty_get(&dev->port); in __rfcomm_release_dev()
473 if (!test_bit(RFCOMM_TTY_OWNED, &dev->status)) in __rfcomm_release_dev()
474 tty_port_put(&dev->port); in __rfcomm_release_dev()
476 tty_port_put(&dev->port); in __rfcomm_release_dev()
513 return -EFAULT; in rfcomm_get_dev_list()
516 return -EINVAL; in rfcomm_get_dev_list()
522 return -ENOMEM; in rfcomm_get_dev_list()
524 di = dl->dev_info; in rfcomm_get_dev_list()
529 if (!tty_port_get(&dev->port)) in rfcomm_get_dev_list()
531 (di + n)->id = dev->id; in rfcomm_get_dev_list()
532 (di + n)->flags = dev->flags; in rfcomm_get_dev_list()
533 (di + n)->state = dev->dlc->state; in rfcomm_get_dev_list()
534 (di + n)->channel = dev->channel; in rfcomm_get_dev_list()
535 bacpy(&(di + n)->src, &dev->src); in rfcomm_get_dev_list()
536 bacpy(&(di + n)->dst, &dev->dst); in rfcomm_get_dev_list()
537 tty_port_put(&dev->port); in rfcomm_get_dev_list()
544 dl->dev_num = n; in rfcomm_get_dev_list()
550 return err ? -EFAULT : 0; in rfcomm_get_dev_list()
562 return -EFAULT; in rfcomm_get_dev_info()
566 return -ENODEV; in rfcomm_get_dev_info()
568 di.flags = dev->flags; in rfcomm_get_dev_info()
569 di.channel = dev->channel; in rfcomm_get_dev_info()
570 di.state = dev->dlc->state; in rfcomm_get_dev_info()
571 bacpy(&di.src, &dev->src); in rfcomm_get_dev_info()
572 bacpy(&di.dst, &dev->dst); in rfcomm_get_dev_info()
575 err = -EFAULT; in rfcomm_get_dev_info()
577 tty_port_put(&dev->port); in rfcomm_get_dev_info()
599 return -EINVAL; in rfcomm_dev_ioctl()
602 /* ---- DLC callbacks ---- */
605 struct rfcomm_dev *dev = dlc->owner; in rfcomm_dev_data_ready()
612 if (!skb_queue_empty(&dev->pending)) { in rfcomm_dev_data_ready()
613 skb_queue_tail(&dev->pending, skb); in rfcomm_dev_data_ready()
617 BT_DBG("dlc %p len %d", dlc, skb->len); in rfcomm_dev_data_ready()
619 tty_insert_flip_string(&dev->port, skb->data, skb->len); in rfcomm_dev_data_ready()
620 tty_flip_buffer_push(&dev->port); in rfcomm_dev_data_ready()
627 struct rfcomm_dev *dev = dlc->owner; in rfcomm_dev_state_change()
633 dev->err = err; in rfcomm_dev_state_change()
634 if (dlc->state == BT_CONNECTED) { in rfcomm_dev_state_change()
637 wake_up_interruptible(&dev->port.open_wait); in rfcomm_dev_state_change()
638 } else if (dlc->state == BT_CLOSED) in rfcomm_dev_state_change()
639 tty_port_tty_hangup(&dev->port, false); in rfcomm_dev_state_change()
644 struct rfcomm_dev *dev = dlc->owner; in rfcomm_dev_modem_status()
650 if ((dev->modem_status & TIOCM_CD) && !(v24_sig & RFCOMM_V24_DV)) in rfcomm_dev_modem_status()
651 tty_port_tty_hangup(&dev->port, true); in rfcomm_dev_modem_status()
653 dev->modem_status = in rfcomm_dev_modem_status()
660 /* ---- TTY functions ---- */
668 rfcomm_dlc_lock(dev->dlc); in rfcomm_tty_copy_pending()
670 while ((skb = skb_dequeue(&dev->pending))) { in rfcomm_tty_copy_pending()
671 inserted += tty_insert_flip_string(&dev->port, skb->data, in rfcomm_tty_copy_pending()
672 skb->len); in rfcomm_tty_copy_pending()
676 rfcomm_dlc_unlock(dev->dlc); in rfcomm_tty_copy_pending()
679 tty_flip_buffer_push(&dev->port); in rfcomm_tty_copy_pending()
687 struct rfcomm_dev *dev = tty->driver_data; in rfcomm_tty_cleanup()
689 clear_bit(RFCOMM_TTY_ATTACHED, &dev->flags); in rfcomm_tty_cleanup()
691 rfcomm_dlc_lock(dev->dlc); in rfcomm_tty_cleanup()
692 tty->driver_data = NULL; in rfcomm_tty_cleanup()
693 rfcomm_dlc_unlock(dev->dlc); in rfcomm_tty_cleanup()
696 * purge the dlc->tx_queue to avoid circular dependencies in rfcomm_tty_cleanup()
699 skb_queue_purge(&dev->dlc->tx_queue); in rfcomm_tty_cleanup()
701 tty_port_put(&dev->port); in rfcomm_tty_cleanup()
714 dev = rfcomm_dev_get(tty->index); in rfcomm_tty_install()
716 return -ENODEV; in rfcomm_tty_install()
718 dlc = dev->dlc; in rfcomm_tty_install()
722 tty->driver_data = dev; in rfcomm_tty_install()
724 set_bit(RFCOMM_TTY_ATTACHED, &dev->flags); in rfcomm_tty_install()
727 err = tty_port_install(&dev->port, driver, tty); in rfcomm_tty_install()
738 if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) { in rfcomm_tty_install()
739 set_bit(RFCOMM_TTY_OWNED, &dev->status); in rfcomm_tty_install()
740 tty_port_put(&dev->port); in rfcomm_tty_install()
748 struct rfcomm_dev *dev = tty->driver_data; in rfcomm_tty_open()
751 BT_DBG("tty %p id %d", tty, tty->index); in rfcomm_tty_open()
753 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst, in rfcomm_tty_open()
754 dev->channel, dev->port.count); in rfcomm_tty_open()
756 err = tty_port_open(&dev->port, tty, filp); in rfcomm_tty_open()
767 rfcomm_dlc_unthrottle(dev->dlc); in rfcomm_tty_open()
774 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_close()
776 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc, in rfcomm_tty_close()
777 dev->port.count); in rfcomm_tty_close()
779 tty_port_close(&dev->port, tty, filp); in rfcomm_tty_close()
784 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_write()
785 struct rfcomm_dlc *dlc = dev->dlc; in rfcomm_tty_write()
792 size = min_t(uint, count, dlc->mtu); in rfcomm_tty_write()
805 count -= size; in rfcomm_tty_write()
813 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_write_room()
816 if (dev && dev->dlc) in rfcomm_tty_write_room()
831 return -ENOIOCTLCMD; in rfcomm_tty_ioctl()
835 return -ENOIOCTLCMD; in rfcomm_tty_ioctl()
843 return -ENOIOCTLCMD; in rfcomm_tty_ioctl()
847 return -ENOIOCTLCMD; in rfcomm_tty_ioctl()
850 return -ENOIOCTLCMD; /* ioctls which we must ignore */ in rfcomm_tty_ioctl()
854 return -ENOIOCTLCMD; in rfcomm_tty_ioctl()
860 struct ktermios *new = &tty->termios; in rfcomm_tty_set_termios()
864 u8 baud, data_bits, stop_bits, parity, x_on, x_off; in rfcomm_tty_set_termios() local
867 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_set_termios()
871 if (!dev || !dev->dlc || !dev->dlc->session) in rfcomm_tty_set_termios()
875 if ((old->c_cflag & CRTSCTS) && !(new->c_cflag & CRTSCTS)) in rfcomm_tty_set_termios()
878 /* Parity on/off and when on, odd/even */ in rfcomm_tty_set_termios()
879 if (((old->c_cflag & PARENB) != (new->c_cflag & PARENB)) || in rfcomm_tty_set_termios()
880 ((old->c_cflag & PARODD) != (new->c_cflag & PARODD))) { in rfcomm_tty_set_termios()
882 BT_DBG("Parity change detected."); in rfcomm_tty_set_termios()
885 /* Mark and space parity are not supported! */ in rfcomm_tty_set_termios()
886 if (new->c_cflag & PARENB) { in rfcomm_tty_set_termios()
887 if (new->c_cflag & PARODD) { in rfcomm_tty_set_termios()
888 BT_DBG("Parity is ODD"); in rfcomm_tty_set_termios()
889 parity = RFCOMM_RPN_PARITY_ODD; in rfcomm_tty_set_termios()
891 BT_DBG("Parity is EVEN"); in rfcomm_tty_set_termios()
892 parity = RFCOMM_RPN_PARITY_EVEN; in rfcomm_tty_set_termios()
895 BT_DBG("Parity is OFF"); in rfcomm_tty_set_termios()
896 parity = RFCOMM_RPN_PARITY_NONE; in rfcomm_tty_set_termios()
900 if (old->c_cc[VSTOP] != new->c_cc[VSTOP]) { in rfcomm_tty_set_termios()
902 x_on = new->c_cc[VSTOP]; in rfcomm_tty_set_termios()
909 if (old->c_cc[VSTART] != new->c_cc[VSTART]) { in rfcomm_tty_set_termios()
911 x_off = new->c_cc[VSTART]; in rfcomm_tty_set_termios()
919 if ((old->c_cflag & CSTOPB) != (new->c_cflag & CSTOPB)) in rfcomm_tty_set_termios()
925 if (new->c_cflag & CSTOPB) in rfcomm_tty_set_termios()
930 /* Handle number of data bits [5-8] */ in rfcomm_tty_set_termios()
931 if ((old->c_cflag & CSIZE) != (new->c_cflag & CSIZE)) in rfcomm_tty_set_termios()
934 switch (new->c_cflag & CSIZE) { in rfcomm_tty_set_termios()
992 rfcomm_send_rpn(dev->dlc->session, 1, dev->dlc->dlci, baud, in rfcomm_tty_set_termios()
993 data_bits, stop_bits, parity, in rfcomm_tty_set_termios()
999 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_throttle()
1003 rfcomm_dlc_throttle(dev->dlc); in rfcomm_tty_throttle()
1008 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_unthrottle()
1012 rfcomm_dlc_unthrottle(dev->dlc); in rfcomm_tty_unthrottle()
1017 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_chars_in_buffer()
1021 if (!dev || !dev->dlc) in rfcomm_tty_chars_in_buffer()
1024 if (!skb_queue_empty(&dev->dlc->tx_queue)) in rfcomm_tty_chars_in_buffer()
1025 return dev->dlc->mtu; in rfcomm_tty_chars_in_buffer()
1032 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_flush_buffer()
1036 if (!dev || !dev->dlc) in rfcomm_tty_flush_buffer()
1039 skb_queue_purge(&dev->dlc->tx_queue); in rfcomm_tty_flush_buffer()
1055 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_hangup()
1059 tty_port_hangup(&dev->port); in rfcomm_tty_hangup()
1064 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_tiocmget()
1068 return dev->modem_status; in rfcomm_tty_tiocmget()
1073 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_tiocmset()
1074 struct rfcomm_dlc *dlc = dev->dlc; in rfcomm_tty_tiocmset()
1104 /* ---- TTY structure ---- */
1135 rfcomm_tty_driver->driver_name = "rfcomm"; in rfcomm_init_ttys()
1136 rfcomm_tty_driver->name = "rfcomm"; in rfcomm_init_ttys()
1137 rfcomm_tty_driver->major = RFCOMM_TTY_MAJOR; in rfcomm_init_ttys()
1138 rfcomm_tty_driver->minor_start = RFCOMM_TTY_MINOR; in rfcomm_init_ttys()
1139 rfcomm_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; in rfcomm_init_ttys()
1140 rfcomm_tty_driver->subtype = SERIAL_TYPE_NORMAL; in rfcomm_init_ttys()
1141 rfcomm_tty_driver->init_termios = tty_std_termios; in rfcomm_init_ttys()
1142 rfcomm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL; in rfcomm_init_ttys()
1143 rfcomm_tty_driver->init_termios.c_lflag &= ~ICANON; in rfcomm_init_ttys()