From patchwork Fri Sep 21 18:47:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jos=C3=A9_Miguel_Gon=C3=A7alves?= X-Patchwork-Id: 185879 X-Patchwork-Delegate: promsoft@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 0D8552C0085 for ; Sat, 22 Sep 2012 04:49:44 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 65319280A2; Fri, 21 Sep 2012 20:49:32 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6Tg6r34B8XR5; Fri, 21 Sep 2012 20:49:32 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B409F280AF; Fri, 21 Sep 2012 20:49:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0D796280A8 for ; Fri, 21 Sep 2012 20:49:00 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CT3ZVFy8UFNW for ; Fri, 21 Sep 2012 20:48:59 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from lmv.inov.pt (lmv.inov.pt [146.193.64.2]) by theia.denx.de (Postfix) with ESMTPS id B7E972808B for ; Fri, 21 Sep 2012 20:48:53 +0200 (CEST) Received: from st-ze.inov.intranet (gtout.inov.pt [146.193.64.254]) by lmv.inov.pt (8.13.1/8.13.1) with ESMTP id q8LIlvlB011996 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 21 Sep 2012 19:48:00 +0100 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20Gon=C3=A7alves?= To: u-boot@lists.denx.de Date: Fri, 21 Sep 2012 19:47:45 +0100 Message-Id: <1348253268-21812-9-git-send-email-jose.goncalves@inov.pt> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1348253268-21812-1-git-send-email-jose.goncalves@inov.pt> References: <1348253268-21812-1-git-send-email-jose.goncalves@inov.pt> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0.1 (lmv.inov.pt [146.193.64.2]); Fri, 21 Sep 2012 19:48:00 +0100 (WEST) X-INOV-EmailServer-Information: Please contact the Email service provider for more information X-INOV-EmailServer: Found to be clean X-INOV-EmailServer-From: jose.goncalves@inov.pt Cc: marex@denx.de, trini@ti.com, =?UTF-8?q?Jos=C3=A9=20Miguel=20Gon=C3=A7alves?= , scottwood@freescale.com Subject: [U-Boot] [PATCH v5 08/11] rtc: Don't allow setting unsuported years on s3c24x0_rtc X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This RTC only supports a 100 years range so rtc_set() should not allow setting years bellow 1970 or above 2069. Signed-off-by: José Miguel Gonçalves --- Changes for v2: - New patch Changes for v3: - None Changes for v4: - None Changes for v5: - None --- drivers/rtc/s3c24x0_rtc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/rtc/s3c24x0_rtc.c b/drivers/rtc/s3c24x0_rtc.c index 3fd5cec..bcd6d44 100644 --- a/drivers/rtc/s3c24x0_rtc.c +++ b/drivers/rtc/s3c24x0_rtc.c @@ -139,6 +139,11 @@ int rtc_set(struct rtc_time *tmp) tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec); #endif + if (tmp->tm_year < 1970 || tmp->tm_year > 2069) { + puts("ERROR: year should be between 1970 and 2069!\n"); + return -1; + } + year = bin2bcd(tmp->tm_year % 100); mon = bin2bcd(tmp->tm_mon); wday = bin2bcd(tmp->tm_wday);