[tip:tools/kvm] kvm tools: Code cleanups to hw/vesa.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  76c1d296c85a580a354186f1b675c8c9b5eb0e9b
Gitweb:     http://git.kernel.org/tip/76c1d296c85a580a354186f1b675c8c9b5eb0e9b
Author:     Pekka Enberg <penberg@xxxxxxxxxx>
AuthorDate: Mon, 23 May 2011 17:52:51 +0300
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Mon, 23 May 2011 17:52:51 +0300

kvm tools: Code cleanups to hw/vesa.c

Tidy up the code in hw/vesa.c:

  - Make videomem local to hw/vesa.c

  - Remove debugging printf() calls

  - Fix up coding style issues

Cc: John Floren <john@xxxxxxxxxxx>
Cc: Sasha Levin <levinsasha928@xxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/hw/vesa.c          |   45 ++++++++++++++++++++++-------------------
 tools/kvm/include/kvm/vesa.h |    2 -
 2 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/tools/kvm/hw/vesa.c b/tools/kvm/hw/vesa.c
index 0be1617..6ab07ee 100644
--- a/tools/kvm/hw/vesa.c
+++ b/tools/kvm/hw/vesa.c
@@ -1,19 +1,20 @@
 #include "kvm/vesa.h"
+
+#include "kvm/virtio-pci-dev.h"
+#include "kvm/kvm-cpu.h"
 #include "kvm/ioport.h"
 #include "kvm/util.h"
+#include "kvm/irq.h"
 #include "kvm/kvm.h"
 #include "kvm/pci.h"
-#include "kvm/kvm-cpu.h"
-#include "kvm/irq.h"
-#include "kvm/virtio-pci-dev.h"
-
-#include <rfb/rfb.h>
 
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <inttypes.h>
 #include <unistd.h>
 
+#include <rfb/rfb.h>
+
 #define VESA_QUEUE_SIZE		128
 #define VESA_IRQ		14
 
@@ -23,23 +24,21 @@
  */
 #define VESA_UPDATE_TIME	6000
 
-u8 videomem[VESA_MEM_SIZE];
+static char videomem[VESA_MEM_SIZE];
 
 static bool vesa_pci_io_in(struct kvm *kvm, u16 port, void *data, int size, u32 count)
 {
-	printf("vesa in port=%u\n", port);
 	return true;
 }
 
 static bool vesa_pci_io_out(struct kvm *kvm, u16 port, void *data, int size, u32 count)
 {
-	printf("vesa out port=%u\n", port);
 	return true;
 }
 
 static struct ioport_operations vesa_io_ops = {
-	.io_in	= vesa_pci_io_in,
-	.io_out	= vesa_pci_io_out,
+	.io_in			= vesa_pci_io_in,
+	.io_out			= vesa_pci_io_out,
 };
 
 static struct pci_device_header vesa_pci_device = {
@@ -50,17 +49,17 @@ static struct pci_device_header vesa_pci_device = {
 	.class			= 0x030000,
 	.subsys_vendor_id	= PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET,
 	.subsys_id		= PCI_SUBSYSTEM_ID_VESA,
-	.bar[0]			= IOPORT_VESA | PCI_BASE_ADDRESS_SPACE_IO,
+	.bar[0]			= IOPORT_VESA   | PCI_BASE_ADDRESS_SPACE_IO,
 	.bar[1]			= VESA_MEM_ADDR | PCI_BASE_ADDRESS_SPACE_MEMORY,
 };
 
 
 void vesa_mmio_callback(u64 addr, u8 *data, u32 len, u8 is_write)
 {
-	if (is_write)
-		memcpy(&videomem[addr - VESA_MEM_ADDR], data, len);
+	if (!is_write)
+		return;
 
-	return;
+	memcpy(&videomem[addr - VESA_MEM_ADDR], data, len);
 }
 
 void vesa__init(struct kvm *kvm)
@@ -71,12 +70,15 @@ void vesa__init(struct kvm *kvm)
 	if (irq__register_device(PCI_DEVICE_ID_VESA, &dev, &pin, &line) < 0)
 		return;
 
-	vesa_pci_device.irq_pin = pin;
-	vesa_pci_device.irq_line = line;
+	vesa_pci_device.irq_pin		= pin;
+	vesa_pci_device.irq_line	= line;
+
 	pci__register(&vesa_pci_device, dev);
+
 	ioport__register(IOPORT_VESA, &vesa_io_ops, IOPORT_VESA_SIZE);
 
 	kvm__register_mmio(VESA_MEM_ADDR, VESA_MEM_SIZE, &vesa_mmio_callback);
+
 	pthread_create(&thread, NULL, vesa__dovnc, kvm);
 }
 
@@ -90,13 +92,14 @@ void *vesa__dovnc(void *v)
 	 * Make a fake argc and argv because the getscreen function
 	 * seems to want it.
 	 */
-	int ac = 1;
-	char av[1][1] = {{0} };
+	char argv[1][1] = {{0}};
+	int argc = 1;
+
 	rfbScreenInfoPtr server;
 
-	server = rfbGetScreen(&ac, (char **)av, VESA_WIDTH, VESA_HEIGHT, 8, 3, 4);
-	server->frameBuffer = (char *)videomem;
-	server->alwaysShared = TRUE;
+	server = rfbGetScreen(&argc, (char **) argv, VESA_WIDTH, VESA_HEIGHT, 8, 3, 4);
+	server->frameBuffer		= videomem;
+	server->alwaysShared		= TRUE;
 	rfbInitServer(server);
 
 	while (rfbIsActive(server)) {
diff --git a/tools/kvm/include/kvm/vesa.h b/tools/kvm/include/kvm/vesa.h
index ff3ec75..e9522a5 100644
--- a/tools/kvm/include/kvm/vesa.h
+++ b/tools/kvm/include/kvm/vesa.h
@@ -22,6 +22,4 @@ void int10_handler(struct int10_args *args);
 void vesa__init(struct kvm *self) { }
 #endif
 
-extern u8 videomem[VESA_MEM_SIZE];
-
 #endif
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux