brute-forced more changes from MontaVista's tree. SCSI partition table read still...
[linux-2.4.git] / drivers / s390 / char / tubttyscl.c
1 /*
2  *  IBM/3270 Driver -- Copyright (C) 2000, 2001 UTS Global LLC
3  *
4  *  tubttyscl.c -- Linemode tty driver scroll-timing functions
5  *
6  *
7  *
8  *
9  *
10  *  Author:  Richard Hitt
11  */
12 #include "tubio.h"
13        void tty3270_scl_settimer(tub_t *);
14        void tty3270_scl_resettimer(tub_t *);
15 static void tty3270_scl_timeout(unsigned long);
16
17 void
18 tty3270_scl_settimer(tub_t *tubp)
19 {
20         struct timer_list *tp = &tubp->tty_stimer;
21
22         if (tubp->flags & TUB_SCROLLTIMING)
23                 return;
24         if (tubp->tty_scrolltime == 0)
25                 return;
26
27         init_timer(tp);
28         tp->expires = jiffies + HZ * tubp->tty_scrolltime;
29         tp->data = (unsigned long)tubp;
30         tp->function = tty3270_scl_timeout;
31         add_timer(tp);
32         tubp->flags |= TUB_SCROLLTIMING;
33 }
34
35 void
36 tty3270_scl_resettimer(tub_t *tubp)
37 {
38         struct timer_list *tp = &tubp->tty_stimer;
39
40         if ((tubp->flags & TUB_SCROLLTIMING) == 0)
41                 return;
42
43         del_timer(tp);
44         tubp->flags &= ~TUB_SCROLLTIMING;
45 }
46
47 static void
48 tty3270_scl_timeout(unsigned long data)
49 {
50         tub_t *tubp = (void *)data;
51         long flags;
52
53         TUBLOCK(tubp->irq, flags);
54         tubp->stat = TBS_RUNNING;
55         tty3270_scl_resettimer(tubp);
56         tubp->cmd = TBC_CLRUPDLOG;
57         tty3270_build(tubp);
58         TUBUNLOCK(tubp->irq, flags);
59 }
60
61 int
62 tty3270_scl_set(tub_t *tubp, char *buf, int count)
63 {
64         if (strncmp(buf, "scrolltime=", 11) == 0) {
65                 tubp->tty_scrolltime =
66                         simple_strtoul(buf + 11, 0, 0);
67                 return count;
68         }
69         return 0;
70 }
71
72 int
73 tty3270_scl_init(tub_t *tubp)
74 {
75         extern int tubscrolltime;
76
77         tubp->tty_scrolltime = tubscrolltime;
78         if (tubp->tty_scrolltime < 0)
79                 tubp->tty_scrolltime = DEFAULT_SCROLLTIME;
80         return 0;
81 }
82
83 void
84 tty3270_scl_fini(tub_t *tubp)
85 {
86         if ((tubp->flags & TUB_OPEN_STET) == 0)
87                 tty3270_scl_resettimer(tubp);
88 }