Linux virtualization list
 help / color / mirror / Atom feed
* Move hyperv out of the drivers/staging/ directory
From: Greg KH @ 2011-10-04 19:34 UTC (permalink / raw)
  To: KY Srinivasan
  Cc: devel@linuxdriverproject.org, linux-kernel@vger.kernel.org,
	virtualization@lists.osdl.org
In-Reply-To: <6E21E5352C11B742B20C142EB499E048081EB86F@TK5EX14MBXC124.redmond.corp.microsoft.com>

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

KY, how about the following patch?

Any objection from the virt developers about this?

KY, I'd like to get your signed-off-by before committing this, care to
test this out and pass it around the other hyperv developers and then
sign off on it?  Then I will be glad to commit this to my tree.

thanks,

greg k-h



[-- Attachment #2: 0001-Staging-hv-move-hyperv-code-out-of-staging-directory.patch --]
[-- Type: text/x-patch, Size: 11797 bytes --]

From 82a986ecb50f336751dc18370a0ec61f2d3002db Mon Sep 17 00:00:00 2001
From: Greg Kroah-Hartman <gregkh@suse.de>
Date: Tue, 4 Oct 2011 12:29:52 -0700
Subject: Staging: hv: move hyperv code out of staging directory

After many years wandering the desert, it is finally time for the
Microsoft HyperV code to move out of the staging directory.  Or at least
the core hyperv bus code, and the utility driver, the rest still have
some review to get through by the various subsystem maintainers.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/Kconfig                                    |    2 +
 drivers/Makefile                                   |    2 +
 drivers/hv/Kconfig                                 |   14 ++++++++++
 drivers/hv/Makefile                                |    7 +++++
 drivers/{staging => }/hv/channel.c                 |    2 +-
 drivers/{staging => }/hv/channel_mgmt.c            |    2 +-
 drivers/{staging => }/hv/connection.c              |    2 +-
 drivers/{staging => }/hv/hv.c                      |    2 +-
 drivers/{staging => }/hv/hv_kvp.c                  |    2 +-
 drivers/{staging => }/hv/hv_kvp.h                  |    0
 drivers/{staging => }/hv/hv_util.c                 |    2 +-
 drivers/{staging => }/hv/hyperv_vmbus.h            |    3 +-
 drivers/{staging => }/hv/ring_buffer.c             |    2 +-
 drivers/{staging => }/hv/vmbus_drv.c               |    2 +-
 drivers/staging/hv/Kconfig                         |   28 ++-----------------
 drivers/staging/hv/Makefile                        |    7 +----
 drivers/staging/hv/hv_mouse.c                      |    3 +-
 drivers/staging/hv/hyperv_net.h                    |    2 +-
 drivers/staging/hv/storvsc_drv.c                   |    2 +-
 {drivers/staging/hv => include/linux}/hyperv.h     |    0
 .../staging/hv/tools => tools/hv}/hv_kvp_daemon.c  |    0
 21 files changed, 41 insertions(+), 45 deletions(-)
 create mode 100644 drivers/hv/Kconfig
 create mode 100644 drivers/hv/Makefile
 rename drivers/{staging => }/hv/channel.c (99%)
 rename drivers/{staging => }/hv/channel_mgmt.c (99%)
 rename drivers/{staging => }/hv/connection.c (99%)
 rename drivers/{staging => }/hv/hv.c (99%)
 rename drivers/{staging => }/hv/hv_kvp.c (99%)
 rename drivers/{staging => }/hv/hv_kvp.h (100%)
 rename drivers/{staging => }/hv/hv_util.c (99%)
 rename drivers/{staging => }/hv/hyperv_vmbus.h (99%)
 rename drivers/{staging => }/hv/ring_buffer.c (99%)
 rename drivers/{staging => }/hv/vmbus_drv.c (99%)
 rename {drivers/staging/hv => include/linux}/hyperv.h (100%)
 rename {drivers/staging/hv/tools => tools/hv}/hv_kvp_daemon.c (100%)

diff --git a/drivers/Kconfig b/drivers/Kconfig
index 95b9e7e..ce3c35f 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -130,4 +130,6 @@ source "drivers/iommu/Kconfig"
 
 source "drivers/virt/Kconfig"
 
+source "drivers/hv/Kconfig"
+
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index 7fa433a..ef693cf 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -127,3 +127,5 @@ obj-$(CONFIG_IOMMU_SUPPORT)	+= iommu/
 
 # Virtualization drivers
 obj-$(CONFIG_VIRT_DRIVERS)	+= virt/
+obj-$(CONFIG_HYPERV)		+= hv/
+
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
new file mode 100644
index 0000000..9fa09ac
--- /dev/null
+++ b/drivers/hv/Kconfig
@@ -0,0 +1,14 @@
+config HYPERV
+	tristate "Microsoft Hyper-V client drivers"
+	depends on X86 && ACPI && PCI
+	help
+	  Select this option to run Linux as a Hyper-V client operating
+	  system.
+
+config HYPERV_UTILS
+	tristate "Microsoft Hyper-V Utilities driver"
+	depends on HYPERV && CONNECTOR && NLS
+	help
+	  Select this option to enable the Hyper-V Utilities.
+
+
diff --git a/drivers/hv/Makefile b/drivers/hv/Makefile
new file mode 100644
index 0000000..a23938b
--- /dev/null
+++ b/drivers/hv/Makefile
@@ -0,0 +1,7 @@
+obj-$(CONFIG_HYPERV)		+= hv_vmbus.o
+obj-$(CONFIG_HYPERV_UTILS)	+= hv_utils.o
+
+hv_vmbus-y := vmbus_drv.o \
+		 hv.o connection.o channel.o \
+		 channel_mgmt.o ring_buffer.o
+hv_utils-y := hv_util.o hv_kvp.o
diff --git a/drivers/staging/hv/channel.c b/drivers/hv/channel.c
similarity index 99%
rename from drivers/staging/hv/channel.c
rename to drivers/hv/channel.c
index b6f3d38..4065374 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -26,8 +26,8 @@
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/hyperv.h>
 
-#include "hyperv.h"
 #include "hyperv_vmbus.h"
 
 #define NUM_PAGES_SPANNED(addr, len) \
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
similarity index 99%
rename from drivers/staging/hv/channel_mgmt.c
rename to drivers/hv/channel_mgmt.c
index 9f00752..41bf287 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -28,8 +28,8 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/completion.h>
+#include <linux/hyperv.h>
 
-#include "hyperv.h"
 #include "hyperv_vmbus.h"
 
 struct vmbus_channel_message_table_entry {
diff --git a/drivers/staging/hv/connection.c b/drivers/hv/connection.c
similarity index 99%
rename from drivers/staging/hv/connection.c
rename to drivers/hv/connection.c
index 649b91b..5f438b6 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -29,8 +29,8 @@
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
+#include <linux/hyperv.h>
 
-#include "hyperv.h"
 #include "hyperv_vmbus.h"
 
 
diff --git a/drivers/staging/hv/hv.c b/drivers/hv/hv.c
similarity index 99%
rename from drivers/staging/hv/hv.c
rename to drivers/hv/hv.c
index 06f1e15..931b7b0 100644
--- a/drivers/staging/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -25,8 +25,8 @@
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
+#include <linux/hyperv.h>
 
-#include "hyperv.h"
 #include "hyperv_vmbus.h"
 
 /* The one and only */
diff --git a/drivers/staging/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
similarity index 99%
rename from drivers/staging/hv/hv_kvp.c
rename to drivers/hv/hv_kvp.c
index 9aa9ede..219124b 100644
--- a/drivers/staging/hv/hv_kvp.c
+++ b/drivers/hv/hv_kvp.c
@@ -26,8 +26,8 @@
 #include <linux/nls.h>
 #include <linux/connector.h>
 #include <linux/workqueue.h>
+#include <linux/hyperv.h>
 
-#include "hyperv.h"
 #include "hv_kvp.h"
 
 
diff --git a/drivers/staging/hv/hv_kvp.h b/drivers/hv/hv_kvp.h
similarity index 100%
rename from drivers/staging/hv/hv_kvp.h
rename to drivers/hv/hv_kvp.h
diff --git a/drivers/staging/hv/hv_util.c b/drivers/hv/hv_util.c
similarity index 99%
rename from drivers/staging/hv/hv_util.c
rename to drivers/hv/hv_util.c
index faa6607..e0e3a6d 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/hv/hv_util.c
@@ -26,8 +26,8 @@
 #include <linux/slab.h>
 #include <linux/sysctl.h>
 #include <linux/reboot.h>
+#include <linux/hyperv.h>
 
-#include "hyperv.h"
 #include "hv_kvp.h"
 
 
diff --git a/drivers/staging/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
similarity index 99%
rename from drivers/staging/hv/hyperv_vmbus.h
rename to drivers/hv/hyperv_vmbus.h
index 3d2d836..8261cb6 100644
--- a/drivers/staging/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -28,8 +28,7 @@
 #include <linux/list.h>
 #include <asm/sync_bitops.h>
 #include <linux/atomic.h>
-
-#include "hyperv.h"
+#include <linux/hyperv.h>
 
 /*
  * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
diff --git a/drivers/staging/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
similarity index 99%
rename from drivers/staging/hv/ring_buffer.c
rename to drivers/hv/ring_buffer.c
index 70e2e66..f594ed0 100644
--- a/drivers/staging/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -25,8 +25,8 @@
 
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/hyperv.h>
 
-#include "hyperv.h"
 #include "hyperv_vmbus.h"
 
 
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
similarity index 99%
rename from drivers/staging/hv/vmbus_drv.c
rename to drivers/hv/vmbus_drv.c
index d2562af..b0d08f9 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -32,8 +32,8 @@
 #include <linux/acpi.h>
 #include <acpi/acpi_bus.h>
 #include <linux/completion.h>
+#include <linux/hyperv.h>
 
-#include "hyperv.h"
 #include "hyperv_vmbus.h"
 
 
diff --git a/drivers/staging/hv/Kconfig b/drivers/staging/hv/Kconfig
index 815f8c2..072185e 100644
--- a/drivers/staging/hv/Kconfig
+++ b/drivers/staging/hv/Kconfig
@@ -1,39 +1,17 @@
-config HYPERV
-	tristate "Microsoft Hyper-V client drivers"
-	depends on X86 && ACPI && PCI
-	default n
-	help
-	  Select this option to run Linux as a Hyper-V client operating
-	  system.
-
-if HYPERV
-
 config HYPERV_STORAGE
 	tristate "Microsoft Hyper-V virtual storage driver"
-	depends on SCSI
-	default HYPERV
+	depends on HYPERV && SCSI
 	help
 	 Select this option to enable the Hyper-V virtual storage driver.
 
 config HYPERV_NET
 	tristate "Microsoft Hyper-V virtual network driver"
-	depends on NET
-	default HYPERV
+	depends on HYPERV && NET
 	help
 	  Select this option to enable the Hyper-V virtual network driver.
 
-config HYPERV_UTILS
-	tristate "Microsoft Hyper-V Utilities driver"
-	depends on CONNECTOR && NLS
-	default HYPERV
-	help
-	  Select this option to enable the Hyper-V Utilities.
-
 config HYPERV_MOUSE
 	tristate "Microsoft Hyper-V mouse driver"
-	depends on HID
-	default HYPERV
+	depends on HYPERV && HID
 	help
 	  Select this option to enable the Hyper-V mouse driver.
-
-endif
diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
index bd176b1..e071c12 100644
--- a/drivers/staging/hv/Makefile
+++ b/drivers/staging/hv/Makefile
@@ -1,12 +1,7 @@
-obj-$(CONFIG_HYPERV)		+= hv_vmbus.o hv_timesource.o
+obj-$(CONFIG_HYPERV)		+= hv_timesource.o
 obj-$(CONFIG_HYPERV_STORAGE)	+= hv_storvsc.o
 obj-$(CONFIG_HYPERV_NET)	+= hv_netvsc.o
-obj-$(CONFIG_HYPERV_UTILS)	+= hv_utils.o
 obj-$(CONFIG_HYPERV_MOUSE)	+= hv_mouse.o
 
-hv_vmbus-y := vmbus_drv.o \
-		 hv.o connection.o channel.o \
-		 channel_mgmt.o ring_buffer.o
 hv_storvsc-y := storvsc_drv.o
 hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o
-hv_utils-y := hv_util.o hv_kvp.o
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index edbb479..c354ade 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -22,8 +22,7 @@
 #include <linux/input.h>
 #include <linux/hid.h>
 #include <linux/hiddev.h>
-
-#include "hyperv.h"
+#include <linux/hyperv.h>
 
 
 struct hv_input_dev_info {
diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h
index 366dd2b..ac1ec84 100644
--- a/drivers/staging/hv/hyperv_net.h
+++ b/drivers/staging/hv/hyperv_net.h
@@ -26,7 +26,7 @@
 #define _HYPERV_NET_H
 
 #include <linux/list.h>
-#include "hyperv.h"
+#include <linux/hyperv.h>
 
 /* Fwd declaration */
 struct hv_netvsc_packet;
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 807c94d..c4dfed4 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -31,6 +31,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/device.h>
+#include <linux/hyperv.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_host.h>
@@ -40,7 +41,6 @@
 #include <scsi/scsi_devinfo.h>
 #include <scsi/scsi_dbg.h>
 
-#include "hyperv.h"
 
 #define STORVSC_RING_BUFFER_SIZE			(20*PAGE_SIZE)
 static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
diff --git a/drivers/staging/hv/hyperv.h b/include/linux/hyperv.h
similarity index 100%
rename from drivers/staging/hv/hyperv.h
rename to include/linux/hyperv.h
diff --git a/drivers/staging/hv/tools/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
similarity index 100%
rename from drivers/staging/hv/tools/hv_kvp_daemon.c
rename to tools/hv/hv_kvp_daemon.c
-- 
1.7.6.4


[-- Attachment #3: Type: text/plain, Size: 159 bytes --]

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

^ permalink raw reply related

* RE: Hyper-V TODO file
From: KY Srinivasan @ 2011-10-04 17:23 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
	virtualization@lists.osdl.org
In-Reply-To: <20111004170415.GA1320@suse.de>



> -----Original Message-----
> From: Greg KH [mailto:gregkh@suse.de]
> Sent: Tuesday, October 04, 2011 1:04 PM
> To: KY Srinivasan
> Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> virtualization@lists.osdl.org
> Subject: Re: Hyper-V TODO file
> 
> On Tue, Oct 04, 2011 at 01:59:56PM +0000, KY Srinivasan wrote:
> > Greg, sometime back you checked in the changes to the TODO file reflecting
> > that there are no outstanding vmbus related issues. What is the process now
> > for getting the vmbus (and util) drivers out of staging. Let me know if there is
> > something I can do to help this along.  As you know, we had posted the
> network
> > driver for public review a while ago (several months ago) and we have
> addressed
> > all the review comments we got. Any guidance on what we should do next
> would be
> > greatly appreciated.
> 
> At this point in time, just ask me, and I will move the files.
> 
> So, to confirm, you want to have the following files moved to
> drivers/hv/:
> 	drivers/staging/hv/Kconfig (part of this file)
> 	drivers/staging/hv/Makefile (part of this file)
> 	drivers/staging/hv/vmbus_drv.c
> 	drivers/staging/hv/hv.c
> 	drivers/staging/hv/connection.c
> 	drivers/staging/hv/channel.c
> 	drivers/staging/hv/channel_mgmt.c
> 	drivers/staging/hv/ring_buffer.c
> 	drivers/staging/hv/hv_util.c
> 	drivers/staging/hv/hv_kmp.c
This is hv_kvp.c
> 	drivers/staging/hv/hv_kvp.h
> 	drivers/staging/hv/hyperv_vmbus.h
> 

Yes; this would be the list of files to be moved to drivers/hv/

> The following file moved to include/linux/:
> 	drivers/staging/hv/hyperv.h
> (I think there is stuff in there that can go into hyperv_vmbus.h as it's
> not needed in the "global" directory, but I can do that movement.)
> 

Correct.
> The following file moved to tools/hv/:
> 	drivers/staging/hv/tools/*
> 
> And the following files modified to tie drivers/hv/ into the build service:
> 	drivers/Makefile
> 	drivers/Kconfig
> 
> Is all of that correct?
> 

Yes; the list you have is correct. Thanks a lot for doing this.

Regards,

K. Y

^ permalink raw reply

* Re: Hyper-V TODO file
From: Greg KH @ 2011-10-04 17:04 UTC (permalink / raw)
  To: KY Srinivasan
  Cc: linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
	virtualization@lists.osdl.org
In-Reply-To: <6E21E5352C11B742B20C142EB499E048081EB789@TK5EX14MBXC124.redmond.corp.microsoft.com>

On Tue, Oct 04, 2011 at 01:59:56PM +0000, KY Srinivasan wrote:
> Greg, sometime back you checked in the changes to the TODO file reflecting
> that there are no outstanding vmbus related issues. What is the process now
> for getting the vmbus (and util) drivers out of staging. Let me know if there is 
> something I can do to help this along.  As you know, we had posted the network 
> driver for public review a while ago (several months ago) and we have addressed 
> all the review comments we got. Any guidance on what we should do next would be
> greatly appreciated.

At this point in time, just ask me, and I will move the files.

So, to confirm, you want to have the following files moved to
drivers/hv/:
	drivers/staging/hv/Kconfig (part of this file)
	drivers/staging/hv/Makefile (part of this file)
	drivers/staging/hv/vmbus_drv.c
	drivers/staging/hv/hv.c
	drivers/staging/hv/connection.c
	drivers/staging/hv/channel.c
	drivers/staging/hv/channel_mgmt.c
	drivers/staging/hv/ring_buffer.c
	drivers/staging/hv/hv_util.c
	drivers/staging/hv/hv_kmp.c
	drivers/staging/hv/hv_kvp.h
	drivers/staging/hv/hyperv_vmbus.h

The following file moved to include/linux/:
	drivers/staging/hv/hyperv.h
(I think there is stuff in there that can go into hyperv_vmbus.h as it's
not needed in the "global" directory, but I can do that movement.)

The following file moved to tools/hv/:
	drivers/staging/hv/tools/*

And the following files modified to tie drivers/hv/ into the build service:
	drivers/Makefile
	drivers/Kconfig

Is all of that correct?

thanks,

greg k-h

^ permalink raw reply

* RE: Hyper-V TODO file
From: KY Srinivasan @ 2011-10-04 13:59 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
	virtualization@lists.osdl.org
In-Reply-To: <20110922173618.GA5624@suse.de>



> -----Original Message-----
> From: Greg KH [mailto:gregkh@suse.de]
> Sent: Thursday, September 22, 2011 1:36 PM
> To: KY Srinivasan
> Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> virtualization@lists.osdl.org
> Subject: Re: Hyper-V TODO file
> 
> On Thu, Sep 22, 2011 at 05:20:59PM +0000, KY Srinivasan wrote:
> >
> >
> > > -----Original Message-----
> > > From: Greg KH [mailto:gregkh@suse.de]
> > > Sent: Thursday, September 22, 2011 1:05 PM
> > > To: KY Srinivasan
> > > Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> > > virtualization@lists.osdl.org
> > > Subject: Re: Hyper-V TODO file
> > >
> > > On Thu, Sep 22, 2011 at 09:17:20AM -0700, K. Y. Srinivasan wrote:
> > > >
> > > > Greg,
> > > >
> > > > With your last checkin of the patches for Hyper-V, I have addressed all of
> > > > the issues you had raised as part of the vmbus audit. Should I send you a
> > > > patch to update the TODO file to reflect this. Let me know.
> > >
> > > Yes, please send patches.
> >
> > Thanks Greg. In addition to the patch to update the TODO file, do you want me
> to
> > send you patches for moving the vmbus and util driver out of staging as well.
> 
> No, I'll do that if we agree that it is ready to do so.

Greg, sometime back you checked in the changes to the TODO file reflecting
that there are no outstanding vmbus related issues. What is the process now
for getting the vmbus (and util) drivers out of staging. Let me know if there is 
something I can do to help this along.  As you know, we had posted the network 
driver for public review a while ago (several months ago) and we have addressed 
all the review comments we got. Any guidance on what we should do next would be
greatly appreciated.

Regards,

K. Y

^ permalink raw reply

* Re: [PATCH 01/24] Staging: hv: mousevsc: Fixup struct hv_input_dev_info
From: Greg KH @ 2011-09-30  3:02 UTC (permalink / raw)
  To: KY Srinivasan
  Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, virtualization@lists.osdl.org,
	ohering@suse.com, Haiyang Zhang
In-Reply-To: <6E21E5352C11B742B20C142EB499E048081EAA5A@TK5EX14MBXC124.redmond.corp.microsoft.com>

On Fri, Sep 30, 2011 at 01:34:21AM +0000, KY Srinivasan wrote:
> > From: Greg KH [mailto:greg@kroah.com]
> > <snip>
> > 
> > I only got 21 emails in this thread, and they seemed to trickle in in
> > odd bunches.  Did they all get sent properly, or do you wish to resend
> > them to ensure they all get here?
> 
> I sent them out as I normally send them. I don't know why they are not being 
> delivered as they should be. Given that you have gotten 21 of the 24 patches,
> if you tell me which patches you have not received, I could resend just those.
> Or I could resend the whole series again if you prefer. Let me know.

It looks like they just now went through.  They got stuck on your
server, linuxonhyperv.com if you look at the email headers.  I suggest
you go give that thing a kick to figure out what went wrong.

So don't worry, I got them now...

greg k-h

^ permalink raw reply

* RE: [PATCH 01/24] Staging: hv: mousevsc: Fixup struct hv_input_dev_info
From: KY Srinivasan @ 2011-09-30  1:34 UTC (permalink / raw)
  To: Greg KH
  Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, virtualization@lists.osdl.org,
	ohering@suse.com, Haiyang Zhang
In-Reply-To: <20110930004739.GA6810@kroah.com>



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Thursday, September 29, 2011 8:48 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; ohering@suse.com;
> Haiyang Zhang
> Subject: Re: [PATCH 01/24] Staging: hv: mousevsc: Fixup struct
> hv_input_dev_info
> 
> On Thu, Sep 29, 2011 at 11:54:41AM -0700, K. Y. Srinivasan wrote:
> 
> <snip>
> 
> I only got 21 emails in this thread, and they seemed to trickle in in
> odd bunches.  Did they all get sent properly, or do you wish to resend
> them to ensure they all get here?

I sent them out as I normally send them. I don't know why they are not being 
delivered as they should be. Given that you have gotten 21 of the 24 patches,
if you tell me which patches you have not received, I could resend just those.
Or I could resend the whole series again if you prefer. Let me know.

Regards,

K. Y 

^ permalink raw reply

* Re: [PATCH 01/24] Staging: hv: mousevsc: Fixup struct hv_input_dev_info
From: Greg KH @ 2011-09-30  0:47 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, ohering,
	Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

On Thu, Sep 29, 2011 at 11:54:41AM -0700, K. Y. Srinivasan wrote:

<snip>

I only got 21 emails in this thread, and they seemed to trickle in in
odd bunches.  Did they all get sent properly, or do you wish to resend
them to ensure they all get here?

thanks,

greg k-h

^ permalink raw reply

* [PATCH 24/24] Staging: hv: mousevsc: Get rid of unnecessary comments
From: K. Y. Srinivasan @ 2011-09-29 18:55 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering; +Cc: Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

Get rid of unnecessary comments.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   21 ---------------------
 1 files changed, 0 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 71b460b..edbb479 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -26,9 +26,6 @@
 #include "hyperv.h"
 
 
-/*
- * Data types
- */
 struct hv_input_dev_info {
 	unsigned int size;
 	unsigned short vendor;
@@ -137,9 +134,6 @@ struct pipe_prt_msg {
 	char data[1];
 };
 
-/*
- * Data types
- */
 struct  mousevsc_prt_msg {
 	enum pipe_prot_msg_type type;
 	u32 size;
@@ -206,11 +200,9 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 	/* Assume success for now */
 	input_device->dev_info_status = 0;
 
-	/* Save the device attr */
 	memcpy(&input_device->hid_dev_info, &device_info->hid_dev_info,
 		sizeof(struct hv_input_dev_info));
 
-	/* Save the hid desc */
 	desc = &device_info->hid_descriptor;
 	WARN_ON(desc->bLength == 0);
 
@@ -221,7 +213,6 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 
 	memcpy(input_device->hid_desc, desc, desc->bLength);
 
-	/* Save the report desc */
 	input_device->report_desc_size = desc->desc[0].wDescriptorLength;
 	if (input_device->report_desc_size == 0)
 		goto cleanup;
@@ -368,10 +359,6 @@ static void mousevsc_on_channel_callback(void *context)
 					bufferlen = packetSize;
 				}
 			} else {
-				/*
-				 * pr_debug("nothing else to read...");
-				 * reset
-				 */
 				if (bufferlen > packetSize) {
 					kfree(buffer);
 
@@ -388,8 +375,6 @@ static void mousevsc_on_channel_callback(void *context)
 			if (buffer == NULL) {
 				buffer = packet;
 				bufferlen = packetSize;
-
-				/* Try again next time around */
 				break;
 			}
 		}
@@ -409,9 +394,6 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 
 	request = &input_dev->protocol_req;
 
-	/*
-	 * Now, initiate the vsc/vsp initialization protocol on the open channel
-	 */
 	memset(request, 0, sizeof(struct mousevsc_prt_msg));
 
 	request->type = PIPE_MESSAGE_DATA;
@@ -525,7 +507,6 @@ static int mousevsc_on_device_add(struct hv_device *device)
 
 	input_dev->init_complete = false;
 
-	/* Open the channel */
 	ret = vmbus_open(device->channel,
 		INPUTVSC_SEND_RING_BUFFER_SIZE,
 		INPUTVSC_RECV_RING_BUFFER_SIZE,
@@ -550,7 +531,6 @@ static int mousevsc_on_device_add(struct hv_device *device)
 	}
 
 
-	/* Send the report desc back up */
 	/* workaround SA-167 */
 	if (input_dev->report_desc[14] == 0x25)
 		input_dev->report_desc[14] = 0x29;
@@ -567,7 +547,6 @@ static int mousevsc_probe(struct hv_device *dev,
 			const struct hv_vmbus_device_id *dev_id)
 {
 
-	/* Call to the vsc driver to add the device */
 	return mousevsc_on_device_add(dev);
 
 }
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 23/24] Staging: hv: mousevsc: Enable autoloading of the mouse driver
From: K. Y. Srinivasan @ 2011-09-29 18:55 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

Now that the mouse driver is functional, enable the auto-loading of the driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 98ae062..71b460b 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -596,10 +596,7 @@ static const struct hv_vmbus_device_id id_table[] = {
 	{ },
 };
 
-/*
- * The mouse driver is not functional; do not auto-load it.
- */
-/* MODULE_DEVICE_TABLE(vmbus, id_table); */
+MODULE_DEVICE_TABLE(vmbus, id_table);
 
 static struct  hv_driver mousevsc_drv = {
 	.name = "mousevsc",
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 22/24] Staging: hv: mousevsc: Cleanup  mousevsc_on_device_add()
From: K. Y. Srinivasan @ 2011-09-29 18:55 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

Cleanup  mousevsc_on_device_add().

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index a526ba5..98ae062 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -513,12 +513,10 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
 	input_device->hid_device = hid_dev;
 }
 
-static int mousevsc_on_device_add(struct hv_device *device,
-					void *additional_info)
+static int mousevsc_on_device_add(struct hv_device *device)
 {
 	int ret = 0;
 	struct mousevsc_dev *input_dev;
-	struct hv_driver *input_drv;
 
 	input_dev = alloc_input_device(device);
 
@@ -551,9 +549,6 @@ static int mousevsc_on_device_add(struct hv_device *device,
 		return ret;
 	}
 
-	input_drv = drv_to_hv_drv(input_dev->device->device.driver);
-
-
 
 	/* Send the report desc back up */
 	/* workaround SA-167 */
@@ -573,7 +568,7 @@ static int mousevsc_probe(struct hv_device *dev,
 {
 
 	/* Call to the vsc driver to add the device */
-	return mousevsc_on_device_add(dev, NULL);
+	return mousevsc_on_device_add(dev);
 
 }
 
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 21/24] Staging: hv: mousevsc: Get rid of mousevsc_on_receive_input_report() by inlining
From: K. Y. Srinivasan @ 2011-09-29 18:55 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering; +Cc: Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

Get rid of mousevsc_on_receive_input_report() by inlining the code.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   27 ++++++++-------------------
 1 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 6621326..a526ba5 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -270,28 +270,13 @@ cleanup:
 	complete(&input_device->wait_event);
 }
 
-static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device,
-				struct synthhid_input_report *input_report)
-{
-	struct hv_driver *input_drv;
-
-	if (!input_device->init_complete)
-		return;
-
-	input_drv = drv_to_hv_drv(input_device->device->device.driver);
-
-
-	hid_input_report(input_device->hid_device,
-			      HID_INPUT_REPORT, input_report->buffer, input_report->header.size, 1);
-
-}
-
 static void mousevsc_on_receive(struct hv_device *device,
 				struct vmpacket_descriptor *packet)
 {
 	struct pipe_prt_msg *pipe_msg;
 	struct synthhid_msg *hid_msg;
 	struct mousevsc_dev *input_dev = hv_get_drvdata(device);
+	struct synthhid_input_report *input_report;
 
 	pipe_msg = (struct pipe_prt_msg *)((unsigned long)packet +
 						(packet->offset8 << 3));
@@ -320,9 +305,13 @@ static void mousevsc_on_receive(struct hv_device *device,
 			(struct synthhid_device_info *)&pipe_msg->data[0]);
 		break;
 	case SYNTH_HID_INPUT_REPORT:
-		mousevsc_on_receive_input_report(input_dev,
-			(struct synthhid_input_report *)&pipe_msg->data[0]);
-
+		input_report =
+			(struct synthhid_input_report *)&pipe_msg->data[0];
+		if (!input_dev->init_complete)
+			break;
+		hid_input_report(input_dev->hid_device,
+				HID_INPUT_REPORT, input_report->buffer,
+				input_report->header.size, 1);
 		break;
 	default:
 		pr_err("unsupported hid msg type - type %d len %d",
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 20/24]  Staging: hv: mousevsc: Cleanup camel cased enums
From: K. Y. Srinivasan @ 2011-09-29 18:55 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

Cleanup all camel cased names.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index e57e0b4..6621326 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -58,12 +58,12 @@ struct hv_input_dev_info {
  * Message types in the synthetic input protocol
  */
 enum synthhid_msg_type {
-	SynthHidProtocolRequest,
-	SynthHidProtocolResponse,
-	SynthHidInitialDeviceInfo,
-	SynthHidInitialDeviceInfoAck,
-	SynthHidInputReport,
-	SynthHidMax
+	SYNTH_HID_PROTOCOL_REQUEST,
+	SYNTH_HID_PROTOCOL_RESPONSE,
+	SYNTH_HID_INITIAL_DEVICE_INFO,
+	SYNTH_HID_INITIAL_DEVICE_INFO_ACK,
+	SYNTH_HID_INPUT_REPORT,
+	SYNTH_HID_MAX
 };
 
 /*
@@ -125,9 +125,9 @@ struct synthhid_input_report {
 #define NBITS(x) (((x)/BITS_PER_LONG)+1)
 
 enum pipe_prot_msg_type {
-	PipeMessageInvalid = 0,
-	PipeMessageData,
-	PipeMessageMaximum
+	PIPE_MESSAGE_INVALID,
+	PIPE_MESSAGE_DATA,
+	PIPE_MESSAGE_MAXIMUM
 };
 
 
@@ -238,10 +238,10 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 	/* Send the ack */
 	memset(&ack, 0, sizeof(struct mousevsc_prt_msg));
 
-	ack.type = PipeMessageData;
+	ack.type = PIPE_MESSAGE_DATA;
 	ack.size = sizeof(struct synthhid_device_info_ack);
 
-	ack.ack.header.type = SynthHidInitialDeviceInfoAck;
+	ack.ack.header.type = SYNTH_HID_INITIAL_DEVICE_INFO_ACK;
 	ack.ack.header.size = 1;
 	ack.ack.reserved = 0;
 
@@ -296,20 +296,20 @@ static void mousevsc_on_receive(struct hv_device *device,
 	pipe_msg = (struct pipe_prt_msg *)((unsigned long)packet +
 						(packet->offset8 << 3));
 
-	if (pipe_msg->type != PipeMessageData)
+	if (pipe_msg->type != PIPE_MESSAGE_DATA)
 		return;
 
 	hid_msg = (struct synthhid_msg *)&pipe_msg->data[0];
 
 	switch (hid_msg->header.type) {
-	case SynthHidProtocolResponse:
+	case SYNTH_HID_PROTOCOL_RESPONSE:
 		memcpy(&input_dev->protocol_resp, pipe_msg,
 		       pipe_msg->size + sizeof(struct pipe_prt_msg) -
 		       sizeof(unsigned char));
 		complete(&input_dev->wait_event);
 		break;
 
-	case SynthHidInitialDeviceInfo:
+	case SYNTH_HID_INITIAL_DEVICE_INFO:
 		WARN_ON(pipe_msg->size < sizeof(struct hv_input_dev_info));
 
 		/*
@@ -319,7 +319,7 @@ static void mousevsc_on_receive(struct hv_device *device,
 		mousevsc_on_receive_device_info(input_dev,
 			(struct synthhid_device_info *)&pipe_msg->data[0]);
 		break;
-	case SynthHidInputReport:
+	case SYNTH_HID_INPUT_REPORT:
 		mousevsc_on_receive_input_report(input_dev,
 			(struct synthhid_input_report *)&pipe_msg->data[0]);
 
@@ -425,10 +425,10 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 	 */
 	memset(request, 0, sizeof(struct mousevsc_prt_msg));
 
-	request->type = PipeMessageData;
+	request->type = PIPE_MESSAGE_DATA;
 	request->size = sizeof(struct synthhid_protocol_request);
 
-	request->request.header.type = SynthHidProtocolRequest;
+	request->request.header.type = SYNTH_HID_PROTOCOL_REQUEST;
 	request->request.header.size = sizeof(unsigned int);
 	request->request.version_requested.version = SYNTHHID_INPUT_VERSION;
 
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 19/24] Staging: hv: mousevsc: Get rid of ref_count state in struct mousevsc_dev
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

Now get rid of the machinery for managing the life-cycle of the mousevsc_dev
as this is not needed.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   54 ++--------------------------------------
 1 files changed, 3 insertions(+), 51 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 317d2be..e57e0b4 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -155,8 +155,6 @@ struct  mousevsc_prt_msg {
  */
 struct mousevsc_dev {
 	struct hv_device	*device;
-	/* 0 indicates the device is being destroyed */
-	atomic_t		ref_count;
 	unsigned char		init_complete;
 	struct mousevsc_prt_msg	protocol_req;
 	struct mousevsc_prt_msg	protocol_resp;
@@ -182,12 +180,6 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *device)
 	if (!input_dev)
 		return NULL;
 
-	/*
-	 * Set to 2 to allow both inbound and outbound traffics
-	 * (ie get_input_device() and must_get_input_device()) to proceed.
-	 */
-	atomic_set(&input_dev->ref_count, 2);
-
 	input_dev->device = device;
 	hv_set_drvdata(device, input_dev);
 	init_completion(&input_dev->wait_event);
@@ -203,32 +195,6 @@ static void free_input_device(struct mousevsc_dev *device)
 	kfree(device);
 }
 
-/*
- * Get the inputdevice object iff exists and its refcount > 0
- */
-static struct mousevsc_dev *must_get_input_device(struct hv_device *device)
-{
-	struct mousevsc_dev *input_dev;
-
-	input_dev = hv_get_drvdata(device);
-
-	if (input_dev && atomic_read(&input_dev->ref_count))
-		atomic_inc(&input_dev->ref_count);
-	else
-		input_dev = NULL;
-
-	return input_dev;
-}
-
-static void put_input_device(struct hv_device *device)
-{
-	struct mousevsc_dev *input_dev;
-
-	input_dev = hv_get_drvdata(device);
-
-	atomic_dec(&input_dev->ref_count);
-}
-
 
 static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 				struct synthhid_device_info *device_info)
@@ -325,19 +291,13 @@ static void mousevsc_on_receive(struct hv_device *device,
 {
 	struct pipe_prt_msg *pipe_msg;
 	struct synthhid_msg *hid_msg;
-	struct mousevsc_dev *input_dev;
-
-	input_dev = must_get_input_device(device);
-	if (!input_dev)
-		return;
+	struct mousevsc_dev *input_dev = hv_get_drvdata(device);
 
 	pipe_msg = (struct pipe_prt_msg *)((unsigned long)packet +
 						(packet->offset8 << 3));
 
-	if (pipe_msg->type != PipeMessageData) {
-		put_input_device(device);
-		return ;
-	}
+	if (pipe_msg->type != PipeMessageData)
+		return;
 
 	hid_msg = (struct synthhid_msg *)&pipe_msg->data[0];
 
@@ -370,7 +330,6 @@ static void mousevsc_on_receive(struct hv_device *device,
 		break;
 	}
 
-	put_input_device(device);
 }
 
 static void mousevsc_on_channel_callback(void *context)
@@ -378,7 +337,6 @@ static void mousevsc_on_channel_callback(void *context)
 	const int packetSize = 0x100;
 	int ret = 0;
 	struct hv_device *device = (struct hv_device *)context;
-	struct mousevsc_dev *input_dev;
 
 	u32 bytes_recvd;
 	u64 req_id;
@@ -387,10 +345,6 @@ static void mousevsc_on_channel_callback(void *context)
 	unsigned char	*buffer = packet;
 	int	bufferlen = packetSize;
 
-	input_dev = must_get_input_device(device);
-
-	if (!input_dev)
-		return;
 
 	do {
 		ret = vmbus_recvpacket_raw(device->channel, buffer,
@@ -452,8 +406,6 @@ static void mousevsc_on_channel_callback(void *context)
 		}
 	} while (1);
 
-	put_input_device(device);
-
 	return;
 }
 
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 18/24] Staging: hv: mousevsc: Now cleanup mousevsc_remove()
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

Now, cleanup mousevsc_remove(). The mouse driver once initialized only
receives data from the host. So, by closing the channel first in the
unload path, we can properly deal with inflight packets. So, we don't need
the machinery for managing the life-cycle of the mousevsc_dev object.
Get rid of the unnecessary code.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   53 ++--------------------------------------
 1 files changed, 3 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 5324429..317d2be 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -197,9 +197,9 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *device)
 
 static void free_input_device(struct mousevsc_dev *device)
 {
-	WARN_ON(atomic_read(&device->ref_count) != 0);
 	kfree(device->hid_desc);
 	kfree(device->report_desc);
+	hv_set_drvdata(device->device, NULL);
 	kfree(device);
 }
 
@@ -229,39 +229,6 @@ static void put_input_device(struct hv_device *device)
 	atomic_dec(&input_dev->ref_count);
 }
 
-/*
- * Drop ref count to 1 to effectively disable get_input_device()
- */
-static struct mousevsc_dev *release_input_device(struct hv_device *device)
-{
-	struct mousevsc_dev *input_dev;
-
-	input_dev = hv_get_drvdata(device);
-
-	/* Busy wait until the ref drop to 2, then set it to 1  */
-	while (atomic_cmpxchg(&input_dev->ref_count, 2, 1) != 2)
-		udelay(100);
-
-	return input_dev;
-}
-
-/*
- * Drop ref count to 0. No one can use input_device object.
- */
-static struct mousevsc_dev *final_release_input_device(struct hv_device *device)
-{
-	struct mousevsc_dev *input_dev;
-
-	input_dev = hv_get_drvdata(device);
-
-	/* Busy wait until the ref drop to 1, then set it to 0  */
-	while (atomic_cmpxchg(&input_dev->ref_count, 1, 0) != 1)
-		udelay(100);
-
-	hv_set_drvdata(device, NULL);
-	return input_dev;
-}
-
 
 static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 				struct synthhid_device_info *device_info)
@@ -673,28 +640,14 @@ static int mousevsc_remove(struct hv_device *dev)
 {
 	struct mousevsc_dev *input_dev = hv_get_drvdata(dev);
 
+	vmbus_close(dev->channel);
+
 	if (input_dev->connected) {
 		hidinput_disconnect(input_dev->hid_device);
 		input_dev->connected = 0;
 		hid_destroy_device(input_dev->hid_device);
 	}
 
-
-	release_input_device(dev);
-
-
-	/*
-	 * At this point, all outbound traffic should be disable. We only
-	 * allow inbound traffic (responses) to proceed
-	 *
-	 * so that outstanding requests can be completed.
-	 */
-
-	input_dev = final_release_input_device(dev);
-
-	/* Close the channel */
-	vmbus_close(dev->channel);
-
 	free_input_device(input_dev);
 
 	return 0;
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 17/24] Staging: hv: mousevsc: Get rid of mousevsc_on_device_remove() by inlining code
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering; +Cc: Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

Get rid of mousevsc_on_device_remove() by inlining code.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   47 ++++++++++++++--------------------------
 1 files changed, 17 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 75ea2db..5324429 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -660,33 +660,6 @@ static int mousevsc_on_device_add(struct hv_device *device,
 	return ret;
 }
 
-static int mousevsc_on_device_remove(struct hv_device *device)
-{
-	struct mousevsc_dev *input_dev;
-	int ret = 0;
-
-
-	input_dev = release_input_device(device);
-
-
-	/*
-	 * At this point, all outbound traffic should be disable. We only
-	 * allow inbound traffic (responses) to proceed
-	 *
-	 * so that outstanding requests can be completed.
-	 */
-
-	input_dev = final_release_input_device(device);
-
-	/* Close the channel */
-	vmbus_close(device->channel);
-
-	free_input_device(input_dev);
-
-	return ret;
-}
-
-
 static int mousevsc_probe(struct hv_device *dev,
 			const struct hv_vmbus_device_id *dev_id)
 {
@@ -706,11 +679,25 @@ static int mousevsc_remove(struct hv_device *dev)
 		hid_destroy_device(input_dev->hid_device);
 	}
 
+
+	release_input_device(dev);
+
+
 	/*
-	 * Call to the vsc driver to let it know that the device
-	 * is being removed
+	 * At this point, all outbound traffic should be disable. We only
+	 * allow inbound traffic (responses) to proceed
+	 *
+	 * so that outstanding requests can be completed.
 	 */
-	return mousevsc_on_device_remove(dev);
+
+	input_dev = final_release_input_device(dev);
+
+	/* Close the channel */
+	vmbus_close(dev->channel);
+
+	free_input_device(input_dev);
+
+	return 0;
 }
 
 static const struct hv_vmbus_device_id id_table[] = {
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 16/24] Staging: hv: mousevsc: Cleanup mousevsc_connect_to_vsp()
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

Cleanup mousevsc_connect_to_vsp(). There is no need to take reference on the
mousevsc device object when we are setting up the device. As part of this
cleanup get rid of get_input_device() as this function is only used here.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   34 +---------------------------------
 1 files changed, 1 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index fc0ba68..75ea2db 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -204,32 +204,6 @@ static void free_input_device(struct mousevsc_dev *device)
 }
 
 /*
- * Get the inputdevice object if exists and its refcount > 1
- */
-static struct mousevsc_dev *get_input_device(struct hv_device *device)
-{
-	struct mousevsc_dev *input_dev;
-
-	input_dev = hv_get_drvdata(device);
-
-/*
- *	FIXME
- *	This sure isn't a valid thing to print for debugging, no matter
- *	what the intention is...
- *
- *	printk(KERN_ERR "-------------------------> REFCOUNT = %d",
- *	       input_dev->ref_count);
- */
-
-	if (input_dev && atomic_read(&input_dev->ref_count) > 1)
-		atomic_inc(&input_dev->ref_count);
-	else
-		input_dev = NULL;
-
-	return input_dev;
-}
-
-/*
  * Get the inputdevice object iff exists and its refcount > 0
  */
 static struct mousevsc_dev *must_get_input_device(struct hv_device *device)
@@ -520,15 +494,10 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 {
 	int ret = 0;
 	int t;
-	struct mousevsc_dev *input_dev;
+	struct mousevsc_dev *input_dev = hv_get_drvdata(device);
 	struct mousevsc_prt_msg *request;
 	struct mousevsc_prt_msg *response;
 
-	input_dev = get_input_device(device);
-
-	if (!input_dev)
-		return -ENODEV;
-
 
 	request = &input_dev->protocol_req;
 
@@ -584,7 +553,6 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		ret = -ENOMEM;
 
 cleanup:
-	put_input_device(device);
 
 	return ret;
 }
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 15/24] Staging: hv: mousevsc: Get rid of mousevsc_on_send_completion()
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering; +Cc: Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

We don't need to handle the "send complete" callback - nothing needs to be done
here; get rid of the code.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   21 ---------------------
 1 files changed, 0 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 38e31ae..fc0ba68 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -288,25 +288,6 @@ static struct mousevsc_dev *final_release_input_device(struct hv_device *device)
 	return input_dev;
 }
 
-static void mousevsc_on_send_completion(struct hv_device *device,
-					struct vmpacket_descriptor *packet)
-{
-	struct mousevsc_dev *input_dev;
-	void *request;
-
-	input_dev = must_get_input_device(device);
-	if (!input_dev)
-		return;
-
-	request = (void *)(unsigned long)packet->trans_id;
-
-	if (request == &input_dev->protocol_req) {
-		/* FIXME */
-		/* Shouldn't we be doing something here? */
-	}
-
-	put_input_device(device);
-}
 
 static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 				struct synthhid_device_info *device_info)
@@ -480,8 +461,6 @@ static void mousevsc_on_channel_callback(void *context)
 
 				switch (desc->type) {
 				case VM_PKT_COMP:
-					mousevsc_on_send_completion(
-						device, desc);
 					break;
 
 				case VM_PKT_DATA_INBAND:
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 14/24] Staging: hv: mousevsc: Cleanup alloc_input_device()
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

Cleanup alloc_input_device(); you can directly set the reference count.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 092c0ff..38e31ae 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -186,7 +186,7 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *device)
 	 * Set to 2 to allow both inbound and outbound traffics
 	 * (ie get_input_device() and must_get_input_device()) to proceed.
 	 */
-	atomic_cmpxchg(&input_dev->ref_count, 0, 2);
+	atomic_set(&input_dev->ref_count, 2);
 
 	input_dev->device = device;
 	hv_set_drvdata(device, input_dev);
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 13/24] Staging: hv: mousevsc: Get rid of the unused state: num_outstanding_req
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

Get rid of the unused state: num_outstanding_req in struct mousevsc_dev.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 326d972..092c0ff 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -157,7 +157,6 @@ struct mousevsc_dev {
 	struct hv_device	*device;
 	/* 0 indicates the device is being destroyed */
 	atomic_t		ref_count;
-	int			num_outstanding_req;
 	unsigned char		init_complete;
 	struct mousevsc_prt_msg	protocol_req;
 	struct mousevsc_prt_msg	protocol_resp;
@@ -729,8 +728,6 @@ static int mousevsc_on_device_remove(struct hv_device *device)
 	 *
 	 * so that outstanding requests can be completed.
 	 */
-	while (input_dev->num_outstanding_req)
-		udelay(100);
 
 	input_dev = final_release_input_device(device);
 
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 12/24] Staging: hv: mousevsc: Free allocated memory in free_input_device()
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering; +Cc: Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

Free all allocated memory in free_input_device().

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 57bc4a3..326d972 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -199,6 +199,8 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *device)
 static void free_input_device(struct mousevsc_dev *device)
 {
 	WARN_ON(atomic_read(&device->ref_count) != 0);
+	kfree(device->hid_desc);
+	kfree(device->report_desc);
 	kfree(device);
 }
 
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 11/24] Staging: hv: mousevsc: Get rid of unnecessary pr_* calls
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering; +Cc: Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

Get rid of unnecessary pr_* calls.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   64 +++++++----------------------------------
 1 files changed, 11 insertions(+), 53 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index fc1f3e6..57bc4a3 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -294,10 +294,8 @@ static void mousevsc_on_send_completion(struct hv_device *device,
 	void *request;
 
 	input_dev = must_get_input_device(device);
-	if (!input_dev) {
-		pr_err("unable to get input device...device being destroyed?");
+	if (!input_dev)
 		return;
-	}
 
 	request = (void *)(unsigned long)packet->trans_id;
 
@@ -329,11 +327,8 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 
 	input_device->hid_desc = kzalloc(desc->bLength, GFP_ATOMIC);
 
-	if (!input_device->hid_desc) {
-		pr_err("unable to allocate hid descriptor - size %d",
-			 desc->bLength);
+	if (!input_device->hid_desc)
 		goto cleanup;
-	}
 
 	memcpy(input_device->hid_desc, desc, desc->bLength);
 
@@ -344,11 +339,8 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 	input_device->report_desc = kzalloc(input_device->report_desc_size,
 					  GFP_ATOMIC);
 
-	if (!input_device->report_desc) {
-		pr_err("unable to allocate report descriptor - size %d",
-			   input_device->report_desc_size);
+	if (!input_device->report_desc)
 		goto cleanup;
-	}
 
 	memcpy(input_device->report_desc,
 	       ((unsigned char *)desc) + desc->bLength,
@@ -371,11 +363,8 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 			(unsigned long)&ack,
 			VM_PKT_DATA_INBAND,
 			VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-	if (ret != 0) {
-		pr_err("unable to send synthhid device info ack - ret %d",
-			   ret);
+	if (ret != 0)
 		goto cleanup;
-	}
 
 	complete(&input_device->wait_event);
 
@@ -397,10 +386,8 @@ static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device,
 {
 	struct hv_driver *input_drv;
 
-	if (!input_device->init_complete) {
-		pr_info("Initialization incomplete...ignoring input_report msg");
+	if (!input_device->init_complete)
 		return;
-	}
 
 	input_drv = drv_to_hv_drv(input_device->device->device.driver);
 
@@ -418,17 +405,13 @@ static void mousevsc_on_receive(struct hv_device *device,
 	struct mousevsc_dev *input_dev;
 
 	input_dev = must_get_input_device(device);
-	if (!input_dev) {
-		pr_err("unable to get input device...device being destroyed?");
+	if (!input_dev)
 		return;
-	}
 
 	pipe_msg = (struct pipe_prt_msg *)((unsigned long)packet +
 						(packet->offset8 << 3));
 
 	if (pipe_msg->type != PipeMessageData) {
-		pr_err("unknown pipe msg type - type %d len %d",
-			   pipe_msg->type, pipe_msg->size);
 		put_input_device(device);
 		return ;
 	}
@@ -483,10 +466,8 @@ static void mousevsc_on_channel_callback(void *context)
 
 	input_dev = must_get_input_device(device);
 
-	if (!input_dev) {
-		pr_err("unable to get input device...device being destroyed?");
+	if (!input_dev)
 		return;
-	}
 
 	do {
 		ret = vmbus_recvpacket_raw(device->channel, buffer,
@@ -545,8 +526,6 @@ static void mousevsc_on_channel_callback(void *context)
 				bufferlen = packetSize;
 
 				/* Try again next time around */
-				pr_err("unable to allocate buffer of size %d!",
-				       bytes_recvd);
 				break;
 			}
 		}
@@ -567,10 +546,8 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 
 	input_dev = get_input_device(device);
 
-	if (!input_dev) {
-		pr_err("unable to get input device...device being destroyed?");
+	if (!input_dev)
 		return -ENODEV;
-	}
 
 
 	request = &input_dev->protocol_req;
@@ -587,7 +564,6 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 	request->request.header.size = sizeof(unsigned int);
 	request->request.version_requested.version = SYNTHHID_INPUT_VERSION;
 
-	pr_info("synthhid protocol request...");
 
 	ret = vmbus_sendpacket(device->channel, request,
 				sizeof(struct pipe_prt_msg) -
@@ -596,10 +572,8 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 				(unsigned long)request,
 				VM_PKT_DATA_INBAND,
 				VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-	if (ret != 0) {
-		pr_err("unable to send synthhid protocol request.");
+	if (ret != 0)
 		goto cleanup;
-	}
 
 	t = wait_for_completion_timeout(&input_dev->wait_event, 5*HZ);
 	if (t == 0) {
@@ -626,9 +600,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 	 * We should have gotten the device attr, hid desc and report
 	 * desc at this point
 	 */
-	if (!input_dev->dev_info_status)
-		pr_info("**** input channel up and running!! ****");
-	else
+	if (input_dev->dev_info_status)
 		ret = -ENOMEM;
 
 cleanup:
@@ -710,18 +682,14 @@ static int mousevsc_on_device_add(struct hv_device *device,
 		);
 
 	if (ret != 0) {
-		pr_err("unable to open channel: %d", ret);
 		free_input_device(input_dev);
 		return ret;
 	}
 
-	pr_info("InputVsc channel open: %d", ret);
 
 	ret = mousevsc_connect_to_vsp(device);
 
 	if (ret != 0) {
-		pr_err("unable to connect channel: %d", ret);
-
 		vmbus_close(device->channel);
 		free_input_device(input_dev);
 		return ret;
@@ -749,8 +717,6 @@ static int mousevsc_on_device_remove(struct hv_device *device)
 	struct mousevsc_dev *input_dev;
 	int ret = 0;
 
-	pr_info("disabling input device (%p)...",
-		    hv_get_drvdata(device));
 
 	input_dev = release_input_device(device);
 
@@ -761,19 +727,11 @@ static int mousevsc_on_device_remove(struct hv_device *device)
 	 *
 	 * so that outstanding requests can be completed.
 	 */
-	while (input_dev->num_outstanding_req) {
-		pr_info("waiting for %d requests to complete...",
-			input_dev->num_outstanding_req);
-
+	while (input_dev->num_outstanding_req)
 		udelay(100);
-	}
-
-	pr_info("removing input device (%p)...", hv_get_drvdata(device));
 
 	input_dev = final_release_input_device(device);
 
-	pr_info("input device (%p) safe to remove", input_dev);
-
 	/* Close the channel */
 	vmbus_close(device->channel);
 
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 10/24] Staging: hv: mousevsc: Cleanup error handling
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering; +Cc: Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

Cleanup error handling in this driver; use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   23 +++++++----------------
 1 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 8dd902a..fc1f3e6 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -569,7 +569,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 
 	if (!input_dev) {
 		pr_err("unable to get input device...device being destroyed?");
-		return -1;
+		return -ENODEV;
 	}
 
 
@@ -612,7 +612,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 	if (!response->response.approved) {
 		pr_err("synthhid protocol request failed (version %d)",
 		       SYNTHHID_INPUT_VERSION);
-		ret = -1;
+		ret = -ENODEV;
 		goto cleanup;
 	}
 
@@ -629,7 +629,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 	if (!input_dev->dev_info_status)
 		pr_info("**** input channel up and running!! ****");
 	else
-		ret = -1;
+		ret = -ENOMEM;
 
 cleanup:
 	put_input_device(device);
@@ -694,10 +694,8 @@ static int mousevsc_on_device_add(struct hv_device *device,
 
 	input_dev = alloc_input_device(device);
 
-	if (!input_dev) {
-		ret = -1;
-		goto cleanup;
-	}
+	if (!input_dev)
+		return -ENOMEM;
 
 	input_dev->init_complete = false;
 
@@ -714,7 +712,7 @@ static int mousevsc_on_device_add(struct hv_device *device,
 	if (ret != 0) {
 		pr_err("unable to open channel: %d", ret);
 		free_input_device(input_dev);
-		return -1;
+		return ret;
 	}
 
 	pr_info("InputVsc channel open: %d", ret);
@@ -743,7 +741,6 @@ static int mousevsc_on_device_add(struct hv_device *device,
 
 	input_dev->init_complete = true;
 
-cleanup:
 	return ret;
 }
 
@@ -789,16 +786,10 @@ static int mousevsc_on_device_remove(struct hv_device *device)
 static int mousevsc_probe(struct hv_device *dev,
 			const struct hv_vmbus_device_id *dev_id)
 {
-	int ret = 0;
-
 
 	/* Call to the vsc driver to add the device */
-	ret = mousevsc_on_device_add(dev, NULL);
+	return mousevsc_on_device_add(dev, NULL);
 
-	if (ret != 0)
-		return -1;
-
-	return 0;
 }
 
 static int mousevsc_remove(struct hv_device *dev)
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 09/24] Staging: hv: mousevsc: Get rid of unnecessary DPRINT calls
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

Get rid of unnecessary DPRINT calls.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   18 +++---------------
 1 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 8d94aef..8dd902a 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -665,10 +665,8 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
 	hid_dev->ll_driver = &mousevsc_ll_driver;
 	hid_dev->driver = &mousevsc_hid_driver;
 
-	if (hid_parse_report(hid_dev, packet, len)) {
-		DPRINT_INFO(INPUTVSC_DRV, "Unable to call hd_parse_report");
+	if (hid_parse_report(hid_dev, packet, len))
 		return;
-	}
 
 	hid_dev->bus = BUS_VIRTUAL;
 	hid_dev->vendor = input_device->hid_dev_info.vendor;
@@ -797,11 +795,8 @@ static int mousevsc_probe(struct hv_device *dev,
 	/* Call to the vsc driver to add the device */
 	ret = mousevsc_on_device_add(dev, NULL);
 
-	if (ret != 0) {
-		DPRINT_ERR(INPUTVSC_DRV, "unable to add input vsc device");
-
+	if (ret != 0)
 		return -1;
-	}
 
 	return 0;
 }
@@ -809,7 +804,6 @@ static int mousevsc_probe(struct hv_device *dev,
 static int mousevsc_remove(struct hv_device *dev)
 {
 	struct mousevsc_dev *input_dev = hv_get_drvdata(dev);
-	int ret;
 
 	if (input_dev->connected) {
 		hidinput_disconnect(input_dev->hid_device);
@@ -821,13 +815,7 @@ static int mousevsc_remove(struct hv_device *dev)
 	 * Call to the vsc driver to let it know that the device
 	 * is being removed
 	 */
-	ret = mousevsc_on_device_remove(dev);
-	if (ret != 0) {
-		DPRINT_ERR(INPUTVSC_DRV,
-			   "unable to remove vsc device (ret %d)", ret);
-	}
-
-	return ret;
+	return mousevsc_on_device_remove(dev);
 }
 
 static const struct hv_vmbus_device_id id_table[] = {
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 08/24] Staging: hv: mousevsc: Cleanup and properly implement reportdesc_callback()
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

Cleanup and properly implement reportdesc_callback(); properly allocate the 
hid_device and properly initialize the hid device structure.


Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   56 +++++++++++++++++------------------------
 1 files changed, 23 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index ea9e1f3..8d94aef 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -646,56 +646,45 @@ static void mousevsc_hid_close(struct hid_device *hid)
 {
 }
 
+static struct hid_ll_driver mousevsc_ll_driver = {
+	.open = mousevsc_hid_open,
+	.close = mousevsc_hid_close,
+};
+
+static struct hid_driver mousevsc_hid_driver;
+
 static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
 {
 	struct hid_device *hid_dev;
 	struct mousevsc_dev *input_device = hv_get_drvdata(dev);
 
-	/* hid_debug = -1; */
-	hid_dev = kmalloc(sizeof(struct hid_device), GFP_KERNEL);
+	hid_dev = hid_allocate_device();
+	if (IS_ERR(hid_dev))
+		return;
+
+	hid_dev->ll_driver = &mousevsc_ll_driver;
+	hid_dev->driver = &mousevsc_hid_driver;
 
 	if (hid_parse_report(hid_dev, packet, len)) {
 		DPRINT_INFO(INPUTVSC_DRV, "Unable to call hd_parse_report");
 		return;
 	}
 
-	if (hid_dev) {
-		DPRINT_INFO(INPUTVSC_DRV, "hid_device created");
-
-		hid_dev->ll_driver->open  = mousevsc_hid_open;
-		hid_dev->ll_driver->close = mousevsc_hid_close;
+	hid_dev->bus = BUS_VIRTUAL;
+	hid_dev->vendor = input_device->hid_dev_info.vendor;
+	hid_dev->product = input_device->hid_dev_info.product;
+	hid_dev->version = input_device->hid_dev_info.version;
 
-		hid_dev->bus = BUS_VIRTUAL;
-		hid_dev->vendor = input_device->hid_dev_info.vendor;
-		hid_dev->product = input_device->hid_dev_info.product;
-		hid_dev->version = input_device->hid_dev_info.version;
-		hid_dev->dev = dev->device;
+	sprintf(hid_dev->name, "%s", "Microsoft Vmbus HID-compliant Mouse");
 
-		sprintf(hid_dev->name, "%s",
-			"Microsoft Vmbus HID-compliant Mouse");
+	if (!hidinput_connect(hid_dev, 0)) {
+		hid_dev->claimed |= HID_CLAIMED_INPUT;
 
-		/*
-		 * HJ Do we want to call it with a 0
-		 */
-		if (!hidinput_connect(hid_dev, 0)) {
-			hid_dev->claimed |= HID_CLAIMED_INPUT;
-
-			input_device->connected = 1;
-
-			DPRINT_INFO(INPUTVSC_DRV,
-				     "HID device claimed by input\n");
-		}
-
-		if (!hid_dev->claimed) {
-			DPRINT_ERR(INPUTVSC_DRV,
-				    "HID device not claimed by "
-				    "input or hiddev\n");
-		}
+		input_device->connected = 1;
 
-		input_device->hid_device = hid_dev;
 	}
 
-	kfree(hid_dev);
+	input_device->hid_device = hid_dev;
 }
 
 static int mousevsc_on_device_add(struct hv_device *device,
@@ -825,6 +814,7 @@ static int mousevsc_remove(struct hv_device *dev)
 	if (input_dev->connected) {
 		hidinput_disconnect(input_dev->hid_device);
 		input_dev->connected = 0;
+		hid_destroy_device(input_dev->hid_device);
 	}
 
 	/*
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 07/24] Staging: hv: mousevsc: Use completion primitive to synchronize
From: K. Y. Srinivasan @ 2011-09-29 18:54 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1317322504-9788-1-git-send-email-kys@microsoft.com>

Use completion primitive to synchronize.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   30 ++++++++++--------------------
 1 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 74faa26..ea9e1f3 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -162,10 +162,7 @@ struct mousevsc_dev {
 	struct mousevsc_prt_msg	protocol_req;
 	struct mousevsc_prt_msg	protocol_resp;
 	/* Synchronize the request/response if needed */
-	wait_queue_head_t	protocol_wait_event;
-	wait_queue_head_t	dev_info_wait_event;
-	int			protocol_wait_condition;
-	int			device_wait_condition;
+	struct completion	wait_event;
 	int			dev_info_status;
 
 	struct hid_descriptor	*hid_desc;
@@ -194,6 +191,7 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *device)
 
 	input_dev->device = device;
 	hv_set_drvdata(device, input_dev);
+	init_completion(&input_dev->wait_event);
 
 	return input_dev;
 }
@@ -379,8 +377,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 		goto cleanup;
 	}
 
-	input_device->device_wait_condition = 1;
-	wake_up(&input_device->dev_info_wait_event);
+	complete(&input_device->wait_event);
 
 	return;
 
@@ -392,8 +389,7 @@ cleanup:
 	input_device->report_desc = NULL;
 
 	input_device->dev_info_status = -1;
-	input_device->device_wait_condition = 1;
-	wake_up(&input_device->dev_info_wait_event);
+	complete(&input_device->wait_event);
 }
 
 static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device,
@@ -444,8 +440,7 @@ static void mousevsc_on_receive(struct hv_device *device,
 		memcpy(&input_dev->protocol_resp, pipe_msg,
 		       pipe_msg->size + sizeof(struct pipe_prt_msg) -
 		       sizeof(unsigned char));
-		input_dev->protocol_wait_condition = 1;
-		wake_up(&input_dev->protocol_wait_event);
+		complete(&input_dev->wait_event);
 		break;
 
 	case SynthHidInitialDeviceInfo:
@@ -565,6 +560,7 @@ static void mousevsc_on_channel_callback(void *context)
 static int mousevsc_connect_to_vsp(struct hv_device *device)
 {
 	int ret = 0;
+	int t;
 	struct mousevsc_dev *input_dev;
 	struct mousevsc_prt_msg *request;
 	struct mousevsc_prt_msg *response;
@@ -576,8 +572,6 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		return -1;
 	}
 
-	init_waitqueue_head(&input_dev->protocol_wait_event);
-	init_waitqueue_head(&input_dev->dev_info_wait_event);
 
 	request = &input_dev->protocol_req;
 
@@ -607,10 +601,8 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		goto cleanup;
 	}
 
-	input_dev->protocol_wait_condition = 0;
-	wait_event_timeout(input_dev->protocol_wait_event,
-		input_dev->protocol_wait_condition, msecs_to_jiffies(1000));
-	if (input_dev->protocol_wait_condition == 0) {
+	t = wait_for_completion_timeout(&input_dev->wait_event, 5*HZ);
+	if (t == 0) {
 		ret = -ETIMEDOUT;
 		goto cleanup;
 	}
@@ -624,10 +616,8 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		goto cleanup;
 	}
 
-	input_dev->device_wait_condition = 0;
-	wait_event_timeout(input_dev->dev_info_wait_event,
-		input_dev->device_wait_condition, msecs_to_jiffies(1000));
-	if (input_dev->device_wait_condition == 0) {
+	t = wait_for_completion_timeout(&input_dev->wait_event, 5*HZ);
+	if (t == 0) {
 		ret = -ETIMEDOUT;
 		goto cleanup;
 	}
-- 
1.7.4.1

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox