[tip:tools/kvm] kvm tools: Fixes for rtc module

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

 



Commit-ID:  2a91235c44d0471651aa0ed2253821d63e035976
Gitweb:     http://git.kernel.org/tip/2a91235c44d0471651aa0ed2253821d63e035976
Author:     Sasha Levin <levinsasha928@xxxxxxxxx>
AuthorDate: Mon, 19 Dec 2011 11:28:17 +0200
Committer:  Sasha Levin <levinsasha928@xxxxxxxxx>
CommitDate: Sun, 29 Jan 2012 09:38:04 -0500

kvm tools: Fixes for rtc module

Fixes include:
 - Error handling
 - Cleanup
 - Standard init/uninit

Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx>
---
 tools/kvm/builtin-run.c     |   10 +++++++++-
 tools/kvm/hw/rtc.c          |   27 +++++++++++++++++++++++----
 tools/kvm/include/kvm/rtc.h |    5 ++++-
 3 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index 7fd8303..d18efce 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -1117,7 +1117,11 @@ static int kvm_cmd_run_init(int argc, const char **argv)
 
 	ioport__setup_arch();
 
-	rtc__init();
+	r = rtc__init(kvm);
+	if (r < 0) {
+		pr_err("rtc__init() failed with error %d\n", r);
+		goto fail;
+	}
 
 	r = serial8250__init(kvm);
 	if (r < 0) {
@@ -1278,6 +1282,10 @@ static void kvm_cmd_run_exit(int guest_ret)
 	if (r < 0)
 		pr_warning("serial8250__exit() failed with error %d\n", r);
 
+	r = rtc__exit(kvm);
+	if (r < 0)
+		pr_warning("rtc__exit() failed with error %d\n", r);
+
 	r = kvm__arch_free_firmware(kvm);
 	if (r < 0)
 		pr_warning("kvm__arch_free_firmware() failed with error %d\n", r);
diff --git a/tools/kvm/hw/rtc.c b/tools/kvm/hw/rtc.c
index 6d4a05a..b4f9f1f 100644
--- a/tools/kvm/hw/rtc.c
+++ b/tools/kvm/hw/rtc.c
@@ -100,7 +100,6 @@ static bool cmos_ram_index_out(struct ioport *ioport, struct kvm *kvm, u16 port,
 	u8 value = ioport__read8(data);
 
 	kvm->nmi_disabled	= value & (1UL << 7);
-
 	rtc.cmos_idx		= value & ~(1UL << 7);
 
 	return true;
@@ -110,9 +109,29 @@ static struct ioport_operations cmos_ram_index_ioport_ops = {
 	.io_out		= cmos_ram_index_out,
 };
 
-void rtc__init(void)
+int rtc__init(struct kvm *kvm)
 {
+	int r = 0;
+
 	/* PORT 0070-007F - CMOS RAM/RTC (REAL TIME CLOCK) */
-	ioport__register(0x0070, &cmos_ram_index_ioport_ops, 1, NULL);
-	ioport__register(0x0071, &cmos_ram_data_ioport_ops, 1, NULL);
+	r = ioport__register(0x0070, &cmos_ram_index_ioport_ops, 1, NULL);
+	if (r < 0)
+		return r;
+
+	r = ioport__register(0x0071, &cmos_ram_data_ioport_ops, 1, NULL);
+	if (r < 0) {
+		ioport__unregister(0x0071);
+		return r;
+	}
+
+	return r;
 }
+
+int rtc__exit(struct kvm *kvm)
+{
+	/* PORT 0070-007F - CMOS RAM/RTC (REAL TIME CLOCK) */
+	ioport__unregister(0x0070);
+	ioport__unregister(0x0071);
+
+	return 0;
+}
\ No newline at end of file
diff --git a/tools/kvm/include/kvm/rtc.h b/tools/kvm/include/kvm/rtc.h
index 0b8d9f9..6aa9299 100644
--- a/tools/kvm/include/kvm/rtc.h
+++ b/tools/kvm/include/kvm/rtc.h
@@ -1,6 +1,9 @@
 #ifndef KVM__RTC_H
 #define KVM__RTC_H
 
-void rtc__init(void);
+struct kvm;
+
+int rtc__init(struct kvm *kvm);
+int rtc__exit(struct kvm *kvm);
 
 #endif /* KVM__RTC_H */
--
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