git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git]
/
net
/
irda
/
irttp.c
diff --git
a/net/irda/irttp.c
b/net/irda/irttp.c
index
d091ccf
..
4703107
100644
(file)
--- a/
net/irda/irttp.c
+++ b/
net/irda/irttp.c
@@
-24,9
+24,9
@@
*
********************************************************************/
*
********************************************************************/
-#include <linux/config.h>
#include <linux/skbuff.h>
#include <linux/init.h>
#include <linux/skbuff.h>
#include <linux/init.h>
+#include <linux/fs.h>
#include <linux/seq_file.h>
#include <asm/byteorder.h>
#include <linux/seq_file.h>
#include <asm/byteorder.h>
@@
-38,7
+38,7
@@
#include <net/irda/parameters.h>
#include <net/irda/irttp.h>
#include <net/irda/parameters.h>
#include <net/irda/irttp.h>
-static struct irttp_cb *irttp
= NULL
;
+static struct irttp_cb *irttp;
static void __irttp_close_tsap(struct tsap_cb *self);
static void __irttp_close_tsap(struct tsap_cb *self);
@@
-86,13
+86,9
@@
static pi_param_info_t param_info = { pi_major_call_table, 1, 0x0f, 4 };
*/
int __init irttp_init(void)
{
*/
int __init irttp_init(void)
{
- /* Initialize the irttp structure. */
- if (irttp == NULL) {
- irttp = kmalloc(sizeof(struct irttp_cb), GFP_KERNEL);
- if (irttp == NULL)
- return -ENOMEM;
- }
- memset(irttp, 0, sizeof(struct irttp_cb));
+ irttp = kzalloc(sizeof(struct irttp_cb), GFP_KERNEL);
+ if (irttp == NULL)
+ return -ENOMEM;
irttp->magic = TTP_MAGIC;
irttp->magic = TTP_MAGIC;
@@
-100,6
+96,7
@@
int __init irttp_init(void)
if (!irttp->tsaps) {
IRDA_ERROR("%s: can't allocate IrTTP hashbin!\n",
__FUNCTION__);
if (!irttp->tsaps) {
IRDA_ERROR("%s: can't allocate IrTTP hashbin!\n",
__FUNCTION__);
+ kfree(irttp);
return -ENOMEM;
}
return -ENOMEM;
}
@@
-115,7
+112,6
@@
int __init irttp_init(void)
void __exit irttp_cleanup(void)
{
/* Check for main structure */
void __exit irttp_cleanup(void)
{
/* Check for main structure */
- IRDA_ASSERT(irttp != NULL, return;);
IRDA_ASSERT(irttp->magic == TTP_MAGIC, return;);
/*
IRDA_ASSERT(irttp->magic == TTP_MAGIC, return;);
/*
@@
-310,7
+306,8
@@
static inline void irttp_fragment_skb(struct tsap_cb *self,
IRDA_DEBUG(2, "%s(), fragmenting ...\n", __FUNCTION__);
/* Make new segment */
IRDA_DEBUG(2, "%s(), fragmenting ...\n", __FUNCTION__);
/* Make new segment */
- frag = dev_alloc_skb(self->max_seg_size+self->max_header_size);
+ frag = alloc_skb(self->max_seg_size+self->max_header_size,
+ GFP_ATOMIC);
if (!frag)
return;
if (!frag)
return;
@@
-382,7
+379,6
@@
struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify)
struct lsap_cb *lsap;
notify_t ttp_notify;
struct lsap_cb *lsap;
notify_t ttp_notify;
- IRDA_ASSERT(irttp != NULL, return NULL;);
IRDA_ASSERT(irttp->magic == TTP_MAGIC, return NULL;);
/* The IrLMP spec (IrLMP 1.1 p10) says that we have the right to
IRDA_ASSERT(irttp->magic == TTP_MAGIC, return NULL;);
/* The IrLMP spec (IrLMP 1.1 p10) says that we have the right to
@@
-394,12
+390,11
@@
struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify)
return NULL;
}
return NULL;
}
- self = k
m
alloc(sizeof(struct tsap_cb), GFP_ATOMIC);
+ self = k
z
alloc(sizeof(struct tsap_cb), GFP_ATOMIC);
if (self == NULL) {
IRDA_DEBUG(0, "%s(), unable to kmalloc!\n", __FUNCTION__);
return NULL;
}
if (self == NULL) {
IRDA_DEBUG(0, "%s(), unable to kmalloc!\n", __FUNCTION__);
return NULL;
}
- memset(self, 0, sizeof(struct tsap_cb));
spin_lock_init(&self->lock);
/* Initialise todo timer */
spin_lock_init(&self->lock);
/* Initialise todo timer */
@@
-810,12
+805,12
@@
static inline void irttp_give_credit(struct tsap_cb *self)
self->send_credit, self->avail_credit, self->remote_credit);
/* Give credit to peer */
self->send_credit, self->avail_credit, self->remote_credit);
/* Give credit to peer */
- tx_skb =
dev_alloc_skb(64
);
+ tx_skb =
alloc_skb(TTP_MAX_HEADER, GFP_ATOMIC
);
if (!tx_skb)
return;
/* Reserve space for LMP, and LAP header */
if (!tx_skb)
return;
/* Reserve space for LMP, and LAP header */
- skb_reserve(tx_skb,
self->max_header_size
);
+ skb_reserve(tx_skb,
LMP_MAX_HEADER
);
/*
* Since we can transmit and receive frames concurrently,
/*
* Since we can transmit and receive frames concurrently,
@@
-1099,12
+1094,13
@@
int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
/* Any userdata supplied? */
if (userdata == NULL) {
/* Any userdata supplied? */
if (userdata == NULL) {
- tx_skb = dev_alloc_skb(64);
+ tx_skb = alloc_skb(TTP_MAX_HEADER + TTP_SAR_HEADER,
+ GFP_ATOMIC);
if (!tx_skb)
return -ENOMEM;
/* Reserve space for MUX_CONTROL and LAP header */
if (!tx_skb)
return -ENOMEM;
/* Reserve space for MUX_CONTROL and LAP header */
- skb_reserve(tx_skb, TTP_MAX_HEADER);
+ skb_reserve(tx_skb, TTP_MAX_HEADER
+ TTP_SAR_HEADER
);
} else {
tx_skb = userdata;
/*
} else {
tx_skb = userdata;
/*
@@
-1152,7
+1148,7
@@
int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
frame[3] = 0x02; /* Value length */
put_unaligned(cpu_to_be16((__u16) max_sdu_size),
frame[3] = 0x02; /* Value length */
put_unaligned(cpu_to_be16((__u16) max_sdu_size),
- (__
u
16 *)(frame+4));
+ (__
be
16 *)(frame+4));
} else {
/* Insert plain TTP header */
frame = skb_push(tx_skb, TTP_HEADER);
} else {
/* Insert plain TTP header */
frame = skb_push(tx_skb, TTP_HEADER);
@@
-1347,12
+1343,13
@@
int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
/* Any userdata supplied? */
if (userdata == NULL) {
/* Any userdata supplied? */
if (userdata == NULL) {
- tx_skb = dev_alloc_skb(64);
+ tx_skb = alloc_skb(TTP_MAX_HEADER + TTP_SAR_HEADER,
+ GFP_ATOMIC);
if (!tx_skb)
return -ENOMEM;
/* Reserve space for MUX_CONTROL and LAP header */
if (!tx_skb)
return -ENOMEM;
/* Reserve space for MUX_CONTROL and LAP header */
- skb_reserve(tx_skb, TTP_MAX_HEADER);
+ skb_reserve(tx_skb, TTP_MAX_HEADER
+ TTP_SAR_HEADER
);
} else {
tx_skb = userdata;
/*
} else {
tx_skb = userdata;
/*
@@
-1398,7
+1395,7
@@
int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
frame[3] = 0x02; /* Value length */
put_unaligned(cpu_to_be16((__u16) max_sdu_size),
frame[3] = 0x02; /* Value length */
put_unaligned(cpu_to_be16((__u16) max_sdu_size),
- (__
u
16 *)(frame+4));
+ (__
be
16 *)(frame+4));
} else {
/* Insert TTP header */
frame = skb_push(tx_skb, TTP_HEADER);
} else {
/* Insert TTP header */
frame = skb_push(tx_skb, TTP_HEADER);
@@
-1458,6
+1455,7
@@
struct tsap_cb *irttp_dup(struct tsap_cb *orig, void *instance)
/* Not everything should be copied */
new->notify.instance = instance;
/* Not everything should be copied */
new->notify.instance = instance;
+ spin_lock_init(&new->lock);
init_timer(&new->todo_timer);
skb_queue_head_init(&new->rx_queue);
init_timer(&new->todo_timer);
skb_queue_head_init(&new->rx_queue);
@@
-1513,7
+1511,7
@@
int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *userdata,
/*
* Check if there is still data segments in the transmit queue
*/
/*
* Check if there is still data segments in the transmit queue
*/
- if (
skb_queue_len(&self->tx_queue) > 0
) {
+ if (
!skb_queue_empty(&self->tx_queue)
) {
if (priority == P_HIGH) {
/*
* No need to send the queued data, if we are
if (priority == P_HIGH) {
/*
* No need to send the queued data, if we are
@@
-1546,14
+1544,14
@@
int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *userdata,
if (!userdata) {
struct sk_buff *tx_skb;
if (!userdata) {
struct sk_buff *tx_skb;
- tx_skb =
dev_alloc_skb(64
);
+ tx_skb =
alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC
);
if (!tx_skb)
return -ENOMEM;
/*
* Reserve space for MUX and LAP header
*/
if (!tx_skb)
return -ENOMEM;
/*
* Reserve space for MUX and LAP header
*/
- skb_reserve(tx_skb,
TT
P_MAX_HEADER);
+ skb_reserve(tx_skb,
LM
P_MAX_HEADER);
userdata = tx_skb;
}
userdata = tx_skb;
}
@@
-1880,10
+1878,8
@@
static int irttp_seq_open(struct inode *inode, struct file *file)
struct seq_file *seq;
int rc = -ENOMEM;
struct irttp_iter_state *s;
struct seq_file *seq;
int rc = -ENOMEM;
struct irttp_iter_state *s;
-
- IRDA_ASSERT(irttp != NULL, return -EINVAL;);
- s = k
m
alloc(sizeof(*s), GFP_KERNEL);
+ s = k
z
alloc(sizeof(*s), GFP_KERNEL);
if (!s)
goto out;
if (!s)
goto out;
@@
-1893,7
+1889,6
@@
static int irttp_seq_open(struct inode *inode, struct file *file)
seq = file->private_data;
seq->private = s;
seq = file->private_data;
seq->private = s;
- memset(s, 0, sizeof(*s));
out:
return rc;
out_kfree:
out:
return rc;
out_kfree: