Netdev List
 help / color / mirror / Atom feed
From: urs.thuermann@gmx.de
To: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Cc: Urs Thuermann <urs.thuermann@volkswagen.de>,
	Oliver Hartkopp <oliver.hartkopp@volkswagen.de>,
	Oliver Hartkopp <oliver@hartkopp.net>
Subject: [patch 2/3] CAN: Move proto_{,un}register() out of spin-locked region
Date: Wed,  6 Feb 2008 23:07:51 +0100	[thread overview]
Message-ID: <20080206220826.20500.2@janus.isnogud.escape.de> (raw)
In-Reply-To: 20080206220749.20500.0@janus.isnogud.escape.de

[-- Attachment #1: proto_register --]
[-- Type: text/plain, Size: 1688 bytes --]

The implementation of proto_register() has changed so that it can now
sleep.  The call to proto_register() must be moved out of the
spin-locked region.

Signed-off-by: Urs Thuermann <urs.thuermann@volkswagen.de>
Signed-off-by: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>

---
 net/can/af_can.c |   27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

Index: net-2.6/net/can/af_can.c
===================================================================
--- net-2.6.orig/net/can/af_can.c	2008-02-06 22:20:46.000000000 +0100
+++ net-2.6/net/can/af_can.c	2008-02-06 22:22:51.000000000 +0100
@@ -656,26 +656,26 @@
 		return -EINVAL;
 	}
 
+	err = proto_register(cp->prot, 0);
+	if (err < 0)
+		return err;
+
 	spin_lock(&proto_tab_lock);
 	if (proto_tab[proto]) {
 		printk(KERN_ERR "can: protocol %d already registered\n",
 		       proto);
 		err = -EBUSY;
-		goto errout;
+	} else {
+		proto_tab[proto] = cp;
+
+		/* use generic ioctl function if not defined by module */
+		if (!cp->ops->ioctl)
+			cp->ops->ioctl = can_ioctl;
 	}
+	spin_unlock(&proto_tab_lock);
 
-	err = proto_register(cp->prot, 0);
 	if (err < 0)
-		goto errout;
-
-	proto_tab[proto] = cp;
-
-	/* use generic ioctl function if the module doesn't bring its own */
-	if (!cp->ops->ioctl)
-		cp->ops->ioctl = can_ioctl;
-
- errout:
-	spin_unlock(&proto_tab_lock);
+		proto_unregister(cp->prot);
 
 	return err;
 }
@@ -694,9 +694,10 @@
 		printk(KERN_ERR "BUG: can: protocol %d is not registered\n",
 		       proto);
 	}
-	proto_unregister(cp->prot);
 	proto_tab[proto] = NULL;
 	spin_unlock(&proto_tab_lock);
+
+	proto_unregister(cp->prot);
 }
 EXPORT_SYMBOL(can_proto_unregister);
 

--

  parent reply	other threads:[~2008-02-06 23:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-06 22:07 [patch 0/3] CAN: Some updates for 2.6.25 urs.thuermann
2008-02-06 22:07 ` [patch 1/3] CAN: Clean up module auto loading urs.thuermann
2008-02-06 22:07 ` urs.thuermann [this message]
2008-02-06 22:07 ` [patch 3/3] CAN: Minor clean-ups urs.thuermann
2008-02-08  2:05 ` [patch 0/3] CAN: Some updates for 2.6.25 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=20080206220826.20500.2@janus.isnogud.escape.de \
    --to=urs.thuermann@gmx.de \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=oliver.hartkopp@volkswagen.de \
    --cc=oliver@hartkopp.net \
    --cc=urs.thuermann@volkswagen.de \
    /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