Commit 90ce6db3 authored by Martin Dalecki's avatar Martin Dalecki Committed by Linus Torvalds

[PATCH] kill warnings 17/19

irttp.c was infected too.
parent 2a6edab9
...@@ -89,15 +89,15 @@ int __init irttp_init(void) ...@@ -89,15 +89,15 @@ int __init irttp_init(void)
return -ENOMEM; return -ENOMEM;
} }
memset(irttp, 0, sizeof(struct irttp_cb)); memset(irttp, 0, sizeof(struct irttp_cb));
irttp->magic = TTP_MAGIC; irttp->magic = TTP_MAGIC;
irttp->tsaps = hashbin_new(HB_LOCAL); irttp->tsaps = hashbin_new(HB_LOCAL);
if (!irttp->tsaps) { if (!irttp->tsaps) {
ERROR(__FUNCTION__ "(), can't allocate IrTTP hashbin!\n"); ERROR("%s: can't allocate IrTTP hashbin!\n", __FUNCTION__);
return -ENOMEM; return -ENOMEM;
} }
return 0; return 0;
} }
...@@ -108,19 +108,19 @@ int __init irttp_init(void) ...@@ -108,19 +108,19 @@ int __init irttp_init(void)
* *
*/ */
#ifdef MODULE #ifdef MODULE
void irttp_cleanup(void) void irttp_cleanup(void)
{ {
/* Check for main structure */ /* Check for main structure */
ASSERT(irttp != NULL, return;); ASSERT(irttp != NULL, return;);
ASSERT(irttp->magic == TTP_MAGIC, return;); ASSERT(irttp->magic == TTP_MAGIC, return;);
/* /*
* Delete hashbin and close all TSAP instances in it * Delete hashbin and close all TSAP instances in it
*/ */
hashbin_delete(irttp->tsaps, (FREE_FUNC) __irttp_close_tsap); hashbin_delete(irttp->tsaps, (FREE_FUNC) __irttp_close_tsap);
irttp->magic = 0; irttp->magic = 0;
/* De-allocate main structure */ /* De-allocate main structure */
kfree(irttp); kfree(irttp);
...@@ -133,7 +133,7 @@ void irttp_cleanup(void) ...@@ -133,7 +133,7 @@ void irttp_cleanup(void)
/* /*
* Function irttp_start_todo_timer (self, timeout) * Function irttp_start_todo_timer (self, timeout)
* *
* Start todo timer. * Start todo timer.
* *
* Made it more effient and unsensitive to race conditions - Jean II * Made it more effient and unsensitive to race conditions - Jean II
*/ */
...@@ -164,7 +164,7 @@ static void irttp_todo_expired(unsigned long data) ...@@ -164,7 +164,7 @@ static void irttp_todo_expired(unsigned long data)
/* Check that we still exist */ /* Check that we still exist */
if (!self || self->magic != TTP_TSAP_MAGIC) if (!self || self->magic != TTP_TSAP_MAGIC)
return; return;
IRDA_DEBUG(4, __FUNCTION__ "(instance=%p)\n", self); IRDA_DEBUG(4, __FUNCTION__ "(instance=%p)\n", self);
/* Try to make some progress, especially on Tx side - Jean II */ /* Try to make some progress, especially on Tx side - Jean II */
...@@ -185,12 +185,12 @@ static void irttp_todo_expired(unsigned long data) ...@@ -185,12 +185,12 @@ static void irttp_todo_expired(unsigned long data)
} else { } else {
/* Try again later */ /* Try again later */
irttp_start_todo_timer(self, HZ/10); irttp_start_todo_timer(self, HZ/10);
/* No reason to try and close now */ /* No reason to try and close now */
return; return;
} }
} }
/* Check if it's closing time */ /* Check if it's closing time */
if (self->close_pend) if (self->close_pend)
/* Finish cleanup */ /* Finish cleanup */
...@@ -205,20 +205,20 @@ static void irttp_todo_expired(unsigned long data) ...@@ -205,20 +205,20 @@ static void irttp_todo_expired(unsigned long data)
void irttp_flush_queues(struct tsap_cb *self) void irttp_flush_queues(struct tsap_cb *self)
{ {
struct sk_buff* skb; struct sk_buff* skb;
IRDA_DEBUG(4, __FUNCTION__ "()\n"); IRDA_DEBUG(4, __FUNCTION__ "()\n");
ASSERT(self != NULL, return;); ASSERT(self != NULL, return;);
ASSERT(self->magic == TTP_TSAP_MAGIC, return;); ASSERT(self->magic == TTP_TSAP_MAGIC, return;);
/* Deallocate frames waiting to be sent */ /* Deallocate frames waiting to be sent */
while ((skb = skb_dequeue(&self->tx_queue)) != NULL) while ((skb = skb_dequeue(&self->tx_queue)) != NULL)
dev_kfree_skb(skb); dev_kfree_skb(skb);
/* Deallocate received frames */ /* Deallocate received frames */
while ((skb = skb_dequeue(&self->rx_queue)) != NULL) while ((skb = skb_dequeue(&self->rx_queue)) != NULL)
dev_kfree_skb(skb); dev_kfree_skb(skb);
/* Deallocate received fragments */ /* Deallocate received fragments */
while ((skb = skb_dequeue(&self->rx_fragments)) != NULL) while ((skb = skb_dequeue(&self->rx_fragments)) != NULL)
dev_kfree_skb(skb); dev_kfree_skb(skb);
...@@ -235,19 +235,19 @@ static struct sk_buff *irttp_reassemble_skb(struct tsap_cb *self) ...@@ -235,19 +235,19 @@ static struct sk_buff *irttp_reassemble_skb(struct tsap_cb *self)
{ {
struct sk_buff *skb, *frag; struct sk_buff *skb, *frag;
int n = 0; /* Fragment index */ int n = 0; /* Fragment index */
ASSERT(self != NULL, return NULL;); ASSERT(self != NULL, return NULL;);
ASSERT(self->magic == TTP_TSAP_MAGIC, return NULL;); ASSERT(self->magic == TTP_TSAP_MAGIC, return NULL;);
IRDA_DEBUG(2, __FUNCTION__ "(), self->rx_sdu_size=%d\n", IRDA_DEBUG(2, __FUNCTION__ "(), self->rx_sdu_size=%d\n",
self->rx_sdu_size); self->rx_sdu_size);
skb = dev_alloc_skb(TTP_HEADER + self->rx_sdu_size); skb = dev_alloc_skb(TTP_HEADER + self->rx_sdu_size);
if (!skb) if (!skb)
return NULL; return NULL;
/* /*
* Need to reserve space for TTP header in case this skb needs to * Need to reserve space for TTP header in case this skb needs to
* be requeued in case delivery failes * be requeued in case delivery failes
*/ */
skb_reserve(skb, TTP_HEADER); skb_reserve(skb, TTP_HEADER);
...@@ -259,7 +259,7 @@ static struct sk_buff *irttp_reassemble_skb(struct tsap_cb *self) ...@@ -259,7 +259,7 @@ static struct sk_buff *irttp_reassemble_skb(struct tsap_cb *self)
while ((frag = skb_dequeue(&self->rx_fragments)) != NULL) { while ((frag = skb_dequeue(&self->rx_fragments)) != NULL) {
memcpy(skb->data+n, frag->data, frag->len); memcpy(skb->data+n, frag->data, frag->len);
n += frag->len; n += frag->len;
dev_kfree_skb(frag); dev_kfree_skb(frag);
} }
IRDA_DEBUG(2, __FUNCTION__ "(), frame len=%d\n", n); IRDA_DEBUG(2, __FUNCTION__ "(), frame len=%d\n", n);
...@@ -307,13 +307,13 @@ static inline void irttp_fragment_skb(struct tsap_cb *self, ...@@ -307,13 +307,13 @@ static inline void irttp_fragment_skb(struct tsap_cb *self,
skb_reserve(frag, self->max_header_size); skb_reserve(frag, self->max_header_size);
/* Copy data from the original skb into this fragment. */ /* Copy data from the original skb into this fragment. */
memcpy(skb_put(frag, self->max_seg_size), skb->data, memcpy(skb_put(frag, self->max_seg_size), skb->data,
self->max_seg_size); self->max_seg_size);
/* Insert TTP header, with the more bit set */ /* Insert TTP header, with the more bit set */
frame = skb_push(frag, TTP_HEADER); frame = skb_push(frag, TTP_HEADER);
frame[0] = TTP_MORE; frame[0] = TTP_MORE;
/* Hide the copied data from the original skb */ /* Hide the copied data from the original skb */
skb_pull(skb, self->max_seg_size); skb_pull(skb, self->max_seg_size);
...@@ -322,7 +322,7 @@ static inline void irttp_fragment_skb(struct tsap_cb *self, ...@@ -322,7 +322,7 @@ static inline void irttp_fragment_skb(struct tsap_cb *self,
} }
/* Queue what is left of the original skb */ /* Queue what is left of the original skb */
IRDA_DEBUG(2, __FUNCTION__ "(), queuing last segment\n"); IRDA_DEBUG(2, __FUNCTION__ "(), queuing last segment\n");
frame = skb_push(skb, TTP_HEADER); frame = skb_push(skb, TTP_HEADER);
frame[0] = 0x00; /* Clear more bit */ frame[0] = 0x00; /* Clear more bit */
...@@ -337,7 +337,7 @@ static inline void irttp_fragment_skb(struct tsap_cb *self, ...@@ -337,7 +337,7 @@ static inline void irttp_fragment_skb(struct tsap_cb *self,
* will be called both when this parameter needs to be inserted into, and * will be called both when this parameter needs to be inserted into, and
* extracted from the connect frames * extracted from the connect frames
*/ */
static int irttp_param_max_sdu_size(void *instance, irda_param_t *param, static int irttp_param_max_sdu_size(void *instance, irda_param_t *param,
int get) int get)
{ {
struct tsap_cb *self; struct tsap_cb *self;
...@@ -353,7 +353,7 @@ static int irttp_param_max_sdu_size(void *instance, irda_param_t *param, ...@@ -353,7 +353,7 @@ static int irttp_param_max_sdu_size(void *instance, irda_param_t *param,
self->tx_max_sdu_size = param->pv.i; self->tx_max_sdu_size = param->pv.i;
IRDA_DEBUG(1, __FUNCTION__ "(), MaxSduSize=%d\n", param->pv.i); IRDA_DEBUG(1, __FUNCTION__ "(), MaxSduSize=%d\n", param->pv.i);
return 0; return 0;
} }
...@@ -366,7 +366,7 @@ static int irttp_param_max_sdu_size(void *instance, irda_param_t *param, ...@@ -366,7 +366,7 @@ static int irttp_param_max_sdu_size(void *instance, irda_param_t *param,
* *
* Create TSAP connection endpoint, * Create TSAP connection endpoint,
*/ */
struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify) struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify)
{ {
struct tsap_cb *self; struct tsap_cb *self;
struct lsap_cb *lsap; struct lsap_cb *lsap;
...@@ -421,10 +421,10 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify) ...@@ -421,10 +421,10 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify)
*/ */
lsap = irlmp_open_lsap(stsap_sel, &ttp_notify, 0); lsap = irlmp_open_lsap(stsap_sel, &ttp_notify, 0);
if (lsap == NULL) { if (lsap == NULL) {
WARNING(__FUNCTION__ "(), unable to allocate LSAP!!\n"); WARNING("%s: unable to allocate LSAP!!\n", __FUNCTION__);
return NULL; return NULL;
} }
/* /*
* If user specified LSAP_ANY as source TSAP selector, then IrLMP * If user specified LSAP_ANY as source TSAP selector, then IrLMP
* will replace it with whatever source selector which is free, so * will replace it with whatever source selector which is free, so
...@@ -443,7 +443,7 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify) ...@@ -443,7 +443,7 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify)
else else
self->initial_credit = credit; self->initial_credit = credit;
return self; return self;
} }
/* /*
...@@ -497,7 +497,7 @@ int irttp_close_tsap(struct tsap_cb *self) ...@@ -497,7 +497,7 @@ int irttp_close_tsap(struct tsap_cb *self)
if (self->connected) { if (self->connected) {
/* Check if disconnect is not pending */ /* Check if disconnect is not pending */
if (!test_bit(0, &self->disconnect_pend)) { if (!test_bit(0, &self->disconnect_pend)) {
WARNING(__FUNCTION__ "(), TSAP still connected!\n"); WARNING("%s: TSAP still connected!\n", __FUNCTION__);
irttp_disconnect_request(self, NULL, P_NORMAL); irttp_disconnect_request(self, NULL, P_NORMAL);
} }
self->close_pend = TRUE; self->close_pend = TRUE;
...@@ -505,7 +505,7 @@ int irttp_close_tsap(struct tsap_cb *self) ...@@ -505,7 +505,7 @@ int irttp_close_tsap(struct tsap_cb *self)
return 0; /* Will be back! */ return 0; /* Will be back! */
} }
tsap = hashbin_remove(irttp->tsaps, (int) self, NULL); tsap = hashbin_remove(irttp->tsaps, (int) self, NULL);
ASSERT(tsap == self, return -1;); ASSERT(tsap == self, return -1;);
...@@ -527,7 +527,7 @@ int irttp_close_tsap(struct tsap_cb *self) ...@@ -527,7 +527,7 @@ int irttp_close_tsap(struct tsap_cb *self)
* Send unreliable data on this TSAP * Send unreliable data on this TSAP
* *
*/ */
int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb) int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb)
{ {
ASSERT(self != NULL, return -1;); ASSERT(self != NULL, return -1;);
ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;); ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;);
...@@ -540,12 +540,12 @@ int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb) ...@@ -540,12 +540,12 @@ int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb)
IRDA_DEBUG(1, __FUNCTION__ "(), No data, or not connected\n"); IRDA_DEBUG(1, __FUNCTION__ "(), No data, or not connected\n");
return -1; return -1;
} }
if (skb->len > self->max_seg_size) { if (skb->len > self->max_seg_size) {
IRDA_DEBUG(1, __FUNCTION__ "(), UData is to large for IrLAP!\n"); IRDA_DEBUG(1, __FUNCTION__ "(), UData is to large for IrLAP!\n");
return -1; return -1;
} }
irlmp_udata_request(self->lsap, skb); irlmp_udata_request(self->lsap, skb);
self->stats.tx_packets++; self->stats.tx_packets++;
...@@ -555,10 +555,10 @@ int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb) ...@@ -555,10 +555,10 @@ int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb)
/* /*
* Function irttp_data_request (handle, skb) * Function irttp_data_request (handle, skb)
* *
* Queue frame for transmission. If SAR is enabled, fragement the frame * Queue frame for transmission. If SAR is enabled, fragement the frame
* and queue the fragments for transmission * and queue the fragments for transmission
*/ */
int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb) int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb)
{ {
__u8 *frame; __u8 *frame;
...@@ -571,33 +571,33 @@ int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb) ...@@ -571,33 +571,33 @@ int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb)
/* Check that nothing bad happens */ /* Check that nothing bad happens */
if ((skb->len == 0) || (!self->connected)) { if ((skb->len == 0) || (!self->connected)) {
WARNING(__FUNCTION__ "(), No data, or not connected\n"); WARNING("%s: No data, or not connected\n", __FUNCTION__);
return -ENOTCONN; return -ENOTCONN;
} }
/* /*
* Check if SAR is disabled, and the frame is larger than what fits * Check if SAR is disabled, and the frame is larger than what fits
* inside an IrLAP frame * inside an IrLAP frame
*/ */
if ((self->tx_max_sdu_size == 0) && (skb->len > self->max_seg_size)) { if ((self->tx_max_sdu_size == 0) && (skb->len > self->max_seg_size)) {
ERROR(__FUNCTION__ ERROR("%s: SAR disabled, and data is to large for IrLAP!\n",
"(), SAR disabled, and data is to large for IrLAP!\n"); __FUNCTION__);
return -EMSGSIZE; return -EMSGSIZE;
} }
/* /*
* Check if SAR is enabled, and the frame is larger than the * Check if SAR is enabled, and the frame is larger than the
* TxMaxSduSize * TxMaxSduSize
*/ */
if ((self->tx_max_sdu_size != 0) && if ((self->tx_max_sdu_size != 0) &&
(self->tx_max_sdu_size != TTP_SAR_UNBOUND) && (self->tx_max_sdu_size != TTP_SAR_UNBOUND) &&
(skb->len > self->tx_max_sdu_size)) (skb->len > self->tx_max_sdu_size))
{ {
ERROR(__FUNCTION__ "(), SAR enabled, " ERROR("%s: SAR enabled, but data is larger than TxMaxSduSize!\n",
"but data is larger than TxMaxSduSize!\n"); __FUNCTION__);
return -EMSGSIZE; return -EMSGSIZE;
} }
/* /*
* Check if transmit queue is full * Check if transmit queue is full
*/ */
if (skb_queue_len(&self->tx_queue) >= TTP_TX_MAX_QUEUE) { if (skb_queue_len(&self->tx_queue) >= TTP_TX_MAX_QUEUE) {
...@@ -610,14 +610,14 @@ int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb) ...@@ -610,14 +610,14 @@ int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb)
* to requeue the packet in the client code - Jean II */ * to requeue the packet in the client code - Jean II */
return -ENOBUFS; return -ENOBUFS;
} }
/* Queue frame, or queue frame segments */ /* Queue frame, or queue frame segments */
if ((self->tx_max_sdu_size == 0) || (skb->len < self->max_seg_size)) { if ((self->tx_max_sdu_size == 0) || (skb->len < self->max_seg_size)) {
/* Queue frame */ /* Queue frame */
ASSERT(skb_headroom(skb) >= TTP_HEADER, return -1;); ASSERT(skb_headroom(skb) >= TTP_HEADER, return -1;);
frame = skb_push(skb, TTP_HEADER); frame = skb_push(skb, TTP_HEADER);
frame[0] = 0x00; /* Clear more bit */ frame[0] = 0x00; /* Clear more bit */
skb_queue_tail(&self->tx_queue, skb); skb_queue_tail(&self->tx_queue, skb);
} else { } else {
/* /*
...@@ -630,11 +630,11 @@ int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb) ...@@ -630,11 +630,11 @@ int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb)
} }
/* Check if we can accept more data from client */ /* Check if we can accept more data from client */
if ((!self->tx_sdu_busy) && if ((!self->tx_sdu_busy) &&
(skb_queue_len(&self->tx_queue) > TTP_TX_HIGH_THRESHOLD)) { (skb_queue_len(&self->tx_queue) > TTP_TX_HIGH_THRESHOLD)) {
/* Tx queue filling up, so stop client. */ /* Tx queue filling up, so stop client. */
if (self->notify.flow_indication) { if (self->notify.flow_indication) {
self->notify.flow_indication(self->notify.instance, self->notify.flow_indication(self->notify.instance,
self, FLOW_STOP); self, FLOW_STOP);
} }
/* self->tx_sdu_busy is the state of the client. /* self->tx_sdu_busy is the state of the client.
...@@ -646,7 +646,7 @@ int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb) ...@@ -646,7 +646,7 @@ int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb)
* Jean II */ * Jean II */
self->tx_sdu_busy = TRUE; self->tx_sdu_busy = TRUE;
} }
/* Try to make some progress */ /* Try to make some progress */
irttp_run_tx_queue(self); irttp_run_tx_queue(self);
...@@ -659,7 +659,7 @@ int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb) ...@@ -659,7 +659,7 @@ int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb)
* Transmit packets queued for transmission (if possible) * Transmit packets queued for transmission (if possible)
* *
*/ */
static void irttp_run_tx_queue(struct tsap_cb *self) static void irttp_run_tx_queue(struct tsap_cb *self)
{ {
struct sk_buff *skb; struct sk_buff *skb;
unsigned long flags; unsigned long flags;
...@@ -680,7 +680,7 @@ static void irttp_run_tx_queue(struct tsap_cb *self) ...@@ -680,7 +680,7 @@ static void irttp_run_tx_queue(struct tsap_cb *self)
(skb = skb_dequeue(&self->tx_queue))) (skb = skb_dequeue(&self->tx_queue)))
{ {
/* /*
* Since we can transmit and receive frames concurrently, * Since we can transmit and receive frames concurrently,
* the code below is a critical region and we must assure that * the code below is a critical region and we must assure that
* nobody messes with the credits while we update them. * nobody messes with the credits while we update them.
*/ */
...@@ -688,7 +688,7 @@ static void irttp_run_tx_queue(struct tsap_cb *self) ...@@ -688,7 +688,7 @@ static void irttp_run_tx_queue(struct tsap_cb *self)
n = self->avail_credit; n = self->avail_credit;
self->avail_credit = 0; self->avail_credit = 0;
/* Only room for 127 credits in frame */ /* Only room for 127 credits in frame */
if (n > 127) { if (n > 127) {
self->avail_credit = n-127; self->avail_credit = n-127;
...@@ -699,19 +699,19 @@ static void irttp_run_tx_queue(struct tsap_cb *self) ...@@ -699,19 +699,19 @@ static void irttp_run_tx_queue(struct tsap_cb *self)
spin_unlock_irqrestore(&self->lock, flags); spin_unlock_irqrestore(&self->lock, flags);
/* /*
* More bit must be set by the data_request() or fragment() * More bit must be set by the data_request() or fragment()
* functions * functions
*/ */
skb->data[0] |= (n & 0x7f); skb->data[0] |= (n & 0x7f);
/* Detach from socket. /* Detach from socket.
* The current skb has a reference to the socket that sent * The current skb has a reference to the socket that sent
* it (skb->sk). When we pass it to IrLMP, the skb will be * it (skb->sk). When we pass it to IrLMP, the skb will be
* stored in in IrLAP (self->wx_list). When we are within * stored in in IrLAP (self->wx_list). When we are within
* IrLAP, we loose the notion of socket, so we should not * IrLAP, we loose the notion of socket, so we should not
* have a reference to a socket. So, we drop it here. * have a reference to a socket. So, we drop it here.
* *
* Why does it matter ? * Why does it matter ?
* When the skb is freed (kfree_skb), if it is associated * When the skb is freed (kfree_skb), if it is associated
* with a socket, it release buffer space on the socket * with a socket, it release buffer space on the socket
...@@ -740,7 +740,7 @@ static void irttp_run_tx_queue(struct tsap_cb *self) ...@@ -740,7 +740,7 @@ static void irttp_run_tx_queue(struct tsap_cb *self)
* to client. That's ok, this test will be true not too often * to client. That's ok, this test will be true not too often
* (max once per LAP window) and we are called from places * (max once per LAP window) and we are called from places
* where we can spend a bit of time doing stuff. - Jean II */ * where we can spend a bit of time doing stuff. - Jean II */
if ((self->tx_sdu_busy) && if ((self->tx_sdu_busy) &&
(skb_queue_len(&self->tx_queue) < TTP_TX_LOW_THRESHOLD) && (skb_queue_len(&self->tx_queue) < TTP_TX_LOW_THRESHOLD) &&
(!self->close_pend)) (!self->close_pend))
{ {
...@@ -764,16 +764,16 @@ static void irttp_run_tx_queue(struct tsap_cb *self) ...@@ -764,16 +764,16 @@ static void irttp_run_tx_queue(struct tsap_cb *self)
* Send a dataless flowdata TTP-PDU and give available credit to peer * Send a dataless flowdata TTP-PDU and give available credit to peer
* TSAP * TSAP
*/ */
static inline void irttp_give_credit(struct tsap_cb *self) static inline void irttp_give_credit(struct tsap_cb *self)
{ {
struct sk_buff *tx_skb = NULL; struct sk_buff *tx_skb = NULL;
unsigned long flags; unsigned long flags;
int n; int n;
ASSERT(self != NULL, return;); ASSERT(self != NULL, return;);
ASSERT(self->magic == TTP_TSAP_MAGIC, return;); ASSERT(self->magic == TTP_TSAP_MAGIC, return;);
IRDA_DEBUG(4, __FUNCTION__ "() send=%d,avail=%d,remote=%d\n", IRDA_DEBUG(4, __FUNCTION__ "() send=%d,avail=%d,remote=%d\n",
self->send_credit, self->avail_credit, self->remote_credit); self->send_credit, self->avail_credit, self->remote_credit);
/* Give credit to peer */ /* Give credit to peer */
...@@ -785,7 +785,7 @@ static inline void irttp_give_credit(struct tsap_cb *self) ...@@ -785,7 +785,7 @@ static inline void irttp_give_credit(struct tsap_cb *self)
skb_reserve(tx_skb, self->max_header_size); skb_reserve(tx_skb, self->max_header_size);
/* /*
* Since we can transmit and receive frames concurrently, * Since we can transmit and receive frames concurrently,
* the code below is a critical region and we must assure that * the code below is a critical region and we must assure that
* nobody messes with the credits while we update them. * nobody messes with the credits while we update them.
*/ */
...@@ -793,7 +793,7 @@ static inline void irttp_give_credit(struct tsap_cb *self) ...@@ -793,7 +793,7 @@ static inline void irttp_give_credit(struct tsap_cb *self)
n = self->avail_credit; n = self->avail_credit;
self->avail_credit = 0; self->avail_credit = 0;
/* Only space for 127 credits in frame */ /* Only space for 127 credits in frame */
if (n > 127) { if (n > 127) {
self->avail_credit = n - 127; self->avail_credit = n - 127;
...@@ -805,7 +805,7 @@ static inline void irttp_give_credit(struct tsap_cb *self) ...@@ -805,7 +805,7 @@ static inline void irttp_give_credit(struct tsap_cb *self)
skb_put(tx_skb, 1); skb_put(tx_skb, 1);
tx_skb->data[0] = (__u8) (n & 0x7f); tx_skb->data[0] = (__u8) (n & 0x7f);
irlmp_data_request(self->lsap, tx_skb); irlmp_data_request(self->lsap, tx_skb);
self->stats.tx_packets++; self->stats.tx_packets++;
} }
...@@ -816,8 +816,8 @@ static inline void irttp_give_credit(struct tsap_cb *self) ...@@ -816,8 +816,8 @@ static inline void irttp_give_credit(struct tsap_cb *self)
* Received some unit-data (unreliable) * Received some unit-data (unreliable)
* *
*/ */
static int irttp_udata_indication(void *instance, void *sap, static int irttp_udata_indication(void *instance, void *sap,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct tsap_cb *self; struct tsap_cb *self;
...@@ -843,10 +843,10 @@ static int irttp_udata_indication(void *instance, void *sap, ...@@ -843,10 +843,10 @@ static int irttp_udata_indication(void *instance, void *sap,
/* /*
* Function irttp_data_indication (instance, sap, skb) * Function irttp_data_indication (instance, sap, skb)
* *
* Receive segment from IrLMP. * Receive segment from IrLMP.
* *
*/ */
static int irttp_data_indication(void *instance, void *sap, static int irttp_data_indication(void *instance, void *sap,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct tsap_cb *self; struct tsap_cb *self;
...@@ -860,7 +860,7 @@ static int irttp_data_indication(void *instance, void *sap, ...@@ -860,7 +860,7 @@ static int irttp_data_indication(void *instance, void *sap,
self->stats.rx_packets++; self->stats.rx_packets++;
/* Deal with inbound credit /* Deal with inbound credit
* Since we can transmit and receive frames concurrently, * Since we can transmit and receive frames concurrently,
* the code below is a critical region and we must assure that * the code below is a critical region and we must assure that
* nobody messes with the credits while we update them. * nobody messes with the credits while we update them.
*/ */
...@@ -870,12 +870,12 @@ static int irttp_data_indication(void *instance, void *sap, ...@@ -870,12 +870,12 @@ static int irttp_data_indication(void *instance, void *sap,
self->remote_credit--; self->remote_credit--;
spin_unlock_irqrestore(&self->lock, flags); spin_unlock_irqrestore(&self->lock, flags);
/* /*
* Data or dataless packet? Dataless frames contains only the * Data or dataless packet? Dataless frames contains only the
* TTP_HEADER. * TTP_HEADER.
*/ */
if (skb->len > 1) { if (skb->len > 1) {
/* /*
* We don't remove the TTP header, since we must preserve the * We don't remove the TTP header, since we must preserve the
* more bit, so the defragment routing knows what to do * more bit, so the defragment routing knows what to do
*/ */
...@@ -904,7 +904,7 @@ static int irttp_data_indication(void *instance, void *sap, ...@@ -904,7 +904,7 @@ static int irttp_data_indication(void *instance, void *sap,
* to miss the next Tx window. The todo timer may take * to miss the next Tx window. The todo timer may take
* a while before it's run... - Jean II */ * a while before it's run... - Jean II */
/* /*
* If the peer device has given us some credits and we didn't have * If the peer device has given us some credits and we didn't have
* anyone from before, then we need to shedule the tx queue. * anyone from before, then we need to shedule the tx queue.
* We need to do that because our Tx have stopped (so we may not * We need to do that because our Tx have stopped (so we may not
...@@ -936,15 +936,15 @@ void irttp_status_indication(void *instance, ...@@ -936,15 +936,15 @@ void irttp_status_indication(void *instance,
IRDA_DEBUG(4, __FUNCTION__ "()\n"); IRDA_DEBUG(4, __FUNCTION__ "()\n");
self = (struct tsap_cb *) instance; self = (struct tsap_cb *) instance;
ASSERT(self != NULL, return;); ASSERT(self != NULL, return;);
ASSERT(self->magic == TTP_TSAP_MAGIC, return;); ASSERT(self->magic == TTP_TSAP_MAGIC, return;);
/* /*
* Inform service user if he has requested it * Inform service user if he has requested it
*/ */
if (self->notify.status_indication != NULL) if (self->notify.status_indication != NULL)
self->notify.status_indication(self->notify.instance, self->notify.status_indication(self->notify.instance,
link, lock); link, lock);
else else
IRDA_DEBUG(2, __FUNCTION__ "(), no handler\n"); IRDA_DEBUG(2, __FUNCTION__ "(), no handler\n");
...@@ -961,10 +961,10 @@ void irttp_flow_indication(void *instance, void *sap, LOCAL_FLOW flow) ...@@ -961,10 +961,10 @@ void irttp_flow_indication(void *instance, void *sap, LOCAL_FLOW flow)
struct tsap_cb *self; struct tsap_cb *self;
self = (struct tsap_cb *) instance; self = (struct tsap_cb *) instance;
ASSERT(self != NULL, return;); ASSERT(self != NULL, return;);
ASSERT(self->magic == TTP_TSAP_MAGIC, return;); ASSERT(self->magic == TTP_TSAP_MAGIC, return;);
IRDA_DEBUG(4, __FUNCTION__ "(instance=%p)\n", self); IRDA_DEBUG(4, __FUNCTION__ "(instance=%p)\n", self);
/* We are "polled" directly from LAP, and the LAP want to fill /* We are "polled" directly from LAP, and the LAP want to fill
...@@ -998,7 +998,7 @@ void irttp_flow_indication(void *instance, void *sap, LOCAL_FLOW flow) ...@@ -998,7 +998,7 @@ void irttp_flow_indication(void *instance, void *sap, LOCAL_FLOW flow)
* Function irttp_flow_request (self, command) * Function irttp_flow_request (self, command)
* *
* This funtion could be used by the upper layers to tell IrTTP to stop * This funtion could be used by the upper layers to tell IrTTP to stop
* delivering frames if the receive queues are starting to get full, or * delivering frames if the receive queues are starting to get full, or
* to tell IrTTP to start delivering frames again. * to tell IrTTP to start delivering frames again.
*/ */
void irttp_flow_request(struct tsap_cb *self, LOCAL_FLOW flow) void irttp_flow_request(struct tsap_cb *self, LOCAL_FLOW flow)
...@@ -1016,7 +1016,7 @@ void irttp_flow_request(struct tsap_cb *self, LOCAL_FLOW flow) ...@@ -1016,7 +1016,7 @@ void irttp_flow_request(struct tsap_cb *self, LOCAL_FLOW flow)
case FLOW_START: case FLOW_START:
IRDA_DEBUG(1, __FUNCTION__ "(), flow start\n"); IRDA_DEBUG(1, __FUNCTION__ "(), flow start\n");
self->rx_sdu_busy = FALSE; self->rx_sdu_busy = FALSE;
/* Client say he can accept more data, try to free our /* Client say he can accept more data, try to free our
* queues ASAP - Jean II */ * queues ASAP - Jean II */
irttp_run_rx_queue(self); irttp_run_rx_queue(self);
...@@ -1026,42 +1026,42 @@ void irttp_flow_request(struct tsap_cb *self, LOCAL_FLOW flow) ...@@ -1026,42 +1026,42 @@ void irttp_flow_request(struct tsap_cb *self, LOCAL_FLOW flow)
IRDA_DEBUG(1, __FUNCTION__ "(), Unknown flow command!\n"); IRDA_DEBUG(1, __FUNCTION__ "(), Unknown flow command!\n");
} }
} }
/* /*
* Function irttp_connect_request (self, dtsap_sel, daddr, qos) * Function irttp_connect_request (self, dtsap_sel, daddr, qos)
* *
* Try to connect to remote destination TSAP selector * Try to connect to remote destination TSAP selector
* *
*/ */
int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel, int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
__u32 saddr, __u32 daddr, __u32 saddr, __u32 daddr,
struct qos_info *qos, __u32 max_sdu_size, struct qos_info *qos, __u32 max_sdu_size,
struct sk_buff *userdata) struct sk_buff *userdata)
{ {
struct sk_buff *skb; struct sk_buff *skb;
__u8 *frame; __u8 *frame;
__u8 n; __u8 n;
IRDA_DEBUG(4, __FUNCTION__ "(), max_sdu_size=%d\n", max_sdu_size); IRDA_DEBUG(4, __FUNCTION__ "(), max_sdu_size=%d\n", max_sdu_size);
ASSERT(self != NULL, return -EBADR;); ASSERT(self != NULL, return -EBADR;);
ASSERT(self->magic == TTP_TSAP_MAGIC, return -EBADR;); ASSERT(self->magic == TTP_TSAP_MAGIC, return -EBADR;);
if (self->connected) if (self->connected)
return -EISCONN; return -EISCONN;
/* Any userdata supplied? */ /* Any userdata supplied? */
if (userdata == NULL) { if (userdata == NULL) {
skb = dev_alloc_skb(64); skb = dev_alloc_skb(64);
if (!skb) if (!skb)
return -ENOMEM; return -ENOMEM;
/* Reserve space for MUX_CONTROL and LAP header */ /* Reserve space for MUX_CONTROL and LAP header */
skb_reserve(skb, TTP_MAX_HEADER); skb_reserve(skb, TTP_MAX_HEADER);
} else { } else {
skb = userdata; skb = userdata;
/* /*
* Check that the client has reserved enough space for * Check that the client has reserved enough space for
* headers * headers
*/ */
ASSERT(skb_headroom(userdata) >= TTP_MAX_HEADER, return -1;); ASSERT(skb_headroom(userdata) >= TTP_MAX_HEADER, return -1;);
...@@ -1079,7 +1079,7 @@ int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel, ...@@ -1079,7 +1079,7 @@ int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
self->remote_credit = 0; self->remote_credit = 0;
self->send_credit = 0; self->send_credit = 0;
/* /*
* Give away max 127 credits for now * Give away max 127 credits for now
*/ */
...@@ -1092,41 +1092,41 @@ int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel, ...@@ -1092,41 +1092,41 @@ int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
/* SAR enabled? */ /* SAR enabled? */
if (max_sdu_size > 0) { if (max_sdu_size > 0) {
ASSERT(skb_headroom(skb) >= (TTP_MAX_HEADER + TTP_SAR_HEADER), ASSERT(skb_headroom(skb) >= (TTP_MAX_HEADER + TTP_SAR_HEADER),
return -1;); return -1;);
/* Insert SAR parameters */ /* Insert SAR parameters */
frame = skb_push(skb, TTP_HEADER+TTP_SAR_HEADER); frame = skb_push(skb, TTP_HEADER+TTP_SAR_HEADER);
frame[0] = TTP_PARAMETERS | n; frame[0] = TTP_PARAMETERS | n;
frame[1] = 0x04; /* Length */ frame[1] = 0x04; /* Length */
frame[2] = 0x01; /* MaxSduSize */ frame[2] = 0x01; /* MaxSduSize */
frame[3] = 0x02; /* Value length */ frame[3] = 0x02; /* Value length */
put_unaligned(cpu_to_be16((__u16) max_sdu_size), put_unaligned(cpu_to_be16((__u16) max_sdu_size),
(__u16 *)(frame+4)); (__u16 *)(frame+4));
} else { } else {
/* Insert plain TTP header */ /* Insert plain TTP header */
frame = skb_push(skb, TTP_HEADER); frame = skb_push(skb, TTP_HEADER);
/* Insert initial credit in frame */ /* Insert initial credit in frame */
frame[0] = n & 0x7f; frame[0] = n & 0x7f;
} }
/* Connect with IrLMP. No QoS parameters for now */ /* Connect with IrLMP. No QoS parameters for now */
return irlmp_connect_request(self->lsap, dtsap_sel, saddr, daddr, qos, return irlmp_connect_request(self->lsap, dtsap_sel, saddr, daddr, qos,
skb); skb);
} }
/* /*
* Function irttp_connect_confirm (handle, qos, skb) * Function irttp_connect_confirm (handle, qos, skb)
* *
* Sevice user confirms TSAP connection with peer. * Sevice user confirms TSAP connection with peer.
* *
*/ */
static void irttp_connect_confirm(void *instance, void *sap, static void irttp_connect_confirm(void *instance, void *sap,
struct qos_info *qos, __u32 max_seg_size, struct qos_info *qos, __u32 max_seg_size,
__u8 max_header_size, struct sk_buff *skb) __u8 max_header_size, struct sk_buff *skb)
{ {
struct tsap_cb *self; struct tsap_cb *self;
int parameters; int parameters;
...@@ -1135,7 +1135,7 @@ static void irttp_connect_confirm(void *instance, void *sap, ...@@ -1135,7 +1135,7 @@ static void irttp_connect_confirm(void *instance, void *sap,
__u8 n; __u8 n;
IRDA_DEBUG(4, __FUNCTION__ "()\n"); IRDA_DEBUG(4, __FUNCTION__ "()\n");
self = (struct tsap_cb *) instance; self = (struct tsap_cb *) instance;
ASSERT(self != NULL, return;); ASSERT(self != NULL, return;);
...@@ -1150,21 +1150,21 @@ static void irttp_connect_confirm(void *instance, void *sap, ...@@ -1150,21 +1150,21 @@ static void irttp_connect_confirm(void *instance, void *sap,
* negotiated QoS for the link. * negotiated QoS for the link.
*/ */
if (qos) { if (qos) {
IRDA_DEBUG(4, "IrTTP, Negotiated BAUD_RATE: %02x\n", IRDA_DEBUG(4, "IrTTP, Negotiated BAUD_RATE: %02x\n",
qos->baud_rate.bits); qos->baud_rate.bits);
IRDA_DEBUG(4, "IrTTP, Negotiated BAUD_RATE: %d bps.\n", IRDA_DEBUG(4, "IrTTP, Negotiated BAUD_RATE: %d bps.\n",
qos->baud_rate.value); qos->baud_rate.value);
} }
n = skb->data[0] & 0x7f; n = skb->data[0] & 0x7f;
IRDA_DEBUG(4, __FUNCTION__ "(), Initial send_credit=%d\n", n); IRDA_DEBUG(4, __FUNCTION__ "(), Initial send_credit=%d\n", n);
self->send_credit = n; self->send_credit = n;
self->tx_max_sdu_size = 0; self->tx_max_sdu_size = 0;
self->connected = TRUE; self->connected = TRUE;
parameters = skb->data[0] & 0x80; parameters = skb->data[0] & 0x80;
ASSERT(skb->len >= TTP_HEADER, return;); ASSERT(skb->len >= TTP_HEADER, return;);
skb_pull(skb, TTP_HEADER); skb_pull(skb, TTP_HEADER);
...@@ -1173,13 +1173,13 @@ static void irttp_connect_confirm(void *instance, void *sap, ...@@ -1173,13 +1173,13 @@ static void irttp_connect_confirm(void *instance, void *sap,
plen = skb->data[0]; plen = skb->data[0];
ret = irda_param_extract_all(self, skb->data+1, ret = irda_param_extract_all(self, skb->data+1,
IRDA_MIN(skb->len-1, plen), IRDA_MIN(skb->len-1, plen),
&param_info); &param_info);
/* Any errors in the parameter list? */ /* Any errors in the parameter list? */
if (ret < 0) { if (ret < 0) {
WARNING(__FUNCTION__ WARNING("%s: error extracting parameters\n",
"(), error extracting parameters\n"); __FUNCTION__);
dev_kfree_skb(skb); dev_kfree_skb(skb);
/* Do not accept this connection attempt */ /* Do not accept this connection attempt */
...@@ -1188,8 +1188,8 @@ static void irttp_connect_confirm(void *instance, void *sap, ...@@ -1188,8 +1188,8 @@ static void irttp_connect_confirm(void *instance, void *sap,
/* Remove parameters */ /* Remove parameters */
skb_pull(skb, IRDA_MIN(skb->len, plen+1)); skb_pull(skb, IRDA_MIN(skb->len, plen+1));
} }
IRDA_DEBUG(4, __FUNCTION__ "() send=%d,avail=%d,remote=%d\n", IRDA_DEBUG(4, __FUNCTION__ "() send=%d,avail=%d,remote=%d\n",
self->send_credit, self->avail_credit, self->remote_credit); self->send_credit, self->avail_credit, self->remote_credit);
IRDA_DEBUG(2, __FUNCTION__ "(), MaxSduSize=%d\n", self->tx_max_sdu_size); IRDA_DEBUG(2, __FUNCTION__ "(), MaxSduSize=%d\n", self->tx_max_sdu_size);
...@@ -1208,8 +1208,8 @@ static void irttp_connect_confirm(void *instance, void *sap, ...@@ -1208,8 +1208,8 @@ static void irttp_connect_confirm(void *instance, void *sap,
* *
*/ */
void irttp_connect_indication(void *instance, void *sap, struct qos_info *qos, void irttp_connect_indication(void *instance, void *sap, struct qos_info *qos,
__u32 max_seg_size, __u8 max_header_size, __u32 max_seg_size, __u8 max_header_size,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct tsap_cb *self; struct tsap_cb *self;
struct lsap_cb *lsap; struct lsap_cb *lsap;
...@@ -1222,7 +1222,7 @@ void irttp_connect_indication(void *instance, void *sap, struct qos_info *qos, ...@@ -1222,7 +1222,7 @@ void irttp_connect_indication(void *instance, void *sap, struct qos_info *qos,
ASSERT(self != NULL, return;); ASSERT(self != NULL, return;);
ASSERT(self->magic == TTP_TSAP_MAGIC, return;); ASSERT(self->magic == TTP_TSAP_MAGIC, return;);
ASSERT(skb != NULL, return;); ASSERT(skb != NULL, return;);
lsap = (struct lsap_cb *) sap; lsap = (struct lsap_cb *) sap;
...@@ -1238,7 +1238,7 @@ void irttp_connect_indication(void *instance, void *sap, struct qos_info *qos, ...@@ -1238,7 +1238,7 @@ void irttp_connect_indication(void *instance, void *sap, struct qos_info *qos,
self->send_credit = n; self->send_credit = n;
self->tx_max_sdu_size = 0; self->tx_max_sdu_size = 0;
parameters = skb->data[0] & 0x80; parameters = skb->data[0] & 0x80;
ASSERT(skb->len >= TTP_HEADER, return;); ASSERT(skb->len >= TTP_HEADER, return;);
...@@ -1246,17 +1246,17 @@ void irttp_connect_indication(void *instance, void *sap, struct qos_info *qos, ...@@ -1246,17 +1246,17 @@ void irttp_connect_indication(void *instance, void *sap, struct qos_info *qos,
if (parameters) { if (parameters) {
plen = skb->data[0]; plen = skb->data[0];
ret = irda_param_extract_all(self, skb->data+1, ret = irda_param_extract_all(self, skb->data+1,
IRDA_MIN(skb->len-1, plen), IRDA_MIN(skb->len-1, plen),
&param_info); &param_info);
/* Any errors in the parameter list? */ /* Any errors in the parameter list? */
if (ret < 0) { if (ret < 0) {
WARNING(__FUNCTION__ WARNING("%s: error extracting parameters\n",
"(), error extracting parameters\n"); __FUNCTION__);
dev_kfree_skb(skb); dev_kfree_skb(skb);
/* Do not accept this connection attempt */ /* Do not accept this connection attempt */
return; return;
} }
...@@ -1266,8 +1266,8 @@ void irttp_connect_indication(void *instance, void *sap, struct qos_info *qos, ...@@ -1266,8 +1266,8 @@ void irttp_connect_indication(void *instance, void *sap, struct qos_info *qos,
} }
if (self->notify.connect_indication) { if (self->notify.connect_indication) {
self->notify.connect_indication(self->notify.instance, self, self->notify.connect_indication(self->notify.instance, self,
qos, self->tx_max_sdu_size, qos, self->tx_max_sdu_size,
self->max_header_size, skb); self->max_header_size, skb);
} else } else
dev_kfree_skb(skb); dev_kfree_skb(skb);
...@@ -1278,9 +1278,9 @@ void irttp_connect_indication(void *instance, void *sap, struct qos_info *qos, ...@@ -1278,9 +1278,9 @@ void irttp_connect_indication(void *instance, void *sap, struct qos_info *qos,
* *
* Service user is accepting the connection, just pass it down to * Service user is accepting the connection, just pass it down to
* IrLMP! * IrLMP!
* *
*/ */
int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size, int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
struct sk_buff *userdata) struct sk_buff *userdata)
{ {
struct sk_buff *skb; struct sk_buff *skb;
...@@ -1291,9 +1291,9 @@ int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size, ...@@ -1291,9 +1291,9 @@ int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
ASSERT(self != NULL, return -1;); ASSERT(self != NULL, return -1;);
ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;); ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;);
IRDA_DEBUG(4, __FUNCTION__ "(), Source TSAP selector=%02x\n", IRDA_DEBUG(4, __FUNCTION__ "(), Source TSAP selector=%02x\n",
self->stsap_sel); self->stsap_sel);
/* Any userdata supplied? */ /* Any userdata supplied? */
if (userdata == NULL) { if (userdata == NULL) {
skb = dev_alloc_skb(64); skb = dev_alloc_skb(64);
...@@ -1304,13 +1304,13 @@ int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size, ...@@ -1304,13 +1304,13 @@ int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
skb_reserve(skb, TTP_MAX_HEADER); skb_reserve(skb, TTP_MAX_HEADER);
} else { } else {
skb = userdata; skb = userdata;
/* /*
* Check that the client has reserved enough space for * Check that the client has reserved enough space for
* headers * headers
*/ */
ASSERT(skb_headroom(skb) >= TTP_MAX_HEADER, return -1;); ASSERT(skb_headroom(skb) >= TTP_MAX_HEADER, return -1;);
} }
self->avail_credit = 0; self->avail_credit = 0;
self->remote_credit = 0; self->remote_credit = 0;
self->rx_max_sdu_size = max_sdu_size; self->rx_max_sdu_size = max_sdu_size;
...@@ -1330,30 +1330,30 @@ int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size, ...@@ -1330,30 +1330,30 @@ int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
/* SAR enabled? */ /* SAR enabled? */
if (max_sdu_size > 0) { if (max_sdu_size > 0) {
ASSERT(skb_headroom(skb) >= (TTP_MAX_HEADER+TTP_SAR_HEADER), ASSERT(skb_headroom(skb) >= (TTP_MAX_HEADER+TTP_SAR_HEADER),
return -1;); return -1;);
/* Insert TTP header with SAR parameters */ /* Insert TTP header with SAR parameters */
frame = skb_push(skb, TTP_HEADER+TTP_SAR_HEADER); frame = skb_push(skb, TTP_HEADER+TTP_SAR_HEADER);
frame[0] = TTP_PARAMETERS | n; frame[0] = TTP_PARAMETERS | n;
frame[1] = 0x04; /* Length */ frame[1] = 0x04; /* Length */
/* irda_param_insert(self, IRTTP_MAX_SDU_SIZE, frame+1, */ /* irda_param_insert(self, IRTTP_MAX_SDU_SIZE, frame+1, */
/* TTP_SAR_HEADER, &param_info) */ /* TTP_SAR_HEADER, &param_info) */
frame[2] = 0x01; /* MaxSduSize */ frame[2] = 0x01; /* MaxSduSize */
frame[3] = 0x02; /* Value length */ frame[3] = 0x02; /* Value length */
put_unaligned(cpu_to_be16((__u16) max_sdu_size), put_unaligned(cpu_to_be16((__u16) max_sdu_size),
(__u16 *)(frame+4)); (__u16 *)(frame+4));
} else { } else {
/* Insert TTP header */ /* Insert TTP header */
frame = skb_push(skb, TTP_HEADER); frame = skb_push(skb, TTP_HEADER);
frame[0] = n & 0x7f; frame[0] = n & 0x7f;
} }
ret = irlmp_connect_response(self->lsap, skb); ret = irlmp_connect_response(self->lsap, skb);
return ret; return ret;
...@@ -1365,7 +1365,7 @@ int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size, ...@@ -1365,7 +1365,7 @@ int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
* Duplicate TSAP, can be used by servers to confirm a connection on a * Duplicate TSAP, can be used by servers to confirm a connection on a
* new TSAP so it can keep listening on the old one. * new TSAP so it can keep listening on the old one.
*/ */
struct tsap_cb *irttp_dup(struct tsap_cb *orig, void *instance) struct tsap_cb *irttp_dup(struct tsap_cb *orig, void *instance)
{ {
struct tsap_cb *new; struct tsap_cb *new;
...@@ -1400,11 +1400,11 @@ struct tsap_cb *irttp_dup(struct tsap_cb *orig, void *instance) ...@@ -1400,11 +1400,11 @@ struct tsap_cb *irttp_dup(struct tsap_cb *orig, void *instance)
/* /*
* Function irttp_disconnect_request (self) * Function irttp_disconnect_request (self)
* *
* Close this connection please! If priority is high, the queued data * Close this connection please! If priority is high, the queued data
* segments, if any, will be deallocated first * segments, if any, will be deallocated first
* *
*/ */
int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *userdata, int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *userdata,
int priority) int priority)
{ {
struct sk_buff *skb; struct sk_buff *skb;
...@@ -1441,15 +1441,15 @@ int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *userdata, ...@@ -1441,15 +1441,15 @@ int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *userdata,
*/ */
if (skb_queue_len(&self->tx_queue) > 0) { if (skb_queue_len(&self->tx_queue) > 0) {
if (priority == P_HIGH) { if (priority == P_HIGH) {
/* /*
* No need to send the queued data, if we are * No need to send the queued data, if we are
* disconnecting right now since the data will * disconnecting right now since the data will
* not have any usable connection to be sent on * not have any usable connection to be sent on
*/ */
IRDA_DEBUG(1, __FUNCTION__ "High priority!!()\n" ); IRDA_DEBUG(1, __FUNCTION__ "High priority!!()\n" );
irttp_flush_queues(self); irttp_flush_queues(self);
} else if (priority == P_NORMAL) { } else if (priority == P_NORMAL) {
/* /*
* Must delay disconnect until after all data segments * Must delay disconnect until after all data segments
* have been sent and the tx_queue is empty * have been sent and the tx_queue is empty
*/ */
...@@ -1474,12 +1474,12 @@ int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *userdata, ...@@ -1474,12 +1474,12 @@ int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *userdata,
skb = dev_alloc_skb(64); skb = dev_alloc_skb(64);
if (!skb) if (!skb)
return -ENOMEM; return -ENOMEM;
/* /*
* Reserve space for MUX and LAP header * Reserve space for MUX and LAP header
*/ */
skb_reserve(skb, TTP_MAX_HEADER); skb_reserve(skb, TTP_MAX_HEADER);
userdata = skb; userdata = skb;
} }
ret = irlmp_disconnect_request(self->lsap, userdata); ret = irlmp_disconnect_request(self->lsap, userdata);
...@@ -1496,21 +1496,21 @@ int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *userdata, ...@@ -1496,21 +1496,21 @@ int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *userdata,
* Disconnect indication, TSAP disconnected by peer? * Disconnect indication, TSAP disconnected by peer?
* *
*/ */
void irttp_disconnect_indication(void *instance, void *sap, LM_REASON reason, void irttp_disconnect_indication(void *instance, void *sap, LM_REASON reason,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct tsap_cb *self; struct tsap_cb *self;
IRDA_DEBUG(4, __FUNCTION__ "()\n"); IRDA_DEBUG(4, __FUNCTION__ "()\n");
self = (struct tsap_cb *) instance; self = (struct tsap_cb *) instance;
ASSERT(self != NULL, return;); ASSERT(self != NULL, return;);
ASSERT(self->magic == TTP_TSAP_MAGIC, return;); ASSERT(self->magic == TTP_TSAP_MAGIC, return;);
/* Prevent higher layer to send more data */ /* Prevent higher layer to send more data */
self->connected = FALSE; self->connected = FALSE;
/* Check if client has already tried to close the TSAP */ /* Check if client has already tried to close the TSAP */
if (self->close_pend) { if (self->close_pend) {
/* In this case, the higher layer is probably gone. Don't /* In this case, the higher layer is probably gone. Don't
...@@ -1558,18 +1558,18 @@ void irttp_do_data_indication(struct tsap_cb *self, struct sk_buff *skb) ...@@ -1558,18 +1558,18 @@ void irttp_do_data_indication(struct tsap_cb *self, struct sk_buff *skb)
/* Usually the layer above will notify that it's input queue is /* Usually the layer above will notify that it's input queue is
* starting to get filled by using the flow request, but this may * starting to get filled by using the flow request, but this may
* be difficult, so it can instead just refuse to eat it and just * be difficult, so it can instead just refuse to eat it and just
* give an error back * give an error back
*/ */
if (err == -ENOMEM) { if (err == -ENOMEM) {
IRDA_DEBUG(0, __FUNCTION__ "() requeueing skb!\n"); IRDA_DEBUG(0, __FUNCTION__ "() requeueing skb!\n");
/* Make sure we take a break */ /* Make sure we take a break */
self->rx_sdu_busy = TRUE; self->rx_sdu_busy = TRUE;
/* Need to push the header in again */ /* Need to push the header in again */
skb_push(skb, TTP_HEADER); skb_push(skb, TTP_HEADER);
skb->data[0] = 0x00; /* Make sure MORE bit is cleared */ skb->data[0] = 0x00; /* Make sure MORE bit is cleared */
/* Put skb back on queue */ /* Put skb back on queue */
skb_queue_head(&self->rx_queue, skb); skb_queue_head(&self->rx_queue, skb);
} }
...@@ -1581,18 +1581,18 @@ void irttp_do_data_indication(struct tsap_cb *self, struct sk_buff *skb) ...@@ -1581,18 +1581,18 @@ void irttp_do_data_indication(struct tsap_cb *self, struct sk_buff *skb)
* Check if we have any frames to be transmitted, or if we have any * Check if we have any frames to be transmitted, or if we have any
* available credit to give away. * available credit to give away.
*/ */
void irttp_run_rx_queue(struct tsap_cb *self) void irttp_run_rx_queue(struct tsap_cb *self)
{ {
struct sk_buff *skb; struct sk_buff *skb;
int more = 0; int more = 0;
IRDA_DEBUG(2, __FUNCTION__ "() send=%d,avail=%d,remote=%d\n", IRDA_DEBUG(2, __FUNCTION__ "() send=%d,avail=%d,remote=%d\n",
self->send_credit, self->avail_credit, self->remote_credit); self->send_credit, self->avail_credit, self->remote_credit);
/* Get exclusive access to the rx queue, otherwise don't touch it */ /* Get exclusive access to the rx queue, otherwise don't touch it */
if (irda_lock(&self->rx_queue_lock) == FALSE) if (irda_lock(&self->rx_queue_lock) == FALSE)
return; return;
/* /*
* Reassemble all frames in receive queue and deliver them * Reassemble all frames in receive queue and deliver them
*/ */
...@@ -1606,7 +1606,7 @@ void irttp_run_rx_queue(struct tsap_cb *self) ...@@ -1606,7 +1606,7 @@ void irttp_run_rx_queue(struct tsap_cb *self)
/* Add the length of the remaining data */ /* Add the length of the remaining data */
self->rx_sdu_size += skb->len; self->rx_sdu_size += skb->len;
/* /*
* If SAR is disabled, or user has requested no reassembly * If SAR is disabled, or user has requested no reassembly
* of received fragments then we just deliver them * of received fragments then we just deliver them
* immediately. This can be requested by clients that * immediately. This can be requested by clients that
...@@ -1621,8 +1621,8 @@ void irttp_run_rx_queue(struct tsap_cb *self) ...@@ -1621,8 +1621,8 @@ void irttp_run_rx_queue(struct tsap_cb *self)
/* Check if this is a fragment, and not the last fragment */ /* Check if this is a fragment, and not the last fragment */
if (more) { if (more) {
/* /*
* Queue the fragment if we still are within the * Queue the fragment if we still are within the
* limits of the maximum size of the rx_sdu * limits of the maximum size of the rx_sdu
*/ */
if (self->rx_sdu_size <= self->rx_max_sdu_size) { if (self->rx_sdu_size <= self->rx_max_sdu_size) {
...@@ -1638,32 +1638,32 @@ void irttp_run_rx_queue(struct tsap_cb *self) ...@@ -1638,32 +1638,32 @@ void irttp_run_rx_queue(struct tsap_cb *self)
* This is the last fragment, so time to reassemble! * This is the last fragment, so time to reassemble!
*/ */
if ((self->rx_sdu_size <= self->rx_max_sdu_size) || if ((self->rx_sdu_size <= self->rx_max_sdu_size) ||
(self->rx_max_sdu_size == TTP_SAR_UNBOUND)) (self->rx_max_sdu_size == TTP_SAR_UNBOUND))
{ {
/* /*
* A little optimizing. Only queue the fragment if * A little optimizing. Only queue the fragment if
* there are other fragments. Since if this is the * there are other fragments. Since if this is the
* last and only fragment, there is no need to * last and only fragment, there is no need to
* reassemble :-) * reassemble :-)
*/ */
if (!skb_queue_empty(&self->rx_fragments)) { if (!skb_queue_empty(&self->rx_fragments)) {
skb_queue_tail(&self->rx_fragments, skb_queue_tail(&self->rx_fragments,
skb); skb);
skb = irttp_reassemble_skb(self); skb = irttp_reassemble_skb(self);
} }
/* Now we can deliver the reassembled skb */ /* Now we can deliver the reassembled skb */
irttp_do_data_indication(self, skb); irttp_do_data_indication(self, skb);
} else { } else {
IRDA_DEBUG(1, __FUNCTION__ "(), Truncated frame\n"); IRDA_DEBUG(1, __FUNCTION__ "(), Truncated frame\n");
/* Free the part of the SDU that is too big */ /* Free the part of the SDU that is too big */
dev_kfree_skb(skb); dev_kfree_skb(skb);
/* Deliver only the valid but truncated part of SDU */ /* Deliver only the valid but truncated part of SDU */
skb = irttp_reassemble_skb(self); skb = irttp_reassemble_skb(self);
irttp_do_data_indication(self, skb); irttp_do_data_indication(self, skb);
} }
self->rx_sdu_size = 0; self->rx_sdu_size = 0;
...@@ -1671,7 +1671,7 @@ void irttp_run_rx_queue(struct tsap_cb *self) ...@@ -1671,7 +1671,7 @@ void irttp_run_rx_queue(struct tsap_cb *self)
/* /*
* It's not trivial to keep track of how many credits are available * It's not trivial to keep track of how many credits are available
* by incrementing at each packet, because delivery may fail * by incrementing at each packet, because delivery may fail
* (irttp_do_data_indication() may requeue the frame) and because * (irttp_do_data_indication() may requeue the frame) and because
* we need to take care of fragmentation. * we need to take care of fragmentation.
* We want the other side to send up to initial_credit packets. * We want the other side to send up to initial_credit packets.
...@@ -1721,11 +1721,11 @@ int irttp_proc_read(char *buf, char **start, off_t offset, int len) ...@@ -1721,11 +1721,11 @@ int irttp_proc_read(char *buf, char **start, off_t offset, int len)
struct tsap_cb *self; struct tsap_cb *self;
unsigned long flags; unsigned long flags;
int i = 0; int i = 0;
ASSERT(irttp != NULL, return 0;); ASSERT(irttp != NULL, return 0;);
len = 0; len = 0;
save_flags(flags); save_flags(flags);
cli(); cli();
...@@ -1735,9 +1735,9 @@ int irttp_proc_read(char *buf, char **start, off_t offset, int len) ...@@ -1735,9 +1735,9 @@ int irttp_proc_read(char *buf, char **start, off_t offset, int len)
break; break;
len += sprintf(buf+len, "TSAP %d, ", i++); len += sprintf(buf+len, "TSAP %d, ", i++);
len += sprintf(buf+len, "stsap_sel: %02x, ", len += sprintf(buf+len, "stsap_sel: %02x, ",
self->stsap_sel); self->stsap_sel);
len += sprintf(buf+len, "dtsap_sel: %02x\n", len += sprintf(buf+len, "dtsap_sel: %02x\n",
self->dtsap_sel); self->dtsap_sel);
len += sprintf(buf+len, " connected: %s, ", len += sprintf(buf+len, " connected: %s, ",
self->connected? "TRUE":"FALSE"); self->connected? "TRUE":"FALSE");
...@@ -1751,9 +1751,9 @@ int irttp_proc_read(char *buf, char **start, off_t offset, int len) ...@@ -1751,9 +1751,9 @@ int irttp_proc_read(char *buf, char **start, off_t offset, int len)
self->stats.tx_packets); self->stats.tx_packets);
len += sprintf(buf+len, "rx packets: %ld, ", len += sprintf(buf+len, "rx packets: %ld, ",
self->stats.rx_packets); self->stats.rx_packets);
len += sprintf(buf+len, "tx_queue len: %d ", len += sprintf(buf+len, "tx_queue len: %d ",
skb_queue_len(&self->tx_queue)); skb_queue_len(&self->tx_queue));
len += sprintf(buf+len, "rx_queue len: %d\n", len += sprintf(buf+len, "rx_queue len: %d\n",
skb_queue_len(&self->rx_queue)); skb_queue_len(&self->rx_queue));
len += sprintf(buf+len, " tx_sdu_busy: %s, ", len += sprintf(buf+len, " tx_sdu_busy: %s, ",
self->tx_sdu_busy? "TRUE":"FALSE"); self->tx_sdu_busy? "TRUE":"FALSE");
...@@ -1766,11 +1766,11 @@ int irttp_proc_read(char *buf, char **start, off_t offset, int len) ...@@ -1766,11 +1766,11 @@ int irttp_proc_read(char *buf, char **start, off_t offset, int len)
len += sprintf(buf+len, "rx_max_sdu_size: %d\n", len += sprintf(buf+len, "rx_max_sdu_size: %d\n",
self->rx_max_sdu_size); self->rx_max_sdu_size);
len += sprintf(buf+len, " Used by (%s)\n", len += sprintf(buf+len, " Used by (%s)\n",
self->notify.name); self->notify.name);
len += sprintf(buf+len, "\n"); len += sprintf(buf+len, "\n");
self = (struct tsap_cb *) hashbin_get_next(irttp->tsaps); self = (struct tsap_cb *) hashbin_get_next(irttp->tsaps);
} }
restore_flags(flags); restore_flags(flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment