19670e29d5706e918d4f9a23077b4670c9a1a5d2
[firefly-linux-kernel-4.4.55.git] / drivers / staging / dgnc / dgnc_proc.h
1 /*
2  * Copyright 2003 Digi International (www.digi.com)
3  *      Scott H Kilau <Scott_Kilau at digi dot com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
12  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13  * PURPOSE.  See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  *      NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
20  *
21  *
22  *     $Id: dgnc_proc.h,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $
23  *
24  *  Description:
25  *
26  *     Describes the private structures used to manipulate the "special"
27  *     proc constructs (not read-only) used by the Digi Neo software.
28  *     The concept is borrowed heavily from the "sysctl" interface of
29  *     the kernel.  I decided not to use the structures and functions
30  *     provided by the kernel for two reasons:
31  *
32  *       1. Due to the planned use of "/proc" in the Neo driver, many
33  *          of the functions of the "sysctl" interface would go unused.
34  *          A simpler interface will be easier to maintain.
35  *
36  *       2. I'd rather divorce our "added package" from the kernel internals.
37  *          If the "sysctl" structures should change, I will be insulated
38  *          from those changes.  These "/proc" entries won't be under the
39  *          "sys" tree anyway, so there is no need to maintain a strict
40  *          dependence relationship.
41  *
42  *  Author:
43  *
44  *     Scott H Kilau
45  *
46  */
47
48 #ifndef _DGNC_RW_PROC_H
49 #define _DGNC_RW_PROC_H
50
51 /*
52  *  The list of DGNC entries with r/w capabilities. 
53  *  These magic numbers are used for identification purposes.
54  */
55 enum {
56         DGNC_INFO = 1,                  /* Get info about the running module    */
57         DGNC_MKNOD = 2,                 /* Get info about driver devices        */
58         DGNC_BOARD_INFO = 3,            /* Get info about the specific board    */
59         DGNC_BOARD_VPD = 4,             /* Get info about the board's VPD       */
60         DGNC_BOARD_TTYSTATS = 5,        /* Get info about the board's tty stats */
61         DGNC_BOARD_TTYINTR = 6,         /* Get info about the board's tty intrs */
62         DGNC_BOARD_TTYFLAGS = 7,        /* Get info about the board's tty flags */
63         DGNC_BOARD_MKNOD = 8,           /* Get info about board devices         */
64         DGNC_PORT_INFO = 9,             /* Get info about the specific port     */
65         DGNC_PORT_SNIFF = 10,           /* Sniff data in/out of specific port   */
66         DGNC_PORT_CUSTOM_TTYNAME = 11,  /* Get info about UDEV tty name         */
67         DGNC_PORT_CUSTOM_PRNAME = 12,   /* Get info about UDEV pr name          */
68 };
69
70 /*
71  *  Directions for proc handlers
72  */
73 enum {
74         INBOUND = 1,            /* Data being written to kernel */
75         OUTBOUND = 2,           /* Data being read from the kernel */
76 };
77
78 /*
79  *  Each entry in a DGNC proc directory is described with a
80  *  "dgnc_proc_entry" structure.  A collection of these
81  *  entries (in an array) represents the members associated
82  *  with a particular "/proc" directory, and is referred to
83  *  as a table.  All "tables" are terminated by an entry with
84  *  zeros for every member.
85  *
86  *  The structure members are as follows:
87  *
88  *    int magic              -- ID number associated with this particular
89  *                              entry.  Should be unique across all of
90  *                              DGNC.
91  *
92  *    const char *name       -- ASCII name associated with the /proc entry.
93  *
94  *    mode_t mode            -- File access permisssions for the /proc entry.
95  *
96  *    dgnc_proc_entry *child -- When set, this entry refers to a directory,
97  *                              and points to the table which describes the
98  *                              entries in the subdirectory
99  *
100  *    dgnc_proc_handler *open_handler -- When set, points to the fxn which
101  *                                       does any "extra" open stuff.
102  *
103  *    dgnc_proc_handler *close_handler -- When set, points to the fxn which
104  *                                        does any "extra" close stuff.
105  *
106  *    dgnc_proc_handler *read_handler -- When set, points to the fxn which
107  *                                       handle outbound data flow
108  *
109  *    dgnc_proc_handler *write_handler -- When set, points to the fxn which
110  *                                        handles inbound data flow
111  *
112  *    struct proc_dir_entry *de -- Pointer to the directory entry for this
113  *                                 object once registered.  Used to grab
114  *                                 the handle of the object for
115  *                                 unregistration
116  *
117  *    void *data;                  When set, points to the parent structure
118  *
119  */
120
121 struct dgnc_proc_entry {
122         int             magic;          /* Integer identifier   */
123         const char      *name;          /* ASCII identifier     */
124         mode_t          mode;           /* File access permissions */
125         struct dgnc_proc_entry *child;  /* Child pointer        */
126
127         int (*open_handler) (struct dgnc_proc_entry *table, int dir, struct file *filp,   
128                 void *buffer, ssize_t *lenp, loff_t *ppos); 
129         int (*close_handler) (struct dgnc_proc_entry *table, int dir, struct file *filp,   
130                 void *buffer, ssize_t *lenp, loff_t *ppos); 
131         int (*read_handler) (struct dgnc_proc_entry *table, int dir, struct file *filp,   
132                 char __user *buffer, ssize_t *lenp, loff_t *ppos); 
133         int (*write_handler) (struct dgnc_proc_entry *table, int dir, struct file *filp,   
134                 const char __user *buffer, ssize_t *lenp, loff_t *ppos); 
135
136         struct proc_dir_entry *de;      /* proc entry pointer   */
137         struct semaphore excl_sem;      /* Protects exclusive access var        */
138         int             excl_cnt;       /* Counts number of curr accesses       */
139         void            *data;          /* Allows storing a pointer to parent   */
140 };
141
142 void dgnc_proc_register_basic_prescan(void);
143 void dgnc_proc_register_basic_postscan(int board_num);
144 void dgnc_proc_unregister_all(void);
145
146
147 #endif /* _DGNC_RW_PROC_H */