1#include <linux/tty.h>
2#include <linux/sched.h>
3#include "dgnc_utils.h"
4#include "digi.h"
5
6/*
7 * dgnc_ms_sleep()
8 *
9 * Put the driver to sleep for x ms's
10 *
11 * Returns 0 if timed out, !0 (showing signal) if interrupted by a signal.
12 */
13int dgnc_ms_sleep(ulong ms)
14{
15	current->state = TASK_INTERRUPTIBLE;
16	schedule_timeout((ms * HZ) / 1000);
17	return signal_pending(current);
18}
19
20/*
21 *      dgnc_ioctl_name() : Returns a text version of each ioctl value.
22 */
23char *dgnc_ioctl_name(int cmd)
24{
25	switch (cmd) {
26
27	case TCGETA:		return "TCGETA";
28	case TCGETS:		return "TCGETS";
29	case TCSETA:		return "TCSETA";
30	case TCSETS:		return "TCSETS";
31	case TCSETAW:		return "TCSETAW";
32	case TCSETSW:		return "TCSETSW";
33	case TCSETAF:		return "TCSETAF";
34	case TCSETSF:		return "TCSETSF";
35	case TCSBRK:		return "TCSBRK";
36	case TCXONC:		return "TCXONC";
37	case TCFLSH:		return "TCFLSH";
38	case TIOCGSID:		return "TIOCGSID";
39
40	case TIOCGETD:		return "TIOCGETD";
41	case TIOCSETD:		return "TIOCSETD";
42	case TIOCGWINSZ:	return "TIOCGWINSZ";
43	case TIOCSWINSZ:	return "TIOCSWINSZ";
44
45	case TIOCMGET:		return "TIOCMGET";
46	case TIOCMSET:		return "TIOCMSET";
47	case TIOCMBIS:		return "TIOCMBIS";
48	case TIOCMBIC:		return "TIOCMBIC";
49
50	/* from digi.h */
51	case DIGI_SETA:		return "DIGI_SETA";
52	case DIGI_SETAW:	return "DIGI_SETAW";
53	case DIGI_SETAF:	return "DIGI_SETAF";
54	case DIGI_SETFLOW:	return "DIGI_SETFLOW";
55	case DIGI_SETAFLOW:	return "DIGI_SETAFLOW";
56	case DIGI_GETFLOW:	return "DIGI_GETFLOW";
57	case DIGI_GETAFLOW:	return "DIGI_GETAFLOW";
58	case DIGI_GETA:		return "DIGI_GETA";
59	case DIGI_GEDELAY:	return "DIGI_GEDELAY";
60	case DIGI_SEDELAY:	return "DIGI_SEDELAY";
61	case DIGI_GETCUSTOMBAUD: return "DIGI_GETCUSTOMBAUD";
62	case DIGI_SETCUSTOMBAUD: return "DIGI_SETCUSTOMBAUD";
63	case TIOCMODG:		return "TIOCMODG";
64	case TIOCMODS:		return "TIOCMODS";
65	case TIOCSDTR:		return "TIOCSDTR";
66	case TIOCCDTR:		return "TIOCCDTR";
67
68	default:		return "unknown";
69	}
70}
71