Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3064452pxj; Mon, 17 May 2021 16:52:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygom/J4FdrPu8tbrLFIheNKSABfMwA3rthyzRYPzF1m6bNVdOlCw8dnFfnpbkoR2ZZBPm0 X-Received: by 2002:a17:906:ad9a:: with SMTP id la26mr2762959ejb.122.1621295525092; Mon, 17 May 2021 16:52:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621295525; cv=none; d=google.com; s=arc-20160816; b=tzkTByYSBc3gBEi944qguhP93+lVuZSoLAIZKeZ6IMX0g+N2/Jutmm1UFfB92aDlsH nA5xNHTigfBrx5Ck68FWWlLjtt9WbOSNV7voqFEeJHtZmM1GntX5X4oNYhWLqQmAfmA5 QaXz3vuDGKMKvN0XNYwcI25TZ66yQGYd1+/ylOEpX/RctQUQQNQCAeSk4/URNbwfy8fw JArF4gP5om4yTrjDAnQB7lYGf8XEH0E4Ib5pDmyrD5UqXyxJsoy1oFTL2cad7TnICgyt 51L7Y2kYKY53jXHRHn6EkpSIA/99mLH/UTDFW4DjVD9/4CY4OaxgbraKShn/nYjpETRB LBFw== 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=fHOjnEZorVSxYpKLsoo3tE3GZ2c2AyIAiukG5wT5/60=; b=aoVOmjy9meTFWrZECV9FUrs1rr+gklSuB7Kf0/kue1iq37HUNlfWmV1yNlMu5vsZcf uSC9YCYncbZRpXps9GiPkv0BvdlO7ekL3xYc3glE+/yjE/f9EbyxZdh3ZCuUItEDm5b+ QpFG3d4gAO8eWpDazJOrPow76RmffsoBrmOOzfaWDiaxfV6oW2pOHfVMOMiiy3wZWGBa nxRce4DhKyYPOhFHtr7/RYyBPIEegnB/ohtxNFPoXTloSG/7Utc5gc+7OUUWXkejWKWU 8ODRt/zHWb5OEjfW9dXtLr7Ir/e8cZg+RjP2hhASRrFqedMooYM/pcmKQOPvBlFd385e 1ogQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0bjN82eu; 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 b12si3981629eju.490.2021.05.17.16.51.42; Mon, 17 May 2021 16:52:05 -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=0bjN82eu; 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 S239401AbhEQOX4 (ORCPT + 99 others); Mon, 17 May 2021 10:23:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:36022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239510AbhEQOU1 (ORCPT ); Mon, 17 May 2021 10:20:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4EC4661440; Mon, 17 May 2021 14:11:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260677; bh=JcwCjE5vdzX03akLgR47m9JznA7dJwpchvmlYgixaBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0bjN82eudoPxrbW9xw2TdaB7jdlqs2G4NhurfBAIr/FN4/QPepPgfr16Vg34zhfR3 jzsc8H0yBo/qbeNO9fN2Q7fSe+r4IpJmrXTfvAxT+V7N/zaCQ3WU0Fbye8ps8ADe3c U0OR+VP3lcWTtmH35WfcknjWFTiRG9b8AZheIKyk= 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.12 191/363] rtc: ds1307: Fix wday settings for rx8130 Date: Mon, 17 May 2021 16:00:57 +0200 Message-Id: <20210517140309.048038565@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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 cd8e438bc9c4..8752620d8e34 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -296,7 +296,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; @@ -343,7 +347,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