Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp503881pxj; Tue, 18 May 2021 08:10:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZGngniPxfM0LIXNnpx5ABAyH9zkjoDIY+ixuxjEmEuPAqBmBa+LJxRSjtpPlChfv769n1 X-Received: by 2002:a05:6638:b14:: with SMTP id a20mr6062985jab.132.1621350608757; Tue, 18 May 2021 08:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621350608; cv=none; d=google.com; s=arc-20160816; b=phlGtj4Bg6rhA5PqH0kDq5VgpoiY7pdlJ2LJ/JwDU1ViU6XisAo7oXPWmz5pCBqpuM U/lEgOHpPws5+DG2KM9jmuzsrGWl+2MuHQ+9PagrYa8KXwxVEPbI7GnUgjzzfg2t6BRM bztB3XamstnMlkm+k0/0xQKSvTwvrjar7quh0cWWDZ0VT4ayfbLPyooDF7UXgzjjf7Mx a0UylSt0NZxKcOReJBHJ0l12HCijvVcYpSWGKjJoGCXWrRzrfX4mgCT8I1ZMLX9X4lzN aHJQgX7PMyiKnLWaI3SZ/s7pbbvtVNu6MMoFivKkm1O18T1+fhliotJbJtv6aKTwYTLl 0n3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KAlLqNSd/LPQgS5WZvilvncg3iVwkTM1ba+xKfUIDOs=; b=A6RXD8cWs7KBtKRSfelRaLJx1cpLMeUJh8k+cUZN+Xo9owPF/+1VFN8SpXZQqYrxDe fYRslhl0eO70f4Rq/bwSSNPugYLxbhHOLEp3Yg+nzlPxDQyjlOLVAXUkxN4xN3+dAVm/ XDB3BZABLFExyjyNBV1tPBTn0muUaHoxKLbsQMMLP9rI/9GK+yL5A3TQYQcbd9/8UgLq JH2OfxYLKYQJSgxh8h9tCU4GUCvoITJtlDa5wANByjtfokjCRUemDjUszS5b4d0ijhBn 6VznR46X+b4PS91wEKfiMO+QezGYp9NZJ+UKHW/wYM98NKFrM+jGNBKxSZ7Fm96bNZ34 soXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=w4RwQ2zG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w11si30263766ilu.8.2021.05.18.08.09.54; Tue, 18 May 2021 08:10:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=w4RwQ2zG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245050AbhEQPvc (ORCPT + 99 others); Mon, 17 May 2021 11:51:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:40080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343638AbhEQPef (ORCPT ); Mon, 17 May 2021 11:34:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C7CBB61CD7; Mon, 17 May 2021 14:39:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262361; bh=uDqoRDxR2iqv0+ZVxmp1vdDkDfh1c5PeQN8QrvFRR3o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w4RwQ2zGTtloyxZU5MZJoepuoRmEZEkj+P+7IX1QeXXChyQtWpXRYuEi7cZXku++g SE0n0F3AWmnlZ+GULXzV7QT+oNfWR8H5HBDnveTJFgJifAsUwGzFolBAoap14l1QA8 eGsCcP4BAQh1cXB2TRcqXZs8Gq+jyecjoL/cxSq0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nobuhiro Iwamatsu , Alexandre Belloni , Sasha Levin Subject: [PATCH 5.10 144/289] rtc: ds1307: Fix wday settings for rx8130 Date: Mon, 17 May 2021 16:01:09 +0200 Message-Id: <20210517140310.000909859@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nobuhiro Iwamatsu [ Upstream commit 204756f016726a380bafe619438ed979088bd04a ] rx8130 wday specifies the bit position, not BCD. Fixes: ee0981be7704 ("rtc: ds1307: Add support for Epson RX8130CE") Signed-off-by: Nobuhiro Iwamatsu Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/20210420023917.1949066-1-nobuhiro1.iwamatsu@toshiba.co.jp Signed-off-by: Sasha Levin --- drivers/rtc/rtc-ds1307.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 9f5f54ca039d..07a9cc91671b 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -295,7 +295,11 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t) t->tm_min = bcd2bin(regs[DS1307_REG_MIN] & 0x7f); tmp = regs[DS1307_REG_HOUR] & 0x3f; t->tm_hour = bcd2bin(tmp); - t->tm_wday = bcd2bin(regs[DS1307_REG_WDAY] & 0x07) - 1; + /* rx8130 is bit position, not BCD */ + if (ds1307->type == rx_8130) + t->tm_wday = fls(regs[DS1307_REG_WDAY] & 0x7f); + else + t->tm_wday = bcd2bin(regs[DS1307_REG_WDAY] & 0x07) - 1; t->tm_mday = bcd2bin(regs[DS1307_REG_MDAY] & 0x3f); tmp = regs[DS1307_REG_MONTH] & 0x1f; t->tm_mon = bcd2bin(tmp) - 1; @@ -342,7 +346,11 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t) regs[DS1307_REG_SECS] = bin2bcd(t->tm_sec); regs[DS1307_REG_MIN] = bin2bcd(t->tm_min); regs[DS1307_REG_HOUR] = bin2bcd(t->tm_hour); - regs[DS1307_REG_WDAY] = bin2bcd(t->tm_wday + 1); + /* rx8130 is bit position, not BCD */ + if (ds1307->type == rx_8130) + regs[DS1307_REG_WDAY] = 1 << t->tm_wday; + else + regs[DS1307_REG_WDAY] = bin2bcd(t->tm_wday + 1); regs[DS1307_REG_MDAY] = bin2bcd(t->tm_mday); regs[DS1307_REG_MONTH] = bin2bcd(t->tm_mon + 1); -- 2.30.2