netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: samuel-jcdQHdrhKHMdnm+yROfE0A@public.gmane.org
To: davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"G. Liakhovetski" <gl-o/hVf8ie6tKzQB+pC5nmwQ@public.gmane.org>,
	irda-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: [PATCH 4/4] [IrDA] tsap init routine factorisation
Date: Mon, 02 Jul 2007 01:14:31 +0300	[thread overview]
Message-ID: <20070701221706.468909173@sortiz.org> (raw)
In-Reply-To: 20070701221427.101308704@sortiz.org

[-- Attachment #1: patch_tsap_init --]
[-- Type: text/plain, Size: 2541 bytes --]

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 <gl-o/hVf8ie6tKzQB+pC5nmwQ@public.gmane.org>
Signed-off-by: Samuel Ortiz <samuel-jcdQHdrhKHMdnm+yROfE0A@public.gmane.org>

--- a/net/irda/irttp.c	2 Apr 2007 10:36:28 -0000	1.1.1.11.4.2
+++ b/net/irda/irttp.c	30 May 2007 13:14:19 -0000
@@ -369,6 +369,20 @@ static int irttp_param_max_sdu_size(void
 /* 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 sts
 		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 sts
 	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
 
 	/* 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);

-- 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

  parent reply	other threads:[~2007-07-01 22:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-01 22:14 [PATCH 0/4] [IrDA] Update for net-2.6.23 samuel-jcdQHdrhKHMdnm+yROfE0A
2007-07-01 22:14 ` [PATCH 1/4] [IrDA] Netlink layer samuel-jcdQHdrhKHMdnm+yROfE0A
2007-07-03  5:54   ` David Miller
2007-07-01 22:14 ` [PATCH 2/4] [IrDA] Monitor mode samuel-jcdQHdrhKHMdnm+yROfE0A
2007-07-03  5:55   ` David Miller
2007-07-01 22:14 ` [PATCH 3/4] [IrDA] kingsun-sir.c charset fix samuel-jcdQHdrhKHMdnm+yROfE0A
     [not found]   ` <20070701221705.948742675-jcdQHdrhKHMdnm+yROfE0A@public.gmane.org>
2007-07-03  5:56     ` David Miller
2007-07-01 22:14 ` samuel-jcdQHdrhKHMdnm+yROfE0A [this message]
2007-07-03  5:57   ` [PATCH 4/4] [IrDA] tsap init routine factorisation David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070701221706.468909173@sortiz.org \
    --to=samuel-jcdqhdrhkhmdnm+yrofe0a@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=gl-o/hVf8ie6tKzQB+pC5nmwQ@public.gmane.org \
    --cc=irda-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).