blob: 23aba6c4d22c77c02e941d3918261882dc51a40a [file] [log] [blame]
Bill Pemberton0b52b742012-09-20 16:55:27 -04001/*
2 *
3 * Copyright 1999 Digi International (www.digi.com)
4 * James Puzzo <jamesp at digi dot com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
13 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 */
17
18#ifndef __DGRP_COMMON_H
19#define __DGRP_COMMON_H
20
21#define DIGI_VERSION "1.9-29"
22
23#include <linux/fs.h>
24#include <linux/timer.h>
25#include "drp.h"
26
27#define DGRP_TTIME 100
28#define DGRP_RTIME 100
29
30/************************************************************************
31 * All global storage allocation.
32 ************************************************************************/
33
Bill Pemberton0b52b742012-09-20 16:55:27 -040034extern int dgrp_register_cudevices; /* enable legacy cu devices */
35extern int dgrp_register_prdevices; /* enable transparent print devices */
36extern int dgrp_poll_tick; /* Poll interval - in ms */
37
38extern struct list_head nd_struct_list;
39
40struct dgrp_poll_data {
41 spinlock_t poll_lock;
42 struct timer_list timer;
43 int poll_tick;
44 ulong poll_round; /* Timer rouding factor */
45 long node_active_count;
46};
47
48extern struct dgrp_poll_data dgrp_poll_data;
49extern void dgrp_poll_handler(unsigned long arg);
50
51/* from dgrp_mon_ops.c */
Al Viroaf064cd2013-03-30 01:03:53 -040052extern const struct file_operations dgrp_mon_ops;
Bill Pemberton0b52b742012-09-20 16:55:27 -040053
54/* from dgrp_tty.c */
55extern int dgrp_tty_init(struct nd_struct *nd);
56extern void dgrp_tty_uninit(struct nd_struct *nd);
57
58/* from dgrp_ports_ops.c */
Al Viroaf064cd2013-03-30 01:03:53 -040059extern const struct file_operations dgrp_ports_ops;
Bill Pemberton0b52b742012-09-20 16:55:27 -040060
61/* from dgrp_net_ops.c */
Al Viroaf064cd2013-03-30 01:03:53 -040062extern const struct file_operations dgrp_net_ops;
Bill Pemberton0b52b742012-09-20 16:55:27 -040063
64/* from dgrp_dpa_ops.c */
Al Viroaf064cd2013-03-30 01:03:53 -040065extern const struct file_operations dgrp_dpa_ops;
Bill Pemberton0b52b742012-09-20 16:55:27 -040066extern void dgrp_dpa_data(struct nd_struct *, int, u8 *, int);
67
68/* from dgrp_sysfs.c */
Alexey Khoroshilov7e1389a2013-04-06 01:14:23 +040069extern int dgrp_create_class_sysfs_files(void);
Bill Pemberton0b52b742012-09-20 16:55:27 -040070extern void dgrp_remove_class_sysfs_files(void);
71
72extern void dgrp_create_node_class_sysfs_files(struct nd_struct *nd);
73extern void dgrp_remove_node_class_sysfs_files(struct nd_struct *nd);
74
75extern void dgrp_create_tty_sysfs(struct un_struct *un, struct device *c);
76extern void dgrp_remove_tty_sysfs(struct device *c);
77
78/* from dgrp_specproc.c */
Bill Pemberton0b52b742012-09-20 16:55:27 -040079extern void dgrp_unregister_proc(void);
80extern void dgrp_register_proc(void);
81
82/*-----------------------------------------------------------------------*
83 *
84 * Declarations for common operations:
85 *
86 * (either used by more than one of net, mon, or tty,
87 * or in interrupt context (i.e. the poller))
88 *
89 *-----------------------------------------------------------------------*/
90
91void dgrp_carrier(struct ch_struct *ch);
Bill Pemberton0b52b742012-09-20 16:55:27 -040092
93
94/*
95 * ID manipulation macros (where c1 & c2 are characters, i is
96 * a long integer, and s is a character array of at least three members
97 */
98
99static inline void ID_TO_CHAR(long i, char *s)
100{
101 s[0] = ((i & 0xff00)>>8);
102 s[1] = (i & 0xff);
103 s[2] = 0;
104}
105
106static inline long CHAR_TO_ID(char *s)
107{
108 return ((s[0] & 0xff) << 8) | (s[1] & 0xff);
109}
110
111static inline struct nd_struct *nd_struct_get(long major)
112{
113 struct nd_struct *nd;
114
115 list_for_each_entry(nd, &nd_struct_list, list) {
116 if (major == nd->nd_major)
117 return nd;
118 }
119
120 return NULL;
121}
122
123static inline int nd_struct_add(struct nd_struct *entry)
124{
125 struct nd_struct *ptr;
126
127 ptr = nd_struct_get(entry->nd_major);
128
129 if (ptr)
130 return -EBUSY;
131
132 list_add_tail(&entry->list, &nd_struct_list);
133
134 return 0;
135}
136
137static inline int nd_struct_del(struct nd_struct *entry)
138{
139 struct nd_struct *nd;
140
141 nd = nd_struct_get(entry->nd_major);
142
143 if (!nd)
144 return -ENODEV;
145
146 list_del(&nd->list);
147 return 0;
148}
149
150#endif /* __DGRP_COMMON_H */