WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 3/3] Add legacy kref support

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 3/3] Add legacy kref support
From: Ben Guthro <bguthro@xxxxxxxxxxxxxxx>
Date: Wed, 29 Aug 2007 14:18:26 -0400
Delivery-date: Wed, 29 Aug 2007 11:21:39 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.5 (X11/20070719)
In kernels <= 2.6.5 kref_init, and kref_put had a different interface.
This patch allows for older kernels to compile with the older interface.

This patch applies against the linux-2.6.18-xen.hg tree

Signed-off-by: Ben Guthro <bguthro@xxxxxxxxxxxxxxx>
diff -r fe774d9684dd drivers/xen/netfront/accel.c
--- a/drivers/xen/netfront/accel.c      Tue Aug 14 12:34:34 2007 -0400
+++ b/drivers/xen/netfront/accel.c      Wed Aug 15 11:17:00 2007 -0400
@@ -45,6 +45,12 @@
 #define WPRINTK(fmt, args...)                          \
        printk(KERN_WARNING "netfront/accel: " fmt, ##args)
 
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 5)
+#define KREF_PUT(x,y) kref_put(x)
+#else
+#define KREF_PUT(x,y) kref_put(x,y)
+#endif
+
 /*
  * List of all netfront accelerator plugin modules available.  Each
  * list entry is of type struct netfront_accelerator.
@@ -59,7 +65,6 @@ static spinlock_t accelerators_lock;
 /* Forward declaration of kref cleanup functions */
 static void accel_kref_release(struct kref *ref);
 static void vif_kref_release(struct kref *ref);
-
 
 void netif_init_accel(void)
 {
@@ -176,7 +181,11 @@ accelerator_set_vif_state_hooks(struct n
         */
        kref_get(&vif_state->np->accelerator->accel_kref);
        /* This persists until vif_state->hooks are cleared */
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 5)
+       kref_init(&vif_state->vif_kref,vif_kref_release);
+#else
        kref_init(&vif_state->vif_kref);
+#endif
 
        /* Make sure there are no data path operations going on */
        netif_poll_disable(vif_state->np->netdev);
@@ -218,7 +227,7 @@ static void accelerator_probe_new_vif(st
                        
                        hooks->new_device(np->netdev, dev);
                        
-                       kref_put(&accelerator->accel_kref,
+                       KREF_PUT(&accelerator->accel_kref,
                                 accel_kref_release);
                        /* 
                         * Hooks will get linked into vif_state by a
@@ -318,8 +327,11 @@ accelerator_probe_vifs(struct netfront_a
         * persist until the accelerator hooks are removed (e.g. by
         * accelerator module unload)
         */
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 5)
+       kref_init(&accelerator->accel_kref,accel_kref_release);
+#else
        kref_init(&accelerator->accel_kref);
-
+#endif
        /* 
         * Store the hooks for future calls to probe a new device, and
         * to wire into the vif_state once the accelerator plugin is
@@ -345,7 +357,7 @@ accelerator_probe_vifs(struct netfront_a
                        
                        hooks->new_device(np->netdev, vif_state->dev);
                        
-                       kref_put(&accelerator->accel_kref, accel_kref_release);
+                       KREF_PUT(&accelerator->accel_kref, accel_kref_release);
 
                        /* Retake lock for next go round the loop */
                        spin_lock_irqsave(&accelerator->vif_states_lock, 
lock_flags);
@@ -510,7 +522,7 @@ static void accelerator_remove_hooks(str
                 * were set, must be called without lock held
                 */
                spin_unlock_irqrestore(&accelerator->vif_states_lock, flags);
-               kref_put(&vif_state->vif_kref, vif_kref_release);
+               KREF_PUT(&vif_state->vif_kref, vif_kref_release);
                spin_lock_irqsave(&accelerator->vif_states_lock, flags);
        }
        
@@ -521,7 +533,7 @@ static void accelerator_remove_hooks(str
 
        if(remove_master)
                /* Remove the reference taken when module loaded */ 
-               kref_put(&accelerator->accel_kref, accel_kref_release);
+               KREF_PUT(&accelerator->accel_kref, accel_kref_release);
 }
 
 
@@ -585,7 +597,7 @@ int netfront_check_accelerator_queue_bus
 
                        rc = np->accel_vif_state.hooks->check_busy(dev);
                        
-                       kref_put(&np->accel_vif_state.vif_kref,
+                       KREF_PUT(&np->accel_vif_state.vif_kref,
                                 vif_kref_release);
                } else {
                        spin_unlock_irqrestore
@@ -620,7 +632,7 @@ int netfront_accelerator_call_remove(str
 
                        rc = np->accel_vif_state.hooks->remove(dev);
 
-                       kref_put(&np->accel_vif_state.vif_kref,
+                       KREF_PUT(&np->accel_vif_state.vif_kref,
                                 vif_kref_release);
                } else {
                        spin_unlock_irqrestore
@@ -656,7 +668,7 @@ int netfront_accelerator_call_suspend(st
 
                        rc = np->accel_vif_state.hooks->suspend(dev);
 
-                       kref_put(&np->accel_vif_state.vif_kref,
+                       KREF_PUT(&np->accel_vif_state.vif_kref,
                                 vif_kref_release);
                } else {
                        spin_unlock_irqrestore
@@ -693,7 +705,7 @@ int netfront_accelerator_call_suspend_ca
 
                        rc = np->accel_vif_state.hooks->suspend_cancel(dev);
 
-                       kref_put(&np->accel_vif_state.vif_kref,
+                       KREF_PUT(&np->accel_vif_state.vif_kref,
                                 vif_kref_release);
                } else {
                        spin_unlock_irqrestore
@@ -727,7 +739,7 @@ int netfront_accelerator_call_resume(str
 
                        rc = np->accel_vif_state.hooks->resume(dev);
 
-                       kref_put(&np->accel_vif_state.vif_kref,
+                       KREF_PUT(&np->accel_vif_state.vif_kref,
                                 vif_kref_release);
                } else {
                        spin_unlock_irqrestore
@@ -762,7 +774,7 @@ void netfront_accelerator_call_backend_c
                        np->accel_vif_state.hooks->backend_changed
                                (dev, backend_state);
 
-                       kref_put(&np->accel_vif_state.vif_kref,
+                       KREF_PUT(&np->accel_vif_state.vif_kref,
                                 vif_kref_release);
                } else {
                        spin_unlock_irqrestore
@@ -796,7 +808,7 @@ void netfront_accelerator_call_stop_napi
 
                        np->accel_vif_state.hooks->stop_napi_irq(dev);
                
-                       kref_put(&np->accel_vif_state.vif_kref,
+                       KREF_PUT(&np->accel_vif_state.vif_kref,
                                 vif_kref_release);
                } else {
                        spin_unlock_irqrestore
@@ -807,7 +819,7 @@ void netfront_accelerator_call_stop_napi
 
 
 /* 
- * Once all users of hooks have kref_put()'d we can signal that it's
+ * Once all users of hooks have KREF_PUT()'d we can signal that it's
  * safe to unload
  */ 
 static void accel_kref_release(struct kref *ref)
@@ -834,7 +846,6 @@ static void accel_kref_release(struct kr
        spin_unlock_irqrestore(&accelerator->vif_states_lock, flags);
 }
 
-
 static void vif_kref_release(struct kref *ref)
 {
        struct netfront_accel_vif_state *vif_state = 
@@ -848,7 +859,7 @@ static void vif_kref_release(struct kref
         * Now that this vif has finished using the hooks, it can
         * decrement the accelerator's global copy ref count 
         */
-       kref_put(&vif_state->np->accelerator->accel_kref, accel_kref_release);
+       KREF_PUT(&vif_state->np->accelerator->accel_kref, accel_kref_release);
 
        spin_lock_irqsave(&vif_state->np->accelerator->vif_states_lock, flags);
        if (vif_state->need_probe) {
@@ -864,3 +875,4 @@ static void vif_kref_release(struct kref
        }
 }
 
+
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 3/3] Add legacy kref support, Ben Guthro <=