Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp382141pxj; Thu, 20 May 2021 11:30:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNt5i3KDS6/wrF7SpJFrjpT4kqExjuvPBsNfljCiu9JqBgF/5VgH3O/YkjDdiVAzhcfXyk X-Received: by 2002:a17:906:f996:: with SMTP id li22mr6006199ejb.255.1621535403406; Thu, 20 May 2021 11:30:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621535403; cv=none; d=google.com; s=arc-20160816; b=X5KyOd2b6Sk6FVASXKdHQTQERorXFlIrSCoAPGs6xD5uSxWMbU4erqHAzfSXXNDY9l DZb2w1YAEza6RQ57OHVAItNBf5H+aWV7AY3LRMgwzcifKb8VoiEeZZKKU2lChTLmvEsf 4QpecZoutAJ/5CWzFOAvTIyx8KCNgukHEpuL0sJOQwpRmtZiRU9X99IJL7XdbJh0aZp0 Wz1Fbpg8hrVve2n19MERJA1Hyr1oiWHBXkQ9p60w8t6ZCZzhdvaGv+tHW22YmUtFWa5s ouAnbSOe9gV5bnvPn8fakk/MtKk28vuMfC50XlFW192EQZyWAQz2+xTYfol9dhMES2F5 kB7g== 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=fiGtmnUjjF8ucabdDjrvxI/aDNRSUmw5U9ZsYuZJjrU=; b=STQFuBz5FPpwCpWZJsu1Zf/ykvTfStVD8Td+kLQB08qeaLLKL+BkOuO0CtGBgqnrko kKaq3QVDqacAwI0LbiIfT9uOHb5Y/MMuGYeknvYPH6IdkoKx9KysoCZey+QngPuIpkwF eyGfDjggyOnsMGLKZKgo2CwV27NomPavfzWlbCLh105YOdrJ85zmg2fFOV/7h8t/tk13 np+wnDHvZ96Z/UFv9U5S4SSxhhGsRg98YrCKr8pzJgXT5m2dunluqvf4uDWe2CNvRUWL QEPVlsQ3H/DV1nE3/vW9JIH88bUGBdaEJ2hLaCVjmIXm+1jzwifwQHVukJXzLEAHOXDQ QPfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lquSfdVd; 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 bl1si3327421ejb.408.2021.05.20.11.29.40; Thu, 20 May 2021 11:30:03 -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=lquSfdVd; 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 S235605AbhETKQV (ORCPT + 99 others); Thu, 20 May 2021 06:16:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:42304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235673AbhETKHZ (ORCPT ); Thu, 20 May 2021 06:07:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2B61161949; Thu, 20 May 2021 09:41:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503707; bh=ser7SnMHAV7kqSBtaETDC4EaoYB/yPNZWqM/f9roDyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lquSfdVd/DgMCp6gBGTgNoJryuRQVpoXrmndSJcOOn78tKq4NthIDgQKMotuxDMnh CSxNAoQX9zH3v7BqgyMYDOOFJ/FOrEnposChhFBYtwXmYA9FgXmF5VQkxKxkBZHRrM UDE7FlMg5qc/3xsnDbjhV6R6M9HfKVQspM65mTYA= 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 4.19 344/425] rtc: ds1307: Fix wday settings for rx8130 Date: Thu, 20 May 2021 11:21:53 +0200 Message-Id: <20210520092142.718241759@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 ebd59e86a567..94d31779933f 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -434,7 +434,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; @@ -481,7 +485,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