Hi,
while searching for the problem of not beeing able to connect to
my mobile via ircomm directly after the modules got loaded i stepped
through ircomm_tty_write and was confused by the while loop.
When i understand this stuff correctly one can only have one skb
at a time which means - If i havent got one i can allocate one
up to "MTU" and send this. If i have one i can extend the skb
to incorporate my "new" data just written. So there is
no need to even try to run the loop again as with case 1
we have already copied all data possible to the skb
(up to MTU) and we cant allocate another skb, or case 2
we have already copied all data we can extend the skb
with and we cant allocate another skb.
So i guess this patch is correct (untested) but probably it
might generate worse code ( i can remember seeing whiles with
goto and breaks for better code ). Probably one of the more
knowledged might tell me:
--- ircomm_tty.c Wed Jun 7 23:26:44 2000
+++ ircomm_tty.c.idea Tue Jan 2 19:04:14 2001
@@ -680,7 +680,6 @@
unsigned long flags;
struct sk_buff *skb;
int tailroom = 0;
- int len = 0;
int size;
IRDA_DEBUG(2, __FUNCTION__ "(), count=%d, hw_stopped=%d\n", count,
@@ -703,12 +702,10 @@
* defragment the data and send it out as one packet as soon as
* possible, but at a safer point in time
*/
- while (count) {
- size = count;
-
+ if (count) {
/* Adjust data size to the max data size */
- if (size > self->max_data_size)
- size = self->max_data_size;
+ if (count > self->max_data_size)
+ count = self->max_data_size;
/*
* Do we already have a buffer ready for transmit, or do
@@ -723,14 +720,10 @@
*/
if ((tailroom = (self->max_data_size-skb->len)) > 0) {
/* Adjust data to tailroom */
- if (size > tailroom)
- size = tailroom;
+ if (count > tailroom)
+ count = tailroom;
} else {
- /*
- * Current transmit frame is full, so break
- * out, so we can send it as soon as possible
- */
- break;
+ count = 0;
}
} else {
/* Prepare a full sized frame */
@@ -746,12 +739,9 @@
/* Copy data */
if (from_user)
- copy_from_user(skb_put(skb,size), buf+len, size);
+ copy_from_user(skb_put(skb, count), buf, count);
else
- memcpy(skb_put(skb,size), buf+len, size);
-
- count -= size;
- len += size;
+ memcpy(skb_put(skb,count), buf, count);
}
restore_flags(flags);
@@ -766,7 +756,7 @@
queue_task(&self->tqueue, &tq_immediate);
mark_bh(IMMEDIATE_BH);
- return len;
+ return count;
}
/*
Flo
--
Florian Lohoff [EMAIL PROTECTED] +49-5201-669912
Why is it called "common sense" when nobody seems to have any?
_______________________________________________
Linux-IrDA mailing list - [EMAIL PROTECTED]
http://www.pasta.cs.UiT.No/mailman/listinfo/linux-irda