Lines Matching +full:full +full:- +full:frame
1 // SPDX-License-Identifier: GPL-2.0
7 * can327.c Author : Max Staudt <max-linux@enpas.org>
37 #include <linux/can/rx-offload.h>
53 /* Bits in elm->cmds_todo */
76 /* Per-channel lock */
101 /* The CAN frame and config the ELM327 is sending/using,
125 lockdep_assert_held(&elm->lock); in can327_send()
127 if (elm->uart_side_failure) in can327_send()
130 memcpy(elm->txbuf, buf, len); in can327_send()
134 * the transfer may be completed inside the ops->write() in can327_send()
140 set_bit(TTY_DO_WRITE_WAKEUP, &elm->tty->flags); in can327_send()
141 written = elm->tty->ops->write(elm->tty, elm->txbuf, len); in can327_send()
143 netdev_err(elm->dev, "Failed to write to tty %s.\n", in can327_send()
144 elm->tty->name); in can327_send()
149 elm->txleft = len - written; in can327_send()
150 elm->txhead = elm->txbuf + written; in can327_send()
160 lockdep_assert_held(&elm->lock); in can327_kick_into_cmd_mode()
162 if (elm->state != CAN327_STATE_GETDUMMYCHAR && in can327_kick_into_cmd_mode()
163 elm->state != CAN327_STATE_GETPROMPT) { in can327_kick_into_cmd_mode()
166 elm->state = CAN327_STATE_GETDUMMYCHAR; in can327_kick_into_cmd_mode()
170 /* Schedule a CAN frame and necessary config changes to be sent to the TTY. */
171 static void can327_send_frame(struct can327 *elm, struct can_frame *frame) in can327_send_frame() argument
173 lockdep_assert_held(&elm->lock); in can327_send_frame()
176 if (elm->can_frame_to_send.can_id != frame->can_id) { in can327_send_frame()
178 if ((frame->can_id ^ elm->can_frame_to_send.can_id) in can327_send_frame()
180 elm->can_config = in can327_send_frame()
181 (frame->can_id & CAN_EFF_FLAG ? 0 : CAN327_CAN_CONFIG_SEND_SFF) | in can327_send_frame()
184 elm->can_bitrate_divisor; in can327_send_frame()
186 set_bit(CAN327_TX_DO_CAN_CONFIG, &elm->cmds_todo); in can327_send_frame()
189 if (frame->can_id & CAN_EFF_FLAG) { in can327_send_frame()
190 clear_bit(CAN327_TX_DO_CANID_11BIT, &elm->cmds_todo); in can327_send_frame()
191 set_bit(CAN327_TX_DO_CANID_29BIT_LOW, &elm->cmds_todo); in can327_send_frame()
192 set_bit(CAN327_TX_DO_CANID_29BIT_HIGH, &elm->cmds_todo); in can327_send_frame()
194 set_bit(CAN327_TX_DO_CANID_11BIT, &elm->cmds_todo); in can327_send_frame()
196 &elm->cmds_todo); in can327_send_frame()
198 &elm->cmds_todo); in can327_send_frame()
202 /* Schedule the CAN frame itself. */ in can327_send_frame()
203 elm->can_frame_to_send = *frame; in can327_send_frame()
204 set_bit(CAN327_TX_DO_CAN_DATA, &elm->cmds_todo); in can327_send_frame()
236 lockdep_assert_held(&elm->lock); in can327_init_device()
238 elm->state = CAN327_STATE_NOTINIT; in can327_init_device()
239 elm->can_frame_to_send.can_id = 0x7df; /* ELM327 HW default */ in can327_init_device()
240 elm->rxfill = 0; in can327_init_device()
241 elm->drop_next_line = 0; in can327_init_device()
247 elm->can_bitrate_divisor = 500000 / elm->can.bittiming.bitrate; in can327_init_device()
248 elm->can_config = in can327_init_device()
250 CAN327_CAN_CONFIG_RECV_BOTH_SFF_EFF | elm->can_bitrate_divisor; in can327_init_device()
253 elm->next_init_cmd = &can327_init_script[0]; in can327_init_device()
254 set_bit(CAN327_TX_DO_INIT, &elm->cmds_todo); in can327_init_device()
255 set_bit(CAN327_TX_DO_SILENT_MONITOR, &elm->cmds_todo); in can327_init_device()
256 set_bit(CAN327_TX_DO_RESPONSES, &elm->cmds_todo); in can327_init_device()
257 set_bit(CAN327_TX_DO_CAN_CONFIG, &elm->cmds_todo); in can327_init_device()
264 lockdep_assert_held(&elm->lock); in can327_feed_frame_to_netdev()
266 if (!netif_running(elm->dev)) { in can327_feed_frame_to_netdev()
272 * rx-offload will update stats and LEDs for us. in can327_feed_frame_to_netdev()
274 if (can_rx_offload_queue_tail(&elm->offload, skb)) in can327_feed_frame_to_netdev()
275 elm->dev->stats.rx_fifo_errors++; in can327_feed_frame_to_netdev()
278 can_rx_offload_irq_finish(&elm->offload); in can327_feed_frame_to_netdev()
284 struct can_frame *frame; in can327_uart_side_failure() local
287 lockdep_assert_held(&elm->lock); in can327_uart_side_failure()
289 elm->uart_side_failure = true; in can327_uart_side_failure()
291 clear_bit(TTY_DO_WRITE_WAKEUP, &elm->tty->flags); in can327_uart_side_failure()
293 elm->can.can_stats.bus_off++; in can327_uart_side_failure()
294 netif_stop_queue(elm->dev); in can327_uart_side_failure()
295 elm->can.state = CAN_STATE_BUS_OFF; in can327_uart_side_failure()
296 can_bus_off(elm->dev); in can327_uart_side_failure()
298 netdev_err(elm->dev, in can327_uart_side_failure()
301 skb = alloc_can_err_skb(elm->dev, &frame); in can327_uart_side_failure()
305 frame->can_id |= CAN_ERR_BUSOFF; in can327_uart_side_failure()
309 /* Compares a byte buffer (non-NUL terminated) to the payload part of
329 struct can_frame *frame; in can327_parse_error() local
332 lockdep_assert_held(&elm->lock); in can327_parse_error()
334 skb = alloc_can_err_skb(elm->dev, &frame); in can327_parse_error()
342 if (can327_rxbuf_cmp(elm->rxbuf, len, "UNABLE TO CONNECT")) { in can327_parse_error()
343 netdev_err(elm->dev, in can327_parse_error()
345 } else if (can327_rxbuf_cmp(elm->rxbuf, len, "BUFFER FULL")) { in can327_parse_error()
348 * emit this kind of error frame instead. in can327_parse_error()
350 frame->can_id |= CAN_ERR_CRTL; in can327_parse_error()
351 frame->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; in can327_parse_error()
352 } else if (can327_rxbuf_cmp(elm->rxbuf, len, "BUS ERROR")) { in can327_parse_error()
353 frame->can_id |= CAN_ERR_BUSERROR; in can327_parse_error()
354 } else if (can327_rxbuf_cmp(elm->rxbuf, len, "CAN ERROR")) { in can327_parse_error()
355 frame->can_id |= CAN_ERR_PROT; in can327_parse_error()
356 } else if (can327_rxbuf_cmp(elm->rxbuf, len, "<RX ERROR")) { in can327_parse_error()
357 frame->can_id |= CAN_ERR_PROT; in can327_parse_error()
358 } else if (can327_rxbuf_cmp(elm->rxbuf, len, "BUS BUSY")) { in can327_parse_error()
359 frame->can_id |= CAN_ERR_PROT; in can327_parse_error()
360 frame->data[2] = CAN_ERR_PROT_OVERLOAD; in can327_parse_error()
361 } else if (can327_rxbuf_cmp(elm->rxbuf, len, "FB ERROR")) { in can327_parse_error()
362 frame->can_id |= CAN_ERR_PROT; in can327_parse_error()
363 frame->data[2] = CAN_ERR_PROT_TX; in can327_parse_error()
364 } else if (len == 5 && !memcmp(elm->rxbuf, "ERR", 3)) { in can327_parse_error()
366 netdev_err(elm->dev, "ELM327 reported an ERR%c%c. Please power it off and on again.\n", in can327_parse_error()
367 elm->rxbuf[3], elm->rxbuf[4]); in can327_parse_error()
368 frame->can_id |= CAN_ERR_CRTL; in can327_parse_error()
372 * Emit a generic error frame. in can327_parse_error()
382 * 29-bit ID (EFF): 12 34 56 78 D PL PL PL PL PL PL PL PL
383 * 11-bit ID (!EFF): 123 D PL PL PL PL PL PL PL PL
393 struct can_frame *frame; in can327_parse_frame() local
399 lockdep_assert_held(&elm->lock); in can327_parse_frame()
401 skb = alloc_can_skb(elm->dev, &frame); in can327_parse_frame()
403 return -ENOMEM; in can327_parse_frame()
405 /* Find first non-hex and non-space character: in can327_parse_frame()
406 * - In the simplest case, there is none. in can327_parse_frame()
407 * - For RTR frames, 'R' is the first non-hex character. in can327_parse_frame()
408 * - An error message may replace the end of the data line. in can327_parse_frame()
411 if (hex_to_bin(elm->rxbuf[hexlen]) < 0 && in can327_parse_frame()
412 elm->rxbuf[hexlen] != ' ') { in can327_parse_frame()
420 if (hexlen < len && !isdigit(elm->rxbuf[hexlen]) && in can327_parse_frame()
421 !isupper(elm->rxbuf[hexlen]) && '<' != elm->rxbuf[hexlen] && in can327_parse_frame()
422 ' ' != elm->rxbuf[hexlen]) { in can327_parse_frame()
427 return -ENODATA; in can327_parse_frame()
431 * No out-of-bounds access: in can327_parse_frame()
432 * We use the fact that we can always read from elm->rxbuf. in can327_parse_frame()
434 if (elm->rxbuf[2] == ' ' && elm->rxbuf[5] == ' ' && in can327_parse_frame()
435 elm->rxbuf[8] == ' ' && elm->rxbuf[11] == ' ' && in can327_parse_frame()
436 elm->rxbuf[13] == ' ') { in can327_parse_frame()
437 frame->can_id = CAN_EFF_FLAG; in can327_parse_frame()
439 } else if (elm->rxbuf[3] == ' ' && elm->rxbuf[5] == ' ') { in can327_parse_frame()
442 /* This is not a well-formatted data line. in can327_parse_frame()
446 return -ENODATA; in can327_parse_frame()
450 /* The line is too short to be a valid frame hex dump. in can327_parse_frame()
454 return -ENODATA; in can327_parse_frame()
458 * at well-defined offsets. in can327_parse_frame()
462 frame->len = (hex_to_bin(elm->rxbuf[datastart - 2]) << 0); in can327_parse_frame()
465 if (frame->can_id & CAN_EFF_FLAG) { in can327_parse_frame()
466 frame->can_id |= (hex_to_bin(elm->rxbuf[0]) << 28) | in can327_parse_frame()
467 (hex_to_bin(elm->rxbuf[1]) << 24) | in can327_parse_frame()
468 (hex_to_bin(elm->rxbuf[3]) << 20) | in can327_parse_frame()
469 (hex_to_bin(elm->rxbuf[4]) << 16) | in can327_parse_frame()
470 (hex_to_bin(elm->rxbuf[6]) << 12) | in can327_parse_frame()
471 (hex_to_bin(elm->rxbuf[7]) << 8) | in can327_parse_frame()
472 (hex_to_bin(elm->rxbuf[9]) << 4) | in can327_parse_frame()
473 (hex_to_bin(elm->rxbuf[10]) << 0); in can327_parse_frame()
475 frame->can_id |= (hex_to_bin(elm->rxbuf[0]) << 8) | in can327_parse_frame()
476 (hex_to_bin(elm->rxbuf[1]) << 4) | in can327_parse_frame()
477 (hex_to_bin(elm->rxbuf[2]) << 0); in can327_parse_frame()
480 /* Check for RTR frame */ in can327_parse_frame()
481 if (elm->rxfill >= hexlen + 3 && in can327_parse_frame()
482 !memcmp(&elm->rxbuf[hexlen], "RTR", 3)) { in can327_parse_frame()
483 frame->can_id |= CAN_RTR_FLAG; in can327_parse_frame()
489 if (!(frame->can_id & CAN_RTR_FLAG) && in can327_parse_frame()
490 (hexlen < frame->len * 3 + datastart)) { in can327_parse_frame()
491 /* Incomplete frame. in can327_parse_frame()
492 * Probably the ELM327's RS232 TX buffer was full. in can327_parse_frame()
493 * Emit an error frame and exit. in can327_parse_frame()
495 frame->can_id = CAN_ERR_FLAG | CAN_ERR_CRTL; in can327_parse_frame()
496 frame->len = CAN_ERR_DLC; in can327_parse_frame()
497 frame->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; in can327_parse_frame()
501 * The line will be re-parsed as an error line, which will fail. in can327_parse_frame()
505 return -ENODATA; in can327_parse_frame()
509 for (i = 0; i < frame->len; i++) { in can327_parse_frame()
510 frame->data[i] = in can327_parse_frame()
511 (hex_to_bin(elm->rxbuf[datastart + 3 * i]) << 4) | in can327_parse_frame()
512 (hex_to_bin(elm->rxbuf[datastart + 3 * i + 1])); in can327_parse_frame()
515 /* Feed the frame to the network layer. */ in can327_parse_frame()
523 lockdep_assert_held(&elm->lock); in can327_parse_line()
530 if (elm->drop_next_line) { in can327_parse_line()
531 elm->drop_next_line = 0; in can327_parse_line()
533 } else if (!memcmp(elm->rxbuf, "AT", 2)) { in can327_parse_line()
538 if (elm->state == CAN327_STATE_RECEIVING && in can327_parse_line()
550 struct can_frame *frame = &elm->can_frame_to_send; in can327_handle_prompt() local
552 * which is currently an 8 byte CAN frame's payload hexdump. in can327_handle_prompt()
557 lockdep_assert_held(&elm->lock); in can327_handle_prompt()
559 if (!elm->cmds_todo) { in can327_handle_prompt()
562 elm->state = CAN327_STATE_RECEIVING; in can327_handle_prompt()
567 netif_wake_queue(elm->dev); in can327_handle_prompt()
572 /* Reconfigure ELM327 step by step as indicated by elm->cmds_todo */ in can327_handle_prompt()
573 if (test_bit(CAN327_TX_DO_INIT, &elm->cmds_todo)) { in can327_handle_prompt()
575 *elm->next_init_cmd); in can327_handle_prompt()
577 elm->next_init_cmd++; in can327_handle_prompt()
578 if (!(*elm->next_init_cmd)) { in can327_handle_prompt()
579 clear_bit(CAN327_TX_DO_INIT, &elm->cmds_todo); in can327_handle_prompt()
583 } else if (test_and_clear_bit(CAN327_TX_DO_SILENT_MONITOR, &elm->cmds_todo)) { in can327_handle_prompt()
586 !!(elm->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)); in can327_handle_prompt()
588 } else if (test_and_clear_bit(CAN327_TX_DO_RESPONSES, &elm->cmds_todo)) { in can327_handle_prompt()
591 !(elm->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)); in can327_handle_prompt()
593 } else if (test_and_clear_bit(CAN327_TX_DO_CAN_CONFIG, &elm->cmds_todo)) { in can327_handle_prompt()
596 set_bit(CAN327_TX_DO_CAN_CONFIG_PART2, &elm->cmds_todo); in can327_handle_prompt()
598 } else if (test_and_clear_bit(CAN327_TX_DO_CAN_CONFIG_PART2, &elm->cmds_todo)) { in can327_handle_prompt()
601 elm->can_config); in can327_handle_prompt()
603 } else if (test_and_clear_bit(CAN327_TX_DO_CANID_29BIT_HIGH, &elm->cmds_todo)) { in can327_handle_prompt()
606 (frame->can_id & CAN_EFF_MASK) >> 24); in can327_handle_prompt()
608 } else if (test_and_clear_bit(CAN327_TX_DO_CANID_29BIT_LOW, &elm->cmds_todo)) { in can327_handle_prompt()
611 frame->can_id & CAN_EFF_MASK & ((1 << 24) - 1)); in can327_handle_prompt()
613 } else if (test_and_clear_bit(CAN327_TX_DO_CANID_11BIT, &elm->cmds_todo)) { in can327_handle_prompt()
616 frame->can_id & CAN_SFF_MASK); in can327_handle_prompt()
618 } else if (test_and_clear_bit(CAN327_TX_DO_CAN_DATA, &elm->cmds_todo)) { in can327_handle_prompt()
619 if (frame->can_id & CAN_RTR_FLAG) { in can327_handle_prompt()
620 /* Send an RTR frame. Their DLC is fixed. in can327_handle_prompt()
625 /* Send a regular CAN data frame */ in can327_handle_prompt()
628 for (i = 0; i < frame->len; i++) { in can327_handle_prompt()
631 frame->data[i]); in can327_handle_prompt()
638 elm->drop_next_line = 1; in can327_handle_prompt()
639 elm->state = CAN327_STATE_RECEIVING; in can327_handle_prompt()
644 netif_wake_queue(elm->dev); in can327_handle_prompt()
660 lockdep_assert_held(&elm->lock); in can327_drop_bytes()
662 memmove(&elm->rxbuf[0], &elm->rxbuf[i], CAN327_SIZE_RXBUF - i); in can327_drop_bytes()
663 elm->rxfill -= i; in can327_drop_bytes()
670 lockdep_assert_held(&elm->lock); in can327_parse_rxbuf()
672 switch (elm->state) { in can327_parse_rxbuf()
674 elm->rxfill = 0; in can327_parse_rxbuf()
679 for (pos = 0; pos < elm->rxfill; pos++) { in can327_parse_rxbuf()
680 if (elm->rxbuf[pos] == CAN327_DUMMY_CHAR) { in can327_parse_rxbuf()
682 elm->state = CAN327_STATE_GETPROMPT; in can327_parse_rxbuf()
685 } else if (can327_is_ready_char(elm->rxbuf[pos])) { in can327_parse_rxbuf()
697 if (can327_is_ready_char(elm->rxbuf[elm->rxfill - 1])) in can327_parse_rxbuf()
700 elm->rxfill = 0; in can327_parse_rxbuf()
706 while (len < elm->rxfill && elm->rxbuf[len] != '\r') in can327_parse_rxbuf()
710 /* Assume the buffer ran full with garbage. in can327_parse_rxbuf()
713 netdev_err(elm->dev, in can327_parse_rxbuf()
716 } else if (len == elm->rxfill) { in can327_parse_rxbuf()
717 if (can327_is_ready_char(elm->rxbuf[elm->rxfill - 1])) { in can327_parse_rxbuf()
722 elm->rxfill = 0; in can327_parse_rxbuf()
727 /* No <CR> found - we haven't received a full line yet. in can327_parse_rxbuf()
731 /* We have a full line to parse. */ in can327_parse_rxbuf()
738 if (elm->rxfill) in can327_parse_rxbuf()
749 spin_lock_bh(&elm->lock); in can327_netdev_open()
751 if (!elm->tty) { in can327_netdev_open()
752 spin_unlock_bh(&elm->lock); in can327_netdev_open()
753 return -ENODEV; in can327_netdev_open()
756 if (elm->uart_side_failure) in can327_netdev_open()
757 netdev_warn(elm->dev, in can327_netdev_open()
761 elm->rxfill = 0; in can327_netdev_open()
762 elm->txleft = 0; in can327_netdev_open()
764 /* open_candev() checks for elm->can.bittiming.bitrate != 0 */ in can327_netdev_open()
767 spin_unlock_bh(&elm->lock); in can327_netdev_open()
772 spin_unlock_bh(&elm->lock); in can327_netdev_open()
774 err = can_rx_offload_add_manual(dev, &elm->offload, CAN327_NAPI_WEIGHT); in can327_netdev_open()
780 can_rx_offload_enable(&elm->offload); in can327_netdev_open()
782 elm->can.state = CAN_STATE_ERROR_ACTIVE; in can327_netdev_open()
793 spin_lock_bh(&elm->lock); in can327_netdev_close()
795 spin_unlock_bh(&elm->lock); in can327_netdev_close()
803 can_rx_offload_disable(&elm->offload); in can327_netdev_close()
804 elm->can.state = CAN_STATE_STOPPED; in can327_netdev_close()
805 can_rx_offload_del(&elm->offload); in can327_netdev_close()
816 struct can_frame *frame = (struct can_frame *)skb->data; in can327_netdev_start_xmit() local
824 if (elm->uart_side_failure) { in can327_netdev_start_xmit()
825 WARN_ON_ONCE(elm->uart_side_failure); in can327_netdev_start_xmit()
834 spin_lock(&elm->lock); in can327_netdev_start_xmit()
835 can327_send_frame(elm, frame); in can327_netdev_start_xmit()
836 spin_unlock(&elm->lock); in can327_netdev_start_xmit()
838 dev->stats.tx_packets++; in can327_netdev_start_xmit()
839 dev->stats.tx_bytes += frame->can_id & CAN_RTR_FLAG ? 0 : frame->len; in can327_netdev_start_xmit()
885 * This will not be re-entered while running, but other ldisc
891 struct can327 *elm = tty->disc_data; in can327_ldisc_rx()
894 if (elm->uart_side_failure) in can327_ldisc_rx()
897 spin_lock_bh(&elm->lock); in can327_ldisc_rx()
902 first_new_char_idx = elm->rxfill; in can327_ldisc_rx()
904 while (count--) { in can327_ldisc_rx()
905 if (elm->rxfill >= CAN327_SIZE_RXBUF) { in can327_ldisc_rx()
906 netdev_err(elm->dev, in can327_ldisc_rx()
912 netdev_err(elm->dev, in can327_ldisc_rx()
927 netdev_err(elm->dev, in can327_ldisc_rx()
933 elm->rxbuf[elm->rxfill++] = *cp; in can327_ldisc_rx()
940 spin_unlock_bh(&elm->lock); in can327_ldisc_rx()
945 spin_unlock_bh(&elm->lock); in can327_ldisc_rx()
956 if (elm->uart_side_failure) in can327_ldisc_tx_worker()
959 spin_lock_bh(&elm->lock); in can327_ldisc_tx_worker()
961 if (elm->txleft) { in can327_ldisc_tx_worker()
962 written = elm->tty->ops->write(elm->tty, elm->txhead, in can327_ldisc_tx_worker()
963 elm->txleft); in can327_ldisc_tx_worker()
965 netdev_err(elm->dev, "Failed to write to tty %s.\n", in can327_ldisc_tx_worker()
966 elm->tty->name); in can327_ldisc_tx_worker()
969 spin_unlock_bh(&elm->lock); in can327_ldisc_tx_worker()
973 elm->txleft -= written; in can327_ldisc_tx_worker()
974 elm->txhead += written; in can327_ldisc_tx_worker()
977 if (!elm->txleft) in can327_ldisc_tx_worker()
978 clear_bit(TTY_DO_WRITE_WAKEUP, &elm->tty->flags); in can327_ldisc_tx_worker()
980 spin_unlock_bh(&elm->lock); in can327_ldisc_tx_worker()
986 struct can327 *elm = tty->disc_data; in can327_ldisc_tx_wakeup()
988 schedule_work(&elm->tx_work); in can327_ldisc_tx_wakeup()
1013 return -EPERM; in can327_ldisc_open()
1015 if (!tty->ops->write) in can327_ldisc_open()
1016 return -EOPNOTSUPP; in can327_ldisc_open()
1020 return -ENFILE; in can327_ldisc_open()
1024 tty->receive_room = 65536; /* We don't flow control */ in can327_ldisc_open()
1025 spin_lock_init(&elm->lock); in can327_ldisc_open()
1026 INIT_WORK(&elm->tx_work, can327_ldisc_tx_worker); in can327_ldisc_open()
1029 elm->can.bitrate_const = can327_bitrate_const; in can327_ldisc_open()
1030 elm->can.bitrate_const_cnt = ARRAY_SIZE(can327_bitrate_const); in can327_ldisc_open()
1031 elm->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY; in can327_ldisc_open()
1034 elm->dev = dev; in can327_ldisc_open()
1035 dev->netdev_ops = &can327_netdev_ops; in can327_ldisc_open()
1036 dev->ethtool_ops = &can327_ethtool_ops; in can327_ldisc_open()
1039 elm->tty = tty; in can327_ldisc_open()
1040 tty->disc_data = elm; in can327_ldisc_open()
1043 err = register_candev(elm->dev); in can327_ldisc_open()
1045 free_candev(elm->dev); in can327_ldisc_open()
1049 netdev_info(elm->dev, "can327 on %s.\n", tty->name); in can327_ldisc_open()
1063 struct can327 *elm = tty->disc_data; in can327_ldisc_close()
1066 unregister_candev(elm->dev); in can327_ldisc_close()
1072 flush_work(&elm->tx_work); in can327_ldisc_close()
1075 spin_lock_bh(&elm->lock); in can327_ldisc_close()
1076 tty->disc_data = NULL; in can327_ldisc_close()
1077 elm->tty = NULL; in can327_ldisc_close()
1078 spin_unlock_bh(&elm->lock); in can327_ldisc_close()
1080 netdev_info(elm->dev, "can327 off %s.\n", tty->name); in can327_ldisc_close()
1082 free_candev(elm->dev); in can327_ldisc_close()
1088 struct can327 *elm = tty->disc_data; in can327_ldisc_ioctl()
1093 tmp = strnlen(elm->dev->name, IFNAMSIZ - 1) + 1; in can327_ldisc_ioctl()
1094 if (copy_to_user((void __user *)arg, elm->dev->name, tmp)) in can327_ldisc_ioctl()
1095 return -EFAULT; in can327_ldisc_ioctl()
1099 return -EINVAL; in can327_ldisc_ioctl()
1131 * userspace - tty_ldisc.c takes care of the module's refcount. in can327_exit()