]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools, rtc: Introduce 'struct rtc_device'
authorPekka Enberg <penberg@kernel.org>
Mon, 28 Nov 2011 19:02:19 +0000 (21:02 +0200)
committerPekka Enberg <penberg@kernel.org>
Mon, 28 Nov 2011 19:02:19 +0000 (21:02 +0200)
This patch introduces a 'struct rtc_device' in preparation for implementing
missing RTC features like alarms which need auxiliary data structures.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/hw/rtc.c

index c6879cce9fe886e0e75b742e8f0cfca46f3ae358..f351e1a1986843db9af26f25280fa5303e7bb42f 100644 (file)
@@ -5,8 +5,6 @@
 
 #include <time.h>
 
-static u8 cmos_index;
-
 #define CMOS_RTC_SECONDS               0x00
 #define CMOS_RTC_MINUTES               0x02
 #define CMOS_RTC_HOURS                 0x04
@@ -14,6 +12,12 @@ static u8 cmos_index;
 #define CMOS_RTC_MONTH                 0x08
 #define CMOS_RTC_YEAR                  0x09
 
+struct rtc_device {
+       u8                      cmos_idx;
+};
+
+static struct rtc_device       rtc;
+
 static inline unsigned char bin2bcd(unsigned val)
 {
        return ((val / 10) << 4) + val % 10;
@@ -28,7 +32,7 @@ static bool cmos_ram_data_in(struct ioport *ioport, struct kvm *kvm, u16 port, v
 
        tm = gmtime(&ti);
 
-       switch (cmos_index) {
+       switch (rtc.cmos_idx) {
        case CMOS_RTC_SECONDS:
                ioport__write8(data, bin2bcd(tm->tm_sec));
                break;
@@ -64,13 +68,11 @@ static struct ioport_operations cmos_ram_data_ioport_ops = {
 
 static bool cmos_ram_index_out(struct ioport *ioport, struct kvm *kvm, u16 port, void *data, int size)
 {
-       u8 value;
-
-       value   = ioport__read8(data);
+       u8 value = ioport__read8(data);
 
        kvm->nmi_disabled       = value & (1UL << 7);
 
-       cmos_index              = value & ~(1UL << 7);
+       rtc.cmos_idx            = value & ~(1UL << 7);
 
        return true;
 }