aboutsummaryrefslogtreecommitdiffstats
path: root/net/irda
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /net/irda
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'net/irda')
-rw-r--r--net/irda/af_irda.c8
-rw-r--r--net/irda/discovery.c1
-rw-r--r--net/irda/ircomm/ircomm_param.c5
-rw-r--r--net/irda/ircomm/ircomm_tty.c328
-rw-r--r--net/irda/ircomm/ircomm_tty_attach.c40
-rw-r--r--net/irda/ircomm/ircomm_tty_ioctl.c35
-rw-r--r--net/irda/irda_device.c1
-rw-r--r--net/irda/irlan/irlan_client.c1
-rw-r--r--net/irda/irlan/irlan_common.c3
-rw-r--r--net/irda/irlan/irlan_eth.c2
-rw-r--r--net/irda/irlan/irlan_provider.c3
-rw-r--r--net/irda/irnet/irnet.h2
-rw-r--r--net/irda/irnetlink.c2
-rw-r--r--net/irda/irqueue.c6
-rw-r--r--net/irda/irsysctl.c10
-rw-r--r--net/irda/irttp.c8
-rw-r--r--net/irda/qos.c2
-rw-r--r--net/irda/timer.c1
18 files changed, 232 insertions, 226 deletions
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index b833677d83d..c24f25ab67d 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -468,7 +468,7 @@ static int irda_open_tsap(struct irda_sock *self, __u8 tsap_sel, char *name)
468 notify_t notify; 468 notify_t notify;
469 469
470 if (self->tsap) { 470 if (self->tsap) {
471 IRDA_DEBUG(0, "%s: busy!\n", __func__); 471 IRDA_WARNING("%s: busy!\n", __func__);
472 return -EBUSY; 472 return -EBUSY;
473 } 473 }
474 474
@@ -955,7 +955,7 @@ out:
955 * The main difference with a "standard" connect is that with IrDA we need 955 * The main difference with a "standard" connect is that with IrDA we need
956 * to resolve the service name into a TSAP selector (in TCP, port number 956 * to resolve the service name into a TSAP selector (in TCP, port number
957 * doesn't have to be resolved). 957 * doesn't have to be resolved).
958 * Because of this service name resolution, we can offer "auto-connect", 958 * Because of this service name resoltion, we can offer "auto-connect",
959 * where we connect to a service without specifying a destination address. 959 * where we connect to a service without specifying a destination address.
960 * 960 *
961 * Note : by consulting "errno", the user space caller may learn the cause 961 * Note : by consulting "errno", the user space caller may learn the cause
@@ -2558,8 +2558,8 @@ bed:
2558 self->errno = 0; 2558 self->errno = 0;
2559 setup_timer(&self->watchdog, irda_discovery_timeout, 2559 setup_timer(&self->watchdog, irda_discovery_timeout,
2560 (unsigned long)self); 2560 (unsigned long)self);
2561 mod_timer(&self->watchdog, 2561 self->watchdog.expires = jiffies + (val * HZ/1000);
2562 jiffies + msecs_to_jiffies(val)); 2562 add_timer(&(self->watchdog));
2563 2563
2564 /* Wait for IR-LMP to call us back */ 2564 /* Wait for IR-LMP to call us back */
2565 __wait_event_interruptible(self->query_wait, 2565 __wait_event_interruptible(self->query_wait,
diff --git a/net/irda/discovery.c b/net/irda/discovery.c
index b0b56a339a8..36c3f037f17 100644
--- a/net/irda/discovery.c
+++ b/net/irda/discovery.c
@@ -35,7 +35,6 @@
35#include <linux/fs.h> 35#include <linux/fs.h>
36#include <linux/seq_file.h> 36#include <linux/seq_file.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/export.h>
39 38
40#include <net/irda/irda.h> 39#include <net/irda/irda.h>
41#include <net/irda/irlmp.h> 40#include <net/irda/irlmp.h>
diff --git a/net/irda/ircomm/ircomm_param.c b/net/irda/ircomm/ircomm_param.c
index 30893912835..8b915f3ac3b 100644
--- a/net/irda/ircomm/ircomm_param.c
+++ b/net/irda/ircomm/ircomm_param.c
@@ -99,6 +99,7 @@ pi_param_info_t ircomm_param_info = { pi_major_call_table, 3, 0x0f, 4 };
99 */ 99 */
100int ircomm_param_request(struct ircomm_tty_cb *self, __u8 pi, int flush) 100int ircomm_param_request(struct ircomm_tty_cb *self, __u8 pi, int flush)
101{ 101{
102 struct tty_struct *tty;
102 unsigned long flags; 103 unsigned long flags;
103 struct sk_buff *skb; 104 struct sk_buff *skb;
104 int count; 105 int count;
@@ -108,6 +109,10 @@ int ircomm_param_request(struct ircomm_tty_cb *self, __u8 pi, int flush)
108 IRDA_ASSERT(self != NULL, return -1;); 109 IRDA_ASSERT(self != NULL, return -1;);
109 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); 110 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
110 111
112 tty = self->tty;
113 if (!tty)
114 return 0;
115
111 /* Make sure we don't send parameters for raw mode */ 116 /* Make sure we don't send parameters for raw mode */
112 if (self->service_type == IRCOMM_3_WIRE_RAW) 117 if (self->service_type == IRCOMM_3_WIRE_RAW)
113 return 0; 118 return 0;
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index a68c88cdec6..b3cc8b3989a 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -52,8 +52,6 @@
52#include <net/irda/ircomm_tty_attach.h> 52#include <net/irda/ircomm_tty_attach.h>
53#include <net/irda/ircomm_tty.h> 53#include <net/irda/ircomm_tty.h>
54 54
55static int ircomm_tty_install(struct tty_driver *driver,
56 struct tty_struct *tty);
57static int ircomm_tty_open(struct tty_struct *tty, struct file *filp); 55static int ircomm_tty_open(struct tty_struct *tty, struct file *filp);
58static void ircomm_tty_close(struct tty_struct * tty, struct file *filp); 56static void ircomm_tty_close(struct tty_struct * tty, struct file *filp);
59static int ircomm_tty_write(struct tty_struct * tty, 57static int ircomm_tty_write(struct tty_struct * tty,
@@ -84,7 +82,6 @@ static struct tty_driver *driver;
84static hashbin_t *ircomm_tty = NULL; 82static hashbin_t *ircomm_tty = NULL;
85 83
86static const struct tty_operations ops = { 84static const struct tty_operations ops = {
87 .install = ircomm_tty_install,
88 .open = ircomm_tty_open, 85 .open = ircomm_tty_open,
89 .close = ircomm_tty_close, 86 .close = ircomm_tty_close,
90 .write = ircomm_tty_write, 87 .write = ircomm_tty_write,
@@ -107,35 +104,6 @@ static const struct tty_operations ops = {
107#endif /* CONFIG_PROC_FS */ 104#endif /* CONFIG_PROC_FS */
108}; 105};
109 106
110static void ircomm_port_raise_dtr_rts(struct tty_port *port, int raise)
111{
112 struct ircomm_tty_cb *self = container_of(port, struct ircomm_tty_cb,
113 port);
114 /*
115 * Here, we use to lock those two guys, but as ircomm_param_request()
116 * does it itself, I don't see the point (and I see the deadlock).
117 * Jean II
118 */
119 if (raise)
120 self->settings.dte |= IRCOMM_RTS | IRCOMM_DTR;
121 else
122 self->settings.dte &= ~(IRCOMM_RTS | IRCOMM_DTR);
123
124 ircomm_param_request(self, IRCOMM_DTE, TRUE);
125}
126
127static int ircomm_port_carrier_raised(struct tty_port *port)
128{
129 struct ircomm_tty_cb *self = container_of(port, struct ircomm_tty_cb,
130 port);
131 return self->settings.dce & IRCOMM_CD;
132}
133
134static const struct tty_port_operations ircomm_port_ops = {
135 .dtr_rts = ircomm_port_raise_dtr_rts,
136 .carrier_raised = ircomm_port_carrier_raised,
137};
138
139/* 107/*
140 * Function ircomm_tty_init() 108 * Function ircomm_tty_init()
141 * 109 *
@@ -154,6 +122,7 @@ static int __init ircomm_tty_init(void)
154 return -ENOMEM; 122 return -ENOMEM;
155 } 123 }
156 124
125 driver->owner = THIS_MODULE;
157 driver->driver_name = "ircomm"; 126 driver->driver_name = "ircomm";
158 driver->name = "ircomm"; 127 driver->name = "ircomm";
159 driver->major = IRCOMM_TTY_MAJOR; 128 driver->major = IRCOMM_TTY_MAJOR;
@@ -183,7 +152,6 @@ static void __exit __ircomm_tty_cleanup(struct ircomm_tty_cb *self)
183 ircomm_tty_shutdown(self); 152 ircomm_tty_shutdown(self);
184 153
185 self->magic = 0; 154 self->magic = 0;
186 tty_port_destroy(&self->port);
187 kfree(self); 155 kfree(self);
188} 156}
189 157
@@ -227,7 +195,7 @@ static int ircomm_tty_startup(struct ircomm_tty_cb *self)
227 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); 195 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
228 196
229 /* Check if already open */ 197 /* Check if already open */
230 if (test_and_set_bit(ASYNCB_INITIALIZED, &self->port.flags)) { 198 if (test_and_set_bit(ASYNC_B_INITIALIZED, &self->flags)) {
231 IRDA_DEBUG(2, "%s(), already open so break out!\n", __func__ ); 199 IRDA_DEBUG(2, "%s(), already open so break out!\n", __func__ );
232 return 0; 200 return 0;
233 } 201 }
@@ -264,7 +232,7 @@ static int ircomm_tty_startup(struct ircomm_tty_cb *self)
264 232
265 return 0; 233 return 0;
266err: 234err:
267 clear_bit(ASYNCB_INITIALIZED, &self->port.flags); 235 clear_bit(ASYNC_B_INITIALIZED, &self->flags);
268 return ret; 236 return ret;
269} 237}
270 238
@@ -275,62 +243,72 @@ err:
275 * 243 *
276 */ 244 */
277static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, 245static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
278 struct tty_struct *tty, struct file *filp) 246 struct file *filp)
279{ 247{
280 struct tty_port *port = &self->port;
281 DECLARE_WAITQUEUE(wait, current); 248 DECLARE_WAITQUEUE(wait, current);
282 int retval; 249 int retval;
283 int do_clocal = 0, extra_count = 0; 250 int do_clocal = 0, extra_count = 0;
284 unsigned long flags; 251 unsigned long flags;
252 struct tty_struct *tty;
285 253
286 IRDA_DEBUG(2, "%s()\n", __func__ ); 254 IRDA_DEBUG(2, "%s()\n", __func__ );
287 255
256 tty = self->tty;
257
288 /* 258 /*
289 * If non-blocking mode is set, or the port is not enabled, 259 * If non-blocking mode is set, or the port is not enabled,
290 * then make the check up front and then exit. 260 * then make the check up front and then exit.
291 */ 261 */
292 if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ 262 if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){
293 /* nonblock mode is set or port is not enabled */ 263 /* nonblock mode is set or port is not enabled */
294 port->flags |= ASYNC_NORMAL_ACTIVE; 264 self->flags |= ASYNC_NORMAL_ACTIVE;
295 IRDA_DEBUG(1, "%s(), O_NONBLOCK requested!\n", __func__ ); 265 IRDA_DEBUG(1, "%s(), O_NONBLOCK requested!\n", __func__ );
296 return 0; 266 return 0;
297 } 267 }
298 268
299 if (tty->termios.c_cflag & CLOCAL) { 269 if (tty->termios->c_cflag & CLOCAL) {
300 IRDA_DEBUG(1, "%s(), doing CLOCAL!\n", __func__ ); 270 IRDA_DEBUG(1, "%s(), doing CLOCAL!\n", __func__ );
301 do_clocal = 1; 271 do_clocal = 1;
302 } 272 }
303 273
304 /* Wait for carrier detect and the line to become 274 /* Wait for carrier detect and the line to become
305 * free (i.e., not in use by the callout). While we are in 275 * free (i.e., not in use by the callout). While we are in
306 * this loop, port->count is dropped by one, so that 276 * this loop, self->open_count is dropped by one, so that
307 * mgsl_close() knows when to free things. We restore it upon 277 * mgsl_close() knows when to free things. We restore it upon
308 * exit, either normal or abnormal. 278 * exit, either normal or abnormal.
309 */ 279 */
310 280
311 retval = 0; 281 retval = 0;
312 add_wait_queue(&port->open_wait, &wait); 282 add_wait_queue(&self->open_wait, &wait);
313 283
314 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n", 284 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
315 __FILE__, __LINE__, tty->driver->name, port->count); 285 __FILE__,__LINE__, tty->driver->name, self->open_count );
316 286
317 spin_lock_irqsave(&port->lock, flags); 287 /* As far as I can see, we protect open_count - Jean II */
288 spin_lock_irqsave(&self->spinlock, flags);
318 if (!tty_hung_up_p(filp)) { 289 if (!tty_hung_up_p(filp)) {
319 extra_count = 1; 290 extra_count = 1;
320 port->count--; 291 self->open_count--;
321 } 292 }
322 spin_unlock_irqrestore(&port->lock, flags); 293 spin_unlock_irqrestore(&self->spinlock, flags);
323 port->blocked_open++; 294 self->blocked_open++;
324 295
325 while (1) { 296 while (1) {
326 if (tty->termios.c_cflag & CBAUD) 297 if (tty->termios->c_cflag & CBAUD) {
327 tty_port_raise_dtr_rts(port); 298 /* Here, we use to lock those two guys, but
299 * as ircomm_param_request() does it itself,
300 * I don't see the point (and I see the deadlock).
301 * Jean II */
302 self->settings.dte |= IRCOMM_RTS + IRCOMM_DTR;
303
304 ircomm_param_request(self, IRCOMM_DTE, TRUE);
305 }
328 306
329 current->state = TASK_INTERRUPTIBLE; 307 current->state = TASK_INTERRUPTIBLE;
330 308
331 if (tty_hung_up_p(filp) || 309 if (tty_hung_up_p(filp) ||
332 !test_bit(ASYNCB_INITIALIZED, &port->flags)) { 310 !test_bit(ASYNC_B_INITIALIZED, &self->flags)) {
333 retval = (port->flags & ASYNC_HUP_NOTIFY) ? 311 retval = (self->flags & ASYNC_HUP_NOTIFY) ?
334 -EAGAIN : -ERESTARTSYS; 312 -EAGAIN : -ERESTARTSYS;
335 break; 313 break;
336 } 314 }
@@ -340,8 +318,8 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
340 * specified, we cannot return before the IrCOMM link is 318 * specified, we cannot return before the IrCOMM link is
341 * ready 319 * ready
342 */ 320 */
343 if (!test_bit(ASYNCB_CLOSING, &port->flags) && 321 if (!test_bit(ASYNC_B_CLOSING, &self->flags) &&
344 (do_clocal || tty_port_carrier_raised(port)) && 322 (do_clocal || (self->settings.dce & IRCOMM_CD)) &&
345 self->state == IRCOMM_TTY_READY) 323 self->state == IRCOMM_TTY_READY)
346 { 324 {
347 break; 325 break;
@@ -353,36 +331,50 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
353 } 331 }
354 332
355 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n", 333 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
356 __FILE__, __LINE__, tty->driver->name, port->count); 334 __FILE__,__LINE__, tty->driver->name, self->open_count );
357 335
358 schedule(); 336 schedule();
359 } 337 }
360 338
361 __set_current_state(TASK_RUNNING); 339 __set_current_state(TASK_RUNNING);
362 remove_wait_queue(&port->open_wait, &wait); 340 remove_wait_queue(&self->open_wait, &wait);
363 341
364 if (extra_count) { 342 if (extra_count) {
365 /* ++ is not atomic, so this should be protected - Jean II */ 343 /* ++ is not atomic, so this should be protected - Jean II */
366 spin_lock_irqsave(&port->lock, flags); 344 spin_lock_irqsave(&self->spinlock, flags);
367 port->count++; 345 self->open_count++;
368 spin_unlock_irqrestore(&port->lock, flags); 346 spin_unlock_irqrestore(&self->spinlock, flags);
369 } 347 }
370 port->blocked_open--; 348 self->blocked_open--;
371 349
372 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n", 350 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
373 __FILE__, __LINE__, tty->driver->name, port->count); 351 __FILE__,__LINE__, tty->driver->name, self->open_count);
374 352
375 if (!retval) 353 if (!retval)
376 port->flags |= ASYNC_NORMAL_ACTIVE; 354 self->flags |= ASYNC_NORMAL_ACTIVE;
377 355
378 return retval; 356 return retval;
379} 357}
380 358
381 359/*
382static int ircomm_tty_install(struct tty_driver *driver, struct tty_struct *tty) 360 * Function ircomm_tty_open (tty, filp)
361 *
362 * This routine is called when a particular tty device is opened. This
363 * routine is mandatory; if this routine is not filled in, the attempted
364 * open will fail with ENODEV.
365 */
366static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
383{ 367{
384 struct ircomm_tty_cb *self; 368 struct ircomm_tty_cb *self;
385 unsigned int line = tty->index; 369 unsigned int line;
370 unsigned long flags;
371 int ret;
372
373 IRDA_DEBUG(2, "%s()\n", __func__ );
374
375 line = tty->index;
376 if (line >= IRCOMM_TTY_PORTS)
377 return -ENODEV;
386 378
387 /* Check if instance already exists */ 379 /* Check if instance already exists */
388 self = hashbin_lock_find(ircomm_tty, line, NULL); 380 self = hashbin_lock_find(ircomm_tty, line, NULL);
@@ -394,8 +386,6 @@ static int ircomm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
394 return -ENOMEM; 386 return -ENOMEM;
395 } 387 }
396 388
397 tty_port_init(&self->port);
398 self->port.ops = &ircomm_port_ops;
399 self->magic = IRCOMM_TTY_MAGIC; 389 self->magic = IRCOMM_TTY_MAGIC;
400 self->flow = FLOW_STOP; 390 self->flow = FLOW_STOP;
401 391
@@ -403,9 +393,13 @@ static int ircomm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
403 INIT_WORK(&self->tqueue, ircomm_tty_do_softint); 393 INIT_WORK(&self->tqueue, ircomm_tty_do_softint);
404 self->max_header_size = IRCOMM_TTY_HDR_UNINITIALISED; 394 self->max_header_size = IRCOMM_TTY_HDR_UNINITIALISED;
405 self->max_data_size = IRCOMM_TTY_DATA_UNINITIALISED; 395 self->max_data_size = IRCOMM_TTY_DATA_UNINITIALISED;
396 self->close_delay = 5*HZ/10;
397 self->closing_wait = 30*HZ;
406 398
407 /* Init some important stuff */ 399 /* Init some important stuff */
408 init_timer(&self->watchdog_timer); 400 init_timer(&self->watchdog_timer);
401 init_waitqueue_head(&self->open_wait);
402 init_waitqueue_head(&self->close_wait);
409 spin_lock_init(&self->spinlock); 403 spin_lock_init(&self->spinlock);
410 404
411 /* 405 /*
@@ -415,50 +409,31 @@ static int ircomm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
415 * 409 *
416 * Note this is completely usafe and doesn't work properly 410 * Note this is completely usafe and doesn't work properly
417 */ 411 */
418 tty->termios.c_iflag = 0; 412 tty->termios->c_iflag = 0;
419 tty->termios.c_oflag = 0; 413 tty->termios->c_oflag = 0;
420 414
421 /* Insert into hash */ 415 /* Insert into hash */
422 hashbin_insert(ircomm_tty, (irda_queue_t *) self, line, NULL); 416 hashbin_insert(ircomm_tty, (irda_queue_t *) self, line, NULL);
423 } 417 }
418 /* ++ is not atomic, so this should be protected - Jean II */
419 spin_lock_irqsave(&self->spinlock, flags);
420 self->open_count++;
424 421
425 tty->driver_data = self; 422 tty->driver_data = self;
426 423 self->tty = tty;
427 return tty_port_install(&self->port, driver, tty); 424 spin_unlock_irqrestore(&self->spinlock, flags);
428}
429
430/*
431 * Function ircomm_tty_open (tty, filp)
432 *
433 * This routine is called when a particular tty device is opened. This
434 * routine is mandatory; if this routine is not filled in, the attempted
435 * open will fail with ENODEV.
436 */
437static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
438{
439 struct ircomm_tty_cb *self = tty->driver_data;
440 unsigned long flags;
441 int ret;
442
443 IRDA_DEBUG(2, "%s()\n", __func__ );
444
445 /* ++ is not atomic, so this should be protected - Jean II */
446 spin_lock_irqsave(&self->port.lock, flags);
447 self->port.count++;
448 spin_unlock_irqrestore(&self->port.lock, flags);
449 tty_port_tty_set(&self->port, tty);
450 425
451 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name, 426 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
452 self->line, self->port.count); 427 self->line, self->open_count);
453 428
454 /* Not really used by us, but lets do it anyway */ 429 /* Not really used by us, but lets do it anyway */
455 tty->low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0; 430 self->tty->low_latency = (self->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
456 431
457 /* 432 /*
458 * If the port is the middle of closing, bail out now 433 * If the port is the middle of closing, bail out now
459 */ 434 */
460 if (tty_hung_up_p(filp) || 435 if (tty_hung_up_p(filp) ||
461 test_bit(ASYNCB_CLOSING, &self->port.flags)) { 436 test_bit(ASYNC_B_CLOSING, &self->flags)) {
462 437
463 /* Hm, why are we blocking on ASYNC_CLOSING if we 438 /* Hm, why are we blocking on ASYNC_CLOSING if we
464 * do return -EAGAIN/-ERESTARTSYS below anyway? 439 * do return -EAGAIN/-ERESTARTSYS below anyway?
@@ -468,15 +443,14 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
468 * probably better sleep uninterruptible? 443 * probably better sleep uninterruptible?
469 */ 444 */
470 445
471 if (wait_event_interruptible(self->port.close_wait, 446 if (wait_event_interruptible(self->close_wait, !test_bit(ASYNC_B_CLOSING, &self->flags))) {
472 !test_bit(ASYNCB_CLOSING, &self->port.flags))) {
473 IRDA_WARNING("%s - got signal while blocking on ASYNC_CLOSING!\n", 447 IRDA_WARNING("%s - got signal while blocking on ASYNC_CLOSING!\n",
474 __func__); 448 __func__);
475 return -ERESTARTSYS; 449 return -ERESTARTSYS;
476 } 450 }
477 451
478#ifdef SERIAL_DO_RESTART 452#ifdef SERIAL_DO_RESTART
479 return (self->port.flags & ASYNC_HUP_NOTIFY) ? 453 return (self->flags & ASYNC_HUP_NOTIFY) ?
480 -EAGAIN : -ERESTARTSYS; 454 -EAGAIN : -ERESTARTSYS;
481#else 455#else
482 return -EAGAIN; 456 return -EAGAIN;
@@ -484,7 +458,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
484 } 458 }
485 459
486 /* Check if this is a "normal" ircomm device, or an irlpt device */ 460 /* Check if this is a "normal" ircomm device, or an irlpt device */
487 if (self->line < 0x10) { 461 if (line < 0x10) {
488 self->service_type = IRCOMM_3_WIRE | IRCOMM_9_WIRE; 462 self->service_type = IRCOMM_3_WIRE | IRCOMM_9_WIRE;
489 self->settings.service_type = IRCOMM_9_WIRE; /* 9 wire as default */ 463 self->settings.service_type = IRCOMM_9_WIRE; /* 9 wire as default */
490 /* Jan Kiszka -> add DSR/RI -> Conform to IrCOMM spec */ 464 /* Jan Kiszka -> add DSR/RI -> Conform to IrCOMM spec */
@@ -500,7 +474,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
500 if (ret) 474 if (ret)
501 return ret; 475 return ret;
502 476
503 ret = ircomm_tty_block_til_ready(self, tty, filp); 477 ret = ircomm_tty_block_til_ready(self, filp);
504 if (ret) { 478 if (ret) {
505 IRDA_DEBUG(2, 479 IRDA_DEBUG(2,
506 "%s(), returning after block_til_ready with %d\n", __func__ , 480 "%s(), returning after block_til_ready with %d\n", __func__ ,
@@ -520,22 +494,81 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
520static void ircomm_tty_close(struct tty_struct *tty, struct file *filp) 494static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
521{ 495{
522 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; 496 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
523 struct tty_port *port = &self->port; 497 unsigned long flags;
524 498
525 IRDA_DEBUG(0, "%s()\n", __func__ ); 499 IRDA_DEBUG(0, "%s()\n", __func__ );
526 500
527 IRDA_ASSERT(self != NULL, return;); 501 IRDA_ASSERT(self != NULL, return;);
528 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); 502 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
529 503
530 if (tty_port_close_start(port, tty, filp) == 0) 504 spin_lock_irqsave(&self->spinlock, flags);
505
506 if (tty_hung_up_p(filp)) {
507 spin_unlock_irqrestore(&self->spinlock, flags);
508
509 IRDA_DEBUG(0, "%s(), returning 1\n", __func__ );
531 return; 510 return;
511 }
512
513 if ((tty->count == 1) && (self->open_count != 1)) {
514 /*
515 * Uh, oh. tty->count is 1, which means that the tty
516 * structure will be freed. state->count should always
517 * be one in these conditions. If it's greater than
518 * one, we've got real problems, since it means the
519 * serial port won't be shutdown.
520 */
521 IRDA_DEBUG(0, "%s(), bad serial port count; "
522 "tty->count is 1, state->count is %d\n", __func__ ,
523 self->open_count);
524 self->open_count = 1;
525 }
526
527 if (--self->open_count < 0) {
528 IRDA_ERROR("%s(), bad serial port count for ttys%d: %d\n",
529 __func__, self->line, self->open_count);
530 self->open_count = 0;
531 }
532 if (self->open_count) {
533 spin_unlock_irqrestore(&self->spinlock, flags);
534
535 IRDA_DEBUG(0, "%s(), open count > 0\n", __func__ );
536 return;
537 }
538
539 /* Hum... Should be test_and_set_bit ??? - Jean II */
540 set_bit(ASYNC_B_CLOSING, &self->flags);
541
542 /* We need to unlock here (we were unlocking at the end of this
543 * function), because tty_wait_until_sent() may schedule.
544 * I don't know if the rest should be protected somehow,
545 * so someone should check. - Jean II */
546 spin_unlock_irqrestore(&self->spinlock, flags);
547
548 /*
549 * Now we wait for the transmit buffer to clear; and we notify
550 * the line discipline to only process XON/XOFF characters.
551 */
552 tty->closing = 1;
553 if (self->closing_wait != ASYNC_CLOSING_WAIT_NONE)
554 tty_wait_until_sent(tty, self->closing_wait);
532 555
533 ircomm_tty_shutdown(self); 556 ircomm_tty_shutdown(self);
534 557
535 tty_driver_flush_buffer(tty); 558 tty_driver_flush_buffer(tty);
559 tty_ldisc_flush(tty);
560
561 tty->closing = 0;
562 self->tty = NULL;
536 563
537 tty_port_close_end(port, tty); 564 if (self->blocked_open) {
538 tty_port_tty_set(port, NULL); 565 if (self->close_delay)
566 schedule_timeout_interruptible(self->close_delay);
567 wake_up_interruptible(&self->open_wait);
568 }
569
570 self->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
571 wake_up_interruptible(&self->close_wait);
539} 572}
540 573
541/* 574/*
@@ -578,7 +611,7 @@ static void ircomm_tty_do_softint(struct work_struct *work)
578 if (!self || self->magic != IRCOMM_TTY_MAGIC) 611 if (!self || self->magic != IRCOMM_TTY_MAGIC)
579 return; 612 return;
580 613
581 tty = tty_port_tty_get(&self->port); 614 tty = self->tty;
582 if (!tty) 615 if (!tty)
583 return; 616 return;
584 617
@@ -599,7 +632,7 @@ static void ircomm_tty_do_softint(struct work_struct *work)
599 } 632 }
600 633
601 if (tty->hw_stopped) 634 if (tty->hw_stopped)
602 goto put; 635 return;
603 636
604 /* Unlink transmit buffer */ 637 /* Unlink transmit buffer */
605 spin_lock_irqsave(&self->spinlock, flags); 638 spin_lock_irqsave(&self->spinlock, flags);
@@ -618,8 +651,6 @@ static void ircomm_tty_do_softint(struct work_struct *work)
618 651
619 /* Check if user (still) wants to be waken up */ 652 /* Check if user (still) wants to be waken up */
620 tty_wakeup(tty); 653 tty_wakeup(tty);
621put:
622 tty_kref_put(tty);
623} 654}
624 655
625/* 656/*
@@ -854,7 +885,7 @@ static void ircomm_tty_throttle(struct tty_struct *tty)
854 ircomm_tty_send_xchar(tty, STOP_CHAR(tty)); 885 ircomm_tty_send_xchar(tty, STOP_CHAR(tty));
855 886
856 /* Hardware flow control? */ 887 /* Hardware flow control? */
857 if (tty->termios.c_cflag & CRTSCTS) { 888 if (tty->termios->c_cflag & CRTSCTS) {
858 self->settings.dte &= ~IRCOMM_RTS; 889 self->settings.dte &= ~IRCOMM_RTS;
859 self->settings.dte |= IRCOMM_DELTA_RTS; 890 self->settings.dte |= IRCOMM_DELTA_RTS;
860 891
@@ -886,7 +917,7 @@ static void ircomm_tty_unthrottle(struct tty_struct *tty)
886 } 917 }
887 918
888 /* Using hardware flow control? */ 919 /* Using hardware flow control? */
889 if (tty->termios.c_cflag & CRTSCTS) { 920 if (tty->termios->c_cflag & CRTSCTS) {
890 self->settings.dte |= (IRCOMM_RTS|IRCOMM_DELTA_RTS); 921 self->settings.dte |= (IRCOMM_RTS|IRCOMM_DELTA_RTS);
891 922
892 ircomm_param_request(self, IRCOMM_DTE, TRUE); 923 ircomm_param_request(self, IRCOMM_DTE, TRUE);
@@ -929,7 +960,7 @@ static void ircomm_tty_shutdown(struct ircomm_tty_cb *self)
929 960
930 IRDA_DEBUG(0, "%s()\n", __func__ ); 961 IRDA_DEBUG(0, "%s()\n", __func__ );
931 962
932 if (!test_and_clear_bit(ASYNCB_INITIALIZED, &self->port.flags)) 963 if (!test_and_clear_bit(ASYNC_B_INITIALIZED, &self->flags))
933 return; 964 return;
934 965
935 ircomm_tty_detach_cable(self); 966 ircomm_tty_detach_cable(self);
@@ -968,7 +999,6 @@ static void ircomm_tty_shutdown(struct ircomm_tty_cb *self)
968static void ircomm_tty_hangup(struct tty_struct *tty) 999static void ircomm_tty_hangup(struct tty_struct *tty)
969{ 1000{
970 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; 1001 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
971 struct tty_port *port = &self->port;
972 unsigned long flags; 1002 unsigned long flags;
973 1003
974 IRDA_DEBUG(0, "%s()\n", __func__ ); 1004 IRDA_DEBUG(0, "%s()\n", __func__ );
@@ -979,17 +1009,14 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
979 /* ircomm_tty_flush_buffer(tty); */ 1009 /* ircomm_tty_flush_buffer(tty); */
980 ircomm_tty_shutdown(self); 1010 ircomm_tty_shutdown(self);
981 1011
982 spin_lock_irqsave(&port->lock, flags); 1012 /* I guess we need to lock here - Jean II */
983 port->flags &= ~ASYNC_NORMAL_ACTIVE; 1013 spin_lock_irqsave(&self->spinlock, flags);
984 if (port->tty) { 1014 self->flags &= ~ASYNC_NORMAL_ACTIVE;
985 set_bit(TTY_IO_ERROR, &port->tty->flags); 1015 self->tty = NULL;
986 tty_kref_put(port->tty); 1016 self->open_count = 0;
987 } 1017 spin_unlock_irqrestore(&self->spinlock, flags);
988 port->tty = NULL;
989 port->count = 0;
990 spin_unlock_irqrestore(&port->lock, flags);
991 1018
992 wake_up_interruptible(&port->open_wait); 1019 wake_up_interruptible(&self->open_wait);
993} 1020}
994 1021
995/* 1022/*
@@ -1049,20 +1076,20 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
1049 IRDA_ASSERT(self != NULL, return;); 1076 IRDA_ASSERT(self != NULL, return;);
1050 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); 1077 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
1051 1078
1052 tty = tty_port_tty_get(&self->port); 1079 tty = self->tty;
1053 1080
1054 status = self->settings.dce; 1081 status = self->settings.dce;
1055 1082
1056 if (status & IRCOMM_DCE_DELTA_ANY) { 1083 if (status & IRCOMM_DCE_DELTA_ANY) {
1057 /*wake_up_interruptible(&self->delta_msr_wait);*/ 1084 /*wake_up_interruptible(&self->delta_msr_wait);*/
1058 } 1085 }
1059 if ((self->port.flags & ASYNC_CHECK_CD) && (status & IRCOMM_DELTA_CD)) { 1086 if ((self->flags & ASYNC_CHECK_CD) && (status & IRCOMM_DELTA_CD)) {
1060 IRDA_DEBUG(2, 1087 IRDA_DEBUG(2,
1061 "%s(), ircomm%d CD now %s...\n", __func__ , self->line, 1088 "%s(), ircomm%d CD now %s...\n", __func__ , self->line,
1062 (status & IRCOMM_CD) ? "on" : "off"); 1089 (status & IRCOMM_CD) ? "on" : "off");
1063 1090
1064 if (status & IRCOMM_CD) { 1091 if (status & IRCOMM_CD) {
1065 wake_up_interruptible(&self->port.open_wait); 1092 wake_up_interruptible(&self->open_wait);
1066 } else { 1093 } else {
1067 IRDA_DEBUG(2, 1094 IRDA_DEBUG(2,
1068 "%s(), Doing serial hangup..\n", __func__ ); 1095 "%s(), Doing serial hangup..\n", __func__ );
@@ -1070,10 +1097,10 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
1070 tty_hangup(tty); 1097 tty_hangup(tty);
1071 1098
1072 /* Hangup will remote the tty, so better break out */ 1099 /* Hangup will remote the tty, so better break out */
1073 goto put; 1100 return;
1074 } 1101 }
1075 } 1102 }
1076 if (tty && tty_port_cts_enabled(&self->port)) { 1103 if (self->flags & ASYNC_CTS_FLOW) {
1077 if (tty->hw_stopped) { 1104 if (tty->hw_stopped) {
1078 if (status & IRCOMM_CTS) { 1105 if (status & IRCOMM_CTS) {
1079 IRDA_DEBUG(2, 1106 IRDA_DEBUG(2,
@@ -1081,10 +1108,10 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
1081 tty->hw_stopped = 0; 1108 tty->hw_stopped = 0;
1082 1109
1083 /* Wake up processes blocked on open */ 1110 /* Wake up processes blocked on open */
1084 wake_up_interruptible(&self->port.open_wait); 1111 wake_up_interruptible(&self->open_wait);
1085 1112
1086 schedule_work(&self->tqueue); 1113 schedule_work(&self->tqueue);
1087 goto put; 1114 return;
1088 } 1115 }
1089 } else { 1116 } else {
1090 if (!(status & IRCOMM_CTS)) { 1117 if (!(status & IRCOMM_CTS)) {
@@ -1094,8 +1121,6 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
1094 } 1121 }
1095 } 1122 }
1096 } 1123 }
1097put:
1098 tty_kref_put(tty);
1099} 1124}
1100 1125
1101/* 1126/*
@@ -1108,7 +1133,6 @@ static int ircomm_tty_data_indication(void *instance, void *sap,
1108 struct sk_buff *skb) 1133 struct sk_buff *skb)
1109{ 1134{
1110 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; 1135 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
1111 struct tty_struct *tty;
1112 1136
1113 IRDA_DEBUG(2, "%s()\n", __func__ ); 1137 IRDA_DEBUG(2, "%s()\n", __func__ );
1114 1138
@@ -1116,8 +1140,7 @@ static int ircomm_tty_data_indication(void *instance, void *sap,
1116 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); 1140 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
1117 IRDA_ASSERT(skb != NULL, return -1;); 1141 IRDA_ASSERT(skb != NULL, return -1;);
1118 1142
1119 tty = tty_port_tty_get(&self->port); 1143 if (!self->tty) {
1120 if (!tty) {
1121 IRDA_DEBUG(0, "%s(), no tty!\n", __func__ ); 1144 IRDA_DEBUG(0, "%s(), no tty!\n", __func__ );
1122 return 0; 1145 return 0;
1123 } 1146 }
@@ -1128,7 +1151,7 @@ static int ircomm_tty_data_indication(void *instance, void *sap,
1128 * Devices like WinCE can do this, and since they don't send any 1151 * Devices like WinCE can do this, and since they don't send any
1129 * params, we can just as well declare the hardware for running. 1152 * params, we can just as well declare the hardware for running.
1130 */ 1153 */
1131 if (tty->hw_stopped && (self->flow == FLOW_START)) { 1154 if (self->tty->hw_stopped && (self->flow == FLOW_START)) {
1132 IRDA_DEBUG(0, "%s(), polling for line settings!\n", __func__ ); 1155 IRDA_DEBUG(0, "%s(), polling for line settings!\n", __func__ );
1133 ircomm_param_request(self, IRCOMM_POLL, TRUE); 1156 ircomm_param_request(self, IRCOMM_POLL, TRUE);
1134 1157
@@ -1141,9 +1164,8 @@ static int ircomm_tty_data_indication(void *instance, void *sap,
1141 * Use flip buffer functions since the code may be called from interrupt 1164 * Use flip buffer functions since the code may be called from interrupt
1142 * context 1165 * context
1143 */ 1166 */
1144 tty_insert_flip_string(tty, skb->data, skb->len); 1167 tty_insert_flip_string(self->tty, skb->data, skb->len);
1145 tty_flip_buffer_push(tty); 1168 tty_flip_buffer_push(self->tty);
1146 tty_kref_put(tty);
1147 1169
1148 /* No need to kfree_skb - see ircomm_ttp_data_indication() */ 1170 /* No need to kfree_skb - see ircomm_ttp_data_indication() */
1149 1171
@@ -1194,13 +1216,12 @@ static void ircomm_tty_flow_indication(void *instance, void *sap,
1194 IRDA_ASSERT(self != NULL, return;); 1216 IRDA_ASSERT(self != NULL, return;);
1195 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); 1217 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
1196 1218
1197 tty = tty_port_tty_get(&self->port); 1219 tty = self->tty;
1198 1220
1199 switch (cmd) { 1221 switch (cmd) {
1200 case FLOW_START: 1222 case FLOW_START:
1201 IRDA_DEBUG(2, "%s(), hw start!\n", __func__ ); 1223 IRDA_DEBUG(2, "%s(), hw start!\n", __func__ );
1202 if (tty) 1224 tty->hw_stopped = 0;
1203 tty->hw_stopped = 0;
1204 1225
1205 /* ircomm_tty_do_softint will take care of the rest */ 1226 /* ircomm_tty_do_softint will take care of the rest */
1206 schedule_work(&self->tqueue); 1227 schedule_work(&self->tqueue);
@@ -1208,19 +1229,15 @@ static void ircomm_tty_flow_indication(void *instance, void *sap,
1208 default: /* If we get here, something is very wrong, better stop */ 1229 default: /* If we get here, something is very wrong, better stop */
1209 case FLOW_STOP: 1230 case FLOW_STOP:
1210 IRDA_DEBUG(2, "%s(), hw stopped!\n", __func__ ); 1231 IRDA_DEBUG(2, "%s(), hw stopped!\n", __func__ );
1211 if (tty) 1232 tty->hw_stopped = 1;
1212 tty->hw_stopped = 1;
1213 break; 1233 break;
1214 } 1234 }
1215
1216 tty_kref_put(tty);
1217 self->flow = cmd; 1235 self->flow = cmd;
1218} 1236}
1219 1237
1220#ifdef CONFIG_PROC_FS 1238#ifdef CONFIG_PROC_FS
1221static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m) 1239static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
1222{ 1240{
1223 struct tty_struct *tty;
1224 char sep; 1241 char sep;
1225 1242
1226 seq_printf(m, "State: %s\n", ircomm_tty_state[self->state]); 1243 seq_printf(m, "State: %s\n", ircomm_tty_state[self->state]);
@@ -1316,43 +1333,40 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
1316 1333
1317 seq_puts(m, "Flags:"); 1334 seq_puts(m, "Flags:");
1318 sep = ' '; 1335 sep = ' ';
1319 if (tty_port_cts_enabled(&self->port)) { 1336 if (self->flags & ASYNC_CTS_FLOW) {
1320 seq_printf(m, "%cASYNC_CTS_FLOW", sep); 1337 seq_printf(m, "%cASYNC_CTS_FLOW", sep);
1321 sep = '|'; 1338 sep = '|';
1322 } 1339 }
1323 if (self->port.flags & ASYNC_CHECK_CD) { 1340 if (self->flags & ASYNC_CHECK_CD) {
1324 seq_printf(m, "%cASYNC_CHECK_CD", sep); 1341 seq_printf(m, "%cASYNC_CHECK_CD", sep);
1325 sep = '|'; 1342 sep = '|';
1326 } 1343 }
1327 if (self->port.flags & ASYNC_INITIALIZED) { 1344 if (self->flags & ASYNC_INITIALIZED) {
1328 seq_printf(m, "%cASYNC_INITIALIZED", sep); 1345 seq_printf(m, "%cASYNC_INITIALIZED", sep);
1329 sep = '|'; 1346 sep = '|';
1330 } 1347 }
1331 if (self->port.flags & ASYNC_LOW_LATENCY) { 1348 if (self->flags & ASYNC_LOW_LATENCY) {
1332 seq_printf(m, "%cASYNC_LOW_LATENCY", sep); 1349 seq_printf(m, "%cASYNC_LOW_LATENCY", sep);
1333 sep = '|'; 1350 sep = '|';
1334 } 1351 }
1335 if (self->port.flags & ASYNC_CLOSING) { 1352 if (self->flags & ASYNC_CLOSING) {
1336 seq_printf(m, "%cASYNC_CLOSING", sep); 1353 seq_printf(m, "%cASYNC_CLOSING", sep);
1337 sep = '|'; 1354 sep = '|';
1338 } 1355 }
1339 if (self->port.flags & ASYNC_NORMAL_ACTIVE) { 1356 if (self->flags & ASYNC_NORMAL_ACTIVE) {
1340 seq_printf(m, "%cASYNC_NORMAL_ACTIVE", sep); 1357 seq_printf(m, "%cASYNC_NORMAL_ACTIVE", sep);
1341 sep = '|'; 1358 sep = '|';
1342 } 1359 }
1343 seq_putc(m, '\n'); 1360 seq_putc(m, '\n');
1344 1361
1345 seq_printf(m, "Role: %s\n", self->client ? "client" : "server"); 1362 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
1346 seq_printf(m, "Open count: %d\n", self->port.count); 1363 seq_printf(m, "Open count: %d\n", self->open_count);
1347 seq_printf(m, "Max data size: %d\n", self->max_data_size); 1364 seq_printf(m, "Max data size: %d\n", self->max_data_size);
1348 seq_printf(m, "Max header size: %d\n", self->max_header_size); 1365 seq_printf(m, "Max header size: %d\n", self->max_header_size);
1349 1366
1350 tty = tty_port_tty_get(&self->port); 1367 if (self->tty)
1351 if (tty) {
1352 seq_printf(m, "Hardware: %s\n", 1368 seq_printf(m, "Hardware: %s\n",
1353 tty->hw_stopped ? "Stopped" : "Running"); 1369 self->tty->hw_stopped ? "Stopped" : "Running");
1354 tty_kref_put(tty);
1355 }
1356} 1370}
1357 1371
1358static int ircomm_tty_proc_show(struct seq_file *m, void *v) 1372static int ircomm_tty_proc_show(struct seq_file *m, void *v)
diff --git a/net/irda/ircomm/ircomm_tty_attach.c b/net/irda/ircomm/ircomm_tty_attach.c
index edab393e0c8..b65d66e0d81 100644
--- a/net/irda/ircomm/ircomm_tty_attach.c
+++ b/net/irda/ircomm/ircomm_tty_attach.c
@@ -130,8 +130,6 @@ static int (*state[])(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event,
130 */ 130 */
131int ircomm_tty_attach_cable(struct ircomm_tty_cb *self) 131int ircomm_tty_attach_cable(struct ircomm_tty_cb *self)
132{ 132{
133 struct tty_struct *tty;
134
135 IRDA_DEBUG(0, "%s()\n", __func__ ); 133 IRDA_DEBUG(0, "%s()\n", __func__ );
136 134
137 IRDA_ASSERT(self != NULL, return -1;); 135 IRDA_ASSERT(self != NULL, return -1;);
@@ -144,11 +142,7 @@ int ircomm_tty_attach_cable(struct ircomm_tty_cb *self)
144 } 142 }
145 143
146 /* Make sure nobody tries to write before the link is up */ 144 /* Make sure nobody tries to write before the link is up */
147 tty = tty_port_tty_get(&self->port); 145 self->tty->hw_stopped = 1;
148 if (tty) {
149 tty->hw_stopped = 1;
150 tty_kref_put(tty);
151 }
152 146
153 ircomm_tty_ias_register(self); 147 ircomm_tty_ias_register(self);
154 148
@@ -404,26 +398,23 @@ void ircomm_tty_disconnect_indication(void *instance, void *sap,
404 struct sk_buff *skb) 398 struct sk_buff *skb)
405{ 399{
406 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; 400 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
407 struct tty_struct *tty;
408 401
409 IRDA_DEBUG(2, "%s()\n", __func__ ); 402 IRDA_DEBUG(2, "%s()\n", __func__ );
410 403
411 IRDA_ASSERT(self != NULL, return;); 404 IRDA_ASSERT(self != NULL, return;);
412 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); 405 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
413 406
414 tty = tty_port_tty_get(&self->port); 407 if (!self->tty)
415 if (!tty)
416 return; 408 return;
417 409
418 /* This will stop control data transfers */ 410 /* This will stop control data transfers */
419 self->flow = FLOW_STOP; 411 self->flow = FLOW_STOP;
420 412
421 /* Stop data transfers */ 413 /* Stop data transfers */
422 tty->hw_stopped = 1; 414 self->tty->hw_stopped = 1;
423 415
424 ircomm_tty_do_event(self, IRCOMM_TTY_DISCONNECT_INDICATION, NULL, 416 ircomm_tty_do_event(self, IRCOMM_TTY_DISCONNECT_INDICATION, NULL,
425 NULL); 417 NULL);
426 tty_kref_put(tty);
427} 418}
428 419
429/* 420/*
@@ -559,15 +550,12 @@ void ircomm_tty_connect_indication(void *instance, void *sap,
559 */ 550 */
560void ircomm_tty_link_established(struct ircomm_tty_cb *self) 551void ircomm_tty_link_established(struct ircomm_tty_cb *self)
561{ 552{
562 struct tty_struct *tty;
563
564 IRDA_DEBUG(2, "%s()\n", __func__ ); 553 IRDA_DEBUG(2, "%s()\n", __func__ );
565 554
566 IRDA_ASSERT(self != NULL, return;); 555 IRDA_ASSERT(self != NULL, return;);
567 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); 556 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
568 557
569 tty = tty_port_tty_get(&self->port); 558 if (!self->tty)
570 if (!tty)
571 return; 559 return;
572 560
573 del_timer(&self->watchdog_timer); 561 del_timer(&self->watchdog_timer);
@@ -578,22 +566,19 @@ void ircomm_tty_link_established(struct ircomm_tty_cb *self)
578 * will have to wait for the peer device (DCE) to raise the CTS 566 * will have to wait for the peer device (DCE) to raise the CTS
579 * line. 567 * line.
580 */ 568 */
581 if (tty_port_cts_enabled(&self->port) && 569 if ((self->flags & ASYNC_CTS_FLOW) && ((self->settings.dce & IRCOMM_CTS) == 0)) {
582 ((self->settings.dce & IRCOMM_CTS) == 0)) {
583 IRDA_DEBUG(0, "%s(), waiting for CTS ...\n", __func__ ); 570 IRDA_DEBUG(0, "%s(), waiting for CTS ...\n", __func__ );
584 goto put; 571 return;
585 } else { 572 } else {
586 IRDA_DEBUG(1, "%s(), starting hardware!\n", __func__ ); 573 IRDA_DEBUG(1, "%s(), starting hardware!\n", __func__ );
587 574
588 tty->hw_stopped = 0; 575 self->tty->hw_stopped = 0;
589 576
590 /* Wake up processes blocked on open */ 577 /* Wake up processes blocked on open */
591 wake_up_interruptible(&self->port.open_wait); 578 wake_up_interruptible(&self->open_wait);
592 } 579 }
593 580
594 schedule_work(&self->tqueue); 581 schedule_work(&self->tqueue);
595put:
596 tty_kref_put(tty);
597} 582}
598 583
599/* 584/*
@@ -992,17 +977,14 @@ static int ircomm_tty_state_ready(struct ircomm_tty_cb *self,
992 ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH); 977 ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH);
993 ircomm_tty_start_watchdog_timer(self, 3*HZ); 978 ircomm_tty_start_watchdog_timer(self, 3*HZ);
994 979
995 if (self->port.flags & ASYNC_CHECK_CD) { 980 if (self->flags & ASYNC_CHECK_CD) {
996 /* Drop carrier */ 981 /* Drop carrier */
997 self->settings.dce = IRCOMM_DELTA_CD; 982 self->settings.dce = IRCOMM_DELTA_CD;
998 ircomm_tty_check_modem_status(self); 983 ircomm_tty_check_modem_status(self);
999 } else { 984 } else {
1000 struct tty_struct *tty = tty_port_tty_get(&self->port);
1001 IRDA_DEBUG(0, "%s(), hanging up!\n", __func__ ); 985 IRDA_DEBUG(0, "%s(), hanging up!\n", __func__ );
1002 if (tty) { 986 if (self->tty)
1003 tty_hangup(tty); 987 tty_hangup(self->tty);
1004 tty_kref_put(tty);
1005 }
1006 } 988 }
1007 break; 989 break;
1008 default: 990 default:
diff --git a/net/irda/ircomm/ircomm_tty_ioctl.c b/net/irda/ircomm/ircomm_tty_ioctl.c
index b343f50dc8d..77c5e6499f8 100644
--- a/net/irda/ircomm/ircomm_tty_ioctl.c
+++ b/net/irda/ircomm/ircomm_tty_ioctl.c
@@ -52,18 +52,17 @@
52 * Change speed of the driver. If the remote device is a DCE, then this 52 * Change speed of the driver. If the remote device is a DCE, then this
53 * should make it change the speed of its serial port 53 * should make it change the speed of its serial port
54 */ 54 */
55static void ircomm_tty_change_speed(struct ircomm_tty_cb *self, 55static void ircomm_tty_change_speed(struct ircomm_tty_cb *self)
56 struct tty_struct *tty)
57{ 56{
58 unsigned int cflag, cval; 57 unsigned cflag, cval;
59 int baud; 58 int baud;
60 59
61 IRDA_DEBUG(2, "%s()\n", __func__ ); 60 IRDA_DEBUG(2, "%s()\n", __func__ );
62 61
63 if (!self->ircomm) 62 if (!self->tty || !self->tty->termios || !self->ircomm)
64 return; 63 return;
65 64
66 cflag = tty->termios.c_cflag; 65 cflag = self->tty->termios->c_cflag;
67 66
68 /* byte size and parity */ 67 /* byte size and parity */
69 switch (cflag & CSIZE) { 68 switch (cflag & CSIZE) {
@@ -82,7 +81,7 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self,
82 cval |= IRCOMM_PARITY_EVEN; 81 cval |= IRCOMM_PARITY_EVEN;
83 82
84 /* Determine divisor based on baud rate */ 83 /* Determine divisor based on baud rate */
85 baud = tty_get_baud_rate(tty); 84 baud = tty_get_baud_rate(self->tty);
86 if (!baud) 85 if (!baud)
87 baud = 9600; /* B0 transition handled in rs_set_termios */ 86 baud = 9600; /* B0 transition handled in rs_set_termios */
88 87
@@ -91,19 +90,19 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self,
91 90
92 /* CTS flow control flag and modem status interrupts */ 91 /* CTS flow control flag and modem status interrupts */
93 if (cflag & CRTSCTS) { 92 if (cflag & CRTSCTS) {
94 self->port.flags |= ASYNC_CTS_FLOW; 93 self->flags |= ASYNC_CTS_FLOW;
95 self->settings.flow_control |= IRCOMM_RTS_CTS_IN; 94 self->settings.flow_control |= IRCOMM_RTS_CTS_IN;
96 /* This got me. Bummer. Jean II */ 95 /* This got me. Bummer. Jean II */
97 if (self->service_type == IRCOMM_3_WIRE_RAW) 96 if (self->service_type == IRCOMM_3_WIRE_RAW)
98 IRDA_WARNING("%s(), enabling RTS/CTS on link that doesn't support it (3-wire-raw)\n", __func__); 97 IRDA_WARNING("%s(), enabling RTS/CTS on link that doesn't support it (3-wire-raw)\n", __func__);
99 } else { 98 } else {
100 self->port.flags &= ~ASYNC_CTS_FLOW; 99 self->flags &= ~ASYNC_CTS_FLOW;
101 self->settings.flow_control &= ~IRCOMM_RTS_CTS_IN; 100 self->settings.flow_control &= ~IRCOMM_RTS_CTS_IN;
102 } 101 }
103 if (cflag & CLOCAL) 102 if (cflag & CLOCAL)
104 self->port.flags &= ~ASYNC_CHECK_CD; 103 self->flags &= ~ASYNC_CHECK_CD;
105 else 104 else
106 self->port.flags |= ASYNC_CHECK_CD; 105 self->flags |= ASYNC_CHECK_CD;
107#if 0 106#if 0
108 /* 107 /*
109 * Set up parity check flag 108 * Set up parity check flag
@@ -149,18 +148,18 @@ void ircomm_tty_set_termios(struct tty_struct *tty,
149 struct ktermios *old_termios) 148 struct ktermios *old_termios)
150{ 149{
151 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; 150 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
152 unsigned int cflag = tty->termios.c_cflag; 151 unsigned int cflag = tty->termios->c_cflag;
153 152
154 IRDA_DEBUG(2, "%s()\n", __func__ ); 153 IRDA_DEBUG(2, "%s()\n", __func__ );
155 154
156 if ((cflag == old_termios->c_cflag) && 155 if ((cflag == old_termios->c_cflag) &&
157 (RELEVANT_IFLAG(tty->termios.c_iflag) == 156 (RELEVANT_IFLAG(tty->termios->c_iflag) ==
158 RELEVANT_IFLAG(old_termios->c_iflag))) 157 RELEVANT_IFLAG(old_termios->c_iflag)))
159 { 158 {
160 return; 159 return;
161 } 160 }
162 161
163 ircomm_tty_change_speed(self, tty); 162 ircomm_tty_change_speed(self);
164 163
165 /* Handle transition to B0 status */ 164 /* Handle transition to B0 status */
166 if ((old_termios->c_cflag & CBAUD) && 165 if ((old_termios->c_cflag & CBAUD) &&
@@ -173,7 +172,7 @@ void ircomm_tty_set_termios(struct tty_struct *tty,
173 if (!(old_termios->c_cflag & CBAUD) && 172 if (!(old_termios->c_cflag & CBAUD) &&
174 (cflag & CBAUD)) { 173 (cflag & CBAUD)) {
175 self->settings.dte |= IRCOMM_DTR; 174 self->settings.dte |= IRCOMM_DTR;
176 if (!(tty->termios.c_cflag & CRTSCTS) || 175 if (!(tty->termios->c_cflag & CRTSCTS) ||
177 !test_bit(TTY_THROTTLED, &tty->flags)) { 176 !test_bit(TTY_THROTTLED, &tty->flags)) {
178 self->settings.dte |= IRCOMM_RTS; 177 self->settings.dte |= IRCOMM_RTS;
179 } 178 }
@@ -182,7 +181,7 @@ void ircomm_tty_set_termios(struct tty_struct *tty,
182 181
183 /* Handle turning off CRTSCTS */ 182 /* Handle turning off CRTSCTS */
184 if ((old_termios->c_cflag & CRTSCTS) && 183 if ((old_termios->c_cflag & CRTSCTS) &&
185 !(tty->termios.c_cflag & CRTSCTS)) 184 !(tty->termios->c_cflag & CRTSCTS))
186 { 185 {
187 tty->hw_stopped = 0; 186 tty->hw_stopped = 0;
188 ircomm_tty_start(tty); 187 ircomm_tty_start(tty);
@@ -271,10 +270,10 @@ static int ircomm_tty_get_serial_info(struct ircomm_tty_cb *self,
271 270
272 memset(&info, 0, sizeof(info)); 271 memset(&info, 0, sizeof(info));
273 info.line = self->line; 272 info.line = self->line;
274 info.flags = self->port.flags; 273 info.flags = self->flags;
275 info.baud_base = self->settings.data_rate; 274 info.baud_base = self->settings.data_rate;
276 info.close_delay = self->port.close_delay; 275 info.close_delay = self->close_delay;
277 info.closing_wait = self->port.closing_wait; 276 info.closing_wait = self->closing_wait;
278 277
279 /* For compatibility */ 278 /* For compatibility */
280 info.type = PORT_16550A; 279 info.type = PORT_16550A;
diff --git a/net/irda/irda_device.c b/net/irda/irda_device.c
index 14653b8d664..3eca35faf2a 100644
--- a/net/irda/irda_device.c
+++ b/net/irda/irda_device.c
@@ -42,7 +42,6 @@
42#include <linux/kmod.h> 42#include <linux/kmod.h>
43#include <linux/spinlock.h> 43#include <linux/spinlock.h>
44#include <linux/slab.h> 44#include <linux/slab.h>
45#include <linux/export.h>
46 45
47#include <asm/ioctls.h> 46#include <asm/ioctls.h>
48#include <asm/uaccess.h> 47#include <asm/uaccess.h>
diff --git a/net/irda/irlan/irlan_client.c b/net/irda/irlan/irlan_client.c
index 42cf1390ce9..ba1a3fc39b5 100644
--- a/net/irda/irlan/irlan_client.c
+++ b/net/irda/irlan/irlan_client.c
@@ -37,6 +37,7 @@
37#include <linux/bitops.h> 37#include <linux/bitops.h>
38#include <net/arp.h> 38#include <net/arp.h>
39 39
40#include <asm/system.h>
40#include <asm/byteorder.h> 41#include <asm/byteorder.h>
41 42
42#include <net/irda/irda.h> 43#include <net/irda/irda.h>
diff --git a/net/irda/irlan/irlan_common.c b/net/irda/irlan/irlan_common.c
index 7ac4d1becbf..77911763627 100644
--- a/net/irda/irlan/irlan_common.c
+++ b/net/irda/irlan/irlan_common.c
@@ -40,6 +40,7 @@
40#include <linux/moduleparam.h> 40#include <linux/moduleparam.h>
41#include <linux/bitops.h> 41#include <linux/bitops.h>
42 42
43#include <asm/system.h>
43#include <asm/byteorder.h> 44#include <asm/byteorder.h>
44 45
45#include <net/irda/irda.h> 46#include <net/irda/irda.h>
@@ -66,7 +67,7 @@ static void *ckey;
66static void *skey; 67static void *skey;
67 68
68/* Module parameters */ 69/* Module parameters */
69static bool eth; /* Use "eth" or "irlan" name for devices */ 70static int eth; /* Use "eth" or "irlan" name for devices */
70static int access = ACCESS_PEER; /* PEER, DIRECT or HOSTED */ 71static int access = ACCESS_PEER; /* PEER, DIRECT or HOSTED */
71 72
72#ifdef CONFIG_PROC_FS 73#ifdef CONFIG_PROC_FS
diff --git a/net/irda/irlan/irlan_eth.c b/net/irda/irlan/irlan_eth.c
index d14152e866d..e8d5f4405d6 100644
--- a/net/irda/irlan/irlan_eth.c
+++ b/net/irda/irlan/irlan_eth.c
@@ -50,7 +50,7 @@ static const struct net_device_ops irlan_eth_netdev_ops = {
50 .ndo_open = irlan_eth_open, 50 .ndo_open = irlan_eth_open,
51 .ndo_stop = irlan_eth_close, 51 .ndo_stop = irlan_eth_close,
52 .ndo_start_xmit = irlan_eth_xmit, 52 .ndo_start_xmit = irlan_eth_xmit,
53 .ndo_set_rx_mode = irlan_eth_set_multicast_list, 53 .ndo_set_multicast_list = irlan_eth_set_multicast_list,
54 .ndo_change_mtu = eth_change_mtu, 54 .ndo_change_mtu = eth_change_mtu,
55 .ndo_validate_addr = eth_validate_addr, 55 .ndo_validate_addr = eth_validate_addr,
56}; 56};
diff --git a/net/irda/irlan/irlan_provider.c b/net/irda/irlan/irlan_provider.c
index 4664855222f..8b61cf0d8a6 100644
--- a/net/irda/irlan/irlan_provider.c
+++ b/net/irda/irlan/irlan_provider.c
@@ -36,6 +36,7 @@
36#include <linux/bitops.h> 36#include <linux/bitops.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38 38
39#include <asm/system.h>
39#include <asm/byteorder.h> 40#include <asm/byteorder.h>
40 41
41#include <net/irda/irda.h> 42#include <net/irda/irda.h>
@@ -296,7 +297,7 @@ void irlan_provider_send_reply(struct irlan_cb *self, int command,
296 skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + 297 skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
297 /* Bigger param length comes from CMD_GET_MEDIA_CHAR */ 298 /* Bigger param length comes from CMD_GET_MEDIA_CHAR */
298 IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") + 299 IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") +
299 IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "BROADCAST") + 300 IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "BORADCAST") +
300 IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "MULTICAST") + 301 IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "MULTICAST") +
301 IRLAN_STRING_PARAMETER_LEN("ACCESS_TYPE", "HOSTED"), 302 IRLAN_STRING_PARAMETER_LEN("ACCESS_TYPE", "HOSTED"),
302 GFP_ATOMIC); 303 GFP_ATOMIC);
diff --git a/net/irda/irnet/irnet.h b/net/irda/irnet/irnet.h
index 564eb0b8afa..979ecb2435a 100644
--- a/net/irda/irnet/irnet.h
+++ b/net/irda/irnet/irnet.h
@@ -254,7 +254,7 @@
254#include <linux/init.h> 254#include <linux/init.h>
255 255
256#include <linux/ppp_defs.h> 256#include <linux/ppp_defs.h>
257#include <linux/ppp-ioctl.h> 257#include <linux/if_ppp.h>
258#include <linux/ppp_channel.h> 258#include <linux/ppp_channel.h>
259 259
260#include <net/irda/irda.h> 260#include <net/irda/irda.h>
diff --git a/net/irda/irnetlink.c b/net/irda/irnetlink.c
index c3297126928..6c7c4b92e4f 100644
--- a/net/irda/irnetlink.c
+++ b/net/irda/irnetlink.c
@@ -100,7 +100,7 @@ static int irda_nl_get_mode(struct sk_buff *skb, struct genl_info *info)
100 goto err_out; 100 goto err_out;
101 } 101 }
102 102
103 hdr = genlmsg_put(msg, info->snd_portid, info->snd_seq, 103 hdr = genlmsg_put(msg, info->snd_pid, info->snd_seq,
104 &irda_nl_family, 0, IRDA_NL_CMD_GET_MODE); 104 &irda_nl_family, 0, IRDA_NL_CMD_GET_MODE);
105 if (hdr == NULL) { 105 if (hdr == NULL) {
106 ret = -EMSGSIZE; 106 ret = -EMSGSIZE;
diff --git a/net/irda/irqueue.c b/net/irda/irqueue.c
index 7152624ed5f..f06947c4fa8 100644
--- a/net/irda/irqueue.c
+++ b/net/irda/irqueue.c
@@ -523,7 +523,7 @@ void *hashbin_remove_first( hashbin_t *hashbin)
523 * Dequeue the entry... 523 * Dequeue the entry...
524 */ 524 */
525 dequeue_general( (irda_queue_t**) &hashbin->hb_queue[ bin ], 525 dequeue_general( (irda_queue_t**) &hashbin->hb_queue[ bin ],
526 entry); 526 (irda_queue_t*) entry );
527 hashbin->hb_size--; 527 hashbin->hb_size--;
528 entry->q_next = NULL; 528 entry->q_next = NULL;
529 entry->q_prev = NULL; 529 entry->q_prev = NULL;
@@ -615,7 +615,7 @@ void* hashbin_remove( hashbin_t* hashbin, long hashv, const char* name)
615 */ 615 */
616 if ( found ) { 616 if ( found ) {
617 dequeue_general( (irda_queue_t**) &hashbin->hb_queue[ bin ], 617 dequeue_general( (irda_queue_t**) &hashbin->hb_queue[ bin ],
618 entry); 618 (irda_queue_t*) entry );
619 hashbin->hb_size--; 619 hashbin->hb_size--;
620 620
621 /* 621 /*
@@ -685,7 +685,7 @@ void* hashbin_remove_this( hashbin_t* hashbin, irda_queue_t* entry)
685 * Dequeue the entry... 685 * Dequeue the entry...
686 */ 686 */
687 dequeue_general( (irda_queue_t**) &hashbin->hb_queue[ bin ], 687 dequeue_general( (irda_queue_t**) &hashbin->hb_queue[ bin ],
688 entry); 688 (irda_queue_t*) entry );
689 hashbin->hb_size--; 689 hashbin->hb_size--;
690 entry->q_next = NULL; 690 entry->q_next = NULL;
691 entry->q_prev = NULL; 691 entry->q_prev = NULL;
diff --git a/net/irda/irsysctl.c b/net/irda/irsysctl.c
index de73f6496db..2615ffc8e78 100644
--- a/net/irda/irsysctl.c
+++ b/net/irda/irsysctl.c
@@ -235,6 +235,12 @@ static ctl_table irda_table[] = {
235 { } 235 { }
236}; 236};
237 237
238static struct ctl_path irda_path[] = {
239 { .procname = "net", },
240 { .procname = "irda", },
241 { }
242};
243
238static struct ctl_table_header *irda_table_header; 244static struct ctl_table_header *irda_table_header;
239 245
240/* 246/*
@@ -245,7 +251,7 @@ static struct ctl_table_header *irda_table_header;
245 */ 251 */
246int __init irda_sysctl_register(void) 252int __init irda_sysctl_register(void)
247{ 253{
248 irda_table_header = register_net_sysctl(&init_net, "net/irda", irda_table); 254 irda_table_header = register_sysctl_paths(irda_path, irda_table);
249 if (!irda_table_header) 255 if (!irda_table_header)
250 return -ENOMEM; 256 return -ENOMEM;
251 257
@@ -260,7 +266,7 @@ int __init irda_sysctl_register(void)
260 */ 266 */
261void irda_sysctl_unregister(void) 267void irda_sysctl_unregister(void)
262{ 268{
263 unregister_net_sysctl_table(irda_table_header); 269 unregister_sysctl_table(irda_table_header);
264} 270}
265 271
266 272
diff --git a/net/irda/irttp.c b/net/irda/irttp.c
index ae43c62f904..285ccd623ae 100644
--- a/net/irda/irttp.c
+++ b/net/irda/irttp.c
@@ -29,7 +29,6 @@
29#include <linux/fs.h> 29#include <linux/fs.h>
30#include <linux/seq_file.h> 30#include <linux/seq_file.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/export.h>
33 32
34#include <asm/byteorder.h> 33#include <asm/byteorder.h>
35#include <asm/unaligned.h> 34#include <asm/unaligned.h>
@@ -440,8 +439,7 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify)
440 */ 439 */
441 lsap = irlmp_open_lsap(stsap_sel, &ttp_notify, 0); 440 lsap = irlmp_open_lsap(stsap_sel, &ttp_notify, 0);
442 if (lsap == NULL) { 441 if (lsap == NULL) {
443 IRDA_DEBUG(0, "%s: unable to allocate LSAP!!\n", __func__); 442 IRDA_WARNING("%s: unable to allocate LSAP!!\n", __func__);
444 __irttp_close_tsap(self);
445 return NULL; 443 return NULL;
446 } 444 }
447 445
@@ -1462,12 +1460,14 @@ struct tsap_cb *irttp_dup(struct tsap_cb *orig, void *instance)
1462 } 1460 }
1463 1461
1464 /* Allocate a new instance */ 1462 /* Allocate a new instance */
1465 new = kmemdup(orig, sizeof(struct tsap_cb), GFP_ATOMIC); 1463 new = kmalloc(sizeof(struct tsap_cb), GFP_ATOMIC);
1466 if (!new) { 1464 if (!new) {
1467 IRDA_DEBUG(0, "%s(), unable to kmalloc\n", __func__); 1465 IRDA_DEBUG(0, "%s(), unable to kmalloc\n", __func__);
1468 spin_unlock_irqrestore(&irttp->tsaps->hb_spinlock, flags); 1466 spin_unlock_irqrestore(&irttp->tsaps->hb_spinlock, flags);
1469 return NULL; 1467 return NULL;
1470 } 1468 }
1469 /* Dup */
1470 memcpy(new, orig, sizeof(struct tsap_cb));
1471 spin_lock_init(&new->lock); 1471 spin_lock_init(&new->lock);
1472 1472
1473 /* We don't need the old instance any more */ 1473 /* We don't need the old instance any more */
diff --git a/net/irda/qos.c b/net/irda/qos.c
index 798ffd9a705..4369f7f41bc 100644
--- a/net/irda/qos.c
+++ b/net/irda/qos.c
@@ -30,8 +30,6 @@
30 * 30 *
31 ********************************************************************/ 31 ********************************************************************/
32 32
33#include <linux/export.h>
34
35#include <asm/byteorder.h> 33#include <asm/byteorder.h>
36 34
37#include <net/irda/irda.h> 35#include <net/irda/irda.h>
diff --git a/net/irda/timer.c b/net/irda/timer.c
index 1d552b3946f..f418cb2ad49 100644
--- a/net/irda/timer.c
+++ b/net/irda/timer.c
@@ -24,6 +24,7 @@
24 * 24 *
25 ********************************************************************/ 25 ********************************************************************/
26 26
27#include <asm/system.h>
27#include <linux/delay.h> 28#include <linux/delay.h>
28 29
29#include <net/irda/timer.h> 30#include <net/irda/timer.h>