From: Pekka Enberg Date: Mon, 28 Nov 2011 19:02:19 +0000 (+0200) Subject: kvm tools, rtc: Introduce 'struct rtc_device' X-Git-Tag: next-20111129~3^2~5 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=80f81ac48228e13fe0d3e5c388cb6d73b76b8503;p=karo-tx-linux.git kvm tools, rtc: Introduce 'struct rtc_device' 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 --- diff --git a/tools/kvm/hw/rtc.c b/tools/kvm/hw/rtc.c index c6879cce9fe8..f351e1a19868 100644 --- a/tools/kvm/hw/rtc.c +++ b/tools/kvm/hw/rtc.c @@ -5,8 +5,6 @@ #include -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; }