patch-2.4.20 linux-2.4.20/net/irda/ircomm/ircomm_tty.c
Next file: linux-2.4.20/net/irda/ircomm/ircomm_tty_attach.c
Previous file: linux-2.4.20/net/irda/discovery.c
Back to the patch index
Back to the overall index
- Lines: 435
- Date:
Thu Nov 28 15:53:16 2002
- Orig file:
linux-2.4.19/net/irda/ircomm/ircomm_tty.c
- Orig date:
Sun Sep 30 12:26:09 2001
diff -urN linux-2.4.19/net/irda/ircomm/ircomm_tty.c linux-2.4.20/net/irda/ircomm/ircomm_tty.c
@@ -93,7 +93,7 @@
{
ircomm_tty = hashbin_new(HB_LOCAL);
if (ircomm_tty == NULL) {
- ERROR(__FUNCTION__ "(), can't allocate hashbin!\n");
+ ERROR("%s(), can't allocate hashbin!\n", __FUNCTION__);
return -ENOMEM;
}
@@ -136,7 +136,7 @@
driver.read_proc = ircomm_tty_read_proc;
#endif /* CONFIG_PROC_FS */
if (tty_register_driver(&driver)) {
- ERROR(__FUNCTION__ "Couldn't register serial driver\n");
+ ERROR("%s: Couldn't register serial driver\n", __FUNCTION__);
return -1;
}
return 0;
@@ -145,7 +145,7 @@
#ifdef MODULE
static void __ircomm_tty_cleanup(struct ircomm_tty_cb *self)
{
- IRDA_DEBUG(0, __FUNCTION__ "()\n");
+ IRDA_DEBUG(0, "%s()\n", __FUNCTION__);
ASSERT(self != NULL, return;);
ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
@@ -166,11 +166,11 @@
{
int ret;
- IRDA_DEBUG(4, __FUNCTION__"()\n");
+ IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
ret = tty_unregister_driver(&driver);
if (ret) {
- ERROR(__FUNCTION__ "(), failed to unregister driver\n");
+ ERROR("%s, failed to unregister driver\n", __FUNCTION__);
return;
}
@@ -189,14 +189,14 @@
notify_t notify;
int ret;
- IRDA_DEBUG(2, __FUNCTION__ "()\n");
+ IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
ASSERT(self != NULL, return -1;);
ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
/* Already open */
if (self->flags & ASYNC_INITIALIZED) {
- IRDA_DEBUG(2, __FUNCTION__ "(), already open so break out!\n");
+ IRDA_DEBUG(2, "%s(), already open so break out!\n", __FUNCTION__);
return 0;
}
@@ -226,7 +226,7 @@
/* Connect IrCOMM link with remote device */
ret = ircomm_tty_attach_cable(self);
if (ret < 0) {
- ERROR(__FUNCTION__ "(), error attaching cable!\n");
+ ERROR("%s(), error attaching cable!\n", __FUNCTION__);
return ret;
}
@@ -250,7 +250,7 @@
unsigned long flags;
struct tty_struct *tty;
- IRDA_DEBUG(2, __FUNCTION__ "()\n");
+ IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
tty = self->tty;
@@ -282,18 +282,18 @@
return -EBUSY;
self->flags |= ASYNC_NORMAL_ACTIVE;
- IRDA_DEBUG(1, __FUNCTION__ "(), O_NONBLOCK requested!\n");
+ IRDA_DEBUG(1, "%s(), O_NONBLOCK requested!\n", __FUNCTION__);
return 0;
}
if (self->flags & ASYNC_CALLOUT_ACTIVE) {
if (self->normal_termios.c_cflag & CLOCAL) {
- IRDA_DEBUG(1, __FUNCTION__ "(), doing CLOCAL!\n");
+ IRDA_DEBUG(1, "%s(), doing CLOCAL!\n", __FUNCTION__);
do_clocal = 1;
}
} else {
if (tty->termios->c_cflag & CLOCAL) {
- IRDA_DEBUG(1, __FUNCTION__ "(), doing CLOCAL!\n");
+ IRDA_DEBUG(1, "%s(), doing CLOCAL!\n", __FUNCTION__);
do_clocal = 1;
}
}
@@ -390,7 +390,7 @@
int line;
int ret;
- IRDA_DEBUG(2, __FUNCTION__ "()\n");
+ IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
MOD_INC_USE_COUNT;
line = MINOR(tty->device) - tty->driver.minor_start;
@@ -405,7 +405,7 @@
/* No, so make new instance */
self = kmalloc(sizeof(struct ircomm_tty_cb), GFP_KERNEL);
if (self == NULL) {
- ERROR(__FUNCTION__"(), kmalloc failed!\n");
+ ERROR("%s(), kmalloc failed!\n", __FUNCTION__);
MOD_DEC_USE_COUNT;
return -ENOMEM;
}
@@ -417,7 +417,7 @@
self->line = line;
self->tqueue.routine = ircomm_tty_do_softint;
self->tqueue.data = self;
- self->max_header_size = 5;
+ self->max_header_size = IRCOMM_TTY_HDR_UNITIALISED;
self->max_data_size = 64-self->max_header_size;
self->close_delay = 5*HZ/10;
self->closing_wait = 30*HZ;
@@ -443,8 +443,8 @@
tty->driver_data = self;
self->tty = tty;
- IRDA_DEBUG(1, __FUNCTION__"(), %s%d, count = %d\n", tty->driver.name,
- self->line, self->open_count);
+ IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __FUNCTION__,
+ tty->driver.name, self->line, self->open_count);
/* Not really used by us, but lets do it anyway */
self->tty->low_latency = (self->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
@@ -470,9 +470,9 @@
self->service_type = IRCOMM_3_WIRE | IRCOMM_9_WIRE;
self->settings.service_type = IRCOMM_9_WIRE; /* 9 wire as default */
self->settings.dce = IRCOMM_CTS | IRCOMM_CD; /* Default line settings */
- IRDA_DEBUG(2, __FUNCTION__ "(), IrCOMM device\n");
+ IRDA_DEBUG(2, "%s(), IrCOMM device\n", __FUNCTION__);
} else {
- IRDA_DEBUG(2, __FUNCTION__ "(), IrLPT device\n");
+ IRDA_DEBUG(2, "%s(), IrLPT device\n", __FUNCTION__);
self->service_type = IRCOMM_3_WIRE_RAW;
self->settings.service_type = IRCOMM_3_WIRE_RAW; /* Default */
}
@@ -484,9 +484,8 @@
ret = ircomm_tty_block_til_ready(self, filp);
if (ret) {
/* MOD_DEC_USE_COUNT; "info->tty" will cause this? */
- IRDA_DEBUG(2, __FUNCTION__
- "(), returning after block_til_ready with %d\n",
- ret);
+ IRDA_DEBUG(2, "%s(), returning after block_til_ready with %d\n",
+ __FUNCTION__, ret);
return ret;
}
@@ -508,7 +507,7 @@
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
unsigned long flags;
- IRDA_DEBUG(0, __FUNCTION__ "()\n");
+ IRDA_DEBUG(0, "%s()\n", __FUNCTION__);
if (!tty)
return;
@@ -520,7 +519,7 @@
MOD_DEC_USE_COUNT;
restore_flags(flags);
- IRDA_DEBUG(0, __FUNCTION__ "(), returning 1\n");
+ IRDA_DEBUG(0, "%s(), returning 1\n", __FUNCTION__);
return;
}
@@ -535,23 +534,22 @@
* one, we've got real problems, since it means the
* serial port won't be shutdown.
*/
- IRDA_DEBUG(0, __FUNCTION__ "(), bad serial port count; "
+ IRDA_DEBUG(0, "%s(), bad serial port count; "
"tty->count is 1, state->count is %d\n",
- self->open_count);
+ __FUNCTION__, self->open_count);
self->open_count = 1;
}
if (--self->open_count < 0) {
- ERROR(__FUNCTION__
- "(), bad serial port count for ttys%d: %d\n",
- self->line, self->open_count);
+ ERROR("%s(), bad serial port count for ttys%d: %d\n",
+ __FUNCTION__, self->line, self->open_count);
self->open_count = 0;
}
if (self->open_count) {
MOD_DEC_USE_COUNT;
restore_flags(flags);
- IRDA_DEBUG(0, __FUNCTION__ "(), open count > 0\n");
+ IRDA_DEBUG(0, "%s(), open count > 0\n", __FUNCTION__);
return;
}
self->flags |= ASYNC_CLOSING;
@@ -625,7 +623,7 @@
unsigned long flags;
struct sk_buff *skb, *ctrl_skb;
- IRDA_DEBUG(2, __FUNCTION__ "()\n");
+ IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
if (!self || self->magic != IRCOMM_TTY_MAGIC)
return;
@@ -690,12 +688,26 @@
int len = 0;
int size;
- IRDA_DEBUG(2, __FUNCTION__ "(), count=%d, hw_stopped=%d\n", count,
- tty->hw_stopped);
+ IRDA_DEBUG(2, "%s(), count=%d, hw_stopped=%d\n",
+ __FUNCTION__, count, tty->hw_stopped);
ASSERT(self != NULL, return -1;);
ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
+ /* We may receive packets from the TTY even before we have finished
+ * our setup. Not cool.
+ * The problem is that we would allocate a skb with bogus header and
+ * data size, and when adding data to it later we would get
+ * confused.
+ * Better to not accept data until we are properly setup. Use bogus
+ * header size to check that (safest way to detect it).
+ * Jean II */
+ if (self->max_header_size == IRCOMM_TTY_HDR_UNITIALISED) {
+ /* TTY will retry */
+ IRDA_DEBUG(2, __FUNCTION__ "() : not initialised\n");
+ return len;
+ }
+
save_flags(flags);
cli();
@@ -792,8 +804,12 @@
ASSERT(self != NULL, return -1;);
ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
- /* Check if we are allowed to transmit any data */
- if (tty->hw_stopped)
+ /* Check if we are allowed to transmit any data.
+ * hw_stopped is the regular flow control.
+ * max_header_size tells us if the channel is initialised or not.
+ * Jean II */
+ if ((tty->hw_stopped) ||
+ (self->max_header_size == IRCOMM_TTY_HDR_UNITIALISED))
ret = 0;
else {
save_flags(flags);
@@ -804,7 +820,7 @@
ret = self->max_data_size;
restore_flags(flags);
}
- IRDA_DEBUG(2, __FUNCTION__ "(), ret=%d\n", ret);
+ IRDA_DEBUG(2, "%s(), ret=%d\n", __FUNCTION__, ret);
return ret;
}
@@ -820,7 +836,7 @@
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
unsigned long orig_jiffies, poll_time;
- IRDA_DEBUG(2, __FUNCTION__ "()\n");
+ IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
ASSERT(self != NULL, return;);
ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
@@ -852,7 +868,7 @@
{
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
- IRDA_DEBUG(2, __FUNCTION__ "()\n");
+ IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
ASSERT(self != NULL, return;);
ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
@@ -883,7 +899,7 @@
{
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
- IRDA_DEBUG(2, __FUNCTION__ "()\n");
+ IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
ASSERT(self != NULL, return;);
ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
@@ -898,7 +914,7 @@
self->settings.dte |= (IRCOMM_RTS|IRCOMM_DELTA_RTS);
ircomm_param_request(self, IRCOMM_DTE, TRUE);
- IRDA_DEBUG(1, __FUNCTION__"(), FLOW_START\n");
+ IRDA_DEBUG(1, "%s(), FLOW_START\n", __FUNCTION__);
}
ircomm_flow_request(self->ircomm, FLOW_START);
}
@@ -936,7 +952,7 @@
ASSERT(self != NULL, return;);
ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
- IRDA_DEBUG(0, __FUNCTION__ "()\n");
+ IRDA_DEBUG(0, "%s()\n", __FUNCTION__);
if (!(self->flags & ASYNC_INITIALIZED))
return;
@@ -980,7 +996,7 @@
{
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
- IRDA_DEBUG(0, __FUNCTION__"()\n");
+ IRDA_DEBUG(0, "%s()\n", __FUNCTION__);
ASSERT(self != NULL, return;);
ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
@@ -1005,7 +1021,7 @@
*/
static void ircomm_tty_send_xchar(struct tty_struct *tty, char ch)
{
- IRDA_DEBUG(0, __FUNCTION__"(), not impl\n");
+ IRDA_DEBUG(0, "%s(), not impl\n", __FUNCTION__);
}
/*
@@ -1049,7 +1065,7 @@
struct tty_struct *tty;
int status;
- IRDA_DEBUG(0, __FUNCTION__ "()\n");
+ IRDA_DEBUG(0, "%s()\n", __FUNCTION__);
ASSERT(self != NULL, return;);
ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
@@ -1062,17 +1078,15 @@
/*wake_up_interruptible(&self->delta_msr_wait);*/
}
if ((self->flags & ASYNC_CHECK_CD) && (status & IRCOMM_DELTA_CD)) {
- IRDA_DEBUG(2, __FUNCTION__
- "(), ircomm%d CD now %s...\n", self->line,
- (status & IRCOMM_CD) ? "on" : "off");
+ IRDA_DEBUG(2, "%s(), ircomm%d CD now %s...\n",
+ __FUNCTION__, self->line, (status & IRCOMM_CD) ? "on" : "off");
if (status & IRCOMM_CD) {
wake_up_interruptible(&self->open_wait);
} else if (!((self->flags & ASYNC_CALLOUT_ACTIVE) &&
(self->flags & ASYNC_CALLOUT_NOHUP)))
{
- IRDA_DEBUG(2, __FUNCTION__
- "(), Doing serial hangup..\n");
+ IRDA_DEBUG(2, "%s(), Doing serial hangup..\n", __FUNCTION__);
if (tty)
tty_hangup(tty);
@@ -1083,8 +1097,7 @@
if (self->flags & ASYNC_CTS_FLOW) {
if (tty->hw_stopped) {
if (status & IRCOMM_CTS) {
- IRDA_DEBUG(2, __FUNCTION__
- "(), CTS tx start...\n");
+ IRDA_DEBUG(2, "%s(), CTS tx start...\n", __FUNCTION__);
tty->hw_stopped = 0;
/* Wake up processes blocked on open */
@@ -1096,8 +1109,7 @@
}
} else {
if (!(status & IRCOMM_CTS)) {
- IRDA_DEBUG(2, __FUNCTION__
- "(), CTS tx stop...\n");
+ IRDA_DEBUG(2, "%s(), CTS tx stop...\n", __FUNCTION__);
tty->hw_stopped = 1;
}
}
@@ -1115,14 +1127,14 @@
{
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
- IRDA_DEBUG(2, __FUNCTION__"()\n");
+ IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
ASSERT(self != NULL, return -1;);
ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
ASSERT(skb != NULL, return -1;);
if (!self->tty) {
- IRDA_DEBUG(0, __FUNCTION__ "(), no tty!\n");
+ IRDA_DEBUG(0, "%s(), no tty!\n", __FUNCTION__);
dev_kfree_skb(skb);
return 0;
}
@@ -1134,7 +1146,7 @@
* params, we can just as well declare the hardware for running.
*/
if (self->tty->hw_stopped && (self->flow == FLOW_START)) {
- IRDA_DEBUG(0, __FUNCTION__ "(), polling for line settings!\n");
+ IRDA_DEBUG(0, "%s(), polling for line settings!\n", __FUNCTION__);
ircomm_param_request(self, IRCOMM_POLL, TRUE);
/* We can just as well declare the hardware for running */
@@ -1165,7 +1177,7 @@
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
int clen;
- IRDA_DEBUG(4, __FUNCTION__"()\n");
+ IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
ASSERT(self != NULL, return -1;);
ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
@@ -1200,7 +1212,7 @@
switch (cmd) {
case FLOW_START:
- IRDA_DEBUG(2, __FUNCTION__ "(), hw start!\n");
+ IRDA_DEBUG(2, "%s(), hw start!\n", __FUNCTION__);
tty->hw_stopped = 0;
/* ircomm_tty_do_softint will take care of the rest */
@@ -1209,7 +1221,7 @@
break;
default: /* If we get here, something is very wrong, better stop */
case FLOW_STOP:
- IRDA_DEBUG(2, __FUNCTION__ "(), hw stopped!\n");
+ IRDA_DEBUG(2, "%s(), hw stopped!\n", __FUNCTION__);
tty->hw_stopped = 1;
break;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)