Get rid of the function count_hv_channel()
by inlining the code.

Signed-off-by: K. Y. Srinivasan <[email protected]>
Signed-off-by: Haiyang Zhang <[email protected]>
Signed-off-by: Abhishek Kane <[email protected]>
Signed-off-by: Hank Janssen <[email protected]>
---
 drivers/staging/hv/channel_mgmt.c |   28 ++++++++++++----------------
 1 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/hv/channel_mgmt.c 
b/drivers/staging/hv/channel_mgmt.c
index 0e4e05a..ef43b00 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -28,10 +28,12 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/completion.h>
+#include <linux/atomic.h>
 
 #include <linux/hyperv.h>
 #include "hyperv_vmbus.h"
 
+static atomic_t num_channels;
 struct vmbus_channel_message_table_entry {
        enum vmbus_channel_message_type message_type;
        void (*message_handler)(struct vmbus_channel_message_header *msg);
@@ -316,21 +318,6 @@ void free_channel(struct vmbus_channel *channel)
 DECLARE_COMPLETION(hv_channel_ready);
 
 /*
- * Count initialized channels, and ensure all channels are ready when hv_vmbus
- * module loading completes.
- */
-static void count_hv_channel(void)
-{
-       static int counter;
-       unsigned long flags;
-
-       spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
-       if (++counter == MAX_MSG_TYPES)
-               complete(&hv_channel_ready);
-       spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
-}
-
-/*
  * vmbus_process_rescind_offer -
  * Rescind the offer by initiating a device removal
  */
@@ -433,7 +420,16 @@ static void vmbus_process_offer(struct work_struct *work)
 
                                pr_info("%s\n", hv_cb_utils[cnt].log_msg);
 
-                               count_hv_channel();
+                               /*
+                                * Count initialized channels, and ensure
+                                * all channels are ready when hv_vmbus
+                                * module loading completes.
+                                */
+
+                               atomic_inc(&num_channels);
+                               if (atomic_read(&num_channels)
+                                        == MAX_MSG_TYPES)
+                                       complete(&hv_channel_ready);
                        }
                }
        }
-- 
1.7.4.1

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

Reply via email to