stop using sk_protinfo
Subsystems (2)
PATCH 10/12 stop using sk_protinfo
Hi David/Jean,
This one addresses Jean concerns.
Regards,
- Arnaldo
===================================================================
[email protected], 2005-01-20 21:21:48-02:00, [email protected]
[IRDA] stop using sk_protinfo
Required to introduce struct connection_sock.
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by David S. Miller <[email protected]>
include/net/irda/af_irda.h | 9 +++++++-- net/irda/af_irda.c | 38 ++++++++++++++------------------------ 2 files changed, 21 insertions(+), 26 deletions(-)
include/net/irda/af_irda.h +7 -2
@@ -33,9 +33,12 @@#include <net/irda/irlmp.h> /* struct lsap_cb */ #include <net/irda/irttp.h> /* struct tsap_cb */ #include <net/irda/discovery.h> /* struct discovery_t */ +#include <net/sock.h> /* IrDA Socket */ struct irda_sock { +/* struct sock has to be the first member of irda_sock */ +struct sock sk;__u32 saddr;/* my local address */ __u32 daddr;/* peer address */
@@ -69,7 +72,6 @@int errno;/* status of the IAS query */ -struct sock *sk;wait_queue_head_t query_wait;/* Wait for the answer to a query */ struct timer_list watchdog;/* Timeout for discovery */
@@ -77,6 +79,9 @@ LOCAL_FLOW rx_flow; }; -#define irda_sk (__sk) ((struct irda_sock *)(__sk)->sk_protinfo) +static inline struct irda_sock *irda_sk (struct sock *sk) +{ +return (struct irda_sock *)sk; +}#endif /* AF_IRDA_H */
net/irda/af_irda.c +14 -24
@@ -87,10 +87,10 @@IRDA_DEBUG (3 ,"%s()\n" , __FUNCTION__); - self = (struct irda_sock *) instance; + self = instance; ASSERT(self != NULL, return -1;); - sk = self->sk; + sk = instance; ASSERT(sk != NULL, return -1;); err =sock_queue_rcv_skb (sk, skb);
@@ -117,7 +117,7 @@struct irda_sock *self;struct sock *sk; - self = (struct irda_sock *) instance; + self = instance;IRDA_DEBUG (2 ,"%s(%p)\n" , __FUNCTION__, self);
@@ -125,7 +125,7 @@if (skb)dev_kfree_skb (skb); - sk = self->sk; + sk = instance;if (sk ==NULL ) {IRDA_DEBUG (0 ,"%s(%p) : BUG : sk is NULL\n" , __FUNCTION__, self);
@@ -183,11 +183,11 @@struct irda_sock *self;struct sock *sk; - self = (struct irda_sock *) instance; + self = instance;IRDA_DEBUG (2 ,"%s(%p)\n" , __FUNCTION__, self); - sk = self->sk; + sk = instance;if (sk ==NULL ) {dev_kfree_skb (skb);return ;
@@ -245,11 +245,11 @@struct irda_sock *self;struct sock *sk; - self = (struct irda_sock *) instance; + self = instance;IRDA_DEBUG (2 ,"%s(%p)\n" , __FUNCTION__, self); - sk = self->sk; + sk = instance;if (sk ==NULL ) {dev_kfree_skb (skb);return ;
@@ -332,10 +332,10 @@IRDA_DEBUG (2 ,"%s()\n" , __FUNCTION__); - self = (struct irda_sock *) instance; + self = instance; ASSERT(self != NULL, return;); - sk = self->sk; + sk = instance; ASSERT(sk != NULL, return;);switch (flow) {
@@ -1082,17 +1082,12 @@ }/* Allocate networking socket */ -if ((sk =sk_alloc (PF_IRDA ,GFP_ATOMIC ,1 ,NULL )) ==NULL ) + sk =sk_alloc (PF_IRDA ,GFP_ATOMIC , +sizeof (struct irda_sock ),NULL ); +if (sk ==NULL )return -ENOMEM ; -/* Allocate IrDA socket */ - self = sk->sk_protinfo =kmalloc (sizeof (struct irda_sock ),GFP_ATOMIC ); -if (self ==NULL ) { -sk_free (sk); -return -ENOMEM ; - } -memset (self,0 ,sizeof (struct irda_sock )); - + self =irda_sk (sk);IRDA_DEBUG (2 ,"%s() : self is %p\n" , __FUNCTION__, self);init_waitqueue_head (&self->query_wait);
@@ -1102,8 +1097,6 @@sk_set_owner (sk,THIS_MODULE ); sk->sk_family =PF_IRDA ; sk->sk_protocol = protocol; -/* Link networking socket and IrDA socket structs together */ - self->sk = sk;switch (sock->type) {case SOCK_STREAM :
@@ -1187,7 +1180,6 @@ self->lsap = NULL; }#endif /* CONFIG_IRDA_ULTRA */ -kfree (self); }/*
@@ -1208,8 +1200,6 @@/* Destroy IrDA socket */ irda_destroy_socket (irda_sk (sk)); -/* Prevent sock_def_destruct() to create havoc */ - sk->sk_protinfo =NULL ;sock_orphan (sk); sock->sk =NULL ;