netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Patrick McHardy <kaber@trash.net>
Subject: [VLAN 11/18]: Clean up unregister_vlan_dev
Date: Sun, 20 Jan 2008 18:11:32 +0100 (MET)	[thread overview]
Message-ID: <20080120171132.7980.16660.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>

[VLAN]: Clean up unregister_vlan_dev

Save two levels of indentation by aborting on error conditions,
remove unnecessary initialization to NULL and remove two obvious
comments.

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit 9f39c0253f370dae13a81cda9cf119052bb11750
tree d27c1417f8f19e0aff3833b6a631453c509c787e
parent 9829059db87d43bb24e82683e6bb4ed4a655fc39
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100

 net/8021q/vlan.c |   72 ++++++++++++++++++++++++------------------------------
 1 files changed, 32 insertions(+), 40 deletions(-)

diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 006d9a9..ad34e4a 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -142,63 +142,55 @@ static void vlan_rcu_free(struct rcu_head *rcu)
 static int unregister_vlan_dev(struct net_device *real_dev,
 			       unsigned short vlan_id)
 {
-	struct net_device *dev = NULL;
+	struct net_device *dev;
 	int real_dev_ifindex = real_dev->ifindex;
 	struct vlan_group *grp;
-	int i, ret;
+	unsigned int i;
+	int ret;
 
-	/* sanity check */
 	if (vlan_id >= VLAN_VID_MASK)
 		return -EINVAL;
 
 	ASSERT_RTNL();
 	grp = __vlan_find_group(real_dev_ifindex);
+	if (!grp)
+		return -ENOENT;
 
-	ret = 0;
-
-	if (grp) {
-		dev = vlan_group_get_device(grp, vlan_id);
-		if (dev) {
-			/* Remove proc entry */
-			vlan_proc_rem_dev(dev);
-
-			/* Take it out of our own structures, but be sure to
-			 * interlock with HW accelerating devices or SW vlan
-			 * input packet processing.
-			 */
-			if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
-				real_dev->vlan_rx_kill_vid(real_dev, vlan_id);
+	dev = vlan_group_get_device(grp, vlan_id);
+	if (!dev)
+		return -ENOENT;
 
-			vlan_group_set_device(grp, vlan_id, NULL);
-			synchronize_net();
+	vlan_proc_rem_dev(dev);
 
+	/* Take it out of our own structures, but be sure to interlock with
+	 * HW accelerating devices or SW vlan input packet processing.
+	 */
+	if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
+		real_dev->vlan_rx_kill_vid(real_dev, vlan_id);
 
-			/* Caller unregisters (and if necessary, puts)
-			 * VLAN device, but we get rid of the reference to
-			 * real_dev here.
-			 */
-			dev_put(real_dev);
+	vlan_group_set_device(grp, vlan_id, NULL);
+	synchronize_net();
 
-			/* If the group is now empty, kill off the
-			 * group.
-			 */
-			for (i = 0; i < VLAN_VID_MASK; i++)
-				if (vlan_group_get_device(grp, i))
-					break;
+	/* Caller unregisters (and if necessary, puts) VLAN device, but we
+	 * get rid of the reference to real_dev here.
+	 */
+	dev_put(real_dev);
 
-			if (i == VLAN_VID_MASK) {
-				if (real_dev->features & NETIF_F_HW_VLAN_RX)
-					real_dev->vlan_rx_register(real_dev, NULL);
+	/* If the group is now empty, kill off the group. */
+	ret = 0;
+	for (i = 0; i < VLAN_VID_MASK; i++)
+		if (vlan_group_get_device(grp, i))
+			break;
 
-				hlist_del_rcu(&grp->hlist);
+	if (i == VLAN_VID_MASK) {
+		if (real_dev->features & NETIF_F_HW_VLAN_RX)
+			real_dev->vlan_rx_register(real_dev, NULL);
 
-				/* Free the group, after all cpu's are done. */
-				call_rcu(&grp->rcu, vlan_rcu_free);
+		hlist_del_rcu(&grp->hlist);
 
-				grp = NULL;
-				ret = 1;
-			}
-		}
+		/* Free the group, after all cpu's are done. */
+		call_rcu(&grp->rcu, vlan_rcu_free);
+		ret = 1;
 	}
 
 	return ret;

  parent reply	other threads:[~2008-01-20 17:11 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-20 17:11 [VLAN 00/18]: Vlan update Patrick McHardy
2008-01-20 17:11 ` [VLAN 01/18]: Remove unnecessary structure declarations Patrick McHardy
2008-01-20 17:11 ` [VLAN 02/18]: Clean up vlan_hdr/vlan_ethhdr structs Patrick McHardy
2008-01-20 17:11 ` [VLAN 03/18]: Kill useless VLAN_NAME define Patrick McHardy
2008-01-20 17:11 ` [VLAN 04/18]: Use dev->stats Patrick McHardy
2008-01-20 17:11 ` [VLAN 05/18]: Move device setup to vlan_dev.c Patrick McHardy
2008-01-20 17:11 ` [VLAN 06/18]: Kill useless check Patrick McHardy
2008-01-20 17:11 ` [ETHER 07/18]: Bring back MAC_FMT Patrick McHardy
2008-01-20 17:11 ` [VLAN 08/18]: Clean up debugging and printks Patrick McHardy
2008-01-20 17:11 ` [VLAN 09/18]: Remove non-implemented ioctls Patrick McHardy
2008-01-20 17:11 ` [VLAN 10/18]: Clean up initialization code Patrick McHardy
2008-01-20 17:11 ` Patrick McHardy [this message]
2008-01-20 17:11 ` [VLAN 12/18]: Simplify vlan unregistration Patrick McHardy
2008-01-20 17:11 ` [VLAN 13/18]: Turn VLAN_DEV_INFO into inline function Patrick McHardy
2008-01-20 17:11 ` [VLAN 14/18]: Turn __constant_htons into htons where possible Patrick McHardy
2008-01-20 17:11 ` [VLAN 15/18]: checkpatch cleanups Patrick McHardy
2008-01-20 17:11 ` [VLAN 16/18]: Update list address Patrick McHardy
2008-01-20 17:11 ` [VLAN 17/18]: Clean up vlan_skb_recv() Patrick McHardy
2008-01-20 17:11 ` [VLAN 18/18]: Move protocol determination to seperate function Patrick McHardy
2008-01-21  8:34 ` [VLAN 00/18]: Vlan update David Miller
2008-01-21 17:48   ` [VLAN] sparse warning fix Stephen Hemminger
2008-01-22  1:28     ` 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=20080120171132.7980.16660.sendpatchset@localhost.localdomain \
    --to=kaber@trash.net \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.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).