1 // SPDX-License-Identifier: GPL-2.0
2 /* vcc.c: sun4v virtual channel concentrator
4 * Copyright (C) 2017 Oracle. All rights reserved.
7 #include <linux/delay.h>
8 #include <linux/interrupt.h>
9 #include <linux/module.h>
10 #include <linux/slab.h>
11 #include <linux/sysfs.h>
12 #include <linux/tty.h>
13 #include <linux/tty_flip.h>
17 MODULE_DESCRIPTION("Sun LDOM virtual console concentrator driver");
18 MODULE_LICENSE("GPL");
19 MODULE_VERSION("1.1");
22 struct vio_driver_state vio
;
26 struct tty_struct
*tty
; /* only populated while dev is open */
27 unsigned long index
; /* index into the vcc_table */
34 /* This buffer is required to support the tty write_room interface
35 * and guarantee that any characters that the driver accepts will
36 * be eventually sent, either immediately or later.
39 struct vio_vcc buffer
;
41 struct timer_list rx_timer
;
42 struct timer_list tx_timer
;
45 /* Microseconds that thread will delay waiting for a vcc port ref */
46 #define VCC_REF_DELAY 100
48 #define VCC_MAX_PORTS 1024
49 #define VCC_MINOR_START 0 /* must be zero */
50 #define VCC_BUFF_LEN VIO_VCC_MTU_SIZE
52 #define VCC_CTL_BREAK -1
53 #define VCC_CTL_HUP -2
55 static struct tty_driver
*vcc_tty_driver
;
57 static struct vcc_port
*vcc_table
[VCC_MAX_PORTS
];
58 static DEFINE_SPINLOCK(vcc_table_lock
);
60 static unsigned int vcc_dbg
;
61 static unsigned int vcc_dbg_ldc
;
62 static unsigned int vcc_dbg_vio
;
64 module_param(vcc_dbg
, uint
, 0664);
65 module_param(vcc_dbg_ldc
, uint
, 0664);
66 module_param(vcc_dbg_vio
, uint
, 0664);
68 #define VCC_DBG_DRV 0x1
69 #define VCC_DBG_LDC 0x2
70 #define VCC_DBG_PKT 0x4
72 #define vccdbg(f, a...) \
74 if (vcc_dbg & VCC_DBG_DRV) \
80 if (vcc_dbg & VCC_DBG_LDC) \
84 #define vccdbgp(pkt) \
86 if (vcc_dbg & VCC_DBG_PKT) { \
88 for (i = 0; i < pkt.tag.stype; i++) \
89 pr_info("[%c]", pkt.data[i]); \
93 /* Note: Be careful when adding flags to this line discipline. Don't
94 * add anything that will cause echoing or we'll go into recursive
95 * loop echoing chars back and forth with the console drivers.
97 static const struct ktermios vcc_tty_termios
= {
98 .c_iflag
= IGNBRK
| IGNPAR
,
100 .c_cflag
= B38400
| CS8
| CREAD
| HUPCL
,
107 * vcc_table_add() - Add VCC port to the VCC table
108 * @port: pointer to the VCC port
110 * Return: index of the port in the VCC table on success,
113 static int vcc_table_add(struct vcc_port
*port
)
118 spin_lock_irqsave(&vcc_table_lock
, flags
);
119 for (i
= VCC_MINOR_START
; i
< VCC_MAX_PORTS
; i
++) {
125 spin_unlock_irqrestore(&vcc_table_lock
, flags
);
127 if (i
< VCC_MAX_PORTS
)
134 * vcc_table_remove() - Removes a VCC port from the VCC table
135 * @index: Index into the VCC table
137 static void vcc_table_remove(unsigned long index
)
141 if (WARN_ON(index
>= VCC_MAX_PORTS
))
144 spin_lock_irqsave(&vcc_table_lock
, flags
);
145 vcc_table
[index
] = NULL
;
146 spin_unlock_irqrestore(&vcc_table_lock
, flags
);
150 * vcc_get() - Gets a reference to VCC port
151 * @index: Index into the VCC table
152 * @excl: Indicates if an exclusive access is requested
154 * Return: reference to the VCC port, if found
155 * NULL, if port not found
157 static struct vcc_port
*vcc_get(unsigned long index
, bool excl
)
159 struct vcc_port
*port
;
163 spin_lock_irqsave(&vcc_table_lock
, flags
);
165 port
= vcc_table
[index
];
167 spin_unlock_irqrestore(&vcc_table_lock
, flags
);
172 if (port
->excl_locked
) {
173 spin_unlock_irqrestore(&vcc_table_lock
, flags
);
174 udelay(VCC_REF_DELAY
);
178 spin_unlock_irqrestore(&vcc_table_lock
, flags
);
183 spin_unlock_irqrestore(&vcc_table_lock
, flags
);
184 /* Threads wanting exclusive access will wait half the time,
185 * probably giving them higher priority in the case of
188 udelay(VCC_REF_DELAY
/2);
193 port
->excl_locked
= true;
194 spin_unlock_irqrestore(&vcc_table_lock
, flags
);
200 * vcc_put() - Returns a reference to VCC port
201 * @port: pointer to VCC port
202 * @excl: Indicates if the returned reference is an exclusive reference
204 * Note: It's the caller's responsibility to ensure the correct value
207 static void vcc_put(struct vcc_port
*port
, bool excl
)
214 spin_lock_irqsave(&vcc_table_lock
, flags
);
216 /* check if caller attempted to put with the wrong flags */
217 if (WARN_ON((excl
&& !port
->excl_locked
) ||
218 (!excl
&& port
->excl_locked
)))
224 port
->excl_locked
= false;
227 spin_unlock_irqrestore(&vcc_table_lock
, flags
);
231 * vcc_get_ne() - Get a non-exclusive reference to VCC port
232 * @index: Index into the VCC table
234 * Gets a non-exclusive reference to VCC port, if it's not removed
236 * Return: pointer to the VCC port, if found
237 * NULL, if port not found
239 static struct vcc_port
*vcc_get_ne(unsigned long index
)
241 struct vcc_port
*port
;
243 port
= vcc_get(index
, false);
245 if (port
&& port
->removed
) {
246 vcc_put(port
, false);
253 static void vcc_kick_rx(struct vcc_port
*port
)
255 struct vio_driver_state
*vio
= &port
->vio
;
257 assert_spin_locked(&port
->lock
);
259 if (!timer_pending(&port
->rx_timer
) && !port
->removed
) {
260 disable_irq_nosync(vio
->vdev
->rx_irq
);
261 port
->rx_timer
.expires
= (jiffies
+ 1);
262 add_timer(&port
->rx_timer
);
266 static void vcc_kick_tx(struct vcc_port
*port
)
268 assert_spin_locked(&port
->lock
);
270 if (!timer_pending(&port
->tx_timer
) && !port
->removed
) {
271 port
->tx_timer
.expires
= (jiffies
+ 1);
272 add_timer(&port
->tx_timer
);
276 static int vcc_rx_check(struct tty_struct
*tty
, int size
)
278 if (WARN_ON(!tty
|| !tty
->port
))
281 /* tty_buffer_request_room won't sleep because it uses
282 * GFP_ATOMIC flag to allocate buffer
284 if (test_bit(TTY_THROTTLED
, &tty
->flags
) ||
285 (tty_buffer_request_room(tty
->port
, VCC_BUFF_LEN
) < VCC_BUFF_LEN
))
291 static int vcc_rx(struct tty_struct
*tty
, char *buf
, int size
)
295 if (WARN_ON(!tty
|| !tty
->port
))
298 len
= tty_insert_flip_string(tty
->port
, buf
, size
);
300 tty_flip_buffer_push(tty
->port
);
305 static int vcc_ldc_read(struct vcc_port
*port
)
307 struct vio_driver_state
*vio
= &port
->vio
;
308 struct tty_struct
*tty
;
314 rv
= ldc_rx_reset(vio
->lp
);
315 vccdbg("VCC: reset rx q: rv=%d\n", rv
);
319 /* Read as long as LDC has incoming data. */
321 if (!vcc_rx_check(tty
, VIO_VCC_MTU_SIZE
)) {
328 rv
= ldc_read(vio
->lp
, &pkt
, sizeof(pkt
));
332 vccdbg("VCC: ldc_read()=%d\n", rv
);
333 vccdbg("TAG [%02x:%02x:%04x:%08x]\n",
334 pkt
.tag
.type
, pkt
.tag
.stype
,
335 pkt
.tag
.stype_env
, pkt
.tag
.sid
);
337 if (pkt
.tag
.type
== VIO_TYPE_DATA
) {
339 /* vcc_rx_check ensures memory availability */
340 vcc_rx(tty
, pkt
.data
, pkt
.tag
.stype
);
342 pr_err("VCC: unknown msg [%02x:%02x:%04x:%08x]\n",
343 pkt
.tag
.type
, pkt
.tag
.stype
,
344 pkt
.tag
.stype_env
, pkt
.tag
.sid
);
349 WARN_ON(rv
!= LDC_PACKET_SIZE
);
356 static void vcc_rx_timer(struct timer_list
*t
)
358 struct vcc_port
*port
= from_timer(port
, t
, rx_timer
);
359 struct vio_driver_state
*vio
;
363 spin_lock_irqsave(&port
->lock
, flags
);
364 port
->rx_timer
.expires
= 0;
368 enable_irq(vio
->vdev
->rx_irq
);
370 if (!port
->tty
|| port
->removed
)
373 rv
= vcc_ldc_read(port
);
374 if (rv
== -ECONNRESET
)
378 spin_unlock_irqrestore(&port
->lock
, flags
);
379 vcc_put(port
, false);
382 static void vcc_tx_timer(struct timer_list
*t
)
384 struct vcc_port
*port
= from_timer(port
, t
, tx_timer
);
390 spin_lock_irqsave(&port
->lock
, flags
);
391 port
->tx_timer
.expires
= 0;
393 if (!port
->tty
|| port
->removed
)
396 tosend
= min(VCC_BUFF_LEN
, port
->chars_in_buffer
);
401 pkt
->tag
.type
= VIO_TYPE_DATA
;
402 pkt
->tag
.stype
= tosend
;
403 vccdbgl(port
->vio
.lp
);
405 rv
= ldc_write(port
->vio
.lp
, pkt
, (VIO_TAG_SIZE
+ tosend
));
409 vccdbg("VCC: ldc_write()=%d\n", rv
);
412 struct tty_struct
*tty
= port
->tty
;
414 port
->chars_in_buffer
= 0;
420 spin_unlock_irqrestore(&port
->lock
, flags
);
421 vcc_put(port
, false);
425 * vcc_event() - LDC event processing engine
426 * @arg: VCC private data
429 * Handles LDC events for VCC
431 static void vcc_event(void *arg
, int event
)
433 struct vio_driver_state
*vio
;
434 struct vcc_port
*port
;
441 spin_lock_irqsave(&port
->lock
, flags
);
444 case LDC_EVENT_RESET
:
446 vio_link_state_change(vio
, event
);
449 case LDC_EVENT_DATA_READY
:
450 rv
= vcc_ldc_read(port
);
451 if (rv
== -ECONNRESET
)
456 pr_err("VCC: unexpected LDC event(%d)\n", event
);
459 spin_unlock_irqrestore(&port
->lock
, flags
);
462 static struct ldc_channel_config vcc_ldc_cfg
= {
464 .mtu
= VIO_VCC_MTU_SIZE
,
465 .mode
= LDC_MODE_RAW
,
469 /* Ordered from largest major to lowest */
470 static struct vio_version vcc_versions
[] = {
471 { .major
= 1, .minor
= 0 },
474 static struct tty_port_operations vcc_port_ops
= { 0 };
476 static ssize_t
vcc_sysfs_domain_show(struct device
*dev
,
477 struct device_attribute
*attr
,
480 struct vcc_port
*port
;
483 port
= dev_get_drvdata(dev
);
487 rv
= scnprintf(buf
, PAGE_SIZE
, "%s\n", port
->domain
);
492 static int vcc_send_ctl(struct vcc_port
*port
, int ctl
)
497 pkt
.tag
.type
= VIO_TYPE_CTRL
;
501 rv
= ldc_write(port
->vio
.lp
, &pkt
, sizeof(pkt
.tag
));
503 vccdbg("VCC: ldc_write(%ld)=%d\n", sizeof(pkt
.tag
), rv
);
508 static ssize_t
vcc_sysfs_break_store(struct device
*dev
,
509 struct device_attribute
*attr
,
510 const char *buf
, size_t count
)
512 struct vcc_port
*port
;
517 port
= dev_get_drvdata(dev
);
521 spin_lock_irqsave(&port
->lock
, flags
);
523 if (sscanf(buf
, "%ud", &brk
) != 1 || brk
!= 1)
525 else if (vcc_send_ctl(port
, VCC_CTL_BREAK
) < 0)
528 spin_unlock_irqrestore(&port
->lock
, flags
);
533 static DEVICE_ATTR(domain
, 0400, vcc_sysfs_domain_show
, NULL
);
534 static DEVICE_ATTR(break, 0200, NULL
, vcc_sysfs_break_store
);
536 static struct attribute
*vcc_sysfs_entries
[] = {
537 &dev_attr_domain
.attr
,
538 &dev_attr_break
.attr
,
542 static struct attribute_group vcc_attribute_group
= {
544 .attrs
= vcc_sysfs_entries
,
548 * vcc_probe() - Initialize VCC port
549 * @vdev: Pointer to VIO device of the new VCC port
552 * Initializes a VCC port to receive serial console data from
553 * the guest domain. Sets up a TTY end point on the control
554 * domain. Sets up VIO/LDC link between the guest & control
557 * Return: status of the probe
559 static int vcc_probe(struct vio_dev
*vdev
, const struct vio_device_id
*id
)
561 struct mdesc_handle
*hp
;
562 struct vcc_port
*port
;
569 vccdbg("VCC: name=%s\n", dev_name(&vdev
->dev
));
571 if (!vcc_tty_driver
) {
572 pr_err("VCC: TTY driver not registered\n");
576 port
= kzalloc(sizeof(struct vcc_port
), GFP_KERNEL
);
580 name
= kstrdup(dev_name(&vdev
->dev
), GFP_KERNEL
);
582 rv
= vio_driver_init(&port
->vio
, vdev
, VDEV_CONSOLE_CON
, vcc_versions
,
583 ARRAY_SIZE(vcc_versions
), NULL
, name
);
587 port
->vio
.debug
= vcc_dbg_vio
;
588 vcc_ldc_cfg
.debug
= vcc_dbg_ldc
;
590 rv
= vio_ldc_alloc(&port
->vio
, &vcc_ldc_cfg
, port
);
594 spin_lock_init(&port
->lock
);
596 port
->index
= vcc_table_add(port
);
597 if (port
->index
== -1) {
598 pr_err("VCC: no more TTY indices left for allocation\n");
603 /* Register the device using VCC table index as TTY index */
604 dev
= tty_register_device(vcc_tty_driver
, port
->index
, &vdev
->dev
);
612 node
= vio_vdev_node(hp
, vdev
);
613 if (node
== MDESC_NODE_NULL
) {
619 domain
= mdesc_get_property(hp
, node
, "vcc-domain-name", NULL
);
625 port
->domain
= kstrdup(domain
, GFP_KERNEL
);
629 rv
= sysfs_create_group(&vdev
->dev
.kobj
, &vcc_attribute_group
);
633 timer_setup(&port
->rx_timer
, vcc_rx_timer
, 0);
634 timer_setup(&port
->tx_timer
, vcc_tx_timer
, 0);
636 dev_set_drvdata(&vdev
->dev
, port
);
638 /* It's possible to receive IRQs in the middle of vio_port_up. Disable
639 * IRQs until the port is up.
641 disable_irq_nosync(vdev
->rx_irq
);
642 vio_port_up(&port
->vio
);
643 enable_irq(vdev
->rx_irq
);
650 tty_unregister_device(vcc_tty_driver
, port
->index
);
652 vcc_table_remove(port
->index
);
654 vio_ldc_free(&port
->vio
);
663 * vcc_remove() - Terminate a VCC port
664 * @vdev: Pointer to VIO device of the VCC port
666 * Terminates a VCC port. Sets up the teardown of TTY and
667 * VIO/LDC link between guest and primary domains.
669 * Return: status of removal
671 static int vcc_remove(struct vio_dev
*vdev
)
673 struct vcc_port
*port
= dev_get_drvdata(&vdev
->dev
);
675 del_timer_sync(&port
->rx_timer
);
676 del_timer_sync(&port
->tx_timer
);
678 /* If there's a process with the device open, do a synchronous
679 * hangup of the TTY. This *may* cause the process to call close
680 * asynchronously, but it's not guaranteed.
683 tty_vhangup(port
->tty
);
685 /* Get exclusive reference to VCC, ensures that there are no other
686 * clients to this port. This cannot fail.
688 vcc_get(port
->index
, true);
690 tty_unregister_device(vcc_tty_driver
, port
->index
);
692 del_timer_sync(&port
->vio
.timer
);
693 vio_ldc_free(&port
->vio
);
694 sysfs_remove_group(&vdev
->dev
.kobj
, &vcc_attribute_group
);
695 dev_set_drvdata(&vdev
->dev
, NULL
);
697 port
->removed
= true;
700 vcc_table_remove(port
->index
);
702 kfree(port
->vio
.name
);
710 static const struct vio_device_id vcc_match
[] = {
716 MODULE_DEVICE_TABLE(vio
, vcc_match
);
718 static struct vio_driver vcc_driver
= {
719 .id_table
= vcc_match
,
721 .remove
= vcc_remove
,
725 static int vcc_open(struct tty_struct
*tty
, struct file
*vcc_file
)
727 struct vcc_port
*port
;
732 port
= vcc_get_ne(tty
->index
);
733 if (unlikely(!port
)) {
734 pr_err("VCC: open: Failed to find VCC port\n");
738 if (unlikely(!port
->vio
.lp
)) {
739 pr_err("VCC: open: LDC channel not configured\n");
740 vcc_put(port
, false);
743 vccdbgl(port
->vio
.lp
);
745 vcc_put(port
, false);
747 if (unlikely(!tty
->port
)) {
748 pr_err("VCC: open: TTY port not found\n");
752 if (unlikely(!tty
->port
->ops
)) {
753 pr_err("VCC: open: TTY ops not defined\n");
757 return tty_port_open(tty
->port
, tty
, vcc_file
);
760 static void vcc_close(struct tty_struct
*tty
, struct file
*vcc_file
)
762 if (unlikely(tty
->count
> 1))
765 if (unlikely(!tty
->port
)) {
766 pr_err("VCC: close: TTY port not found\n");
770 tty_port_close(tty
->port
, tty
, vcc_file
);
773 static void vcc_ldc_hup(struct vcc_port
*port
)
777 spin_lock_irqsave(&port
->lock
, flags
);
779 if (vcc_send_ctl(port
, VCC_CTL_HUP
) < 0)
782 spin_unlock_irqrestore(&port
->lock
, flags
);
785 static void vcc_hangup(struct tty_struct
*tty
)
787 struct vcc_port
*port
;
789 port
= vcc_get_ne(tty
->index
);
790 if (unlikely(!port
)) {
791 pr_err("VCC: hangup: Failed to find VCC port\n");
795 if (unlikely(!tty
->port
)) {
796 pr_err("VCC: hangup: TTY port not found\n");
797 vcc_put(port
, false);
803 vcc_put(port
, false);
805 tty_port_hangup(tty
->port
);
808 static int vcc_write(struct tty_struct
*tty
, const unsigned char *buf
,
811 struct vcc_port
*port
;
818 port
= vcc_get_ne(tty
->index
);
819 if (unlikely(!port
)) {
820 pr_err("VCC: write: Failed to find VCC port");
824 spin_lock_irqsave(&port
->lock
, flags
);
827 pkt
->tag
.type
= VIO_TYPE_DATA
;
830 /* Minimum of data to write and space available */
831 tosend
= min(count
, (VCC_BUFF_LEN
- port
->chars_in_buffer
));
836 memcpy(&pkt
->data
[port
->chars_in_buffer
], &buf
[total_sent
],
838 port
->chars_in_buffer
+= tosend
;
839 pkt
->tag
.stype
= tosend
;
841 vccdbg("TAG [%02x:%02x:%04x:%08x]\n", pkt
->tag
.type
,
842 pkt
->tag
.stype
, pkt
->tag
.stype_env
, pkt
->tag
.sid
);
843 vccdbg("DATA [%s]\n", pkt
->data
);
844 vccdbgl(port
->vio
.lp
);
846 /* Since we know we have enough room in VCC buffer for tosend
847 * we record that it was sent regardless of whether the
848 * hypervisor actually took it because we have it buffered.
850 rv
= ldc_write(port
->vio
.lp
, pkt
, (VIO_TAG_SIZE
+ tosend
));
851 vccdbg("VCC: write: ldc_write(%d)=%d\n",
852 (VIO_TAG_SIZE
+ tosend
), rv
);
854 total_sent
+= tosend
;
861 port
->chars_in_buffer
= 0;
864 spin_unlock_irqrestore(&port
->lock
, flags
);
866 vcc_put(port
, false);
868 vccdbg("VCC: write: total=%d rv=%d", total_sent
, rv
);
870 return total_sent
? total_sent
: rv
;
873 static unsigned int vcc_write_room(struct tty_struct
*tty
)
875 struct vcc_port
*port
;
878 port
= vcc_get_ne(tty
->index
);
879 if (unlikely(!port
)) {
880 pr_err("VCC: write_room: Failed to find VCC port\n");
884 num
= VCC_BUFF_LEN
- port
->chars_in_buffer
;
886 vcc_put(port
, false);
891 static int vcc_chars_in_buffer(struct tty_struct
*tty
)
893 struct vcc_port
*port
;
896 port
= vcc_get_ne(tty
->index
);
897 if (unlikely(!port
)) {
898 pr_err("VCC: chars_in_buffer: Failed to find VCC port\n");
902 num
= port
->chars_in_buffer
;
904 vcc_put(port
, false);
909 static int vcc_break_ctl(struct tty_struct
*tty
, int state
)
911 struct vcc_port
*port
;
914 port
= vcc_get_ne(tty
->index
);
915 if (unlikely(!port
)) {
916 pr_err("VCC: break_ctl: Failed to find VCC port\n");
922 vcc_put(port
, false);
926 spin_lock_irqsave(&port
->lock
, flags
);
928 if (vcc_send_ctl(port
, VCC_CTL_BREAK
) < 0)
931 spin_unlock_irqrestore(&port
->lock
, flags
);
933 vcc_put(port
, false);
938 static int vcc_install(struct tty_driver
*driver
, struct tty_struct
*tty
)
940 struct vcc_port
*port_vcc
;
941 struct tty_port
*port_tty
;
944 if (tty
->index
>= VCC_MAX_PORTS
)
947 ret
= tty_standard_install(driver
, tty
);
951 port_tty
= kzalloc(sizeof(struct tty_port
), GFP_KERNEL
);
955 port_vcc
= vcc_get(tty
->index
, true);
957 pr_err("VCC: install: Failed to find VCC port\n");
963 tty_port_init(port_tty
);
964 port_tty
->ops
= &vcc_port_ops
;
965 tty
->port
= port_tty
;
969 vcc_put(port_vcc
, true);
974 static void vcc_cleanup(struct tty_struct
*tty
)
976 struct vcc_port
*port
;
978 port
= vcc_get(tty
->index
, true);
983 vcc_table_remove(tty
->index
);
984 kfree(port
->vio
.name
);
992 tty_port_destroy(tty
->port
);
997 static const struct tty_operations vcc_ops
= {
1000 .hangup
= vcc_hangup
,
1002 .write_room
= vcc_write_room
,
1003 .chars_in_buffer
= vcc_chars_in_buffer
,
1004 .break_ctl
= vcc_break_ctl
,
1005 .install
= vcc_install
,
1006 .cleanup
= vcc_cleanup
,
1009 #define VCC_TTY_FLAGS (TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_REAL_RAW)
1011 static int vcc_tty_init(void)
1015 vcc_tty_driver
= tty_alloc_driver(VCC_MAX_PORTS
, VCC_TTY_FLAGS
);
1016 if (IS_ERR(vcc_tty_driver
)) {
1017 pr_err("VCC: TTY driver alloc failed\n");
1018 return PTR_ERR(vcc_tty_driver
);
1021 vcc_tty_driver
->driver_name
= "vcc";
1022 vcc_tty_driver
->name
= "vcc";
1024 vcc_tty_driver
->minor_start
= VCC_MINOR_START
;
1025 vcc_tty_driver
->type
= TTY_DRIVER_TYPE_SYSTEM
;
1026 vcc_tty_driver
->init_termios
= vcc_tty_termios
;
1028 tty_set_operations(vcc_tty_driver
, &vcc_ops
);
1030 rv
= tty_register_driver(vcc_tty_driver
);
1032 pr_err("VCC: TTY driver registration failed\n");
1033 put_tty_driver(vcc_tty_driver
);
1034 vcc_tty_driver
= NULL
;
1038 vccdbg("VCC: TTY driver registered\n");
1043 static void vcc_tty_exit(void)
1045 tty_unregister_driver(vcc_tty_driver
);
1046 put_tty_driver(vcc_tty_driver
);
1047 vccdbg("VCC: TTY driver unregistered\n");
1049 vcc_tty_driver
= NULL
;
1052 static int __init
vcc_init(void)
1056 rv
= vcc_tty_init();
1058 pr_err("VCC: TTY init failed\n");
1062 rv
= vio_register_driver(&vcc_driver
);
1064 pr_err("VCC: VIO driver registration failed\n");
1067 vccdbg("VCC: VIO driver registered successfully\n");
1073 static void __exit
vcc_exit(void)
1075 vio_unregister_driver(&vcc_driver
);
1076 vccdbg("VCC: VIO driver unregistered\n");
1078 vccdbg("VCC: TTY driver unregistered\n");
1081 module_init(vcc_init
);
1082 module_exit(vcc_exit
);