linux/audit.h: move ptrace.h include to kernel header
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / dgrp / dgrp_common.h
blob0583fe9c7b035cd6810635bf6beb7c6e5a47daf1
1 /*
3 * Copyright 1999 Digi International (www.digi.com)
4 * James Puzzo <jamesp at digi dot com>
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.
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.
18 #ifndef __DGRP_COMMON_H
19 #define __DGRP_COMMON_H
21 #define DIGI_VERSION "1.9-29"
23 #include <linux/fs.h>
24 #include <linux/timer.h>
25 #include "drp.h"
27 #define DGRP_TTIME 100
28 #define DGRP_RTIME 100
30 /************************************************************************
31 * All global storage allocation.
32 ************************************************************************/
34 extern int dgrp_register_cudevices; /* enable legacy cu devices */
35 extern int dgrp_register_prdevices; /* enable transparent print devices */
36 extern int dgrp_poll_tick; /* Poll interval - in ms */
38 extern struct list_head nd_struct_list;
40 struct 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;
48 extern struct dgrp_poll_data dgrp_poll_data;
49 extern void dgrp_poll_handler(unsigned long arg);
51 /* from dgrp_mon_ops.c */
52 extern void dgrp_register_mon_hook(struct proc_dir_entry *de);
54 /* from dgrp_tty.c */
55 extern int dgrp_tty_init(struct nd_struct *nd);
56 extern void dgrp_tty_uninit(struct nd_struct *nd);
58 /* from dgrp_ports_ops.c */
59 extern void dgrp_register_ports_hook(struct proc_dir_entry *de);
61 /* from dgrp_net_ops.c */
62 extern void dgrp_register_net_hook(struct proc_dir_entry *de);
64 /* from dgrp_dpa_ops.c */
65 extern void dgrp_register_dpa_hook(struct proc_dir_entry *de);
66 extern void dgrp_dpa_data(struct nd_struct *, int, u8 *, int);
68 /* from dgrp_sysfs.c */
69 extern void dgrp_create_class_sysfs_files(void);
70 extern void dgrp_remove_class_sysfs_files(void);
72 extern void dgrp_create_node_class_sysfs_files(struct nd_struct *nd);
73 extern void dgrp_remove_node_class_sysfs_files(struct nd_struct *nd);
75 extern void dgrp_create_tty_sysfs(struct un_struct *un, struct device *c);
76 extern void dgrp_remove_tty_sysfs(struct device *c);
78 /* from dgrp_specproc.c */
80 * The list of DGRP entries with r/w capabilities. These
81 * magic numbers are used for identification purposes.
83 enum {
84 DGRP_CONFIG = 1, /* Configure portservers */
85 DGRP_NETDIR = 2, /* Directory for "net" devices */
86 DGRP_MONDIR = 3, /* Directory for "mon" devices */
87 DGRP_PORTSDIR = 4, /* Directory for "ports" devices */
88 DGRP_INFO = 5, /* Get info. about the running module */
89 DGRP_NODEINFO = 6, /* Get info. about the configured nodes */
90 DGRP_DPADIR = 7, /* Directory for the "dpa" devices */
94 * Directions for proc handlers
96 enum {
97 INBOUND = 1, /* Data being written to kernel */
98 OUTBOUND = 2, /* Data being read from the kernel */
102 * dgrp_proc_entry: structure for dgrp proc dirs
103 * @id: ID number associated with this particular entry. Should be
104 * unique across all of DGRP.
105 * @name: text name associated with the /proc entry
106 * @mode: file access permisssions for the /proc entry
107 * @child: pointer to table describing a subdirectory for this entry
108 * @de: pointer to directory entry for this object once registered. Used
109 * to grab the handle of the object for unregistration
110 * @excl_sem: semaphore to provide exclusive to struct
111 * @excl_cnt: counter of current accesses
113 * Each entry in a DGRP proc directory is described with a
114 * dgrp_proc_entry structure. A collection of these
115 * entries (in an array) represents the members associated
116 * with a particular /proc directory, and is referred to
117 * as a table. All tables are terminated by an entry with
118 * zeros for every member.
120 struct dgrp_proc_entry {
121 int id; /* Integer identifier */
122 const char *name; /* ASCII identifier */
123 mode_t mode; /* File access permissions */
124 struct dgrp_proc_entry *child; /* Child pointer */
126 /* file ops to use, pass NULL to use default */
127 struct file_operations *proc_file_ops;
129 struct proc_dir_entry *de; /* proc entry pointer */
130 struct semaphore excl_sem; /* Protects exclusive access var */
131 int excl_cnt; /* Counts number of curr accesses */
134 extern void dgrp_unregister_proc(void);
135 extern void dgrp_register_proc(void);
137 /*-----------------------------------------------------------------------*
139 * Declarations for common operations:
141 * (either used by more than one of net, mon, or tty,
142 * or in interrupt context (i.e. the poller))
144 *-----------------------------------------------------------------------*/
146 void dgrp_carrier(struct ch_struct *ch);
147 extern int dgrp_inode_permission(struct inode *inode, int op);
148 extern int dgrp_chk_perm(int mode, int op);
152 * ID manipulation macros (where c1 & c2 are characters, i is
153 * a long integer, and s is a character array of at least three members
156 static inline void ID_TO_CHAR(long i, char *s)
158 s[0] = ((i & 0xff00)>>8);
159 s[1] = (i & 0xff);
160 s[2] = 0;
163 static inline long CHAR_TO_ID(char *s)
165 return ((s[0] & 0xff) << 8) | (s[1] & 0xff);
168 static inline struct nd_struct *nd_struct_get(long major)
170 struct nd_struct *nd;
172 list_for_each_entry(nd, &nd_struct_list, list) {
173 if (major == nd->nd_major)
174 return nd;
177 return NULL;
180 static inline int nd_struct_add(struct nd_struct *entry)
182 struct nd_struct *ptr;
184 ptr = nd_struct_get(entry->nd_major);
186 if (ptr)
187 return -EBUSY;
189 list_add_tail(&entry->list, &nd_struct_list);
191 return 0;
194 static inline int nd_struct_del(struct nd_struct *entry)
196 struct nd_struct *nd;
198 nd = nd_struct_get(entry->nd_major);
200 if (!nd)
201 return -ENODEV;
203 list_del(&nd->list);
204 return 0;
207 #endif /* __DGRP_COMMON_H */