Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=93cce3d3657bfb5d04789afcd5104f8c48700f32
Commit:     93cce3d3657bfb5d04789afcd5104f8c48700f32
Parent:     66f5e51ed5a300291b34bf3e2b1e22ac28ca3631
Author:     G. Liakhovetski <[EMAIL PROTECTED]>
AuthorDate: Mon Jul 2 22:56:57 2007 -0700
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Tue Jul 10 22:16:52 2007 -0700

    [IrDA]: tsap init routine factorisation.
    
    This patch extracts common code from irttp_open_tsap() and irttp_dup()
    into a new function to 1) avoid code duplication, 2) help avoid
    forgetting object initialization in the tsap duplication path in the
    future.
    
    Signed-off-by: G. Liakhovetski <[EMAIL PROTECTED]>
    Signed-off-by: Samuel Ortiz <[EMAIL PROTECTED]>
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
---
 net/irda/irttp.c |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/net/irda/irttp.c b/net/irda/irttp.c
index 7069e4a..ce46475 100644
--- a/net/irda/irttp.c
+++ b/net/irda/irttp.c
@@ -369,6 +369,20 @@ static int irttp_param_max_sdu_size(void *instance, 
irda_param_t *param,
 /* Everything is happily mixed up. Waiting for next clean up - Jean II */
 
 /*
+ * Initialization, that has to be done on new tsap
+ * instance allocation and on duplication
+ */
+static void irttp_init_tsap(struct tsap_cb *tsap)
+{
+       spin_lock_init(&tsap->lock);
+       init_timer(&tsap->todo_timer);
+
+       skb_queue_head_init(&tsap->rx_queue);
+       skb_queue_head_init(&tsap->tx_queue);
+       skb_queue_head_init(&tsap->rx_fragments);
+}
+
+/*
  * Function irttp_open_tsap (stsap, notify)
  *
  *    Create TSAP connection endpoint,
@@ -395,10 +409,11 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int 
credit, notify_t *notify)
                IRDA_DEBUG(0, "%s(), unable to kmalloc!\n", __FUNCTION__);
                return NULL;
        }
-       spin_lock_init(&self->lock);
+
+       /* Initialize internal objects */
+       irttp_init_tsap(self);
 
        /* Initialise todo timer */
-       init_timer(&self->todo_timer);
        self->todo_timer.data     = (unsigned long) self;
        self->todo_timer.function = &irttp_todo_expired;
 
@@ -418,9 +433,6 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, 
notify_t *notify)
        self->magic = TTP_TSAP_MAGIC;
        self->connected = FALSE;
 
-       skb_queue_head_init(&self->rx_queue);
-       skb_queue_head_init(&self->tx_queue);
-       skb_queue_head_init(&self->rx_fragments);
        /*
         *  Create LSAP at IrLMP layer
         */
@@ -1455,12 +1467,9 @@ struct tsap_cb *irttp_dup(struct tsap_cb *orig, void 
*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);
-       skb_queue_head_init(&new->tx_queue);
-       skb_queue_head_init(&new->rx_fragments);
+       /* Initialize internal objects */
+       irttp_init_tsap(new);
 
        /* This is locked */
        hashbin_insert(irttp->tsaps, (irda_queue_t *) new, (long) new, NULL);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to