From patchwork Fri Dec 14 22:53:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Mathys X-Patchwork-Id: 206589 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EA0F42C0093 for ; Sat, 15 Dec 2012 09:53:53 +1100 (EST) Received: from localhost ([::1]:45428 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tje8d-0002Cs-MO for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2012 17:53:51 -0500 Received: from eggs.gnu.org ([208.118.235.92]:36989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tje8W-0002Cm-P2 for qemu-devel@nongnu.org; Fri, 14 Dec 2012 17:53:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tje8V-0001j0-IG for qemu-devel@nongnu.org; Fri, 14 Dec 2012 17:53:44 -0500 Received: from mail-wi0-f171.google.com ([209.85.212.171]:40275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tje8V-0001iu-C3 for qemu-devel@nongnu.org; Fri, 14 Dec 2012 17:53:43 -0500 Received: by mail-wi0-f171.google.com with SMTP id hn14so812086wib.10 for ; Fri, 14 Dec 2012 14:53:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=I/fLboqPZNLSjOZ26ULGP60zYJz4c0LoNn44DfXJmXE=; b=s12WcY4NOmxxwMIQf+sdgaYjpeo74LC/ikSLYPqRInJnYNS2/yYxfE5dfoxZyntmGf sJFeTfHYIvKi+u6lvAPfveS9jFqkNcv7Xe35DrPStnfGIp4RHF6tNmr08JEWU/y3rKOp F0uRABsK/KED9LlnGPpJJGnH4eHIvd6+kN13myX9DQYUM/XosD1F/7gc3TeEgL2G1115 +StFhZZ5enAULUPRAMoolIybWaBPv6s3CHEAqiK/go+mb1V5RVyBzZ186JSltGPNE7/g W66dExjJ+MVnT2AetHkJHGNxNMzSddqqzn2KpdCl10Q9Z6gVtKCw6JF8X51/DWINHaB1 pfPw== Received: by 10.194.78.162 with SMTP id c2mr5910644wjx.46.1355525621286; Fri, 14 Dec 2012 14:53:41 -0800 (PST) Received: from localhost.localdomain (adsl-84-227-231-245.adslplus.ch. [84.227.231.245]) by mx.google.com with ESMTPS id bd7sm9925167wib.8.2012.12.14.14.53.39 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Dec 2012 14:53:40 -0800 (PST) From: Antoine Mathys To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2012 23:53:27 +0100 Message-Id: <1355525607-2398-1-git-send-email-barsamin@gmail.com> X-Mailer: git-send-email 1.7.10.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.212.171 Cc: Antoine Mathys , peter.maydell@linaro.org, paul@codesourcery.com Subject: [Qemu-devel] [PATCH] Fix conversion between 12 hours and 24 hours modes. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The proper mapping between 24 hours and 12 hours modes is: 0 12 AM 1-11 1-11 AM 12 12 PM 13-23 1-11 PM Fix code accordingly. Signed-off-by: Antoine Mathys Reviewed-by: Peter Maydell --- hw/ds1338.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/ds1338.c b/hw/ds1338.c index 1aefa3b..9e6b490 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -59,8 +59,8 @@ static void capture_current_time(DS1338State *s) s->nvram[1] = to_bcd(now.tm_min); if (s->nvram[2] & HOURS_12) { int tmp = now.tm_hour; - if (tmp == 0) { - tmp = 24; + if (tmp % 12 == 0) { + tmp += 12; } if (tmp <= 12) { s->nvram[2] = HOURS_12 | to_bcd(tmp); @@ -145,8 +145,8 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data) if (data & HOURS_PM) { tmp += 12; } - if (tmp == 24) { - tmp = 0; + if (tmp % 12 == 0) { + tmp -= 12; } now.tm_hour = tmp; } else {