Lines Matching refs:dev

83 	struct rfcomm_dev *dev = container_of(port, struct rfcomm_dev, port);  in rfcomm_dev_destruct()  local
84 struct rfcomm_dlc *dlc = dev->dlc; in rfcomm_dev_destruct()
86 BT_DBG("dev %p dlc %p", dev, dlc); in rfcomm_dev_destruct()
90 if (dlc->owner == dev) in rfcomm_dev_destruct()
96 if (dev->tty_dev) in rfcomm_dev_destruct()
97 tty_unregister_device(rfcomm_tty_driver, dev->id); in rfcomm_dev_destruct()
100 list_del(&dev->list); in rfcomm_dev_destruct()
103 kfree(dev); in rfcomm_dev_destruct()
113 struct rfcomm_dev *dev = container_of(port, struct rfcomm_dev, port); in rfcomm_dev_activate() local
116 err = rfcomm_dlc_open(dev->dlc, &dev->src, &dev->dst, dev->channel); in rfcomm_dev_activate()
125 struct rfcomm_dev *dev = container_of(port, struct rfcomm_dev, port); in rfcomm_dev_carrier_raised() local
127 return (dev->dlc->state == BT_CONNECTED); in rfcomm_dev_carrier_raised()
133 struct rfcomm_dev *dev = container_of(port, struct rfcomm_dev, port); in rfcomm_dev_shutdown() local
135 if (dev->tty_dev->parent) in rfcomm_dev_shutdown()
136 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST); in rfcomm_dev_shutdown()
139 rfcomm_dlc_close(dev->dlc, 0); in rfcomm_dev_shutdown()
151 struct rfcomm_dev *dev; in __rfcomm_dev_lookup() local
153 list_for_each_entry(dev, &rfcomm_dev_list, list) in __rfcomm_dev_lookup()
154 if (dev->id == id) in __rfcomm_dev_lookup()
155 return dev; in __rfcomm_dev_lookup()
162 struct rfcomm_dev *dev; in rfcomm_dev_get() local
166 dev = __rfcomm_dev_lookup(id); in rfcomm_dev_get()
168 if (dev && !tty_port_get(&dev->port)) in rfcomm_dev_get()
169 dev = NULL; in rfcomm_dev_get()
173 return dev; in rfcomm_dev_get()
176 static void rfcomm_reparent_device(struct rfcomm_dev *dev) in rfcomm_reparent_device() argument
181 hdev = hci_get_route(&dev->dst, &dev->src); in rfcomm_reparent_device()
189 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &dev->dst); in rfcomm_reparent_device()
194 if (conn && device_is_registered(&conn->dev)) in rfcomm_reparent_device()
195 device_move(dev->tty_dev, &conn->dev, DPM_ORDER_DEV_AFTER_PARENT); in rfcomm_reparent_device()
203 struct rfcomm_dev *dev = dev_get_drvdata(tty_dev); in show_address() local
204 return sprintf(buf, "%pMR\n", &dev->dst); in show_address()
209 struct rfcomm_dev *dev = dev_get_drvdata(tty_dev); in show_channel() local
210 return sprintf(buf, "%d\n", dev->channel); in show_channel()
219 struct rfcomm_dev *dev, *entry; in __rfcomm_dev_add() local
223 dev = kzalloc(sizeof(struct rfcomm_dev), GFP_KERNEL); in __rfcomm_dev_add()
224 if (!dev) in __rfcomm_dev_add()
230 dev->id = 0; in __rfcomm_dev_add()
233 if (entry->id != dev->id) in __rfcomm_dev_add()
236 dev->id++; in __rfcomm_dev_add()
240 dev->id = req->dev_id; in __rfcomm_dev_add()
243 if (entry->id == dev->id) { in __rfcomm_dev_add()
248 if (entry->id > dev->id - 1) in __rfcomm_dev_add()
255 if ((dev->id < 0) || (dev->id > RFCOMM_MAX_DEV - 1)) { in __rfcomm_dev_add()
260 sprintf(dev->name, "rfcomm%d", dev->id); in __rfcomm_dev_add()
262 list_add(&dev->list, head); in __rfcomm_dev_add()
264 bacpy(&dev->src, &req->src); in __rfcomm_dev_add()
265 bacpy(&dev->dst, &req->dst); in __rfcomm_dev_add()
266 dev->channel = req->channel; in __rfcomm_dev_add()
268 dev->flags = req->flags & in __rfcomm_dev_add()
271 tty_port_init(&dev->port); in __rfcomm_dev_add()
272 dev->port.ops = &rfcomm_port_ops; in __rfcomm_dev_add()
274 skb_queue_head_init(&dev->pending); in __rfcomm_dev_add()
288 skb_queue_tail(&dev->pending, skb); in __rfcomm_dev_add()
297 dlc->owner = dev; in __rfcomm_dev_add()
298 dev->dlc = dlc; in __rfcomm_dev_add()
309 return dev; in __rfcomm_dev_add()
313 kfree(dev); in __rfcomm_dev_add()
319 struct rfcomm_dev *dev; in rfcomm_dev_add() local
324 dev = __rfcomm_dev_add(req, dlc); in rfcomm_dev_add()
325 if (IS_ERR(dev)) { in rfcomm_dev_add()
327 return PTR_ERR(dev); in rfcomm_dev_add()
330 tty = tty_port_register_device(&dev->port, rfcomm_tty_driver, in rfcomm_dev_add()
331 dev->id, NULL); in rfcomm_dev_add()
333 tty_port_put(&dev->port); in rfcomm_dev_add()
337 dev->tty_dev = tty; in rfcomm_dev_add()
338 rfcomm_reparent_device(dev); in rfcomm_dev_add()
339 dev_set_drvdata(dev->tty_dev, dev); in rfcomm_dev_add()
341 if (device_create_file(dev->tty_dev, &dev_attr_address) < 0) in rfcomm_dev_add()
344 if (device_create_file(dev->tty_dev, &dev_attr_channel) < 0) in rfcomm_dev_add()
347 return dev->id; in rfcomm_dev_add()
351 static inline unsigned int rfcomm_room(struct rfcomm_dev *dev) in rfcomm_room() argument
353 struct rfcomm_dlc *dlc = dev->dlc; in rfcomm_room()
356 int pending = 40 - atomic_read(&dev->wmem_alloc); in rfcomm_room()
363 struct rfcomm_dev *dev = (void *) skb->sk; in rfcomm_wfree() local
364 atomic_dec(&dev->wmem_alloc); in rfcomm_wfree()
365 if (test_bit(RFCOMM_TTY_ATTACHED, &dev->flags)) in rfcomm_wfree()
366 tty_port_tty_wakeup(&dev->port); in rfcomm_wfree()
367 tty_port_put(&dev->port); in rfcomm_wfree()
370 static void rfcomm_set_owner_w(struct sk_buff *skb, struct rfcomm_dev *dev) in rfcomm_set_owner_w() argument
372 tty_port_get(&dev->port); in rfcomm_set_owner_w()
373 atomic_inc(&dev->wmem_alloc); in rfcomm_set_owner_w()
374 skb->sk = (void *) dev; in rfcomm_set_owner_w()
378 static struct sk_buff *rfcomm_wmalloc(struct rfcomm_dev *dev, unsigned long size, gfp_t priority) in rfcomm_wmalloc() argument
382 rfcomm_set_owner_w(skb, dev); in rfcomm_wmalloc()
441 struct rfcomm_dev *dev; in __rfcomm_release_dev() local
449 dev = rfcomm_dev_get(req.dev_id); in __rfcomm_release_dev()
450 if (!dev) in __rfcomm_release_dev()
453 if (dev->flags != NOCAP_FLAGS && !capable(CAP_NET_ADMIN)) { in __rfcomm_release_dev()
454 tty_port_put(&dev->port); in __rfcomm_release_dev()
459 if (test_and_set_bit(RFCOMM_DEV_RELEASED, &dev->status)) { in __rfcomm_release_dev()
460 tty_port_put(&dev->port); in __rfcomm_release_dev()
465 rfcomm_dlc_close(dev->dlc, 0); in __rfcomm_release_dev()
468 tty = tty_port_tty_get(&dev->port); in __rfcomm_release_dev()
474 if (!test_bit(RFCOMM_TTY_OWNED, &dev->status)) in __rfcomm_release_dev()
475 tty_port_put(&dev->port); in __rfcomm_release_dev()
477 tty_port_put(&dev->port); in __rfcomm_release_dev()
505 struct rfcomm_dev *dev; in rfcomm_get_dev_list() local
529 list_for_each_entry(dev, &rfcomm_dev_list, list) { in rfcomm_get_dev_list()
530 if (!tty_port_get(&dev->port)) in rfcomm_get_dev_list()
532 (di + n)->id = dev->id; in rfcomm_get_dev_list()
533 (di + n)->flags = dev->flags; in rfcomm_get_dev_list()
534 (di + n)->state = dev->dlc->state; in rfcomm_get_dev_list()
535 (di + n)->channel = dev->channel; in rfcomm_get_dev_list()
536 bacpy(&(di + n)->src, &dev->src); in rfcomm_get_dev_list()
537 bacpy(&(di + n)->dst, &dev->dst); in rfcomm_get_dev_list()
538 tty_port_put(&dev->port); in rfcomm_get_dev_list()
556 struct rfcomm_dev *dev; in rfcomm_get_dev_info() local
565 dev = rfcomm_dev_get(di.id); in rfcomm_get_dev_info()
566 if (!dev) in rfcomm_get_dev_info()
569 di.flags = dev->flags; in rfcomm_get_dev_info()
570 di.channel = dev->channel; in rfcomm_get_dev_info()
571 di.state = dev->dlc->state; in rfcomm_get_dev_info()
572 bacpy(&di.src, &dev->src); in rfcomm_get_dev_info()
573 bacpy(&di.dst, &dev->dst); in rfcomm_get_dev_info()
578 tty_port_put(&dev->port); in rfcomm_get_dev_info()
606 struct rfcomm_dev *dev = dlc->owner; in rfcomm_dev_data_ready() local
608 if (!dev) { in rfcomm_dev_data_ready()
613 if (!skb_queue_empty(&dev->pending)) { in rfcomm_dev_data_ready()
614 skb_queue_tail(&dev->pending, skb); in rfcomm_dev_data_ready()
620 tty_insert_flip_string(&dev->port, skb->data, skb->len); in rfcomm_dev_data_ready()
621 tty_flip_buffer_push(&dev->port); in rfcomm_dev_data_ready()
628 struct rfcomm_dev *dev = dlc->owner; in rfcomm_dev_state_change() local
629 if (!dev) in rfcomm_dev_state_change()
632 BT_DBG("dlc %p dev %p err %d", dlc, dev, err); in rfcomm_dev_state_change()
634 dev->err = err; in rfcomm_dev_state_change()
636 rfcomm_reparent_device(dev); in rfcomm_dev_state_change()
638 wake_up_interruptible(&dev->port.open_wait); in rfcomm_dev_state_change()
640 tty_port_tty_hangup(&dev->port, false); in rfcomm_dev_state_change()
645 struct rfcomm_dev *dev = dlc->owner; in rfcomm_dev_modem_status() local
646 if (!dev) in rfcomm_dev_modem_status()
649 BT_DBG("dlc %p dev %p v24_sig 0x%02x", dlc, dev, v24_sig); in rfcomm_dev_modem_status()
651 if ((dev->modem_status & TIOCM_CD) && !(v24_sig & RFCOMM_V24_DV)) in rfcomm_dev_modem_status()
652 tty_port_tty_hangup(&dev->port, true); in rfcomm_dev_modem_status()
654 dev->modem_status = in rfcomm_dev_modem_status()
662 static void rfcomm_tty_copy_pending(struct rfcomm_dev *dev) in rfcomm_tty_copy_pending() argument
667 BT_DBG("dev %p", dev); in rfcomm_tty_copy_pending()
669 rfcomm_dlc_lock(dev->dlc); in rfcomm_tty_copy_pending()
671 while ((skb = skb_dequeue(&dev->pending))) { in rfcomm_tty_copy_pending()
672 inserted += tty_insert_flip_string(&dev->port, skb->data, in rfcomm_tty_copy_pending()
677 rfcomm_dlc_unlock(dev->dlc); in rfcomm_tty_copy_pending()
680 tty_flip_buffer_push(&dev->port); in rfcomm_tty_copy_pending()
688 struct rfcomm_dev *dev = tty->driver_data; in rfcomm_tty_cleanup() local
690 clear_bit(RFCOMM_TTY_ATTACHED, &dev->flags); in rfcomm_tty_cleanup()
692 rfcomm_dlc_lock(dev->dlc); in rfcomm_tty_cleanup()
694 rfcomm_dlc_unlock(dev->dlc); in rfcomm_tty_cleanup()
700 skb_queue_purge(&dev->dlc->tx_queue); in rfcomm_tty_cleanup()
702 tty_port_put(&dev->port); in rfcomm_tty_cleanup()
711 struct rfcomm_dev *dev; in rfcomm_tty_install() local
715 dev = rfcomm_dev_get(tty->index); in rfcomm_tty_install()
716 if (!dev) in rfcomm_tty_install()
719 dlc = dev->dlc; in rfcomm_tty_install()
723 tty->driver_data = dev; in rfcomm_tty_install()
725 set_bit(RFCOMM_TTY_ATTACHED, &dev->flags); in rfcomm_tty_install()
728 err = tty_port_install(&dev->port, driver, tty); in rfcomm_tty_install()
739 if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) { in rfcomm_tty_install()
740 set_bit(RFCOMM_TTY_OWNED, &dev->status); in rfcomm_tty_install()
741 tty_port_put(&dev->port); in rfcomm_tty_install()
749 struct rfcomm_dev *dev = tty->driver_data; in rfcomm_tty_open() local
754 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst, in rfcomm_tty_open()
755 dev->channel, dev->port.count); in rfcomm_tty_open()
757 err = tty_port_open(&dev->port, tty, filp); in rfcomm_tty_open()
766 rfcomm_tty_copy_pending(dev); in rfcomm_tty_open()
768 rfcomm_dlc_unthrottle(dev->dlc); in rfcomm_tty_open()
775 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_close() local
777 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc, in rfcomm_tty_close()
778 dev->port.count); in rfcomm_tty_close()
780 tty_port_close(&dev->port, tty, filp); in rfcomm_tty_close()
785 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_write() local
786 struct rfcomm_dlc *dlc = dev->dlc; in rfcomm_tty_write()
795 skb = rfcomm_wmalloc(dev, size + RFCOMM_SKB_RESERVE, GFP_ATOMIC); in rfcomm_tty_write()
814 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_write_room() local
817 if (dev && dev->dlc) in rfcomm_tty_write_room()
818 room = rfcomm_room(dev); in rfcomm_tty_write_room()
879 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_set_termios() local
883 if (!dev || !dev->dlc || !dev->dlc->session) in rfcomm_tty_set_termios()
1004 rfcomm_send_rpn(dev->dlc->session, 1, dev->dlc->dlci, baud, in rfcomm_tty_set_termios()
1011 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_throttle() local
1013 BT_DBG("tty %p dev %p", tty, dev); in rfcomm_tty_throttle()
1015 rfcomm_dlc_throttle(dev->dlc); in rfcomm_tty_throttle()
1020 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_unthrottle() local
1022 BT_DBG("tty %p dev %p", tty, dev); in rfcomm_tty_unthrottle()
1024 rfcomm_dlc_unthrottle(dev->dlc); in rfcomm_tty_unthrottle()
1029 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_chars_in_buffer() local
1031 BT_DBG("tty %p dev %p", tty, dev); in rfcomm_tty_chars_in_buffer()
1033 if (!dev || !dev->dlc) in rfcomm_tty_chars_in_buffer()
1036 if (!skb_queue_empty(&dev->dlc->tx_queue)) in rfcomm_tty_chars_in_buffer()
1037 return dev->dlc->mtu; in rfcomm_tty_chars_in_buffer()
1044 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_flush_buffer() local
1046 BT_DBG("tty %p dev %p", tty, dev); in rfcomm_tty_flush_buffer()
1048 if (!dev || !dev->dlc) in rfcomm_tty_flush_buffer()
1051 skb_queue_purge(&dev->dlc->tx_queue); in rfcomm_tty_flush_buffer()
1067 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_hangup() local
1069 BT_DBG("tty %p dev %p", tty, dev); in rfcomm_tty_hangup()
1071 tty_port_hangup(&dev->port); in rfcomm_tty_hangup()
1076 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_tiocmget() local
1078 BT_DBG("tty %p dev %p", tty, dev); in rfcomm_tty_tiocmget()
1080 return dev->modem_status; in rfcomm_tty_tiocmget()
1085 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; in rfcomm_tty_tiocmset() local
1086 struct rfcomm_dlc *dlc = dev->dlc; in rfcomm_tty_tiocmset()
1089 BT_DBG("tty %p dev %p set 0x%02x clear 0x%02x", tty, dev, set, clear); in rfcomm_tty_tiocmset()