From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfDAx-0002FT-83 for qemu-devel@nongnu.org; Sun, 02 Dec 2012 12:17:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TfDAw-0000OW-5I for qemu-devel@nongnu.org; Sun, 02 Dec 2012 12:17:55 -0500 Received: from mail-bk0-f45.google.com ([209.85.214.45]:35571) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfDAv-0000OR-UV for qemu-devel@nongnu.org; Sun, 02 Dec 2012 12:17:54 -0500 Received: by mail-bk0-f45.google.com with SMTP id jk13so680283bkc.4 for ; Sun, 02 Dec 2012 09:17:53 -0800 (PST) Message-ID: <50BB8D3D.8050205@gmail.com> Date: Sun, 02 Dec 2012 18:17:49 +0100 From: Antoine Mathys MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 2/4] hw/ds1338.c: Minor fixes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, paul@codesourcery.com Minor fixes in the handling of the RTC registers. Signed-off-by: Antoine Mathys --- hw/ds1338.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/ds1338.c b/hw/ds1338.c index 1274b22..1fb152e 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -62,9 +62,9 @@ static void capture_current_time(DS1338State *s) } else { s->nvram[2] = to_bcd(now.tm_hour); } - s->nvram[3] = to_bcd(now.tm_wday) + 1; + s->nvram[3] = to_bcd(now.tm_wday + 1); s->nvram[4] = to_bcd(now.tm_mday); - s->nvram[5] = to_bcd(now.tm_mon) + 1; + s->nvram[5] = to_bcd(now.tm_mon + 1); s->nvram[6] = to_bcd(now.tm_year - 100); } @@ -119,7 +119,8 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data) s->addr_byte = false; return 0; } - if (s->ptr < 8) { + if (s->ptr < 7) { + /* Time register. */ struct tm now; qemu_get_timedate(&now, s->offset); switch(s->ptr) { @@ -145,7 +146,7 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data) } break; case 3: - now.tm_wday = from_bcd(data & 7) - 1; + now.tm_wday = from_bcd(data & 0x07) - 1; break; case 4: now.tm_mday = from_bcd(data & 0x3f); @@ -156,11 +157,11 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data) case 6: now.tm_year = from_bcd(data) + 100; break; - case 7: - /* Control register. Currently ignored. */ - break; } s->offset = qemu_timedate_diff(&now); + } else if (s->ptr == 7) { + /* Control register. Currently ignored. */ + s->nvram[s->ptr] = data; } else { s->nvram[s->ptr] = data; } -- 1.7.10.4