drm/i915: Unref old_obj on get_fence_reg() error path
[linux/fpc-iii.git] / net / irda / irsysctl.c
blob57f8817c3979029a38a680d1ea65d948766d2ef9
1 /*********************************************************************
3 * Filename: irsysctl.c
4 * Version: 1.0
5 * Description: Sysctl interface for IrDA
6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Sun May 24 22:12:06 1998
9 * Modified at: Fri Jun 4 02:50:15 1999
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
12 * Copyright (c) 1997, 1999 Dag Brattli, All Rights Reserved.
13 * Copyright (c) 2000-2001 Jean Tourrilhes <jt@hpl.hp.com>
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
20 * Neither Dag Brattli nor University of Tromsø admit liability nor
21 * provide warranty for any of this software. This material is
22 * provided "AS-IS" and at no charge.
24 ********************************************************************/
26 #include <linux/mm.h>
27 #include <linux/ctype.h>
28 #include <linux/sysctl.h>
29 #include <linux/init.h>
31 #include <net/irda/irda.h> /* irda_debug */
32 #include <net/irda/irlmp.h>
33 #include <net/irda/timer.h>
34 #include <net/irda/irias_object.h>
36 extern int sysctl_discovery;
37 extern int sysctl_discovery_slots;
38 extern int sysctl_discovery_timeout;
39 extern int sysctl_slot_timeout;
40 extern int sysctl_fast_poll_increase;
41 extern char sysctl_devname[];
42 extern int sysctl_max_baud_rate;
43 extern int sysctl_min_tx_turn_time;
44 extern int sysctl_max_tx_data_size;
45 extern int sysctl_max_tx_window;
46 extern int sysctl_max_noreply_time;
47 extern int sysctl_warn_noreply_time;
48 extern int sysctl_lap_keepalive_time;
50 extern struct irlmp_cb *irlmp;
52 /* this is needed for the proc_dointvec_minmax - Jean II */
53 static int max_discovery_slots = 16; /* ??? */
54 static int min_discovery_slots = 1;
55 /* IrLAP 6.13.2 says 25ms to 10+70ms - allow higher since some devices
56 * seems to require it. (from Dag's comment) */
57 static int max_slot_timeout = 160;
58 static int min_slot_timeout = 20;
59 static int max_max_baud_rate = 16000000; /* See qos.c - IrLAP spec */
60 static int min_max_baud_rate = 2400;
61 static int max_min_tx_turn_time = 10000; /* See qos.c - IrLAP spec */
62 static int min_min_tx_turn_time;
63 static int max_max_tx_data_size = 2048; /* See qos.c - IrLAP spec */
64 static int min_max_tx_data_size = 64;
65 static int max_max_tx_window = 7; /* See qos.c - IrLAP spec */
66 static int min_max_tx_window = 1;
67 static int max_max_noreply_time = 40; /* See qos.c - IrLAP spec */
68 static int min_max_noreply_time = 3;
69 static int max_warn_noreply_time = 3; /* 3s == standard */
70 static int min_warn_noreply_time = 1; /* 1s == min WD_TIMER */
71 static int max_lap_keepalive_time = 10000; /* 10s */
72 static int min_lap_keepalive_time = 100; /* 100us */
73 /* For other sysctl, I've no idea of the range. Maybe Dag could help
74 * us on that - Jean II */
76 static int do_devname(ctl_table *table, int write, struct file *filp,
77 void __user *buffer, size_t *lenp, loff_t *ppos)
79 int ret;
81 ret = proc_dostring(table, write, filp, buffer, lenp, ppos);
82 if (ret == 0 && write) {
83 struct ias_value *val;
85 val = irias_new_string_value(sysctl_devname);
86 if (val)
87 irias_object_change_attribute("Device", "DeviceName", val);
89 return ret;
93 static int do_discovery(ctl_table *table, int write, struct file *filp,
94 void __user *buffer, size_t *lenp, loff_t *ppos)
96 int ret;
98 ret = proc_dointvec(table, write, filp, buffer, lenp, ppos);
99 if (ret)
100 return ret;
102 if (irlmp == NULL)
103 return -ENODEV;
105 if (sysctl_discovery)
106 irlmp_start_discovery_timer(irlmp, sysctl_discovery_timeout*HZ);
107 else
108 del_timer_sync(&irlmp->discovery_timer);
110 return ret;
113 /* One file */
114 static ctl_table irda_table[] = {
116 .ctl_name = NET_IRDA_DISCOVERY,
117 .procname = "discovery",
118 .data = &sysctl_discovery,
119 .maxlen = sizeof(int),
120 .mode = 0644,
121 .proc_handler = do_discovery,
122 .strategy = sysctl_intvec
125 .ctl_name = NET_IRDA_DEVNAME,
126 .procname = "devname",
127 .data = sysctl_devname,
128 .maxlen = 65,
129 .mode = 0644,
130 .proc_handler = do_devname,
131 .strategy = sysctl_string
133 #ifdef CONFIG_IRDA_DEBUG
135 .ctl_name = NET_IRDA_DEBUG,
136 .procname = "debug",
137 .data = &irda_debug,
138 .maxlen = sizeof(int),
139 .mode = 0644,
140 .proc_handler = proc_dointvec
142 #endif
143 #ifdef CONFIG_IRDA_FAST_RR
145 .ctl_name = NET_IRDA_FAST_POLL,
146 .procname = "fast_poll_increase",
147 .data = &sysctl_fast_poll_increase,
148 .maxlen = sizeof(int),
149 .mode = 0644,
150 .proc_handler = proc_dointvec
152 #endif
154 .ctl_name = NET_IRDA_DISCOVERY_SLOTS,
155 .procname = "discovery_slots",
156 .data = &sysctl_discovery_slots,
157 .maxlen = sizeof(int),
158 .mode = 0644,
159 .proc_handler = proc_dointvec_minmax,
160 .strategy = sysctl_intvec,
161 .extra1 = &min_discovery_slots,
162 .extra2 = &max_discovery_slots
165 .ctl_name = NET_IRDA_DISCOVERY_TIMEOUT,
166 .procname = "discovery_timeout",
167 .data = &sysctl_discovery_timeout,
168 .maxlen = sizeof(int),
169 .mode = 0644,
170 .proc_handler = proc_dointvec
173 .ctl_name = NET_IRDA_SLOT_TIMEOUT,
174 .procname = "slot_timeout",
175 .data = &sysctl_slot_timeout,
176 .maxlen = sizeof(int),
177 .mode = 0644,
178 .proc_handler = proc_dointvec_minmax,
179 .strategy = sysctl_intvec,
180 .extra1 = &min_slot_timeout,
181 .extra2 = &max_slot_timeout
184 .ctl_name = NET_IRDA_MAX_BAUD_RATE,
185 .procname = "max_baud_rate",
186 .data = &sysctl_max_baud_rate,
187 .maxlen = sizeof(int),
188 .mode = 0644,
189 .proc_handler = proc_dointvec_minmax,
190 .strategy = sysctl_intvec,
191 .extra1 = &min_max_baud_rate,
192 .extra2 = &max_max_baud_rate
195 .ctl_name = NET_IRDA_MIN_TX_TURN_TIME,
196 .procname = "min_tx_turn_time",
197 .data = &sysctl_min_tx_turn_time,
198 .maxlen = sizeof(int),
199 .mode = 0644,
200 .proc_handler = proc_dointvec_minmax,
201 .strategy = sysctl_intvec,
202 .extra1 = &min_min_tx_turn_time,
203 .extra2 = &max_min_tx_turn_time
206 .ctl_name = NET_IRDA_MAX_TX_DATA_SIZE,
207 .procname = "max_tx_data_size",
208 .data = &sysctl_max_tx_data_size,
209 .maxlen = sizeof(int),
210 .mode = 0644,
211 .proc_handler = proc_dointvec_minmax,
212 .strategy = sysctl_intvec,
213 .extra1 = &min_max_tx_data_size,
214 .extra2 = &max_max_tx_data_size
217 .ctl_name = NET_IRDA_MAX_TX_WINDOW,
218 .procname = "max_tx_window",
219 .data = &sysctl_max_tx_window,
220 .maxlen = sizeof(int),
221 .mode = 0644,
222 .proc_handler = proc_dointvec_minmax,
223 .strategy = sysctl_intvec,
224 .extra1 = &min_max_tx_window,
225 .extra2 = &max_max_tx_window
228 .ctl_name = NET_IRDA_MAX_NOREPLY_TIME,
229 .procname = "max_noreply_time",
230 .data = &sysctl_max_noreply_time,
231 .maxlen = sizeof(int),
232 .mode = 0644,
233 .proc_handler = proc_dointvec_minmax,
234 .strategy = sysctl_intvec,
235 .extra1 = &min_max_noreply_time,
236 .extra2 = &max_max_noreply_time
239 .ctl_name = NET_IRDA_WARN_NOREPLY_TIME,
240 .procname = "warn_noreply_time",
241 .data = &sysctl_warn_noreply_time,
242 .maxlen = sizeof(int),
243 .mode = 0644,
244 .proc_handler = proc_dointvec_minmax,
245 .strategy = sysctl_intvec,
246 .extra1 = &min_warn_noreply_time,
247 .extra2 = &max_warn_noreply_time
250 .ctl_name = NET_IRDA_LAP_KEEPALIVE_TIME,
251 .procname = "lap_keepalive_time",
252 .data = &sysctl_lap_keepalive_time,
253 .maxlen = sizeof(int),
254 .mode = 0644,
255 .proc_handler = proc_dointvec_minmax,
256 .strategy = sysctl_intvec,
257 .extra1 = &min_lap_keepalive_time,
258 .extra2 = &max_lap_keepalive_time
260 { .ctl_name = 0 }
263 static struct ctl_path irda_path[] = {
264 { .procname = "net", .ctl_name = CTL_NET, },
265 { .procname = "irda", .ctl_name = NET_IRDA, },
269 static struct ctl_table_header *irda_table_header;
272 * Function irda_sysctl_register (void)
274 * Register our sysctl interface
277 int __init irda_sysctl_register(void)
279 irda_table_header = register_sysctl_paths(irda_path, irda_table);
280 if (!irda_table_header)
281 return -ENOMEM;
283 return 0;
287 * Function irda_sysctl_unregister (void)
289 * Unregister our sysctl interface
292 void irda_sysctl_unregister(void)
294 unregister_sysctl_table(irda_table_header);