From 0d081b2c802ee0ada910434cc76e4382c4b1fd5b Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 23 Nov 2007 15:24:01 -0500 Subject: [PATCH] Linux 2.2.0 o Final fixes for the computone driver (Michael Warfield) --- Documentation/computone.txt | 96 ++++++++----- Makefile | 2 +- drivers/char/hfmodem/tables.h | 90 ------------ drivers/char/ip2/i2lib.c | 256 +++++++++++++--------------------- drivers/char/ip2/i2lib.h | 6 + drivers/char/ip2main.c | 185 ++++++++++-------------- 6 files changed, 236 insertions(+), 399 deletions(-) delete mode 100644 drivers/char/hfmodem/tables.h diff --git a/Documentation/computone.txt b/Documentation/computone.txt index 3ef6db35ffd5..97ee950bda80 100644 --- a/Documentation/computone.txt +++ b/Documentation/computone.txt @@ -6,11 +6,10 @@ Release Notes For Linux Kernel 2.2 and higher. These notes are for the drivers which have already been integrated into the kernel and have been tested on Linux kernels 2.0, 2.2, 2.3, and 2.4. -Version: 1.2.11 -Date: 10/21/2001 +Version: 1.2.14 +Date: 11/01/2001 Historical Author: Andrew Manison -Primary Author: Doug McNash -Testing: larryg@computone.com +Primary Author: Doug McNash Support: support@computone.com Fixes and Updates: Mike Warfield @@ -27,7 +26,7 @@ with the exception of the MicroChannel controllers. It does not support products previous to the Intelliport II. This driver was developed on the v2.0.x Linux tree and has been tested up -to v2.2.14; it will probably not work with earlier v1.X kernels,. +to v2.4.14; it will probably not work with earlier v1.X kernels,. 2. QUICK INSTALLATION @@ -193,18 +192,26 @@ Linux tty naming conventions: ttyF0 - ttyF255 for normal devices, and cuf0 - cuf255 for callout devices. If you are using devfs, existing devices are automatically created within -the devfs name space. Normal devices will be ttf/0 - ttf/255 and callout -devices will be cuf/0 - cuf/255. With devfs installed, ip2mkdev will +the devfs name space. Normal devices will be tts/F0 - tts/F255 and callout +devices will be cua/F0 - cua/F255. With devfs installed, ip2mkdev will create symbolic links in /dev from the old conventional names to the newer devfs names as follows: /dev/ip2ipl[n] -> /dev/ip2/ipl[n] n = 0 - 3 /dev/ip2stat[n] -> /dev/ip2/stat[n] n = 0 - 3 - /dev/ttyF[n] -> /dev/ttf/[n] n = 0 - 255 - /dev/cuf[n] -> /dev/cuf/[n] n = 0 - 255 + /dev/ttyF[n] -> /dev/tts/F[n] n = 0 - 255 + /dev/cuf[n] -> /dev/cua/F[n] n = 0 - 255 Only devices for existing ports and boards will be created. +IMPORTANT NOTE: The naming convention used for devfs by this driver +was changed from 1.2.12 to 1.2.13. The old naming convention was to +use ttf/%d for the tty device and cuf/%d for the cua device. That +has been changed to conform to an agreed-upon standard of placing +all the tty devices under tts. The device names are now tts/F%d for +the tty device and cua/F%d for the cua devices. If you were using +the older devfs names, you must update for the newer convention. + You do not need to run ip2mkdev if you are using devfs and only want to use the devfs native device names. @@ -260,18 +267,26 @@ names. More details on devfs can be found on the DEVFS home site at documentation files, .../linux/Documentation/filesystems/devfs/REAME. If you are using devfs, existing devices are automatically created within -the devfs name space. Normal devices will be ttf/0 - ttf/255 and callout -devices will be cuf/0 - cuf/255. With devfs installed, ip2mkdev will +the devfs name space. Normal devices will be tts/F0 - tts/F255 and callout +devices will be cua/F0 - cua/F255. With devfs installed, ip2mkdev will create symbolic links in /dev from the old conventional names to the newer devfs names as follows: /dev/ip2ipl[n] -> /dev/ip2/ipl[n] n = 0 - 3 /dev/ip2stat[n] -> /dev/ip2/stat[n] n = 0 - 3 - /dev/ttyF[n] -> /dev/ttf/[n] n = 0 - 255 - /dev/cuf[n] -> /dev/cuf/[n] n = 0 - 255 + /dev/ttyF[n] -> /dev/tts/F[n] n = 0 - 255 + /dev/cuf[n] -> /dev/cua/F[n] n = 0 - 255 Only devices for existing ports and boards will be created. +IMPORTANT NOTE: The naming convention used for devfs by this driver +was changed from 1.2.12 to 1.2.13. The old naming convention was to +use ttf/%d for the tty device and cuf/%d for the cua device. That +has been changed to conform to an agreed-upon standard of placing +all the tty devices under tts. The device names are now tts/F%d for +the tty device and cua/F%d for the cua devices. If you were using +the older devfs names, you must update for the newer convention. + You do not need to run ip2mkdev if you are using devfs and only want to use the devfs native device names. @@ -300,19 +315,19 @@ are present on you system at the time it is run. #!/bin/sh -# This is a shell archive (produced by GNU sharutils 4.2). +# This is a shell archive (produced by GNU sharutils 4.2.1). # To extract the files from this archive, save it to some FILE, remove # everything before the `!/bin/sh' line above, then type `sh FILE'. # -# Made on 2000-03-10 11:55 EST by . -# Source directory was `/mnt1/src/linux-2.3.50c/Documentation'. +# Made on 2001-10-29 10:32 EST by . +# Source directory was `/home2/src/tmp'. # # Existing files will *not* be overwritten unless `-c' is specified. # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ -# 4061 -rwxr-xr-x ip2mkdev +# 4251 -rwxr-xr-x ip2mkdev # save_IFS="${IFS}" IFS="${IFS}:" @@ -347,9 +362,12 @@ else export TEXTDOMAIN echo="$gettext_dir/gettext -s" fi -touch -am 1231235999 $$.touch >/dev/null 2>&1 -if test ! -f 1231235999 && test -f $$.touch; then - shar_touch=touch +if touch -am -t 200112312359.59 $$.touch >/dev/null 2>&1 && test ! -f 200112312359.59 -a -f $$.touch; then + shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"' +elif touch -am 123123592001.59 $$.touch >/dev/null 2>&1 && test ! -f 123123592001.59 -a ! -f 123123592001.5 -a -f $$.touch; then + shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"' +elif touch -am 1231235901 $$.touch >/dev/null 2>&1 && test ! -f 1231235901 -a -f $$.touch; then + shar_touch='touch -am $3$4$5$6$2 "$8"' else shar_touch=: echo @@ -357,9 +375,9 @@ else $echo "installing GNU \`touch', distributed in GNU File Utilities..." echo fi -rm -f 1231235999 $$.touch +rm -f 200112312359.59 123123592001.59 123123592001.5 1231235901 $$.touch # -if mkdir _sh17088; then +if mkdir _sh17581; then $echo 'x -' 'creating lock directory' else $echo 'failed to create lock directory' @@ -387,11 +405,14 @@ else # before running this script. Running this script will then recreate # all the valid devices. # -# =mhw= # Michael H. Warfield +# /\/\|=mhw=|\/\/ # mhw@wittsend.com # -# Updated 03/09/2000 for devfs support in ip2 drivers. =mhw= +# Updated 10/29/2000 for version 1.2.13 naming convention +# under devfs. /\/\|=mhw=|\/\/ +# +# Updated 03/09/2000 for devfs support in ip2 drivers. /\/\|=mhw=|\/\/ # X if test -d /dev/ip2 ; then @@ -406,18 +427,19 @@ X rm -f ip2$i X ln -s ip2/$i ip2$i X fi X done -X for i in `ls ttf` ; do -X if test ! -L ttyF$i ; then +X for i in `( cd tts ; ls F* )` ; do +X if test ! -L tty$i ; then X # Remove it incase it wasn't a symlink (old device) -X rm -f ttyF$i -X ln -s ttyf/$i ttyF$i +X rm -f tty$i +X ln -s tts/$i tty$i X fi X done -X for i in `ls cuf` ; do -X if test ! -L cuf$i ; then +X for i in `( cd cua ; ls F* )` ; do +X DEVNUMBER=`expr $i : 'F\(.*\)'` +X if test ! -L cuf$DEVNUMBER ; then X # Remove it incase it wasn't a symlink (old device) -X rm -f cuf$i -X ln -s cuf/$i cuf$i +X rm -f cuf$DEVNUMBER +X ln -s cua/$i cuf$DEVNUMBER X fi X done X exit 0 @@ -539,20 +561,20 @@ done X Xexit 0 SHAR_EOF - $shar_touch -am 03101153100 'ip2mkdev' && + (set 20 01 10 29 10 32 01 'ip2mkdev'; eval "$shar_touch") && chmod 0755 'ip2mkdev' || $echo 'restore of' 'ip2mkdev' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'ip2mkdev:' 'MD5 check failed' -b0671abeba07b0a9266b70aaf24509b3 ip2mkdev +cb5717134509f38bad9fde6b1f79b4a4 ip2mkdev SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'ip2mkdev'`" - test 4061 -eq "$shar_count" || - $echo 'ip2mkdev:' 'original size' '4061,' 'current size' "$shar_count!" + test 4251 -eq "$shar_count" || + $echo 'ip2mkdev:' 'original size' '4251,' 'current size' "$shar_count!" fi fi -rm -fr _sh17088 +rm -fr _sh17581 exit 0 diff --git a/Makefile b/Makefile index fe47f8706b62..54b565991ebc 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 2 SUBLEVEL = 20 -EXTRAVERSION = pre12 +EXTRAVERSION = ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/) diff --git a/drivers/char/hfmodem/tables.h b/drivers/char/hfmodem/tables.h deleted file mode 100644 index d976c8e53bce..000000000000 --- a/drivers/char/hfmodem/tables.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This file is automatically generated by ./gentbl, DO NOT EDIT! -*/ - -#define SINTABBITS 9 -#define SINTABSIZE (1<tqueue_status.routine = (void(*)(void*)) do_status; pCh->tqueue_status.data = pCh; +#ifdef IP2DEBUG_TRACE pCh->trace = ip2trace; +#endif ++pCh; --nChannels; @@ -554,9 +556,9 @@ i2QueueCommands(int type, i2ChanStrPtr pCh, int timeout, int nCommands, if ( !i2Validate ( pCh ) ) { return -1; } -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_QUEUE, ITRC_ENTER, 0 ); -#endif + pB = pCh->pMyBord; // Board must also exist, and THE INTERRUPT COMMAND ALREADY SENT @@ -634,9 +636,9 @@ i2QueueCommands(int type, i2ChanStrPtr pCh, int timeout, int nCommands, if (--bufroom < 0) { bufroom += maxBuff; } -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_QUEUE, 2, 1, bufroom ); -#endif + // Check for overflow if (totalsize <= bufroom) { // Normal Expected path - We still hold LOCK @@ -644,9 +646,8 @@ i2QueueCommands(int type, i2ChanStrPtr pCh, int timeout, int nCommands, } } -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_QUEUE, 3, 1, totalsize ); -#endif + // Prepare to wait for buffers to empty WRITE_UNLOCK_IRQRESTORE(lock_var_p,flags); serviceOutgoingFifo(pB); // Dump what we got @@ -669,9 +670,8 @@ i2QueueCommands(int type, i2ChanStrPtr pCh, int timeout, int nCommands, return 0; // Wake up! Time to die!!! } -#ifdef IP2DEBUG_TRACE - ip2trace (CHANN, ITRC_QUEUE, 4, 0 ); -#endif + ip2trace (CHANN, ITRC_QUEUE, 4, 0 ); + } // end of for(;;) // At this point we have room and the lock - stick them in. @@ -693,9 +693,9 @@ i2QueueCommands(int type, i2ChanStrPtr pCh, int timeout, int nCommands, // pCs->cmd[0]. if (pCs == CMD_BMARK_REQ) { pCh->bookMarks++; -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_DRAIN, 30, 1, pCh->bookMarks ); -#endif + } cnt = pCs->length; @@ -703,9 +703,9 @@ i2QueueCommands(int type, i2ChanStrPtr pCh, int timeout, int nCommands, // if the last command had to be at the end of a block, we end // the existing block here and start a new one. if ((blocksize + cnt > maxBlock) || lastended) { -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_QUEUE, 5, 0 ); -#endif + PTYPE_OF(pInsert) = type; CHANNEL_OF(pInsert) = channel; // count here does not include the header @@ -767,9 +767,9 @@ i2QueueCommands(int type, i2ChanStrPtr pCh, int timeout, int nCommands, i2QueueNeeds(pB, pCh, NEED_BYPASS); break; } -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_QUEUE, ITRC_RETURN, 1, nCommands ); -#endif + return nCommands; // Good status: number of commands sent } @@ -792,9 +792,7 @@ i2GetStatus(i2ChanStrPtr pCh, int resetBits) unsigned short status; i2eBordStrPtr pB; -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_STATUS, ITRC_ENTER, 2, pCh->dataSetIn, resetBits ); -#endif // Make sure the channel exists, otherwise do nothing */ if ( !i2Validate ( pCh ) ) @@ -812,9 +810,7 @@ i2GetStatus(i2ChanStrPtr pCh, int resetBits) pCh->dataSetIn &= ~(I2_DDCD | I2_DCTS | I2_DDSR | I2_DRI); } -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_STATUS, ITRC_RETURN, 1, pCh->dataSetIn ); -#endif return status; } @@ -839,9 +835,7 @@ i2Input(i2ChanStrPtr pCh) int count; unsigned long flags = 0; -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_INPUT, ITRC_ENTER, 0); -#endif // Ensure channel structure seems real if ( !i2Validate( pCh ) ) { @@ -907,9 +901,8 @@ i2Input(i2ChanStrPtr pCh) i2Input_exit: -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_INPUT, ITRC_RETURN, 1, count); -#endif + return count; } @@ -933,9 +926,7 @@ i2InputFlush(i2ChanStrPtr pCh) if ( !i2Validate ( pCh ) ) return -1; -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_INPUT, 10, 0); -#endif WRITE_LOCK_IRQSAVE(&pCh->Ibuf_spinlock,flags); count = pCh->Ibuf_stuff - pCh->Ibuf_strip; @@ -963,9 +954,9 @@ i2InputFlush(i2ChanStrPtr pCh) } else { WRITE_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags); } -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_INPUT, 19, 1, count); -#endif + return count; } @@ -1035,9 +1026,7 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user ) int bailout = 10; -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_OUTPUT, ITRC_ENTER, 2, count, user ); -#endif // Ensure channel structure seems real if ( !i2Validate ( pCh ) ) @@ -1084,9 +1073,8 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user ) // Small WINDOW here with no LOCK but I can't call Flush with LOCK // We would be flushing (or ending flush) anyway -#ifdef IP2DEBUG_TRACE - ip2trace (CHANN, ITRC_OUTPUT, 10, 1, amountToMove ); -#endif + ip2trace (CHANN, ITRC_OUTPUT, 10, 1, amountToMove ); + if ( !(pCh->flush_flags && i2RetryFlushOutput(pCh) ) && amountToMove > 0 ) { @@ -1124,9 +1112,7 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user ) WRITE_UNLOCK_IRQRESTORE(&pCh->Obuf_spinlock,flags); -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_OUTPUT, 13, 1, stuffIndex ); -#endif } else { @@ -1134,25 +1120,23 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user ) // becuz we need to stuff a flush // or amount to move is <= 0 -#ifdef IP2DEBUG_TRACE ip2trace(CHANN, ITRC_OUTPUT, 14, 3, - amountToMove, pB->i2eFifoRemains, pB->i2eWaitingForEmptyFifo ); -#endif + amountToMove, pB->i2eFifoRemains, + pB->i2eWaitingForEmptyFifo ); + // Put this channel back on queue // this ultimatly gets more data or wakes write output i2QueueNeeds(pB, pCh, NEED_INLINE); if ( pB->i2eWaitingForEmptyFifo ) { -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_OUTPUT, 16, 0 ); -#endif + // or schedule if (!in_interrupt()) { -#ifdef IP2DEBUG_TRACE - ip2trace (CHANN, ITRC_OUTPUT, 61, 0 ); -#endif + ip2trace (CHANN, ITRC_OUTPUT, 61, 0 ); + current->state = TASK_INTERRUPTIBLE; current->counter = 0; schedule_timeout(2); @@ -1161,9 +1145,9 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user ) } continue; } else { -#ifdef IP2DEBUG_TRACE - ip2trace (CHANN, ITRC_OUTPUT, 62, 0 ); -#endif + + ip2trace (CHANN, ITRC_OUTPUT, 62, 0 ); + // let interrupt in = WAS restore_flags() // We hold no lock nor is irq off anymore??? @@ -1173,31 +1157,31 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user ) } else if ( pB->i2eFifoRemains < 32 && !pB->i2eTxMailEmpty ( pB ) ) { -#ifdef IP2DEBUG_TRACE - ip2trace (CHANN, ITRC_OUTPUT, 19, 2, pB->i2eFifoRemains, - pB->i2eTxMailEmpty ); -#endif + ip2trace (CHANN, ITRC_OUTPUT, 19, 2, + pB->i2eFifoRemains, + pB->i2eTxMailEmpty ); + break; // from while(count) } else if ( pCh->channelNeeds & NEED_CREDIT ) { -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_OUTPUT, 22, 0 ); -#endif + break; // from while(count) } else if ( --bailout) { // Try to throw more things (maybe not us) in the fifo if we're // not already waiting for it. -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_OUTPUT, 20, 0 ); -#endif + serviceOutgoingFifo(pB); //break; CONTINUE; } else { -#ifdef IP2DEBUG_TRACE - ip2trace (CHANN, ITRC_OUTPUT, 21, 3, pB->i2eFifoRemains, - pB->i2eOutMailWaiting, pB->i2eWaitingForEmptyFifo ); -#endif + ip2trace (CHANN, ITRC_OUTPUT, 21, 3, + pB->i2eFifoRemains, + pB->i2eOutMailWaiting, + pB->i2eWaitingForEmptyFifo ); + break; // from while(count) } } @@ -1208,14 +1192,13 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user ) // We drop through either when the count expires, or when there is some // count left, but there was a non-blocking write. if (countOriginal > count) { -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_OUTPUT, 17, 2, countOriginal, count ); -#endif + serviceOutgoingFifo( pB ); } -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_OUTPUT, ITRC_RETURN, 2, countOriginal, count ); -#endif return countOriginal - count; } @@ -1234,23 +1217,20 @@ static inline void i2FlushOutput(i2ChanStrPtr pCh) { -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_FLUSH, 1, 1, pCh->flush_flags ); -#endif if (pCh->flush_flags) return; if ( 1 != i2QueueCommands(PTYPE_BYPASS, pCh, 0, 1, CMD_STARTFL) ) { pCh->flush_flags = STARTFL_FLAG; // Failed - flag for later -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_FLUSH, 2, 0 ); -#endif + } else if ( 1 != i2QueueCommands(PTYPE_INLINE, pCh, 0, 1, CMD_STOPFL) ) { pCh->flush_flags = STOPFL_FLAG; // Failed - flag for later -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_FLUSH, 3, 0 ); -#endif } } @@ -1259,9 +1239,7 @@ i2RetryFlushOutput(i2ChanStrPtr pCh) { int old_flags = pCh->flush_flags; -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_FLUSH, 14, 1, old_flags ); -#endif pCh->flush_flags = 0; // Clear flag so we can avoid recursion // and queue the commands @@ -1272,23 +1250,21 @@ i2RetryFlushOutput(i2ChanStrPtr pCh) } else { old_flags = STARTFL_FLAG; //Failure - Flag for retry later } -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_FLUSH, 15, 1, old_flags ); -#endif + } if ( old_flags & STOPFL_FLAG ) { if ( 1 == i2QueueCommands(PTYPE_INLINE, pCh, 0, 1, CMD_STOPFL) > 0 ) { old_flags = 0; // Success - clear flags } -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_FLUSH, 16, 1, old_flags ); -#endif } - pCh->flush_flags = old_flags; + pCh->flush_flags = old_flags; -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_FLUSH, 17, 1, old_flags ); -#endif + return old_flags; } @@ -1305,9 +1281,8 @@ i2RetryFlushOutput(i2ChanStrPtr pCh) static void i2DrainWakeup(i2ChanStrPtr pCh) { -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_DRAIN, 10, 1, pCh->BookmarkTimer.expires ); -#endif + pCh->BookmarkTimer.expires = 0; wake_up_interruptible( &pCh->pBookmarkWait ); } @@ -1318,9 +1293,8 @@ i2DrainOutput(i2ChanStrPtr pCh, int timeout) wait_queue_t wait; i2eBordStrPtr pB; -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_DRAIN, ITRC_ENTER, 1, pCh->BookmarkTimer.expires); -#endif + pB = pCh->pMyBord; // If the board has gone fatal, return bad, // and also hit the trap routine if it exists. @@ -1337,9 +1311,7 @@ i2DrainOutput(i2ChanStrPtr pCh, int timeout) pCh->BookmarkTimer.function = (void*)(unsigned long)i2DrainWakeup; pCh->BookmarkTimer.data = (unsigned long)pCh; -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_DRAIN, 1, 1, pCh->BookmarkTimer.expires ); -#endif add_timer( &(pCh->BookmarkTimer) ); } @@ -1363,14 +1335,11 @@ i2DrainOutput(i2ChanStrPtr pCh, int timeout) (pCh->BookmarkTimer.expires > jiffies)) { del_timer( &(pCh->BookmarkTimer) ); pCh->BookmarkTimer.expires = 0; -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_DRAIN, 3, 1, pCh->BookmarkTimer.expires ); -#endif } -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_DRAIN, ITRC_RETURN, 1, pCh->BookmarkTimer.expires ); -#endif return; } @@ -1415,18 +1384,17 @@ ip2_owake( PTTY tp) pCh = tp->driver_data; -#ifdef IP2DEBUG_TRACE - ip2trace (CHANN, ITRC_SICMD, 10, 2, tp->flags, (1 << TTY_DO_WRITE_WAKEUP) ); -#endif + ip2trace (CHANN, ITRC_SICMD, 10, 2, tp->flags, + (1 << TTY_DO_WRITE_WAKEUP) ); + wake_up_interruptible ( &tp->write_wait ); wake_up_interruptible ( &tp->poll_wait ); if ( ( tp->flags & (1 << TTY_DO_WRITE_WAKEUP) ) && tp->ldisc.write_wakeup ) { (tp->ldisc.write_wakeup) ( tp ); -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_SICMD, 11, 0 ); -#endif } } @@ -1512,14 +1480,11 @@ i2StripFifo(i2eBordStrPtr pB) unsigned char dss_change; unsigned long bflags,cflags; -#ifdef IP2DEBUG_TRACE - //ip2trace (ITRC_NO_PORT, ITRC_SFIFO, ITRC_ENTER, 0 ); -#endif +// ip2trace (ITRC_NO_PORT, ITRC_SFIFO, ITRC_ENTER, 0 ); while (HAS_INPUT(pB)) { -#ifdef IP2DEBUG_TRACE - //ip2trace (ITRC_NO_PORT, ITRC_SFIFO, 2, 0 ); -#endif +// ip2trace (ITRC_NO_PORT, ITRC_SFIFO, 2, 0 ); + // Process packet from fifo a one atomic unit WRITE_LOCK_IRQSAVE(&pB->read_fifo_spinlock,bflags); @@ -1532,9 +1497,8 @@ i2StripFifo(i2eBordStrPtr pB) case PTYPE_DATA: pB->got_input = 1; -#ifdef IP2DEBUG_TRACE - //ip2trace (ITRC_NO_PORT, ITRC_SFIFO, 3, 0 ); -#endif +// ip2trace (ITRC_NO_PORT, ITRC_SFIFO, 3, 0 ); + channel = CHANNEL_OF(pB->i2eLeadoffWord); /* Store channel */ count = iiReadWord(pB); /* Count is in the next word */ @@ -1634,9 +1598,7 @@ i2StripFifo(i2eBordStrPtr pB) break; // From switch: ready for next packet case PTYPE_STATUS: -#ifdef IP2DEBUG_TRACE ip2trace (ITRC_NO_PORT, ITRC_SFIFO, 4, 0 ); -#endif count = CMD_COUNT_OF(pB->i2eLeadoffWord); @@ -1649,9 +1611,9 @@ i2StripFifo(i2eBordStrPtr pB) while (pc < pcLimit) { channel = *pc++; -#ifdef IP2DEBUG_TRACE + ip2trace (channel, ITRC_SFIFO, 7, 2, channel, *pc ); -#endif + /* check for valid channel */ if (channel < pB->i2eChannelCnt && @@ -1684,41 +1646,32 @@ i2StripFifo(i2eBordStrPtr pB) break; case STAT_DCD_UP: -#ifdef IP2DEBUG_TRACE ip2trace (channel, ITRC_MODEM, 1, 1, pCh->dataSetIn ); -#endif + if ( !(pCh->dataSetIn & I2_DCD) ) { -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_MODEM, 2, 0 ); -#endif pCh->dataSetIn |= I2_DDCD; pCh->icount.dcd++; dss_change = 1; } pCh->dataSetIn |= I2_DCD; -#ifdef IP2DEBUG_TRACE + ip2trace (channel, ITRC_MODEM, 3, 1, pCh->dataSetIn ); -#endif break; case STAT_DCD_DN: -#ifdef IP2DEBUG_TRACE ip2trace (channel, ITRC_MODEM, 4, 1, pCh->dataSetIn ); -#endif if ( pCh->dataSetIn & I2_DCD ) { -#ifdef IP2DEBUG_TRACE ip2trace (channel, ITRC_MODEM, 5, 0 ); -#endif pCh->dataSetIn |= I2_DDCD; pCh->icount.dcd++; dss_change = 1; } pCh->dataSetIn &= ~I2_DCD; -#ifdef IP2DEBUG_TRACE + ip2trace (channel, ITRC_MODEM, 6, 1, pCh->dataSetIn ); -#endif break; case STAT_DSR_UP: @@ -1774,9 +1727,8 @@ i2StripFifo(i2eBordStrPtr pB) if (pCh->bookMarks <= 0 ) { pCh->bookMarks = 0; wake_up_interruptible( &pCh->pBookmarkWait ); -#ifdef IP2DEBUG_TRACE + ip2trace (channel, ITRC_DRAIN, 20, 1, pCh->BookmarkTimer.expires ); -#endif } break; @@ -1786,22 +1738,21 @@ i2StripFifo(i2eBordStrPtr pB) pCh->outfl.room = ((flowStatPtr)pc)->room - (pCh->outfl.asof - ((flowStatPtr)pc)->asof); -#ifdef IP2DEBUG_TRACE + ip2trace (channel, ITRC_STFLW, 1, 1, pCh->outfl.room ); -#endif + if (pCh->channelNeeds & NEED_CREDIT) { -#ifdef IP2DEBUG_TRACE - ip2trace (channel, ITRC_STFLW, 2, 1, pCh->channelNeeds); -#endif + ip2trace (channel, ITRC_STFLW, 2, 1, pCh->channelNeeds); + pCh->channelNeeds &= ~NEED_CREDIT; i2QueueNeeds(pB, pCh, NEED_INLINE); if ( pCh->pTTY ) ip2_owake(pCh->pTTY); } -#ifdef IP2DEBUG_TRACE + ip2trace (channel, ITRC_STFLW, 3, 1, pCh->channelNeeds); -#endif + pc += sizeof(flowStat); break; @@ -1897,16 +1848,15 @@ i2StripFifo(i2eBordStrPtr pB) break; default: // Neither packet? should be impossible -#ifdef IP2DEBUG_TRACE ip2trace (ITRC_NO_PORT, ITRC_SFIFO, 5, 1, PTYPE_OF(pB->i2eLeadoffWord) ); -#endif + break; } // End of switch on type of packets } //while(board HAS_INPUT) -#ifdef IP2DEBUG_TRACE + ip2trace (ITRC_NO_PORT, ITRC_SFIFO, ITRC_RETURN, 0 ); -#endif + // Send acknowledgement to the board even if there was no data! pB->i2eOutMailWaiting |= MB_IN_STRIPPED; return; @@ -2024,9 +1974,8 @@ i2StuffFifoFlow(i2eBordStrPtr pB) i2ChanStrPtr pCh; unsigned short paddedSize = ROUNDUP(sizeof(flowIn)); -#ifdef IP2DEBUG_TRACE -ip2trace (ITRC_NO_PORT, ITRC_SFLOW, ITRC_ENTER, 2, pB->i2eFifoRemains, paddedSize ); -#endif + ip2trace (ITRC_NO_PORT, ITRC_SFLOW, ITRC_ENTER, 2, + pB->i2eFifoRemains, paddedSize ); // Continue processing so long as there are entries, or there is room in the // fifo. Each entry represents a channel with something to do. @@ -2038,14 +1987,12 @@ ip2trace (ITRC_NO_PORT, ITRC_SFLOW, ITRC_ENTER, 2, pB->i2eFifoRemains, paddedSiz break; } #ifdef DEBUG_FIFO -WriteDBGBuf("FLOW",(unsigned char *) &(pCh->infl), paddedSize); + WriteDBGBuf("FLOW",(unsigned char *) &(pCh->infl), paddedSize); #endif /* DEBUG_FIFO */ } // Either clogged or finished all the work -#ifdef IP2DEBUG_TRACE ip2trace (ITRC_NO_PORT, ITRC_SFLOW, ITRC_RETURN, 0 ); -#endif } //****************************************************************************** @@ -2073,10 +2020,8 @@ i2StuffFifoInline(i2eBordStrPtr pB) int bailout = 1000; int bailout2; -#ifdef IP2DEBUG_TRACE ip2trace (ITRC_NO_PORT, ITRC_SICMD, ITRC_ENTER, 3, pB->i2eFifoRemains, pB->i2Dbuf_strip, pB->i2Dbuf_stuff ); -#endif // Continue processing so long as there are entries, or there is room in the // fifo. Each entry represents a channel with something to do. @@ -2086,9 +2031,8 @@ i2StuffFifoInline(i2eBordStrPtr pB) WRITE_LOCK_IRQSAVE(&pCh->Obuf_spinlock,flags); stripIndex = pCh->Obuf_strip; -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_SICMD, 3, 2, stripIndex, pCh->Obuf_stuff ); -#endif + // as long as there are packets for this channel... bailout2 = 1000; while ( --bailout2 && stripIndex != pCh->Obuf_stuff) { @@ -2107,16 +2051,15 @@ i2StuffFifoInline(i2eBordStrPtr pB) flowsize = CREDIT_USAGE(flowsize); paddedSize = ROUNDUP(packetSize); -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_SICMD, 4, 2, pB->i2eFifoRemains, paddedSize ); -#endif + // If we don't have enough credits from the board to send the data, // flag the channel that we are waiting for flow control credit, and // break out. This will clean up this channel and remove us from the // queue of hot things to do. -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_SICMD, 5, 2, pCh->outfl.room, flowsize ); -#endif + if (pCh->outfl.room <= flowsize) { // Do Not have the credits to send this packet. i2QueueNeeds(pB, pCh, NEED_CREDIT); @@ -2144,15 +2087,15 @@ WriteDBGBuf("DATA", pRemove, paddedSize); } pRemove += packetSize; stripIndex += packetSize; -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_SICMD, 6, 2, stripIndex, pCh->Obuf_strip); -#endif + if (stripIndex >= OBUF_SIZE) { stripIndex = 0; pRemove = pCh->Obuf; -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_SICMD, 7, 1, stripIndex ); -#endif + } } /* while */ if ( !bailout2 ) { @@ -2164,23 +2107,20 @@ WriteDBGBuf("DATA", pRemove, paddedSize); WRITE_UNLOCK_IRQRESTORE(&pCh->Obuf_spinlock,flags); if ( notClogged ) { -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_SICMD, 8, 0 ); -#endif + if ( pCh->pTTY ) { ip2_owake(pCh->pTTY); } } } // Either clogged or finished all the work -#ifdef IP2DEBUG_TRACE + if ( !bailout ) { ip2trace (ITRC_NO_PORT, ITRC_ERROR, 4, 0 ); } -#endif -#ifdef IP2DEBUG_TRACE ip2trace (ITRC_NO_PORT, ITRC_SICMD, ITRC_RETURN, 1,pB->i2Dbuf_strip); -#endif } //****************************************************************************** @@ -2250,9 +2190,7 @@ i2ServiceBoard ( i2eBordStrPtr pB ) } pB->i2eStartMail = NO_MAIL_HERE; -#ifdef IP2DEBUG_TRACE ip2trace (ITRC_NO_PORT, ITRC_INTR, 2, 1, inmail ); -#endif if (inmail != NO_MAIL_HERE) { // If the board has gone fatal, nothing to do but hit a bit that will @@ -2274,16 +2212,14 @@ i2ServiceBoard ( i2eBordStrPtr pB ) pB->i2eFifoRemains = pB->i2eFifoSize; pB->i2eWaitingForEmptyFifo = 0; WRITE_UNLOCK_IRQRESTORE(&pB->write_fifo_spinlock,flags); -#ifdef IP2DEBUG_TRACE - ip2trace (ITRC_NO_PORT, ITRC_INTR, 30, 1, pB->i2eFifoRemains ); -#endif + + ip2trace (ITRC_NO_PORT, ITRC_INTR, 30, 1, pB->i2eFifoRemains ); + } serviceOutgoingFifo(pB); } -#ifdef IP2DEBUG_TRACE ip2trace (ITRC_NO_PORT, ITRC_INTR, 8, 0 ); -#endif exit_i2ServiceBoard: diff --git a/drivers/char/ip2/i2lib.h b/drivers/char/ip2/i2lib.h index 873ba9348a11..0da0b7f3d039 100644 --- a/drivers/char/ip2/i2lib.h +++ b/drivers/char/ip2/i2lib.h @@ -341,6 +341,12 @@ static int i2OutputFree(i2ChanStrPtr); static int i2ServiceBoard(i2eBordStrPtr); static void i2DrainOutput(i2ChanStrPtr, int); +#ifdef IP2DEBUG_TRACE +void ip2trace(unsigned short,unsigned char,unsigned char,unsigned long,...); +#else +#define ip2trace(a,b,c,d...) do {} while (0) +#endif + // Argument to i2QueueCommands // #define C_IN_LINE 1 diff --git a/drivers/char/ip2main.c b/drivers/char/ip2main.c index 86834cdd5dc3..17579c94f7d9 100644 --- a/drivers/char/ip2main.c +++ b/drivers/char/ip2main.c @@ -14,6 +14,18 @@ // // Done: // +// 1.2.14 /\/\|=mhw=|\/\/ +// Added bounds checking to ip2_ipl_ioctl to avoid potential terroristic acts. +// Changed the definition of ip2trace to be more consistant with kernel style +// Thanks to Andreas Dilger for these updates +// +// 1.2.13 /\/\|=mhw=|\/\/ +// DEVFS: Renamed ttf/{n} to tts/F{n} and cuf/{n} to cua/F{n} to conform +// to agreed devfs serial device naming convention. +// +// 1.2.12 /\/\|=mhw=|\/\/ +// Cleaned up some remove queue cut and paste errors +// // 1.2.11 /\/\|=mhw=|\/\/ // Clean up potential NULL pointer dereferences // Clean up devfs registration @@ -230,13 +242,13 @@ struct proc_dir_entry ip2_proc_entry = { /* String constants to identify ourselves */ static char *pcName = "Computone IntelliPort Plus multiport driver"; -static char *pcVersion = "1.2.11"; +static char *pcVersion = "1.2.14"; /* String constants for port names */ static char *pcDriver_name = "ip2"; #ifdef CONFIG_DEVFS_FS -static char *pcTty = "ttf/%d"; -static char *pcCallout = "cuf/%d"; +static char *pcTty = "tts/F%d"; +static char *pcCallout = "cua/F%d"; #else static char *pcTty = "ttyF"; static char *pcCallout = "cuf"; @@ -304,7 +316,6 @@ static ssize_t ip2_ipl_write(struct file *, const char *, size_t, loff_t *); static int ip2_ipl_ioctl(struct inode *, struct file *, UINT, ULONG); static int ip2_ipl_open(struct inode *, struct file *); -void ip2trace(unsigned short,unsigned char,unsigned char,unsigned long,...); static int DumpTraceBuffer(char *, int); static int DumpFifoBuffer( char *, int); @@ -611,9 +622,7 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize) ) i2eBordStrPtr pB = NULL; int rc = -1; -#ifdef IP2DEBUG_TRACE ip2trace (ITRC_NO_PORT, ITRC_INIT, ITRC_ENTER, 0 ); -#endif /* process command line arguments to modprobe or insmod i.e. iop & irqp */ @@ -817,9 +826,7 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize) ) } } -#ifdef IP2DEBUG_TRACE ip2trace (ITRC_NO_PORT, ITRC_INIT, 2, 0 ); -#endif /* Zero out the normal tty device structure. */ memset ( &ip2_tty_driver, 0, sizeof ip2_tty_driver ); @@ -878,9 +885,7 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize) ) ip2_callout_driver.major = IP2_CALLOUT_MAJOR; ip2_callout_driver.subtype = SERIAL_TYPE_CALLOUT; -#ifdef IP2DEBUG_TRACE ip2trace (ITRC_NO_PORT, ITRC_INIT, 3, 0 ); -#endif /* Register the tty devices. */ if ( ( err = tty_register_driver ( &ip2_tty_driver ) ) ) { @@ -903,9 +908,7 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize) ) printk(KERN_ERR "IP2: failed to register read_procmem (%d)\n", err ); } else { -#ifdef IP2DEBUG_TRACE ip2trace (ITRC_NO_PORT, ITRC_INIT, 4, 0 ); -#endif /* Register the interrupt handler or poll handler, depending upon the * specified interrupt. */ @@ -994,9 +997,7 @@ retry: } } } -#ifdef IP2DEBUG_TRACE ip2trace (ITRC_NO_PORT, ITRC_INIT, ITRC_RETURN, 0 ); -#endif return 0; } @@ -1396,9 +1397,7 @@ ip2_interrupt(int irq, void *dev_id, struct pt_regs * regs) int i; i2eBordStrPtr pB; -#ifdef IP2DEBUG_TRACE ip2trace (ITRC_NO_PORT, ITRC_INTR, 99, 1, irq ); -#endif /* Service just the boards on the list using this irq */ for( i = 0; i < i2nBoards; ++i ) { @@ -1432,9 +1431,7 @@ ip2_interrupt(int irq, void *dev_id, struct pt_regs * regs) ++irq_counter; -#ifdef IP2DEBUG_TRACE ip2trace (ITRC_NO_PORT, ITRC_INTR, ITRC_RETURN, 0 ); -#endif } /******************************************************************************/ @@ -1450,9 +1447,8 @@ ip2_interrupt(int irq, void *dev_id, struct pt_regs * regs) static void ip2_poll(unsigned long arg) { -#ifdef IP2DEBUG_TRACE ip2trace (ITRC_NO_PORT, ITRC_INTR, 100, 0 ); -#endif + TimerOn = 0; // it's the truth but not checked in service // Just polled boards, IRQ = 0 will hit all non-interrupt boards. @@ -1464,9 +1460,7 @@ ip2_poll(unsigned long arg) add_timer( &PollTimer ); TimerOn = 1; -#ifdef IP2DEBUG_TRACE ip2trace (ITRC_NO_PORT, ITRC_INTR, ITRC_RETURN, 0 ); -#endif } static inline void @@ -1474,9 +1468,8 @@ do_input( i2ChanStrPtr pCh ) { unsigned long flags; -#ifdef IP2DEBUG_TRACE ip2trace(CHANN, ITRC_INPUT, 21, 0 ); -#endif + // Data input if ( pCh->pTTY != NULL ) { READ_LOCK_IRQSAVE(&pCh->Ibuf_spinlock,flags) @@ -1486,9 +1479,8 @@ do_input( i2ChanStrPtr pCh ) } else READ_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags) } else { -#ifdef IP2DEBUG_TRACE ip2trace(CHANN, ITRC_INPUT, 22, 0 ); -#endif + i2InputFlush( pCh ); } } @@ -1513,9 +1505,7 @@ do_status( i2ChanStrPtr pCh ) status = i2GetStatus( pCh, (I2_BRK|I2_PAR|I2_FRA|I2_OVR) ); -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_STATUS, 21, 1, status ); -#endif if (pCh->pTTY && (status & (I2_BRK|I2_PAR|I2_FRA|I2_OVR)) ) { if ( (status & I2_BRK) ) { @@ -1576,9 +1566,7 @@ skip_this: } } -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_STATUS, 26, 0 ); -#endif } /******************************************************************************/ @@ -1633,9 +1621,7 @@ ip2_open( PTTY tty, struct file *pFile ) int do_clocal = 0; i2ChanStrPtr pCh = DevTable[MINOR(tty->device)]; -#ifdef IP2DEBUG_TRACE ip2trace (MINOR(tty->device), ITRC_OPEN, ITRC_ENTER, 0 ); -#endif if ( pCh == NULL ) { return -ENODEV; @@ -1744,7 +1730,7 @@ ip2_open( PTTY tty, struct file *pFile ) } if ( tty_hung_up_p(pFile) ) { set_current_state( TASK_RUNNING ); - remove_wait_queue(&pCh->dss_now_wait, &wait); + remove_wait_queue(&pCh->open_wait, &wait); return ( pCh->flags & ASYNC_HUP_NOTIFY ) ? -EBUSY : -ERESTARTSYS; } if ( !(pCh->flags & ASYNC_CALLOUT_ACTIVE) && @@ -1761,10 +1747,8 @@ ip2_open( PTTY tty, struct file *pFile ) (pCh->flags & ASYNC_CLOSING)?"True":"False"); printk(KERN_DEBUG "OpenBlock: waiting for CD or signal\n"); #endif -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_OPEN, 3, 2, (pCh->flags & ASYNC_CALLOUT_ACTIVE), - (pCh->flags & ASYNC_CLOSING) ); -#endif + (pCh->flags & ASYNC_CLOSING) ); /* check for signal */ if (signal_pending(current)) { rc = (( pCh->flags & ASYNC_HUP_NOTIFY ) ? -EAGAIN : -ERESTARTSYS); @@ -1773,12 +1757,12 @@ ip2_open( PTTY tty, struct file *pFile ) schedule(); } set_current_state( TASK_RUNNING ); - remove_wait_queue(&pCh->dss_now_wait, &wait); + remove_wait_queue(&pCh->open_wait, &wait); --pCh->wopen; //why count? -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_OPEN, 4, 0 ); -#endif + if (rc != 0 ) { return rc; } @@ -1815,9 +1799,8 @@ noblock: #endif serviceOutgoingFifo( pCh->pMyBord ); -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_OPEN, ITRC_RETURN, 0 ); -#endif + return 0; } @@ -1840,9 +1823,7 @@ ip2_close( PTTY tty, struct file *pFile ) return; } -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_CLOSE, ITRC_ENTER, 0 ); -#endif #ifdef IP2DEBUG_OPEN printk(KERN_DEBUG "IP2:close ttyF%02X:\n",MINOR(tty->device)); @@ -1851,16 +1832,15 @@ ip2_close( PTTY tty, struct file *pFile ) if ( tty_hung_up_p ( pFile ) ) { MOD_DEC_USE_COUNT; -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_CLOSE, 2, 1, 2 ); -#endif + return; } if ( tty->count > 1 ) { /* not the last close */ MOD_DEC_USE_COUNT; -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_CLOSE, 2, 1, 3 ); -#endif + return; } pCh->flags |= ASYNC_CLOSING; // last close actually @@ -1928,9 +1908,8 @@ ip2_close( PTTY tty, struct file *pFile ) MOD_DEC_USE_COUNT; -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_CLOSE, ITRC_RETURN, 1, 1 ); -#endif + return; } @@ -1952,9 +1931,7 @@ ip2_hangup ( PTTY tty ) return; } -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_HANGUP, ITRC_ENTER, 0 ); -#endif ip2_flush_buffer(tty); @@ -1977,9 +1954,7 @@ ip2_hangup ( PTTY tty ) pCh->pTTY = NULL; wake_up_interruptible ( &pCh->open_wait ); -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_HANGUP, ITRC_RETURN, 0 ); -#endif } /******************************************************************************/ @@ -2007,9 +1982,7 @@ ip2_write( PTTY tty, int user, const unsigned char *pData, int count) int bytesSent = 0; unsigned long flags; -#ifdef IP2DEBUG_TRACE - ip2trace (CHANN, ITRC_WRITE, ITRC_ENTER, 2, count, -1 ); -#endif + ip2trace (CHANN, ITRC_WRITE, ITRC_ENTER, 2, count, -1 ); /* Flush out any buffered data left over from ip2_putchar() calls. */ ip2_flush_chars( tty ); @@ -2019,9 +1992,8 @@ ip2_write( PTTY tty, int user, const unsigned char *pData, int count) bytesSent = i2Output( pCh, pData, count, user ); WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); -#ifdef IP2DEBUG_TRACE - ip2trace (CHANN, ITRC_WRITE, ITRC_RETURN, 1, bytesSent ); -#endif + ip2trace (CHANN, ITRC_WRITE, ITRC_RETURN, 1, bytesSent ); + return bytesSent > 0 ? bytesSent : 0; } @@ -2041,9 +2013,7 @@ ip2_putchar( PTTY tty, unsigned char ch ) i2ChanStrPtr pCh = tty->driver_data; unsigned long flags; -#ifdef IP2DEBUG_TRACE // ip2trace (CHANN, ITRC_PUTC, ITRC_ENTER, 1, ch ); -#endif WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); pCh->Pbuf[pCh->Pbuf_stuff++] = ch; @@ -2053,9 +2023,7 @@ ip2_putchar( PTTY tty, unsigned char ch ) } else WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); -#ifdef IP2DEBUG_TRACE // ip2trace (CHANN, ITRC_PUTC, ITRC_RETURN, 1, ch ); -#endif } /******************************************************************************/ @@ -2075,9 +2043,9 @@ ip2_flush_chars( PTTY tty ) WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); if ( pCh->Pbuf_stuff ) { -#ifdef IP2DEBUG_TRACE -// ip2trace (CHANN, ITRC_PUTC, 10, 1, strip ); -#endif + +// ip2trace (CHANN, ITRC_PUTC, 10, 1, strip ); + // // We may need to restart i2Output if it does not fullfill this request // @@ -2109,9 +2077,7 @@ ip2_write_room ( PTTY tty ) bytesFree = i2OutputFree( pCh ) - pCh->Pbuf_stuff; READ_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_WRITE, 11, 1, bytesFree ); -#endif return ((bytesFree > 0) ? bytesFree : 0); } @@ -2131,9 +2097,9 @@ ip2_chars_in_buf ( PTTY tty ) i2ChanStrPtr pCh = tty->driver_data; int rc; unsigned long flags; -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_WRITE, 12, 1, pCh->Obuf_char_count + pCh->Pbuf_stuff ); -#endif + #ifdef IP2DEBUG_WRITE printk (KERN_DEBUG "IP2: chars in buffer = %d (%d,%d)\n", pCh->Obuf_char_count + pCh->Pbuf_stuff, @@ -2163,9 +2129,8 @@ ip2_flush_buffer( PTTY tty ) i2ChanStrPtr pCh = tty->driver_data; unsigned long flags; -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_FLUSH, ITRC_ENTER, 0 ); -#endif + #ifdef IP2DEBUG_WRITE printk (KERN_DEBUG "IP2: flush buffer\n" ); #endif @@ -2174,9 +2139,9 @@ ip2_flush_buffer( PTTY tty ) WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); i2FlushOutput( pCh ); ip2_owake(tty); -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_FLUSH, ITRC_RETURN, 0 ); -#endif + } /******************************************************************************/ @@ -2322,9 +2287,7 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) return -ENODEV; } -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_IOCTL, ITRC_ENTER, 2, cmd, arg ); -#endif #ifdef IP2DEBUG_IOCTL printk(KERN_DEBUG "IP2: ioctl cmd (%x), arg (%lx)\n", cmd, arg ); @@ -2332,18 +2295,18 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) switch(cmd) { case TIOCGSERIAL: -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_IOCTL, 2, 1, rc ); -#endif + rc = get_serial_info(pCh, (struct serial_struct *) arg); if (rc) return rc; break; case TIOCSSERIAL: -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_IOCTL, 3, 1, rc ); -#endif + rc = set_serial_info(pCh, (struct serial_struct *) arg); if (rc) return rc; @@ -2379,9 +2342,9 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) case TCSBRK: /* SVID version: non-zero arg --> no break */ rc = tty_check_change(tty); -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_IOCTL, 4, 1, rc ); -#endif + if (!rc) { ip2_wait_until_sent(tty,0); if (!arg) { @@ -2393,9 +2356,9 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) case TCSBRKP: /* support for POSIX tcsendbreak() */ rc = tty_check_change(tty); -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_IOCTL, 5, 1, rc ); -#endif + if (!rc) { ip2_wait_until_sent(tty,0); i2QueueCommands(PTYPE_INLINE, pCh, 100, 1, @@ -2405,18 +2368,18 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) break; case TIOCGSOFTCAR: -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_IOCTL, 6, 1, rc ); -#endif + PUT_USER(rc,C_CLOCAL(tty) ? 1 : 0, (unsigned long *) arg); if (rc) return rc; break; case TIOCSSOFTCAR: -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_IOCTL, 7, 1, rc ); -#endif + GET_USER(rc,arg,(unsigned long *) arg); if (rc) return rc; @@ -2426,9 +2389,9 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) break; case TIOCMGET: -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_IOCTL, 8, 1, rc ); -#endif + i2QueueCommands(PTYPE_BYPASS, pCh, 100, 1, CMD_DSS_NOW); init_waitqueue_entry(&wait, current); @@ -2458,9 +2421,8 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) case TIOCMBIS: case TIOCMBIC: case TIOCMSET: -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_IOCTL, 9, 0 ); -#endif + rc = set_modem_info(pCh, cmd, (unsigned int *) arg); break; @@ -2481,13 +2443,12 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) serviceOutgoingFifo( pCh->pMyBord ); for(;;) { -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_IOCTL, 10, 0 ); -#endif + schedule(); -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_IOCTL, 11, 0 ); -#endif + /* see if a signal did it */ if (signal_pending(current)) { rc = -ERESTARTSYS; @@ -2531,9 +2492,8 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) * serial driver. */ case TIOCGICOUNT: -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_IOCTL, 11, 1, rc ); -#endif + save_flags(flags);cli(); cnow = pCh->icount; restore_flags(flags); @@ -2564,15 +2524,14 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) case TIOCSERSETMULTI: default: -#ifdef IP2DEBUG_TRACE ip2trace (CHANN, ITRC_IOCTL, 12, 0 ); -#endif + rc = -ENOIOCTLCMD; break; } -#ifdef IP2DEBUG_TRACE + ip2trace (CHANN, ITRC_IOCTL, ITRC_RETURN, 0 ); -#endif + return rc; } @@ -2783,9 +2742,9 @@ ip2_set_line_discipline ( PTTY tty ) #ifdef IP2DEBUG_IOCTL printk (KERN_DEBUG "IP2: set line discipline\n" ); #endif -#ifdef IP2DEBUG_TRACE + ip2trace (((i2ChanStrPtr)tty->driver_data)->port_index, ITRC_IOCTL, 16, 0 ); -#endif + } /******************************************************************************/ @@ -3241,12 +3200,16 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg ) break; default: - pCh = DevTable[cmd]; - if ( pCh ) - { - COPY_TO_USER(rc, (char*)arg, (char*)pCh, sizeof(i2ChanStr) ); + if (cmd < IP2_MAX_PORTS) { + pCh = DevTable[cmd]; + if ( pCh ) + { + COPY_TO_USER(rc, (char*)arg, (char*)pCh, sizeof(i2ChanStr) ); + } else { + rc = -ENODEV; + } } else { - rc = cmd < 64 ? -ENODEV : -EINVAL; + rc = -EINVAL; } } break; @@ -3561,10 +3524,10 @@ int ip2_read_proc(char *page, char **start, off_t off, /* */ /* */ /******************************************************************************/ +#ifdef IP2DEBUG_TRACE void ip2trace (unsigned short pn, unsigned char cat, unsigned char label, unsigned long codes, ...) { -#ifdef IP2DEBUG_TRACE long flags; unsigned long *pCode = &codes; union ip2breadcrumb bc; @@ -3604,7 +3567,7 @@ ip2trace (unsigned short pn, unsigned char cat, unsigned char label, unsigned lo tracebuf[tracestuff++] = *++pCode; } -#endif } +#endif -- 2.39.5