Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  n_tracerouter.c - Trace data router through tty space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Copyright (C) Intel 2011
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * This trace router uses the Linux line discipline framework to route
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * trace data coming from a HW Modem to a PTI (Parallel Trace Module) port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * The solution is not specific to a HW modem and this line disciple can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * be used to route any stream of data in kernel space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * This is part of a solution for the P1149.7, compact JTAG, standard.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/ioctl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/tty.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/tty_ldisc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <linux/bug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include "n_tracesink.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * Other ldisc drivers use 65536 which basically means,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * 'I can always accept 64k' and flow control is off.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * This number is deemed appropriate for this driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define RECEIVE_ROOM	65536
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define DRIVERNAME	"n_tracerouter"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * struct to hold private configuration data for this ldisc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * opencalled is used to hold if this ldisc has been opened.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * kref_tty holds the tty reference the ldisc sits on top of.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) struct tracerouter_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	u8 opencalled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	struct tty_struct *kref_tty;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) static struct tracerouter_data *tr_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) /* lock for when tty reference is being used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) static DEFINE_MUTEX(routelock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * n_tracerouter_open() - Called when a tty is opened by a SW entity.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * @tty: terminal device to the ldisc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * Return:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  *      0 for success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  * Caveats: This should only be opened one time per SW entity.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) static int n_tracerouter_open(struct tty_struct *tty)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	int retval = -EEXIST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	mutex_lock(&routelock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	if (tr_data->opencalled == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		tr_data->kref_tty = tty_kref_get(tty);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		if (tr_data->kref_tty == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 			retval = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 			tr_data->opencalled = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 			tty->disc_data      = tr_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 			tty->receive_room   = RECEIVE_ROOM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 			tty_driver_flush_buffer(tty);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 			retval = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	mutex_unlock(&routelock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  * n_tracerouter_close() - close connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  * @tty: terminal device to the ldisc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  * Called when a software entity wants to close a connection.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) static void n_tracerouter_close(struct tty_struct *tty)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	struct tracerouter_data *tptr = tty->disc_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	mutex_lock(&routelock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	WARN_ON(tptr->kref_tty != tr_data->kref_tty);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	tty_driver_flush_buffer(tty);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	tty_kref_put(tr_data->kref_tty);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	tr_data->kref_tty = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	tr_data->opencalled = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	tty->disc_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	mutex_unlock(&routelock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * n_tracerouter_read() - read request from user space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  * @tty:  terminal device passed into the ldisc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  * @file: pointer to open file object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  * @buf:  pointer to the data buffer that gets eventually returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  * @nr:   number of bytes of the data buffer that is returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  * function that allows read() functionality in userspace. By default if this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  * is not implemented it returns -EIO. This module is functioning like a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  * router via n_tracerouter_receivebuf(), and there is no real requirement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  * to implement this function. However, an error return value other than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  * -EIO should be used just to show that there was an intent not to have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  * this function implemented.  Return value based on read() man pages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  * Return:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  *	 -EINVAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static ssize_t n_tracerouter_read(struct tty_struct *tty, struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 				  unsigned char *buf, size_t nr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 				  void **cookie, unsigned long offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * n_tracerouter_write() - Function that allows write() in userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  * @tty:  terminal device passed into the ldisc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  * @file: pointer to open file object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  * @buf:  pointer to the data buffer that gets eventually returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  * @nr:   number of bytes of the data buffer that is returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  * By default if this is not implemented, it returns -EIO.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  * This should not be implemented, ever, because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)  * 1. this driver is functioning like a router via
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)  *    n_tracerouter_receivebuf()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  * 2. No writes to HW will ever go through this line discpline driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)  * However, an error return value other than -EIO should be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  * just to show that there was an intent not to have this function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  * implemented.  Return value based on write() man pages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  * Return:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  *	-EINVAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) static ssize_t n_tracerouter_write(struct tty_struct *tty, struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 				   const unsigned char *buf, size_t nr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  * n_tracerouter_receivebuf() - Routing function for driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  * @tty: terminal device passed into the ldisc.  It's assumed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  *       tty will never be NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  * @cp:  buffer, block of characters to be eventually read by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  *       someone, somewhere (user read() call or some kernel function).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  * @fp:  flag buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  * @count: number of characters (aka, bytes) in cp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  * This function takes the input buffer, cp, and passes it to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  * an external API function for processing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) static void n_tracerouter_receivebuf(struct tty_struct *tty,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 					const unsigned char *cp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 					char *fp, int count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	mutex_lock(&routelock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	n_tracesink_datadrain((u8 *) cp, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	mutex_unlock(&routelock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)  * Flush buffer is not impelemented as the ldisc has no internal buffering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  * so the tty_driver_flush_buffer() is sufficient for this driver's needs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) static struct tty_ldisc_ops tty_ptirouter_ldisc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	.owner		= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	.magic		= TTY_LDISC_MAGIC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	.name		= DRIVERNAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	.open		= n_tracerouter_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	.close		= n_tracerouter_close,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	.read		= n_tracerouter_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	.write		= n_tracerouter_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	.receive_buf	= n_tracerouter_receivebuf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  * n_tracerouter_init -	module initialisation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  * Registers this module as a line discipline driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  * Return:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)  *	0 for success, any other value error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) static int __init n_tracerouter_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	tr_data = kzalloc(sizeof(struct tracerouter_data), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	if (tr_data == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	/* Note N_TRACEROUTER is defined in linux/tty.h */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	retval = tty_register_ldisc(N_TRACEROUTER, &tty_ptirouter_ldisc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	if (retval < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		pr_err("%s: Registration failed: %d\n", __func__, retval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		kfree(tr_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)  * n_tracerouter_exit -	module unload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)  * Removes this module as a line discipline driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) static void __exit n_tracerouter_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	int retval = tty_unregister_ldisc(N_TRACEROUTER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	if (retval < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		pr_err("%s: Unregistration failed: %d\n", __func__,  retval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		kfree(tr_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) module_init(n_tracerouter_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) module_exit(n_tracerouter_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) MODULE_AUTHOR("Jay Freyensee");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) MODULE_ALIAS_LDISC(N_TRACEROUTER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) MODULE_DESCRIPTION("Trace router ldisc driver");