patch-2.3.4 linux/drivers/isdn/hisax/fsm.c
Next file: linux/drivers/isdn/hisax/hfc_2bds0.c
Previous file: linux/drivers/isdn/hisax/elsa_ser.c
Back to the patch index
Back to the overall index
- Lines: 205
- Date:
Sun May 23 10:03:41 1999
- Orig file:
v2.3.3/linux/drivers/isdn/hisax/fsm.c
- Orig date:
Wed Apr 1 16:20:58 1998
diff -u --recursive --new-file v2.3.3/linux/drivers/isdn/hisax/fsm.c linux/drivers/isdn/hisax/fsm.c
@@ -1,4 +1,4 @@
-/* $Id: fsm.c,v 1.7 1997/11/06 17:09:13 keil Exp $
+/* $Id: fsm.c,v 1.10 1998/11/15 23:54:39 keil Exp $
* Author Karsten Keil (keil@temic-ech.spacenet.de)
* based on the teles driver from Jan den Ouden
@@ -7,6 +7,18 @@
* Fritz Elfert
*
* $Log: fsm.c,v $
+ * Revision 1.10 1998/11/15 23:54:39 keil
+ * changes from 2.0
+ *
+ * Revision 1.9 1998/03/26 07:10:02 paul
+ * The jumpmatrix table in struct Fsm was an array of "int". This is not
+ * large enough for pointers to functions on Linux/Alpha (instant crash
+ * on "insmod hisax). Now there is a typedef for the pointer to function.
+ * This also prevents warnings about "incompatible pointer types".
+ *
+ * Revision 1.8 1998/03/07 22:56:59 tsbogend
+ * made HiSax working on Linux/Alpha
+ *
* Revision 1.7 1997/11/06 17:09:13 keil
* New 2.1 init code
*
@@ -41,18 +53,18 @@
{
int i;
- fsm->jumpmatrix = (int *)
- kmalloc(4L * fsm->state_count * fsm->event_count, GFP_KERNEL);
- memset(fsm->jumpmatrix, 0, 4L * fsm->state_count * fsm->event_count);
+ fsm->jumpmatrix = (FSMFNPTR *)
+ kmalloc(sizeof (FSMFNPTR) * fsm->state_count * fsm->event_count, GFP_KERNEL);
+ memset(fsm->jumpmatrix, 0, sizeof (FSMFNPTR) * fsm->state_count * fsm->event_count);
for (i = 0; i < fncount; i++)
if ((fnlist[i].state>=fsm->state_count) || (fnlist[i].event>=fsm->event_count)) {
- printk(KERN_ERR "FsmNew Error line %d st(%d/%d) ev(%d/%d)\n",
- i,fnlist[i].state,fsm->state_count,
- fnlist[i].event,fsm->event_count);
+ printk(KERN_ERR "FsmNew Error line %d st(%ld/%ld) ev(%ld/%ld)\n",
+ i,(long)fnlist[i].state,(long)fsm->state_count,
+ (long)fnlist[i].event,(long)fsm->event_count);
} else
fsm->jumpmatrix[fsm->state_count * fnlist[i].event +
- fnlist[i].state] = (int) fnlist[i].routine;
+ fnlist[i].state] = (FSMFNPTR) fnlist[i].routine;
}
void
@@ -64,31 +76,26 @@
int
FsmEvent(struct FsmInst *fi, int event, void *arg)
{
- void (*r) (struct FsmInst *, int, void *);
- char str[80];
+ FSMFNPTR r;
if ((fi->state>=fi->fsm->state_count) || (event >= fi->fsm->event_count)) {
- printk(KERN_ERR "FsmEvent Error st(%d/%d) ev(%d/%d)\n",
- fi->state,fi->fsm->state_count,event,fi->fsm->event_count);
+ printk(KERN_ERR "FsmEvent Error st(%ld/%ld) ev(%d/%ld)\n",
+ (long)fi->state,(long)fi->fsm->state_count,event,(long)fi->fsm->event_count);
return(1);
}
- r = (void (*)) fi->fsm->jumpmatrix[fi->fsm->state_count * event + fi->state];
+ r = fi->fsm->jumpmatrix[fi->fsm->state_count * event + fi->state];
if (r) {
- if (fi->debug) {
- sprintf(str, "State %s Event %s",
+ if (fi->debug)
+ fi->printdebug(fi, "State %s Event %s",
fi->fsm->strState[fi->state],
fi->fsm->strEvent[event]);
- fi->printdebug(fi, str);
- }
r(fi, event, arg);
return (0);
} else {
- if (fi->debug) {
- sprintf(str, "State %s Event %s no routine",
+ if (fi->debug)
+ fi->printdebug(fi, "State %s Event %s no routine",
fi->fsm->strState[fi->state],
fi->fsm->strEvent[event]);
- fi->printdebug(fi, str);
- }
return (!0);
}
}
@@ -96,25 +103,18 @@
void
FsmChangeState(struct FsmInst *fi, int newstate)
{
- char str[80];
-
fi->state = newstate;
- if (fi->debug) {
- sprintf(str, "ChangeState %s",
+ if (fi->debug)
+ fi->printdebug(fi, "ChangeState %s",
fi->fsm->strState[newstate]);
- fi->printdebug(fi, str);
- }
}
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);
- }
+ if (ft->fi->debug)
+ ft->fi->printdebug(ft->fi, "FsmExpireTimer %lx", (long) ft);
#endif
FsmEvent(ft->fi, ft->event, ft->arg);
}
@@ -126,11 +126,8 @@
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);
- }
+ if (ft->fi->debug)
+ ft->fi->printdebug(ft->fi, "FsmInitTimer %lx", (long) ft);
#endif
init_timer(&ft->tl);
}
@@ -139,11 +136,8 @@
FsmDelTimer(struct FsmTimer *ft, int where)
{
#if FSM_TIMER_DEBUG
- if (ft->fi->debug) {
- char str[40];
- sprintf(str, "FsmDelTimer %lx %d", (long) ft, where);
- ft->fi->printdebug(ft->fi, str);
- }
+ if (ft->fi->debug)
+ ft->fi->printdebug(ft->fi, "FsmDelTimer %lx %d", (long) ft, where);
#endif
del_timer(&ft->tl);
}
@@ -154,11 +148,9 @@
{
#if FSM_TIMER_DEBUG
- if (ft->fi->debug) {
- char str[40];
- sprintf(str, "FsmAddTimer %lx %d %d", (long) ft, millisec, where);
- ft->fi->printdebug(ft->fi, str);
- }
+ if (ft->fi->debug)
+ ft->fi->printdebug(ft->fi, "FsmAddTimer %lx %d %d",
+ (long) ft, millisec, where);
#endif
if (ft->tl.next || ft->tl.prev) {
@@ -180,11 +172,9 @@
{
#if FSM_TIMER_DEBUG
- if (ft->fi->debug) {
- char str[40];
- sprintf(str, "FsmRestartTimer %lx %d %d", (long) ft, millisec, where);
- ft->fi->printdebug(ft->fi, str);
- }
+ if (ft->fi->debug)
+ ft->fi->printdebug(ft->fi, "FsmRestartTimer %lx %d %d",
+ (long) ft, millisec, where);
#endif
if (ft->tl.next || ft->tl.prev)
@@ -194,25 +184,4 @@
ft->arg = arg;
ft->tl.expires = jiffies + (millisec * HZ) / 1000;
add_timer(&ft->tl);
-}
-
-void
-jiftime(char *s, long mark)
-{
- s += 8;
-
- *s-- = '\0';
- *s-- = mark % 10 + '0';
- mark /= 10;
- *s-- = mark % 10 + '0';
- mark /= 10;
- *s-- = '.';
- *s-- = mark % 10 + '0';
- mark /= 10;
- *s-- = mark % 6 + '0';
- mark /= 6;
- *s-- = ':';
- *s-- = mark % 10 + '0';
- mark /= 10;
- *s-- = mark % 10 + '0';
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)