diff -u --recursive --new-file linux-2.0.27.h1.4/drivers/isdn/hisax/isdnl1.c linux/drivers/isdn/hisax/isdnl1.c
--- linux-2.0.27.h1.4/drivers/isdn/hisax/isdnl1.c	Thu Jan  9 19:47:40 1997
+++ linux/drivers/isdn/hisax/isdnl1.c	Fri Jan 10 13:58:53 1997
@@ -1,16 +1,19 @@
-/* $Id: isdnl1.c,v 1.4 1996/12/08 19:44:53 keil Exp $
+/* $Id: isdnl1.c,v 1.5 1997/01/10 12:51:19 keil Exp $
  *
  * isdnl1.c     common low level stuff for Siemens Chipsetbased isdn cards
  *              based on the teles driver from Jan den Ouden
- * 
+ *
  * Author	Karsten Keil (keil@temic-ech.spacenet.de)
  *
  * Thanks to	Jan den Ouden
- *	        Fritz Elfert	
+ *	        Fritz Elfert
  * 	        Beat Doebeli
- *            
- * 
+ *
+ *
  * $Log: isdnl1.c,v $
+ * Revision 1.5  1997/01/10 12:51:19  keil
+ * cleanup; set newversion
+ *
  * Revision 1.4  1996/12/08 19:44:53  keil
  * L2FRAME_DEBUG and other changes from Pekka Sarnila
  *
@@ -27,7 +30,7 @@
  *
 */
 
-const	char	*l1_revision        = "$Revision: 1.4 $";
+const	char	*l1_revision        = "$Revision: 1.5 $";
 
 #define __NO_VERSION__
 #include "hisax.h"
@@ -61,7 +64,7 @@
 
 static  char    *ISACVer[] = {"2086/2186 V1.1","2085 B1","2085 B2",
 			      "2085 V2.3"};
- 
+
 extern void     tei_handler(struct PStack *st, byte pr,
 			    struct BufHeader *ibh);
 extern struct   IsdnCard cards[];
@@ -75,7 +78,7 @@
 
 	jiftime(tm, jiffies);
 	sprintf(tmp, "%s Card %d %s\n", tm, sp->cardnr+1, msg);
-	HiSax_putstatus(tmp); 
+	HiSax_putstatus(tmp);
 }
 
 /*
@@ -341,7 +344,7 @@
 		  break;
 	  case (PH_DATA_PULLED):
 		  if (sp->xmtibh) {
-			  if (sp->debug & L1_DEB_WARN) 
+			  if (sp->debug & L1_DEB_WARN)
         			debugl1(sp, " l2l1 xmtibh exist this shouldn't happen");
 			  break;
 		  }
@@ -649,7 +652,7 @@
 	sp->cardnr = cardnr;
 	sp->cfg_reg  = 0;
 	sp->protocol = card->protocol;
-	
+
 	if ((card->typ>0) && (card->typ<31)) {
 		if (!((1<<card->typ) & SUPORTED_CARDS)) {
                         printk(KERN_WARNING
@@ -666,7 +669,7 @@
 	sp->dlogspace = Smalloc(4096, GFP_KERNEL, "dlogspace");
 	sp->typ      = card->typ;
 	sp->CallFlags = 0;
-	
+
 	printk(KERN_NOTICE
 		"HiSax: Card %d Protocol %s\n", cardnr+1,
                 (card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" : "EDSS1");
@@ -694,7 +697,7 @@
                 ret=setup_elsa(card);
                 break;
 #endif
-          default: 
+          default:
                 printk(KERN_WARNING  "HiSax: Unknown Card Typ %d\n",
                   			card->typ);
 				Sfree(sp->dlogspace);
@@ -711,7 +714,7 @@
 	BufPoolInit(&sp->smallpool, ISAC_SMALLBUF_ORDER, ISAC_SMALLBUF_BPPS,
 		    ISAC_SMALLBUF_MAXPAGES);
 
-	
+
 	sp->rcvibh  = NULL;
 	sp->rcvptr  = 0;
 	sp->xmtibh  = NULL;
@@ -865,7 +868,7 @@
                                 st->l1.requestpull = !0;
                         break;
 	}
-        
+
 }
 extern struct IsdnBuffers *tracebuf;
 
@@ -962,7 +965,7 @@
 HiSax_reportcard(int cardnr)
 {
 	struct IsdnCardState *sp = cards[cardnr].sp;
-	
+
 	printk(KERN_DEBUG "HiSax: reportcard No %d\n",cardnr+1);
 	printk(KERN_DEBUG "HiSax: Type %s\n", CardType[sp->typ]);
 	printk(KERN_DEBUG "HiSax: debuglevel %x\n", sp->debug);
diff -u --recursive --new-file linux-2.0.27.h1.4/drivers/isdn/hisax/config.c linux/drivers/isdn/hisax/config.c
--- linux-2.0.27.h1.4/drivers/isdn/hisax/config.c	Thu Jan  9 19:47:39 1997
+++ linux/drivers/isdn/hisax/config.c	Thu Jan  9 19:55:17 1997
@@ -1,10 +1,13 @@
-/* $Id: config.c,v 1.4 1996/11/05 19:35:17 keil Exp $
+/* $Id: config.c,v 1.5 1997/01/09 18:28:20 keil Exp $
  *
  * Author       Karsten Keil (keil@temic-ech.spacenet.de)
  *              based on the teles driver from Jan den Ouden
  *
  *
  * $Log: config.c,v $
+ * Revision 1.5  1997/01/09 18:28:20  keil
+ * cosmetic cleanups
+ *
  * Revision 1.4  1996/11/05 19:35:17  keil
  * using config.h; some spelling fixes
  *
@@ -30,7 +33,7 @@
 /*
  * This structure array contains one entry per card. An entry looks
  * like this:
- * 
+ *
  * { type, protocol, p0, p1, p2, NULL }
  *
  * type
@@ -40,7 +43,7 @@
  *    4 Creatix PNP   	p0=irq p1=IO0 (ISAC)  p2=IO1 (HSCX)
  *    5 AVM A1 (Fritz)  p0=irq p1=iobase
  *    6 ELSA PCC16 	[p0=iobase] or nothing (autodetect)
- *                    
+ *
  *
  * protocol can be either ISDN_PTYPE_EURO or ISDN_PTYPE_1TR6
  *
@@ -83,7 +86,7 @@
 #ifndef DEFAULT_CARD
 #error "HiSax: No cards configured"
 #endif
- 
+
 #define FIRST_CARD { \
   DEFAULT_CARD, \
   DEFAULT_PROTO, \
@@ -228,7 +231,7 @@
 	printk(KERN_NOTICE "HiSax: Revision (");
 	strcpy(tmp,l1_revision);
 	printk("%s)\n",HiSax_getrev(tmp));
-	
+
 
 	for (i = 0; i < 16; i++) {
 		if ((io[i].typ>0) && (io[i].typ<=ISDN_CTYPE_COUNT)) {
diff -u --recursive --new-file linux-2.0.27.h1.4/drivers/isdn/hisax/elsa.c linux/drivers/isdn/hisax/elsa.c
--- linux-2.0.27.h1.4/drivers/isdn/hisax/elsa.c	Thu Jan  9 19:47:39 1997
+++ linux/drivers/isdn/hisax/elsa.c	Thu Jan  9 19:55:17 1997
@@ -1,4 +1,4 @@
-/* $Id: elsa.c,v 1.5 1996/12/08 19:46:14 keil Exp $
+/* $Id: elsa.c,v 1.6 1997/01/09 18:22:46 keil Exp $
  *
  * elsa.c     low level stuff for Elsa isdn cards
  *
@@ -8,6 +8,9 @@
  *
  * 
  * $Log: elsa.c,v $
+ * Revision 1.6  1997/01/09 18:22:46  keil
+ * one more PCC-8 fix
+ *
  * Revision 1.5  1996/12/08 19:46:14  keil
  * PCC-8 correct IRQs; starting ARCOFI support
  *
@@ -1134,8 +1137,8 @@
 		in2 = inb(adr + CARD_CONFIG);  /* jedem Zugriff */
 		p16_1 += 0x04 & in1;
 		p16_2 += 0x04 & in2;
-		pcc_1 += 0x02 & in1;
-		pcc_2 += 0x02 & in2;
+		pcc_1 += 0x01 & in1;
+		pcc_2 += 0x01 & in2;
 		pfp_1 += 0x40 & in1;
 		pfp_2 += 0x40 & in2;
 	}
@@ -1147,7 +1150,7 @@
         } else if (1025 == ++pfp_1 * ++pfp_2) {
                 printk(" PCF-Pro found\n");
                 return(2);
-        } else if (33 == ++pcc_1 * ++pcc_2) {
+        } else if (17 == ++pcc_1 * ++pcc_2) {
                 printk(" PCC8 found\n");
                 return(1);
         } else {
@@ -1224,7 +1227,7 @@
 
 	switch (sp->subtyp) {
 		case ELSA_PCC:  bytecnt = 8;
-				sp->mask1 = TIMER_RUN_PCC;
+				sp->mask1 = TIMER_RUN;
 				break;
 		case ELSA_PCFPRO:bytecnt = 16;
 				sp->mask1 = TIMER_RUN;
@@ -1256,8 +1259,9 @@
 	bytein(sp->cfg_reg +CARD_START_TIMER);
 	if (!(bytein(sp->cfg_reg +CARD_CONFIG) & sp->mask1)) {
 		bytein(sp->cfg_reg +CARD_START_TIMER); /* 2. Versuch */
-		if (!(bytein(sp->cfg_reg +CARD_CONFIG) & sp->mask1)) { 
-        		printk(KERN_WARNING "Elsa: timer do not start\n");
+		if (!((val=bytein(sp->cfg_reg +CARD_CONFIG)) & sp->mask1)) { 
+        		printk(KERN_WARNING 
+        			"Elsa: timer do not start (%02x)\n",val);
         		release_io_elsa(card);
         		return(0);
         	}
diff -u --recursive --new-file linux-2.0.27.h1.4/drivers/isdn/hisax/fsm.c linux/drivers/isdn/hisax/fsm.c
--- linux-2.0.27.h1.4/drivers/isdn/hisax/fsm.c	Thu Jan  9 19:47:39 1997
+++ linux/drivers/isdn/hisax/fsm.c	Thu Jan  9 22:03:49 1997
@@ -1,4 +1,4 @@
-/* $Id: fsm.c,v 1.1 1996/10/13 20:04:52 keil Exp $
+/* $Id: fsm.c,v 1.2 1997/01/09 20:57:27 keil Exp $
  *
  * Author       Karsten Keil (keil@temic-ech.spacenet.de)
  *              based on the teles driver from Jan den Ouden
@@ -7,6 +7,9 @@
  *              Fritz Elfert
  *
  * $Log: fsm.c,v $
+ * Revision 1.2  1997/01/09 20:57:27  keil
+ * cleanup & FSM_TIMER_DEBUG
+ *
  * Revision 1.1  1996/10/13 20:04:52  keil
  * Initial revision
  *
@@ -15,6 +18,8 @@
 #define __NO_VERSION__
 #include "hisax.h"
 
+#define FSM_TIMER_DEBUG 0
+
 void
 FsmNew(struct Fsm *fsm,
        struct FsmNode *fnlist, int fncount)
@@ -79,6 +84,13 @@
 static void
 FsmExpireTimer(struct FsmTimer *ft)
 {
+#if FSM_TIMER_DEBUG
+	if (ft->fi->debug) {
+		char str[40];
+		sprintf(str, "FsmExpireTimer %lx", (long)ft);
+		ft->fi->printdebug(ft->fi, str);
+	}
+#endif
 	FsmEvent(ft->fi, ft->event, ft->arg);
 }
 
@@ -88,6 +100,13 @@
 	ft->fi = fi;
 	ft->tl.function = (void *) FsmExpireTimer;
 	ft->tl.data = (long) ft;
+#if FSM_TIMER_DEBUG
+	if (ft->fi->debug) {
+		char str[40];
+		sprintf(str, "FsmInitTimer %lx", (long)ft);
+		ft->fi->printdebug(ft->fi, str);
+	}
+#endif
 	init_timer(&ft->tl);
 }
 
@@ -96,13 +115,13 @@
 {
 	long            flags;
 
-#if 0
+#if FSM_TIMER_DEBUG
 	if (ft->fi->debug) {
-		sprintf(str, "FsmDelTimer %lx %d", ft, where);
+		char str[40];
+		sprintf(str, "FsmDelTimer %lx %d", (long)ft, where);
 		ft->fi->printdebug(ft->fi, str);
 	}
 #endif
-
 	save_flags(flags);
 	cli();
 	if (ft->tl.next)
@@ -115,15 +134,17 @@
 	    int millisec, int event, void *arg, int where)
 {
 
-#if 0
+#if FSM_TIMER_DEBUG
 	if (ft->fi->debug) {
-		sprintf(str, "FsmAddTimer %lx %d %d", ft, millisec, where);
+		char str[40];
+		sprintf(str, "FsmAddTimer %lx %d %d", (long)ft, millisec, where);
 		ft->fi->printdebug(ft->fi, str);
 	}
 #endif
 
 	if (ft->tl.next) {
 		printk(KERN_WARNING "FsmAddTimer: timer already active!\n");
+		ft->fi->printdebug(ft->fi, "FsmAddTimer already active!");
 		return -1;
 	}
 	init_timer(&ft->tl);
diff -u --recursive --new-file linux-2.0.27.h1.4/drivers/isdn/hisax/hisax.h linux/drivers/isdn/hisax/hisax.h
--- linux-2.0.27.h1.4/drivers/isdn/hisax/hisax.h	Thu Jan  9 19:47:39 1997
+++ linux/drivers/isdn/hisax/hisax.h	Thu Jan  9 20:23:03 1997
@@ -1,8 +1,11 @@
-/* $Id: hisax.h,v 1.5 1996/12/08 19:49:19 keil Exp $
+/* $Id: hisax.h,v 1.6 1997/01/04 13:48:28 keil Exp $
  *
  *   Basic declarations, defines and prototypes
  *
  * $Log: hisax.h,v $
+ * Revision 1.6  1997/01/04 13:48:28  keil
+ * primitiv for MDL_REMOVE added
+ *
  * Revision 1.5  1996/12/08 19:49:19  keil
  * Monitor channel support
  *
@@ -97,11 +100,13 @@
 
 #define PH_REQUEST_PULL        49
 #define PH_PULL_ACK            50
-#define	PH_DATA_PULLED	       51
+#define PH_DATA_PULLED	       51
 #define CC_INFO_CHARGE         52
 
+#define MDL_REMOVE             60
+
 /*
- * Message-Types 
+ * Message-Types
  */
 
 #define MT_ALERTING            0x01
@@ -175,7 +180,7 @@
 void            Sfree(byte * ptr);
 
 /*
- * Statemachine 
+ * Statemachine
  */
 struct Fsm {
 	int            *jumpmatrix;
@@ -304,7 +309,7 @@
 	char            calling[40]; /* Called Id                       */
 	char            called[40];  /* Caller Id                       */
 	int             chargeinfo;  /* Charge Info - only for 1tr6 in
-				      * the moment 
+				      * the moment
 				      */
 	int		spv;	     /* SPV Flag */
 };
@@ -388,7 +393,7 @@
 #define  ISDN_CTYPE_8_0		2
 #define  ISDN_CTYPE_16_3	3
 #define  ISDN_CTYPE_PNP		4
-#define  ISDN_CTYPE_A1		5 
+#define  ISDN_CTYPE_A1		5
 #define  ISDN_CTYPE_ELSA	6
 
 #define  ISDN_CTYPE_COUNT	6
diff -u --recursive --new-file linux-2.0.27.h1.4/drivers/isdn/hisax/isdnl2.c linux/drivers/isdn/hisax/isdnl2.c
--- linux-2.0.27.h1.4/drivers/isdn/hisax/isdnl2.c	Thu Jan  9 19:47:40 1997
+++ linux/drivers/isdn/hisax/isdnl2.c	Thu Jan  9 19:55:17 1997
@@ -1,4 +1,4 @@
-/* $Id: isdnl2.c,v 1.4 1996/12/08 19:51:51 keil Exp $
+/* $Id: isdnl2.c,v 1.5 1997/01/04 13:47:06 keil Exp $
  *
  * Author       Karsten Keil (keil@temic-ech.spacenet.de)
  *              based on the teles driver from Jan den Ouden
@@ -7,6 +7,9 @@
  *              Fritz Elfert
  *
  * $Log: isdnl2.c,v $
+ * Revision 1.5  1997/01/04 13:47:06  keil
+ * handling of MDL_REMOVE added (Thanks to Sim Yskes)
+ *
  * Revision 1.4  1996/12/08 19:51:51  keil
  * many fixes from Pekka Sarnila
  *
@@ -68,6 +71,7 @@
 	EV_L2_DL_DATA,
 	EV_L2_DL_ESTABLISH,
 	EV_L2_MDL_ASSIGN,
+	EV_L2_MDL_REMOVE,
 	EV_L2_DL_UNIT_DATA,
 	EV_L2_DL_RELEASE,
 	EV_L2_MDL_NOTEIPROC,
@@ -92,6 +96,7 @@
 	"EV_L2_DL_DATA",
 	"EV_L2_DL_ESTABLISH",
 	"EV_L2_MDL_ASSIGN",
+	"EV_L2_MDL_REMOVE",
 	"EV_L2_DL_UNIT_DATA",
 	"EV_L2_DL_RELEASE",
 	"EV_L2_MDL_NOTEIPROC",
@@ -725,7 +730,7 @@
 	}
 	else
 	      nrerrorrecovery(fi);
-  
+
 	if (wasok)
 	        st->l2.l2l3(st, DL_DATA, ibh);
 }
@@ -746,7 +751,7 @@
 	}
 	else
 	      nrerrorrecovery(fi);
-  
+
 	if (wasok)
 	        st->l2.l2l3(st, DL_DATA, ibh);
 }
@@ -1164,6 +1169,31 @@
 	BufPoolRelease(ibh);
 }
 
+static void
+l2s30(struct FsmInst *fi, int event, void *arg)
+{
+	struct PStack  *st = fi->userdata;
+
+/*TODO
+	if( DL_RELEASE.req outstanding ) {
+		... issue DL_RELEASE.confirm
+	} else {
+	    if( fi->state != ST_L2_4 ) {
+		... issue DL_RELEASE.indication
+	    }
+        }
+TODO*/
+	discard_i_queue(st);  /* There is no UI queue in layer 2 */
+	st->l2.tei = 255;
+	if (st->l2.t200_running) {
+		FsmDelTimer(&st->l2.t200_timer, 18);
+		st->l2.t200_running = 0;
+	}
+	FsmDelTimer(&st->l2.t203_timer, 19);
+	st->l2.l2man(st, DL_RELEASE, NULL);	/* TEMP */
+	FsmChangeState(fi, ST_L2_1);
+}
+
 static int
 IsUI(byte * data, int ext)
 {
@@ -1263,6 +1293,15 @@
 	{ST_L2_7, EV_L2_T200, l2s23},
 	{ST_L2_7, EV_L2_T203, l2s25},
 	{ST_L2_8, EV_L2_T200, l2s26},
+
+	{ST_L2_1, EV_L2_MDL_REMOVE, l2s30 },
+/*	{ST_L2_2, EV_L2_MDL_REMOVE, l2s30 }, */
+	{ST_L2_3, EV_L2_MDL_REMOVE, l2s30 },
+	{ST_L2_4, EV_L2_MDL_REMOVE, l2s30 },
+	{ST_L2_5, EV_L2_MDL_REMOVE, l2s30 },
+	{ST_L2_6, EV_L2_MDL_REMOVE, l2s30 },
+	{ST_L2_7, EV_L2_MDL_REMOVE, l2s30 },
+	{ST_L2_8, EV_L2_MDL_REMOVE, l2s30 },
 };
 
 #define L2_FN_COUNT (sizeof(L2FnList)/sizeof(struct FsmNode))
@@ -1353,6 +1392,9 @@
 	switch (pr) {
 	  case (MDL_ASSIGN):
 		  FsmEvent(&st->l2.l2m, EV_L2_MDL_ASSIGN, arg);
+		  break;
+	  case (MDL_REMOVE):
+		  FsmEvent(&st->l2.l2m, EV_L2_MDL_REMOVE, arg);
 		  break;
 	}
 }
diff -u --recursive --new-file linux-2.0.27.h1.4/drivers/isdn/hisax/l3_1tr6.c linux/drivers/isdn/hisax/l3_1tr6.c
--- linux-2.0.27.h1.4/drivers/isdn/hisax/l3_1tr6.c	Thu Jan  9 19:47:40 1997
+++ linux/drivers/isdn/hisax/l3_1tr6.c	Thu Jan  9 19:55:18 1997
@@ -1,4 +1,4 @@
-/* $Id: l3_1tr6.c,v 1.5 1996/12/08 19:55:17 keil Exp $
+/* $Id: l3_1tr6.c,v 1.6 1996/12/14 21:07:20 keil Exp $
  *
  *  German 1TR6 D-channel protocol
  *
@@ -6,6 +6,9 @@
  *
  *
  * $Log: l3_1tr6.c,v $
+ * Revision 1.6  1996/12/14 21:07:20  keil
+ * additional states for CC_REJECT
+ *
  * Revision 1.5  1996/12/08 19:55:17  keil
  * change CC_REJECT_REQ routine
  *
@@ -455,7 +458,7 @@
         {SBIT(1)| SBIT(2)| SBIT(3)| SBIT(4)| SBIT(6)| SBIT(7)| SBIT(8)|
          	SBIT(10)| SBIT(12)| SBIT(19),
         	CC_DLRL, l3_1tr6_reset},
-	{SBIT(6),
+	{SBIT(1)| SBIT(3)| SBIT(4)| SBIT(6),
 		CC_REJECT_REQ, l3_1tr6_disconn_req},
 	{SBIT(6)|SBIT(7),
 		CC_SETUP_RSP, l3_1tr6_conn},
diff -u --recursive --new-file linux-2.0.27.h1.4/drivers/isdn/hisax/l3dss1.c linux/drivers/isdn/hisax/l3dss1.c
--- linux-2.0.27.h1.4/drivers/isdn/hisax/l3dss1.c	Thu Jan  9 19:47:40 1997
+++ linux/drivers/isdn/hisax/l3dss1.c	Thu Jan  9 19:55:18 1997
@@ -1,4 +1,4 @@
-/* $Id: l3dss1.c,v 1.6 1996/12/08 22:59:16 keil Exp $
+/* $Id: l3dss1.c,v 1.7 1996/12/14 21:06:59 keil Exp $
  *
  * EURO/DSS1 D-channel protocol
  *
@@ -9,6 +9,9 @@
  *              Fritz Elfert
  *
  * $Log: l3dss1.c,v $
+ * Revision 1.7  1996/12/14 21:06:59  keil
+ * additional states for CC_REJECT
+ *
  * Revision 1.6  1996/12/08 22:59:16  keil
  * fixed calling party number without octet 3a
  *
@@ -354,7 +357,10 @@
 	*p++ = IE_CAUSE;
 	*p++ = 0x2;
 	*p++ = 0x80;
-	*p++ = 0x95;  /* Call rejected */
+	if (st->l3.state == 6) 
+		*p++ = 0x95;  /* Call rejected */
+	else
+		*p++ = 0x90; /* normal Call clearing */
 
 	dibh->datasize = p - DATAPTR(dibh);
 	st->l3.l3l2(st, DL_DATA, dibh);
@@ -422,7 +428,7 @@
         {SBIT(1)| SBIT(3)| SBIT(4)| SBIT(6)| SBIT(7)| SBIT(8)| SBIT(10)|
         	SBIT(19),
         	CC_DLRL,l3s13},
-        {SBIT(6),
+        {SBIT(1)| SBIT(3)| SBIT(4)| SBIT(6),
         	CC_REJECT_REQ,l3s18_6},
         {SBIT(6),
         	CC_ALERTING_REQ,l3s20},
diff -u --recursive --new-file linux-2.0.27.h1.4/drivers/isdn/hisax/tei.c linux/drivers/isdn/hisax/tei.c
--- linux-2.0.27.h1.4/drivers/isdn/hisax/tei.c	Thu Jan  9 19:47:40 1997
+++ linux/drivers/isdn/hisax/tei.c	Thu Jan  9 19:55:18 1997
@@ -1,4 +1,4 @@
-/* $Id: tei.c,v 1.2 1996/12/08 19:52:39 keil Exp $
+/* $Id: tei.c,v 1.3 1997/01/04 13:45:02 keil Exp $
  *
  * Author       Karsten Keil (keil@temic-ech.spacenet.de)
  *              based on the teles driver from Jan den Ouden
@@ -7,6 +7,9 @@
  *              Fritz Elfert
  *
  * $Log: tei.c,v $
+ * Revision 1.3  1997/01/04 13:45:02  keil
+ * cleanup,adding remove tei request (thanks to Sim Yskes)
+ *
  * Revision 1.2  1996/12/08 19:52:39  keil
  * minor debug fix
  *
@@ -51,13 +54,96 @@
 	return (NULL);
 }
 
-void 
+static void
+mdl_unit_data_res(struct PStack *st, unsigned int ri, byte mt, byte ai )
+{
+    struct BufHeader *ibh;
+    byte *bp;
+
+    if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 7))
+	return ;
+    bp = DATAPTR(ibh);
+    bp += 3;
+    bp[0] = 0xf;
+    bp[1] = ri >> 8;
+    bp[2] = ri & 0xff;
+    bp[3] = mt ;
+    bp[4] = ( ai << 1) | 1;
+    ibh->datasize = 8;
+    st->l3.l3l2(st, DL_UNIT_DATA, ibh);
+}
+
+static void
+mdl_unit_data_ind(struct PStack *st, unsigned int ri, byte mt, byte ai )
+{
+    unsigned int    tces;
+    struct PStack  *otsp, *ptr;
+
+    switch (mt) {
+	case (2):
+	    tces = ri ;
+	    if (st->l3.debug)
+		printk(KERN_DEBUG "tei identity assigned for %d=%d\n",
+					tces, ai );
+	    if ((otsp = findces(st, tces)))
+		otsp->ma.teil2(otsp, MDL_ASSIGN, (void *)(int)ai );
+	    break;
+	case (4):
+	    if (st->l3.debug)
+		printk(KERN_DEBUG "checking identity for %d\n", ai );
+	    if (ai == 0x7f) {
+		ptr = *(st->l1.stlistp);
+		while (ptr) {
+		    if ((ptr->l2.tei & 0x7f) != 0x7f) {
+			/* send identity check response (user->network) */
+			mdl_unit_data_res( st, ptr->l2.ces, 5, ptr->l2.tei );
+		    }
+		    ptr = ptr->next;
+		}
+	    } else {
+		otsp = findtei(st, ai);
+		if (!otsp)
+		    break;
+		if (st->l3.debug)
+		    printk(KERN_DEBUG "ces is %d\n", otsp->l2.ces);
+		/* send identity check response (user->network) */
+		mdl_unit_data_res( st, otsp->l2.ces, 5, otsp->l2.tei );
+	    }
+	    break;
+	case (6) :
+	    if( st->l3.debug ) {
+		printk(KERN_DEBUG "tei removal for %d\n", ai );
+	    }
+	    if (ai == 0x7f) {
+		ptr = *(st->l1.stlistp);
+		while (ptr) {
+		    if ((ptr->l2.tei & 0x7f) != 0x7f) {
+			if (st->l3.debug)
+			    printk(KERN_DEBUG "rem ces is %d\n", ptr->l2.ces);
+			ptr->ma.teil2(ptr, MDL_REMOVE, 0 );
+		    }
+		    ptr = ptr->next;
+		}
+	    } else {
+		otsp = findtei(st, ai);
+		if (!otsp)
+		    break;
+		if (st->l3.debug)
+		    printk(KERN_DEBUG "rem ces is %d\n", otsp->l2.ces);
+		otsp->ma.teil2(otsp, MDL_REMOVE, 0 );
+	    }
+	    break ;
+	default:
+	    if (st->l3.debug)
+		printk(KERN_DEBUG "tei message unknown %d ai %d\n", mt, ai );
+    }
+}
+
+void
 tei_handler(struct PStack *st,
 	    byte pr, struct BufHeader *ibh)
 {
 	byte           *bp;
-	unsigned int    tces;
-	struct PStack  *otsp, *ptr;
 	unsigned int    data;
 
 	if (st->l2.debug)
@@ -80,76 +166,23 @@
 		  st->l3.l3l2(st, DL_UNIT_DATA, ibh);
 		  break;
 	  case (DL_UNIT_DATA):
-		  bp = DATAPTR(ibh);
-		  bp += 3;
-		  if (bp[0] != 0xf)
-			  break;
-		  switch (bp[3]) {
-		    case (2):
-			    tces = (bp[1] << 8) | bp[2];
-			    BufPoolRelease(ibh);
-			    if (st->l3.debug)
-				    printk(KERN_DEBUG "tei identity assigned for %d=%d\n", tces,
-					   bp[4] >> 1);
-			    if ((otsp = findces(st, tces)))
-				    otsp->ma.teil2(otsp, MDL_ASSIGN,
-						   (void *)(bp[4] >> 1));
-			    break;
-		    case (4):
-			    if (st->l3.debug)
-				    printk(KERN_DEBUG "checking identity for %d\n", bp[4] >> 1);
-			    if (bp[4] >> 1 == 0x7f) {
-				    BufPoolRelease(ibh);
-				    ptr = *(st->l1.stlistp);
-				    while (ptr) {
-					    if ((ptr->l2.tei & 0x7f) != 0x7f) {
-						    if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 7))
-							    break;
-						    bp = DATAPTR(ibh);
-						    bp += 3;
-						    bp[0] = 0xf;
-						    bp[1] = ptr->l2.ces >> 8;
-						    bp[2] = ptr->l2.ces & 0xff;
-						    bp[3] = 0x5;
-						    bp[4] = (ptr->l2.tei << 1) | 1;
-						    ibh->datasize = 8;
-						    st->l3.l3l2(st, DL_UNIT_DATA, ibh);
-					    }
-					    ptr = ptr->next;
-				    }
-			    } else {
-				    otsp = findtei(st, bp[4] >> 1);
-				    BufPoolRelease(ibh);
-				    if (!otsp)
-					    break;
-				    if (st->l3.debug)
-					    printk(KERN_DEBUG "ces is %d\n", otsp->l2.ces);
-				    if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 7))
-					    break;
-				    bp = DATAPTR(ibh);
-				    bp += 3;
-				    bp[0] = 0xf;
-				    bp[1] = otsp->l2.ces >> 8;
-				    bp[2] = otsp->l2.ces & 0xff;
-				    bp[3] = 0x5;
-				    bp[4] = (otsp->l2.tei << 1) | 1;
-				    ibh->datasize = 8;
-				    st->l3.l3l2(st, DL_UNIT_DATA, ibh);
-			    }
-			    break;
-		    default:
-			    BufPoolRelease(ibh);
-			    if (st->l3.debug)
-				    printk(KERN_DEBUG "tei message unknown %d ai %d\n", bp[3], bp[4] >> 1);
-		  }
-		  break;
+		bp = DATAPTR(ibh);
+		bp += 3;
+		if (bp[0] != 0xf) {
+		    /* wrong management entity identifier, ignore */
+		    /* shouldn't ibh be released??? */
+		    break ;
+		}
+		mdl_unit_data_ind( st, (bp[1] << 8) | bp[2], bp[3], bp[4] >> 1 );
+		BufPoolRelease(ibh);
+		break;
 	  default:
 		  printk(KERN_WARNING "tei handler unknown primitive %d\n", pr);
 		  break;
 	}
 }
 
-unsigned int 
+unsigned int
 randomces(void)
 {
 	int             x = jiffies & 0xffff;
@@ -157,13 +190,13 @@
 	return (x);
 }
 
-static void 
+static void
 tei_man(struct PStack *sp, int i, void *v)
 {
 	printk(KERN_DEBUG "tei_man\n");
 }
 
-static void 
+static void
 tei_l2tei(struct PStack *st, int pr, void *arg)
 {
 	struct IsdnCardState *sp = st->l1.hardware;
@@ -171,13 +204,13 @@
 	tei_handler(sp->teistack, pr, arg);
 }
 
-void 
+void
 setstack_tei(struct PStack *st)
 {
 	st->l2.l2tei = tei_l2tei;
 }
 
-static void 
+static void
 init_tei(struct IsdnCardState *sp, int protocol)
 {
 	struct PStack  *st;
@@ -215,7 +248,8 @@
 	sprintf(tmp, "Card %d tei ", sp->cardnr+1);
 	setstack_isdnl2(st, tmp);
 	st->l2.debug = 0;
-	st->l3.debug = 0;
+/* SGY 	st->l3.debug = 0; */
+	st->l3.debug = 0xff ;
 
 	st->ma.manl2(st, MDL_NOTEIPROC, NULL);
 
@@ -223,12 +257,12 @@
 	st->l1.l1man = tei_man;
 	st->l2.l2man = tei_man;
 	st->l4.l2writewakeup = NULL;
-	
+
 	HiSax_addlist(sp, st);
 	sp->teistack = st;
 }
 
-static void 
+static void
 release_tei(struct IsdnCardState *sp)
 {
 	struct PStack  *st = sp->teistack;
@@ -237,7 +271,7 @@
 	Sfree((void *) st);
 }
 
-void 
+void
 TeiNew(void)
 {
 	int             i;
@@ -247,7 +281,7 @@
 			init_tei(cards[i].sp, cards[i].protocol);
 }
 
-void 
+void
 TeiFree(void)
 {
 	int             i;
diff -u --recursive --new-file linux-2.0.27.h1.4/drivers/isdn/hisax/teles3.c linux/drivers/isdn/hisax/teles3.c
--- linux-2.0.27.h1.4/drivers/isdn/hisax/teles3.c	Thu Jan  9 19:47:40 1997
+++ linux/drivers/isdn/hisax/teles3.c	Thu Jan  9 19:55:18 1997
@@ -1,4 +1,4 @@
-/* $Id: teles3.c,v 1.3 1996/11/05 19:56:54 keil Exp $
+/* $Id: teles3.c,v 1.4 1996/12/14 21:05:41 keil Exp $
  *
  * teles3.c     low level stuff for Teles 16.3 & PNP isdn cards
  *
@@ -11,6 +11,9 @@
  * 	        Beat Doebeli
  * 
  * $Log: teles3.c,v $
+ * Revision 1.4  1996/12/14 21:05:41  keil
+ * Reset for 16.3 PnP
+ *
  * Revision 1.3  1996/11/05 19:56:54  keil
  * debug output fixed
  *
@@ -966,6 +969,12 @@
                 cli();
                 timout = jiffies + (HZ / 10) + 1;
                 byteout(sp->cfg_reg + 4, cfval | 1);
+                sti();
+                while (jiffies <= timout);
+	} else { 
+		/* Reset off for 16.3 PnP , thanks to Georg Acher */
+		byteout(sp->isac + 0x1c, 1);
+                timout = jiffies + 2;
                 sti();
                 while (jiffies <= timout);
 	}
