[kernel] fix ipset compile error on 2.6.27
[openwrt.git] / package / broadcom-diag / src / diag.h
1 /*
2 * diag.h - GPIO interface driver for Broadcom boards
3 *
4 * Copyright (C) 2006 Mike Baker <mbm@openwrt.org>,
5 * Felix Fietkau <nbd@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 * $Id:$
22 */
23
24 #include <linux/irq.h>
25 #define MODULE_NAME "diag"
26
27 #define MAX_GPIO 16
28 #define FLASH_TIME HZ/6
29
30 enum polarity_t {
31 REVERSE = 0,
32 NORMAL = 1,
33 INPUT = 2,
34 };
35
36 enum {
37 PROC_BUTTON,
38 PROC_LED,
39 PROC_MODEL,
40 PROC_GPIOMASK
41 };
42
43 struct prochandler_t {
44 int type;
45 void *ptr;
46 };
47
48 struct button_t {
49 struct prochandler_t proc;
50 char *name;
51 u32 gpio;
52 unsigned long seen;
53 u8 pressed;
54 };
55
56 struct led_t {
57 struct prochandler_t proc;
58 char *name;
59 u32 gpio;
60 u8 polarity;
61 u8 flash;
62 u8 state;
63 };
64
65 struct platform_t {
66 char *name;
67
68 struct button_t buttons[MAX_GPIO];
69 u32 button_mask;
70 u32 button_polarity;
71 void (*platform_init)(void);
72
73 struct led_t leds[MAX_GPIO];
74 };
75
76 struct event_t {
77 struct work_struct wq;
78 unsigned long seen;
79 char *name, *action;
80 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
81 struct sk_buff *skb;
82 #else
83 char *scratch;
84 char *argv[4];
85 char *envp[7];
86 u8 enr, anr;
87 #endif
88 };
89
90 extern char *nvram_get(char *str);
91
92 static struct platform_t platform;
93
94 /* buttons */
95
96 static void register_buttons(struct button_t *b);
97 static void unregister_buttons(struct button_t *b);
98
99 #ifndef LINUX_2_4
100 static void hotplug_button(struct work_struct *work);
101 static irqreturn_t button_handler(int irq, void *dev_id);
102 #else
103 static void hotplug_button(struct event_t *event);
104 static irqreturn_t button_handler(int irq, void *dev_id, struct pt_regs *regs);
105 #endif
106
107 /* leds */
108
109 static void register_leds(struct led_t *l);
110 static void unregister_leds(struct led_t *l);
111
112 static void set_led_extif(struct led_t *led);
113 static void led_flash(unsigned long dummy);
114
115 /* 2.4 compatibility */
116 #ifndef TIMER_INITIALIZER
117 #define TIMER_INITIALIZER(_function, _expires, _data) \
118 { \
119 /* _expires and _data currently unused */ \
120 function: _function \
121 }
122 #endif
123
124 static struct timer_list led_timer = TIMER_INITIALIZER(&led_flash, 0, 0);
125
126 /* proc */
127
128 static struct proc_dir_entry *diag, *leds;
129
130 static ssize_t diag_proc_read(struct file *file, char *buf, size_t count, loff_t *ppos);
131 static ssize_t diag_proc_write(struct file *file, const char *buf, size_t count, loff_t *ppos);
132
133 static struct file_operations diag_proc_fops = {
134 read: diag_proc_read,
135 write: diag_proc_write
136 };
137
138 static struct prochandler_t proc_model = { .type = PROC_MODEL };
139 static struct prochandler_t proc_gpiomask = { .type = PROC_GPIOMASK };
140
This page took 0.052491 seconds and 5 git commands to generate.