Bill Pemberton | 0b52b74 | 2012-09-20 16:55:27 -0400 | [diff] [blame] | 1 | /* |
| 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 Pemberton | 0b52b74 | 2012-09-20 16:55:27 -0400 | [diff] [blame] | 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 */ |
| 37 | |
| 38 | extern struct list_head nd_struct_list; |
| 39 | |
| 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; |
| 46 | }; |
| 47 | |
| 48 | extern struct dgrp_poll_data dgrp_poll_data; |
| 49 | extern void dgrp_poll_handler(unsigned long arg); |
| 50 | |
| 51 | /* from dgrp_mon_ops.c */ |
Al Viro | af064cd | 2013-03-30 01:03:53 -0400 | [diff] [blame] | 52 | extern const struct file_operations dgrp_mon_ops; |
Bill Pemberton | 0b52b74 | 2012-09-20 16:55:27 -0400 | [diff] [blame] | 53 | |
| 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); |
| 57 | |
| 58 | /* from dgrp_ports_ops.c */ |
Al Viro | af064cd | 2013-03-30 01:03:53 -0400 | [diff] [blame] | 59 | extern const struct file_operations dgrp_ports_ops; |
Bill Pemberton | 0b52b74 | 2012-09-20 16:55:27 -0400 | [diff] [blame] | 60 | |
| 61 | /* from dgrp_net_ops.c */ |
Al Viro | af064cd | 2013-03-30 01:03:53 -0400 | [diff] [blame] | 62 | extern const struct file_operations dgrp_net_ops; |
Bill Pemberton | 0b52b74 | 2012-09-20 16:55:27 -0400 | [diff] [blame] | 63 | |
| 64 | /* from dgrp_dpa_ops.c */ |
Al Viro | af064cd | 2013-03-30 01:03:53 -0400 | [diff] [blame] | 65 | extern const struct file_operations dgrp_dpa_ops; |
Bill Pemberton | 0b52b74 | 2012-09-20 16:55:27 -0400 | [diff] [blame] | 66 | extern void dgrp_dpa_data(struct nd_struct *, int, u8 *, int); |
| 67 | |
| 68 | /* from dgrp_sysfs.c */ |
Alexey Khoroshilov | 7e1389a | 2013-04-06 01:14:23 +0400 | [diff] [blame] | 69 | extern int dgrp_create_class_sysfs_files(void); |
Bill Pemberton | 0b52b74 | 2012-09-20 16:55:27 -0400 | [diff] [blame] | 70 | extern void dgrp_remove_class_sysfs_files(void); |
| 71 | |
| 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); |
| 74 | |
| 75 | extern void dgrp_create_tty_sysfs(struct un_struct *un, struct device *c); |
| 76 | extern void dgrp_remove_tty_sysfs(struct device *c); |
| 77 | |
| 78 | /* from dgrp_specproc.c */ |
Bill Pemberton | 0b52b74 | 2012-09-20 16:55:27 -0400 | [diff] [blame] | 79 | extern void dgrp_unregister_proc(void); |
| 80 | extern 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 | |
| 91 | void dgrp_carrier(struct ch_struct *ch); |
Bill Pemberton | 0b52b74 | 2012-09-20 16:55:27 -0400 | [diff] [blame] | 92 | |
| 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 | |
| 99 | static 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 | |
| 106 | static inline long CHAR_TO_ID(char *s) |
| 107 | { |
| 108 | return ((s[0] & 0xff) << 8) | (s[1] & 0xff); |
| 109 | } |
| 110 | |
| 111 | static 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 | |
| 123 | static 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 | |
| 137 | static 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 */ |