linux/drivers/tty/n_tracerouter.c
<<
"v2/spaval "v2/formal "v2a "v href="../linux+v3.7.4/drivers/tty/n_tracerouter.c"> "v2img src="../.static/gfx/right.png" alt=">>"> 2/spaval 2spav class="lxr_search"> "v2input typ >hidden" nam >navtarget" 1" >"> "v2input typ >text" nam >search" id >search"> "v2butt3.1typ >submit">Search "vPrefsl "v2/a> 2/spaval "v v2/dival "v v2form acon v="ajax+*" method="post" onsubmit="return false;"> 2input typ >hidden" nam >ajax_lookup" id >ajax_lookup" 1" >"> "v v2/formal "v v2div class="headingbott3m">search_results" class="search_results"l "al "v v2/dival 2div id >content">l 2div id >file_contents"a
8d/77/5e67103a3404fab60c90f05880a22d86ff24_3/0"aL1" class="line" nam  >L1">v v12/a>2spav class="comment">/*2/spavalL2" class="line" nam  >L2">v v22/a>2spav class="comment"> *  n_tracerouter.c - Trace data router through tty space2/spavalL3" class="line" nam  >L3">v v32/a>2spav class="comment"> *2/spavalL4" class="line" nam  >L4">v v42/a>2spav class="comment"> *  Copyright (C) Intel 201 opspavalL5" class="line" nam  >L5">v v52/a>2spav class="comment"> *2/spavalL6" class="line" nam  >L6">v v62/a>2spav class="comment"> * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~2/spavalL7" class="line" nam  >L7">v v72/a>2spav class="comment"> *2/spavalL8" class="line" nam  >L8">v v82/a>2spav class="comment"> *  This program is free software; you cav redistribute it and/or modify2/spavalL9" class="line" nam  >L9">v v92/a>2spav class="comment"> *  it under the terms of the GNU General Public License vers33.122/spavalL10" class="line" nam  >L10">v  2spav class="comment"> *  as published by the Free Software Foundaon v.2/spavalL11" class="line" nam  >L11">v 112/a>2spav class="comment"> *2/spavalL12" class="line" nam  >L12">v 122/a>2spav class="comment"> *  This program is distributed in the hope that it will be useful,2/spavalL13" class="line" nam  >L13">v 132/a>2spav class="comment"> *  but WITHOUT ANY WARRANTY; without even the implied warranty of2/spavalL14" class="line" nam  >L14">v 142/a>2spav class="comment"> *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the2/spavalL15" class="line" nam  >L15">v 152/a>2spav class="comment"> *  GNU General Public License for more details.2/spavalL16" class="line" nam  >L16">v 162/a>2spav class="comment"> *2/spavalL17" class="line" nam  >L17">v 172/a>2spav class="comment"> * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~2/spavalL18" class="line" nam  >L18">v 182/a>2spav class="comment"> *2/spavalL19" class="line" nam  >L19">v 192/a>2spav class="comment"> * This trace router uses the Linux line discipline framework to route2/spavalL20" class="line" nam  >L20">v 22spav class="comment"> * trace data coming from a HW Modem to a PTI (Parallel Trace Module) port.2/spavalL21" class="line" nam  >L21">v 212/a>2spav class="comment"> * The solu.33.1is not specific to a HW modem and this line disciple cav2/spavalL22" class="line" nam  >L22">v 222/a>2spav class="comment"> * be used to route any stream of data in kernel space.2/spavalL23" class="line" nam  >L23">v 232/a>2spav class="comment"> * This is part of a solu.33.1for the P1149.7, compact JTAG, standard.2/spavalL24" class="line" nam  >L24">v 242/a>2spav class="comment"> */2/spavalL25" class="line" nam  >L25">v 252/a>lL26" class="line" nam  >L26">v 262/a>#include <linux/init.h2/a>>lL27" class="line" nam  >L27">v 272/a>#include <linux/kernel.h2/a>>lL28" class="line" nam  >L28">v 282/a>#include <linux/module.h2/a>>lL29" class="line" nam  >L29">v 292/a>#include <linux/typ s.h2/a>>lL30" class="line" nam  >L30">v 302/a>#include <linux/ioctl.h2/a>>lL31" class="line" nam  >L31">v 312/a>#include <linux/tty.h2/a>>lL32" class="line" nam  >L32">v 322/a>#include <linux/tty_ldisc.h2/a>>lL33" class="line" nam  >L33">v 332/a>#include <linux/errno.h2/a>>lL34" class="line" nam  >L34">v 342/a>#include <linux/string.h2/a>>lL35" class="line" nam  >L35">v 352/a>#include <linux/mutex.h2/a>>lL36" class="line" nam  >L36">v 362/a>#include <linux/slab.h2/a>>lL37" class="line" nam  >L37">v 372/a>#include <asm-generic/bug.h2/a>>lL38" class="line" nam  >L38">v 382/a>#include "n_tracesink.h2/a>"lL39" class="line" nam  >L39">v 392/a>lL40" class="line" nam  >L40">v 42spav class="comment">/*2/spavalL41" class="line" nam  >L41">v 412/a>2spav class="comment"> * Other ldisc drivers use 65536 which basically means,2/spavalL42" class="line" nam  >L42">v 422/a>2spav class="comment"> * 'I cav always accept 64k' and flow control is off.2/spavalL43" class="line" nam  >L43">v 432/a>2spav class="comment"> * This number is deemed appropriate1for this driver.2/spavalL44" class="line" nam  >L44">v 442/a>2spav class="comment"> */2/spavalL45" class="line" nam  >L45">v 452/a>#define 2a href="+code=RECEIVE_ROOM" class="sref">RECEIVE_ROOM2/a>"v v65536lL46" class="line" nam  >L46">v 462/a>#define 2a href="+code=DRIVERNAME" class="sref">DRIVERNAME2/a>"v v  2spav class="string">"n_tracerouter"L47" class="line" nam  >L47">v 472/a>lL48" class="line" nam  >L48">v 482/a>2spav class="comment">/*2/spavalL49" class="line" nam  >L49">v 492/a>2spav class="comment"> * struct to hold private1configuraon v data for this ldisc.opspavalL50" class="line" nam  >L50">v 52spav class="comment"> * opencalled is used to hold if this ldisc has been opened.2/spavalL51" class="line" nam  >L51">v 512/a>2spav class="comment"> * kref_tty holds the tty reference the ldisc sits on top of.2/spavalL52" class="line" nam  >L52">v 522/a>2spav class="comment"> */2/spavalL53" class="line" nam  >L53">v 532/a>struct 2a href="+code=tracerouter_data" class="sref">tracerouter_data2/a>"{lL54" class="line" nam  >L54">v 542/a>"v v    2a href="+code=u8" class="sref">u82/a> 2a href="+code=opencalled" class="sref">opencalled2/a>;lL55" class="line" nam  >L55">v 552/a>"v v    struct 2a href="+code=tty_struct" class="sref">tty_struct2/a>"*2a href="+code=kref_tty" class="sref">kref_tty2/a>;lL56" class="line" nam  >L56">v 562/a>};lL57" class="line" nam  >L57">v 572/a>static struct 2a href="+code=tracerouter_data" class="sref">tracerouter_data2/a>"*2a href="+code=tr_data" class="sref">tr_data2/a>;lL58" class="line" nam  >L58">v 582/a>lL59" class="line" nam  >L59">v 592/a>2spav class="comment">/* lock for when tty reference is being used */2/spavalL60" class="line" nam  >L60">v 602/a>static 2a href="+code=DEFINE_MUTEX" class="sref">DEFINE_MUTEX2/a>(2a href="+code=routelock" class="sref">routelock2/a>);lL61" class="line" nam  >L61">v 612/a>lL62" class="line" nam  >L62">v 622/a>2spav class="comment">/**2/spavalL63" class="line" nam  >L63">v 632/a>2spav class="comment"> * n_tracerouter_open() - Called when a tty is opened by a SW entity.2/spavalL64" class="line" nam  >L64">v 642/a>2spav class="comment"> * @tty: terminal device to the ldisc.2/spavalL65" class="line" nam  >L65">v 652/a>2spav class="comment"> *2/spavalL66" class="line" nam  >L66">v 662/a>2spav class="comment"> * Return:2/spavalL67" class="line" nam  >L67">v 672/a>2spav class="comment"> *      0 for success.2/spavalL68" class="line" nam  >L68">v 682/a>2spav class="comment"> *2/spavalL69" class="line" nam  >L69">v 692/a>2spav class="comment"> * Caveats: This should only be opened one time per SW entity.2/spavalL70" class="line" nam  >L70">v 72spav class="comment"> */2/spavalL71" class="line" nam  >L71">v 712/a>static int 2a href="+code=n_tracerouter_open" class="sref">n_tracerouter_open2/a>(struct 2a href="+code=tty_struct" class="sref">tty_struct2/a>"*2a href="+code=tty" class="sref">tty2/a>)lL72" class="line" nam  >L72">v 722/a>{lL73" class="line" nam  >L73">v 732/a>"v v    int 2a href="+code=retval" class="sref">retval2/a>"= -2a href="+code=EEXIST" class="sref">EEXIST2/a>;lL74" class="line" nam  >L74">v 742/a>lL75" class="line" nam  >L75">v 752/a>"v v    2a href="+code=mutex_lock" class="sref">mutex_lock2/a>(&2a href="+code=routelock" class="sref">routelock2/a>);lL76" class="line" nam  >L76">v 762/a>"v v    if (2a href="+code=tr_data" class="sref">tr_data2/a>->2a href="+code=opencalled" class="sref">opencalled2/a> == 0)"{lL77" class="line" nam  >L77">v 772/a>lL78" class="line" nam  >L78">v 782/a>"v v    "v v    2a href="+code=tr_data" class="sref">tr_data2/a>->2a href="+code=kref_tty" class="sref">kref_tty2/a>"= 2a href="+code=tty_kref_get" class="sref">tty_kref_get2/a>(2a href="+code=tty" class="sref">tty2/a>);lL79" class="line" nam  >L79">v 792/a>"v v    "v v    if (2a href="+code=tr_data" class="sref">tr_data2/a>->2a href="+code=kref_tty" class="sref">kref_tty2/a>"== 2a href="+code=NULL" class="sref">NULL2/a>)"{lL80" class="line" nam  >L80">v 802/a>"v v    "v v    "v v    2a href="+code=retval" class="sref">retval2/a>"= -2a href="+code=EFAULT" class="sref">EFAULT2/a>;lL81" class="line" nam  >L81">v 812/a>"v v    "v v    } else"{lL82" class="line" nam  >L82">v 822/a>"v v    "v v    "v v    2a href="+code=tr_data" class="sref">tr_data2/a>->2a href="+code=opencalled" class="sref">opencalled2/a> = 1;lL83" class="line" nam  >L83">v 832/a>"v v    "v v    "v v    2a href="+code=tty" class="sref">tty2/a>->2a href="+code=disc_data" class="sref">disc_data2/a>"v v  = 2a href="+code=tr_data" class="sref">tr_data2/a>;lL84" class="line" nam  >L84">v 842/a>"v v    "v v    "v v    2a href="+code=tty" class="sref">tty2/a>->2a href="+code=receive_room" class="sref">receive_room2/a>"v = 2a href="+code=RECEIVE_ROOM" class="sref">RECEIVE_ROOM2/a>;lL85" class="line" nam  >L85">v 852/a>"v v    "v v    "v v    2a href="+code=tty_driver_flush_buffer" class="sref">tty_driver_flush_buffer2/a>(2a href="+code=tty" class="sref">tty2/a>);lL86" class="line" nam  >L86">v 862/a>"v v    "v v    "v v    2a href="+code=retval" class="sref">retval2/a>"= 0;lL87" class="line" nam  >L87">v 872/a>"v v    "v v    }lL88" class="line" nam  >L88">v 882/a>"v v    }lL89" class="line" nam  >L89">v 892/a>"v v    2a href="+code=mutex_unlock" class="sref">mutex_unlock2/a>(&2a href="+code=routelock" class="sref">routelock2/a>);lL90" class="line" nam  >L90">v 902/a>"v v    return 2a href="+code=retval" class="sref">retval2/a>;lL91" class="line" nam  >L91">v 912/a>}lL92" class="line" nam  >L92">v 922/a>lL93" class="line" nam  >L93">v 932/a>2spav class="comment">/**2/spavalL94" class="line" nam  >L94">v 942/a>2spav class="comment"> * n_tracerouter_close() - close1connecon v2/spavalL95" class="line" nam  >L95">v 952/a>2spav class="comment"> * @tty: terminal device to the ldisc.2/spavalL96" class="line" nam  >L96">v 962/a>2spav class="comment"> *2/spavalL97" class="line" nam  >L97">v 972/a>2spav class="comment"> * Called when a software entity wants to close1a1connecon v.2/spavalL98" class="line" nam  >L98">v 982/a>2spav class="comment"> */2/spavalL99" class="line" nam  >L99">v 992/a>static void 2a href="+code=n_tracerouter_close" class="sref">n_tracerouter_close2/a>(struct 2a href="+code=tty_struct" class="sref">tty_struct2/a>"*2a href="+code=tty" class="sref">tty2/a>)lL100" class="line" nam  >L100">v1002/a>{lL101" class="line" nam  >L101">v1012/a>"v v    struct 2a href="+code=tracerouter_data" class="sref">tracerouter_data2/a>"*2a href="+code=tptr" class="sref">tptr2/a>"= 2a href="+code=tty" class="sref">tty2/a>->2a href="+code=disc_data" class="sref">disc_data2/a>;lL102" class="line" nam  >L102">v1022/a>lL103" class="line" nam  >L103">v1032/a>"v v    2a href="+code=mutex_lock" class="sref">mutex_lock2/a>(&2a href="+code=routelock" class="sref">routelock2/a>);lL104" class="line" nam  >L104">v1042/a>"v v    2a href="+code=WARN_ON" class="sref">WARN_ON2/a>(2a href="+code=tptr" class="sref">tptr2/a>->2a href="+code=kref_tty" class="sref">kref_tty2/a>"!= 2a href="+code=tr_data" class="sref">tr_data2/a>->2a href="+code=kref_tty" class="sref">kref_tty2/a>);lL105" class="line" nam  >L105">v1052/a>"v v    2a href="+code=tty_driver_flush_buffer" class="sref">tty_driver_flush_buffer2/a>(2a href="+code=tty" class="sref">tty2/a>);lL106" class="line" nam  >L106">v1062/a>"v v    2a href="+code=tty_kref_put" class="sref">tty_kref_put2/a>(2a href="+code=tr_data" class="sref">tr_data2/a>->2a href="+code=kref_tty" class="sref">kref_tty2/a>);lL107" class="line" nam  >L107">v1072/a>"v v    2a href="+code=tr_data" class="sref">tr_data2/a>->2a href="+code=kref_tty" class="sref">kref_tty2/a>"= 2a href="+code=NULL" class="sref">NULL2/a>;lL108" class="line" nam  >L108">v1082/a>"v v    2a href="+code=tr_data" class="sref">tr_data2/a>->2a href="+code=opencalled" class="sref">opencalled2/a> = 0;lL109" class="line" nam  >L109">v1092/a>"v v    2a href="+code=tty" class="sref">tty2/a>->2a href="+code=disc_data" class="sref">disc_data2/a>"= 2a href="+code=NULL" class="sref">NULL2/a>;lL110" class="line" nam  >L110">v1102/a>"v v    2a href="+code=mutex_unlock" class="sref">mutex_unlock2/a>(&2a href="+code=routelock" class="sref">routelock2/a>);lL111" class="line" nam  >L111">v1112/a>}lL112" class="line" nam  >L112">v1122/a>lL113" class="line" nam  >L113">v1132/a>2spav class="comment">/**2/spavalL114" class="line" nam  >L114">v1142/a>2spav class="comment"> * n_tracerouter_read() - read request from user space2/spavalL115" class="line" nam  >L115">v1152/a>2spav class="comment"> * @tty:  terminal device passed into the ldisc.2/spavalL116" class="line" nam  >L116">v1162/a>2spav class="comment"> * @file: pointer to open file objeco.2/spavalL117" class="line" nam  >L117">v1172/a>2spav class="comment"> * @buf:  pointer to the data buffer that gets eventually returned.2/spavalL118" class="line" nam  >L118">v1182/a>2spav class="comment"> * @nr:   number of bytes of the data buffer that is returned.2/spavalL119" class="line" nam  >L119">v1192/a>2spav class="comment"> *2/spavalL120" class="line" nam  >L120">v122spav class="comment"> * funcon v that allows read() funcon vality in userspace. By default if this2/spavalL121" class="line" nam  >L121">v1212/a>2spav class="comment"> * is not implemented it returns -EIO. This module is funcon ving like a2/spavalL122" class="line" nam  >L122">v1222/a>2spav class="comment"> * router via n_tracerouter_receivebuf(), and there is no real requirement2/spavalL123" class="line" nam  >L123">v1232/a>2spav class="comment"> * to implement this funcon v. However, an error return 1"
	  other thav2/spavalL124" class="line" nam  >L124">v1242/a>2spav class="comment"> * -EIO should be used just to show that there was an intent not to have2/spavalL125" class="line" nam  >L125">v1252/a>2spav class="comment"> * this funcon v implemented.  Return 1"
	  based on read() mav pages.2/spavalL126" class="line" nam  >L126">v1262/a>2spav class="comment"> *2/spavalL127" class="line" nam  >L127">v1272/a>2spav class="comment"> * Return:2/spavalL128" class="line" nam  >L128">v1282/a>2spav class="comment"> *       -EINVAL2/spavalL129" class="line" nam  >L129">v1292/a>2spav class="comment"> */2/spavalL130" class="line" nam  >L130">v1302/a>static 2a href="+code=ssize_t" class="sref">ssize_t2/a>"2a href="+code=n_tracerouter_read" class="sref">n_tracerouter_read2/a>(struct 2a href="+code=tty_struct" class="sref">tty_struct2/a>"*2a href="+code=tty" class="sref">tty2/a>, struct 2a href="+code=file" class="sref">file2/a>"*2a href="+code=file" class="sref">file2/a>,lL131" class="line" nam  >L131">v1312/a>"v v    "v v                      unsigned char 2a href="+code=__user" class="sref">__user2/a>"*2a href="+code=buf" class="sref">buf2/a>, 2a href="+code=size_t" class="sref">size_t2/a>"2a href="+code=nr" class="sref">nr2/a>)"{lL132" class="line" nam  >L132">v1322/a>"v v    return -2a href="+code=EINVAL" class="sref">EINVAL2/a>;lL133" class="line" nam  >L133">v1332/a>}lL134" class="line" nam  >L134">v1342/a>lL135" class="line" nam  >L135">v1352/a>2spav class="comment">/**2/spavalL136" class="line" nam  >L136">v1362/a>2spav class="comment"> * n_tracerouter_write() - Funcon v that allows write() in userspace.2/spavalL137" class="line" nam  >L137">v1372/a>2spav class="comment"> * @tty:  terminal device passed into the ldisc.2/spavalL138" class="line" nam  >L138">v1382/a>2spav class="comment"> * @file: pointer to open file objeco.2/spavalL139" class="line" nam  >L139">v1392/a>2spav class="comment"> * @buf:  pointer to the data buffer that gets eventually returned.2/spavalL140" class="line" nam  >L140">v142spav class="comment"> * @nr:   number of bytes of the data buffer that is returned.2/spavalL141" class="line" nam  >L141">v1412/a>2spav class="comment"> *2/spavalL142" class="line" nam  >L142">v1422/a>2spav class="comment"> * By default if this is not implemented, it returns -EIO.2/spavalL143" class="line" nam  >L143">v1432/a>2spav class="comment"> * This should not be implemented, ever, because2/spavalL144" class="line" nam  >L144">v1442/a>2spav class="comment"> * 1. this driver is funcon ving like a router via2/spavalL145" class="line" nam  >L145">v1452/a>2spav class="comment"> *    n_tracerouter_receivebuf()2/spavalL146" class="line" nam  >L146">v1462/a>2spav class="comment"> * 2. No writes to HW will ever go through this line discpline driver.2/spavalL147" class="line" nam  >L147">v1472/a>2spav class="comment"> * However, an error return 1"
	  other thav -EIO should be used2/spavalL148" class="line" nam  >L148">v1482/a>2spav class="comment"> * just to show that there was an intent not to have this funcon v2/spavalL149" class="line" nam  >L149">v1492/a>2spav class="comment"> * implemented.  Return 1"
	  based on write() mav pages.2/spavalL150" class="line" nam  >L150">v152spav class="comment"> *2/spavalL151" class="line" nam  >L151">v1512/a>2spav class="comment"> * Return:2/spavalL152" class="line" nam  >L152">v1522/a>2spav class="comment"> *      -EINVAL2/spavalL153" class="line" nam  >L153">v1532/a>2spav class="comment"> */2/spavalL154" class="line" nam  >L154">v1542/a>static 2a href="+code=ssize_t" class="sref">ssize_t2/a>"2a href="+code=n_tracerouter_write" class="sref">n_tracerouter_write2/a>(struct 2a href="+code=tty_struct" class="sref">tty_struct2/a>"*2a href="+code=tty" class="sref">tty2/a>, struct 2a href="+code=file" class="sref">file2/a>"*2a href="+code=file" class="sref">file2/a>,lL155" class="line" nam  >L155">v1552/a>"v v    "v v    "v v               const unsigned char *2a href="+code=buf" class="sref">buf2/a>, 2a href="+code=size_t" class="sref">size_t2/a>"2a href="+code=nr" class="sref">nr2/a>)"{lL156" class="line" nam  >L156">v1562/a>"v v    return -2a href="+code=EINVAL" class="sref">EINVAL2/a>;lL157" class="line" nam  >L157">v1572/a>}lL158" class="line" nam  >L158">v1582/a>lL159" class="line" nam  >L159">v1592/a>2spav class="comment">/**2/spavalL160" class="line" nam  >L160">v162spav class="comment"> * n_tracerouter_receivebuf() - Routing funcon v for driver.2/spavalL161" class="line" nam  >L161">v1612/a>2spav class="comment"> * @tty: terminal device passed into the ldisc.  It's assumed2/spavalL162" class="line" nam  >L162">v1622/a>2spav class="comment"> *       tty will never be NULL.2/spavalL163" class="line" nam  >L163">v1632/a>2spav class="comment"> * @cp:  buffer, block of characters to be eventually read by2/spavalL164" class="line" nam  >L164">v1642/a>2spav class="comment"> *       someone, somewhere (user read() call or some kernel funcon v).2/spavalL165" class="line" nam  >L165">v1652/a>2spav class="comment"> * @fp:  flag buffer.2/spavalL166" class="line" nam  >L166">v1662/a>2spav class="comment"> * @count: number of characters (aka, bytes) in cp.2/spavalL167" class="line" nam  >L167">v1672/a>2spav class="comment"> *2/spavalL168" class="line" nam  >L168">v1682/a>2spav class="comment"> * This funcon v takes the input buffer, cp, and passes it to2/spavalL169" class="line" nam  >L169">v1692/a>2spav class="comment"> * an external API funcon v for processing.2/spavalL170" class="line" nam  >L170">v172spav class="comment"> */2/spavalL171" class="line" nam  >L171">v1712/a>static void 2a href="+code=n_tracerouter_receivebuf" class="sref">n_tracerouter_receivebuf2/a>(struct 2a href="+code=tty_struct" class="sref">tty_struct2/a>"*2a href="+code=tty" class="sref">tty2/a>,lL172" class="line" nam  >L172">v1722/a>"v v    "v v    "v v    v               const unsigned char *2a href="+code=cp" class="sref">cp2/a>,lL173" class="line" nam  >L173">v1732/a>"v v    "v v    "v v    v               char *2a href="+code=fp" class="sref">fp2/a>, int 2a href="+code=count" class="sref">count2/a>)lL174" class="line" nam  >L174">v1742/a>{lL175" class="line" nam  >L175">v1752/a>"v v    2a href="+code=mutex_lock" class="sref">mutex_lock2/a>(&2a href="+code=routelock" class="sref">routelock2/a>);lL176" class="line" nam  >L176">v1762/a>"v v    2a href="+code=n_tracesink_datadrain" class="sref">n_tracesink_datadrain2/a>((2a href="+code=u8" class="sref">u82/a> *) 2a href="+code=cp" class="sref">cp2/a>, 2a href="+code=count" class="sref">count2/a>);lL177" class="line" nam  >L177">v1772/a>"v v    2a href="+code=mutex_unlock" class="sref">mutex_unlock2/a>(&2a href="+code=routelock" class="sref">routelock2/a>);lL178" class="line" nam  >L178">v1782/a>}lL179" class="line" nam  >L179">v1792/a>lL180" class="line" nam  >L180">v182spav class="comment">/*2/spavalL181" class="line" nam  >L181">v1812/a>2spav class="comment"> * Flush buffer is not impelemented as the ldisc has no internal buffering2/spavalL182" class="line" nam  >L182">v1822/a>2spav class="comment"> * so the tty_driver_flush_buffer() is sufficient for this driver's needs.2/spavalL183" class="line" nam  >L183">v1832/a>2spav class="comment"> */2/spavalL184" class="line" nam  >L184">v1842/a>lL185" class="line" nam  >L185">v1852/a>static struct 2a href="+code=tty_ldisc_ops" class="sref">tty_ldisc_ops2/a>"2a href="+code=tty_ptirouter_ldisc" class="sref">tty_ptirouter_ldisc2/a>"= {lL186" class="line" nam  >L186">v1862/a>"v v    .2a href="+code=owner" class="sref">owner2/a>"v v    "v= 2a href="+code=THIS_MODULE" class="sref">THIS_MODULE2/a>,lL187" class="line" nam  >L187">v1872/a>"v v    .2a href="+code=magic" class="sref">magic2/a>"v v    "v= 2a href="+code=TTY_LDISC_MAGIC" class="sref">TTY_LDISC_MAGIC2/a>,lL188" class="line" nam  >L188">v1882/a>"v v    .2a href="+code=nam " class="sref">nam 2/a>"v v    "v = 2a href="+code=DRIVERNAME" class="sref">DRIVERNAME2/a>,lL189" class="line" nam  >L189">v1892/a>"v v    .2a href="+code=open" class="sref">open2/a>"v v    "v = 2a href="+code=n_tracerouter_open" class="sref">n_tracerouter_open2/a>,lL190" class="line" nam  >L190">v1902/a>"v v    .2a href="+code=close" class="sref">close2/a>v v    "v = 2a href="+code=n_tracerouter_close" class="sref">n_tracerouter_close2/a>,lL191" class="line" nam  >L191">v1912/a>"v v    .2a href="+code=read" class="sref">read2/a>"v v    "v = 2a href="+code=n_tracerouter_read" class="sref">n_tracerouter_read2/a>,lL192" class="line" nam  >L192">v1922/a>"v v    .2a href="+code=write" class="sref">write2/a>v v    "v = 2a href="+code=n_tracerouter_write" class="sref">n_tracerouter_write2/a>,lL193" class="line" nam  >L193">v1932/a>"v v    .2a href="+code=receive_buf" class="sref">receive_buf2/a>"v v= 2a href="+code=n_tracerouter_receivebuf" class="sref">n_tracerouter_receivebuf2/a>lL194" class="line" nam  >L194">v1942/a>};lL195" class="line" nam  >L195">v1952/a>lL196" class="line" nam  >L196">v1962/a>2spav class="comment">/**2/spavalL197" class="line" nam  >L197">v1972/a>2spav class="comment"> * n_tracerouter_init - module initialisaon v2/spavalL198" class="line" nam  >L198">v1982/a>2spav class="comment"> *2/spavalL199" class="line" nam  >L199">v1992/a>2spav class="comment"> * Registers this module as a line discipline driver.2/spavalL200" class="line" nam  >L200">v202spav class="comment"> *2/spavalL201" class="line" nam  >L201">v2012/a>2spav class="comment"> * Return:2/spavalL202" class="line" nam  >L202">v2022/a>2spav class="comment"> *      0 for success, any other 1"
	  error.2/spavalL203" class="line" nam  >L203">v2032/a>2spav class="comment"> */2/spavalL204" class="line" nam  >L204">v2042/a>static int 2a href="+code=__init" class="sref">__init2/a>"2a href="+code=n_tracerouter_init" class="sref">n_tracerouter_init2/a>(void)lL205" class="line" nam  >L205">v2052/a>{lL206" class="line" nam  >L206">v2062/a>"v v    int 2a href="+code=retval" class="sref">retval2/a>;lL207" class="line" nam  >L207">v2072/a>lL208" class="line" nam  >L208">v2082/a>"v v    2a href="+code=tr_data" class="sref">tr_data2/a>v= 2a href="+code=kzalloc" class="sref">kzalloc2/a>(sizeof(struct 2a href="+code=tracerouter_data" class="sref">tracerouter_data2/a>), 2a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL2/a>);lL209" class="line" nam  >L209">v2092/a>"v v    if (2a href="+code=tr_data" class="sref">tr_data2/a>"== 2a href="+code=NULL" class="sref">NULL2/a>)lL210" class="line" nam  >L210">v2102/a>"v v    "v v    return -2a href="+code=ENOMEM" class="sref">ENOMEM2/a>;lL211" class="line" nam  >L211">v2112/a>lL212" class="line" nam  >L212">v2122/a>lL213" class="line" nam  >L213">v2132/a>"v v    2spav class="comment">/* Note N_TRACEROUTER is defined in linux/tty.h */2/spavalL214" class="line" nam  >L214">v2142/a>"v v    2a href="+code=retval" class="sref">retval2/a>"= 2a href="+code=tty_register_ldisc" class="sref">tty_register_ldisc2/a>(2a href="+code=N_TRACEROUTER" class="sref">N_TRACEROUTER2/a>, &2a href="+code=tty_ptirouter_ldisc" class="sref">tty_ptirouter_ldisc2/a>);lL215" class="line" nam  >L215">v2152/a>"v v    if (2a href="+code=retval" class="sref">retval2/a>"< 0)"{lL216" class="line" nam  >L216">v2162/a>"v v    "v v    2a href="+code=pr_err" class="sref">pr_err2/a>(2spav class="string">"%s: Registraon v failed: %d\n"__func__2/a>, 2a href="+code=retval" class="sref">retval2/a>);lL217" class="line" nam  >L217">v2172/a>"v v    "v v    2a href="+code=kfree" class="sref">kfree2/a>(2a href="+code=tr_data" class="sref">tr_data2/a>);lL218" class="line" nam  >L218">v2182/a>"v v    }lL219" class="line" nam  >L219">v2192/a>"v v    return 2a href="+code=retval" class="sref">retval2/a>;lL220" class="line" nam  >L220">v22}lL221" class="line" nam  >L221">v2212/a>lL222" class="line" nam  >L222">v2222/a>2spav class="comment">/**2/spavalL223" class="line" nam  >L223">v2232/a>2spav class="comment"> * n_tracerouter_exit - module unload2/spavalL224" class="line" nam  >L224">v2242/a>2spav class="comment"> *2/spavalL225" class="line" nam  >L225">v2252/a>2spav class="comment"> * Removes this module as a line discipline driver.2/spavalL226" class="line" nam  >L226">v2262/a>2spav class="comment"> */2/spavalL227" class="line" nam  >L227">v2272/a>static void 2a href="+code=__exit" class="sref">__exit2/a>"2a href="+code=n_tracerouter_exit" class="sref">n_tracerouter_exit2/a>(void)lL228" class="line" nam  >L228">v2282/a>{lL229" class="line" nam  >L229">v2292/a>"v v    int 2a href="+code=retval" class="sref">retval2/a>"= 2a href="+code=tty_unregister_ldisc" class="sref">tty_unregister_ldisc2/a>(2a href="+code=N_TRACEROUTER" class="sref">N_TRACEROUTER2/a>);lL230" class="line" nam  >L230">v2302/a>lL231" class="line" nam  >L231">v2312/a>"v v    if (2a href="+code=retval" class="sref">retval2/a>"< 0)lL232" class="line" nam  >L232">v2322/a>"v v    "v v    2a href="+code=pr_err" class="sref">pr_err2/a>(2spav class="string">"%s: Unregistraon v failed: %d\n"__func__2/a>,  2a href="+code=retval" class="sref">retval2/a>);lL233" class="line" nam  >L233">v2332/a>"v v    elselL234" class="line" nam  >L234">v2342/a>"v v    "v v    2a href="+code=kfree" class="sref">kfree2/a>(2a href="+code=tr_data" class="sref">tr_data2/a>);lL235" class="line" nam  >L235">v2352/a>}lL236" class="line" nam  >L236">v2362/a>lL237" class="line" nam  >L237">v2372/a>2a href="+code=module_init" class="sref">module_init2/a>(2a href="+code=n_tracerouter_init" class="sref">n_tracerouter_init2/a>);lL238" class="line" nam  >L238">v2382/a>2a href="+code=module_exit" class="sref">module_exit2/a>(2a href="+code=n_tracerouter_exit" class="sref">n_tracerouter_exit2/a>);lL239" class="line" nam  >L239">v2392/a>lL240" class="line" nam  >L240">v242a href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSE2/a>(2spav class="string">"GPL"L241" class="line" nam  >L241">v2412/a>2a href="+code=MODULE_AUTHOR" class="sref">MODULE_AUTHOR2/a>(2spav class="string">"Jay Freyensee"L242" class="line" nam  >L242">v2422/a>2a href="+code=MODULE_ALIAS_LDISC" class="sref">MODULE_ALIAS_LDISC2/a>(2a href="+code=N_TRACEROUTER" class="sref">N_TRACEROUTER2/a>);lL243" class="line" nam  >L243">v2432/a>2a href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTION2/a>(2spav class="string">"Trace router ldisc driver"L244" class="line" nam  >L244">v2442/a>2/pre>2/div>


2/div>