From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0DCDFC433F5 for ; Mon, 25 Apr 2022 13:50:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0710583AE7; Mon, 25 Apr 2022 15:50:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=walle.cc Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=walle.cc header.i=@walle.cc header.b="iMGFNwSg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EF85A83953; Mon, 25 Apr 2022 15:50:08 +0200 (CEST) Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B16AD83B4C for ; Mon, 25 Apr 2022 15:50:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=walle.cc Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=michael@walle.cc Received: from ssl.serverraum.org (web.serverraum.org [172.16.0.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id E49D622246; Mon, 25 Apr 2022 15:50:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1650894603; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=65C9VD+GBiVfZ6sBM1YzqGbVX2i5bbNKPETsiMO/9BQ=; b=iMGFNwSg22efcpzOC0DhhY5ndX1MG2NwB4Wz3QUtkIQq+YtV5Ls6dC5gPJUQ9y44Y335V6 HK/69r3U/7Blhg5T0eXOjjd8UQBHcJ9e9KMOiuuafv1newjHZIGvOg3zG9Oh8aLcpr5JS0 K2w4hHE/K81GV+9WSLp5iOMmkLAh79U= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 25 Apr 2022 15:50:02 +0200 From: Michael Walle To: u-boot@lists.denx.de, michael@walle.cc Cc: hs@denx.de, philipp.tomsich@theobroma-systems.com, sjg@chromium.org, oliver.graute@kococonnector.com Subject: Re: possible off-by-one error on month counting in rtc rv8803 driver In-Reply-To: <20220425125539.GA16510@optiplex> References: <20220425125539.GA16510@optiplex> User-Agent: Roundcube Webmail/1.4.13 Message-ID: X-Sender: michael@walle.cc X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Hi, Am 2022-04-25 14:55, schrieb Oliver Graute: > I stumbled across the following possible off-by-one error in counting > the > month in RTC driver rv8803. .. > (drivers/rtc/rv8803.c) > rv8803_rtc_set() > ... > buf[RTC_MON_REG_ADDR] = bin2bcd(tm->tm_mon) > ... > > rv8803_rtc_get() > ... > tm->tm_mon = bcd2bin(buf[RTC_MON_REG_ADDR] & 0x1F); > ... > > I assume that the error is here and increase and decrease by one is > also > required here like in the Linux driver code for RTC 8803. Indeed. tm_mon has a range from 0 .. 11, but the RTC expects 1..12. Nice catch. > Can someone verify and comment on this. Then I would prepare a patch > later on. Yes please. -michael