Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 2516

kernel-2.6.18-238.el5.src.rpm

From: Mike Christie <mchristi@redhat.com>
Date: Thu, 18 Nov 2010 17:00:45 -0500
Subject: [net] cnic: Add cnic_free_uio
Message-id: <1290099647-9514-3-git-send-email-mchristi@redhat.com>
Patchwork-id: 29495
O-Subject: [RHEL 5.6 PATCH 2/4] cnic: Add cnic_free_uio
Bugzilla: 651287
RH-Acked-by: David S. Miller <davem@redhat.com>

From: Mike Christie <mchristi@redhat.com>

This is for bz 651287.

>From upstream commit:

commit c06c0462250a5dbc9e58d00caab4cd7e6675128c
Author: Michael Chan <mchan@broadcom.com>
Date:   Wed Oct 13 14:06:48 2010 +0000

    cnic: Add cnic_free_uio()

    to free all UIO related structures.

diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index f38c6b3..f70aa9f 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -774,20 +774,15 @@ static void cnic_free_context(struct cnic_dev *dev)
 	}
 }
 
-static void cnic_free_resc(struct cnic_dev *dev)
+static void __cnic_free_uio(struct cnic_dev *dev)
 {
 	struct cnic_local *cp = dev->cnic_priv;
-	int i = 0;
 
-	if (cp->cnic_uinfo) {
-		while (cp->uio_dev != -1 && i < 15) {
-			msleep(100);
-			i++;
-		}
+	if (cp->cnic_uinfo)
 		uio_unregister_device(cp->cnic_uinfo);
-		kfree(cp->cnic_uinfo);
-		cp->cnic_uinfo = NULL;
-	}
+
+	kfree(cp->cnic_uinfo);
+	cp->cnic_uinfo = NULL;
 
 	if (cp->l2_buf) {
 		dma_free_coherent(&dev->pcidev->dev, cp->l2_buf_size,
@@ -800,6 +795,28 @@ static void cnic_free_resc(struct cnic_dev *dev)
 				  cp->l2_ring, cp->l2_ring_map);
 		cp->l2_ring = NULL;
 	}
+}
+
+static void cnic_free_uio(struct cnic_dev *dev)
+{
+	if (!dev)
+		return;
+
+	__cnic_free_uio(dev);
+}
+
+static void cnic_free_resc(struct cnic_dev *dev)
+{
+	struct cnic_local *cp = dev->cnic_priv;
+	int i = 0;
+
+	if (cp->cnic_uinfo) {
+		while (cp->uio_dev != -1 && i < 15) {
+			msleep(100);
+			i++;
+		}
+		cnic_free_uio(dev);
+	}
 
 	cnic_free_context(dev);
 	kfree(cp->ctx_arr);