Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp2120669lkv; Thu, 20 May 2021 03:54:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzt8IqRs7oy4DMYO2Gc9rQvNuRmfhQkK9zGGkUy75xLZdS2d3lTYxvV1GCq24+vbcDc//I4 X-Received: by 2002:a6b:7d03:: with SMTP id c3mr5113034ioq.2.1621508073551; Thu, 20 May 2021 03:54:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621508073; cv=none; d=google.com; s=arc-20160816; b=krvZ6imF7/7F4fHMu0AAu0aO3+aIyE2yAO0IGSHgJXjn1N2ypDFvaUPSGAxBFNuhO7 IPiX0v/2V5n6jlvRiO+mGCJcJaoV5TfpDqPBnq6ThAJ86lJ3/61LWZZEqEWzBBSjUdYh H31cpIf6MZp6U96Pr3jo8VKFyZUVE8G/yOaRFE/bDgZJ0E17aGrblapPKwYkysIUIWko 5cSnjBmR33OZSPEZ8H20ckhKDqxZNKaXxTavOGBgUdz5c2fzDloYGJZQi8QC4W+hboFg f9wwhuNfZDjE3zLNXipwizPWFCZWz2rEj/B42QS/2NKM1otWTKSMt6xQlOU1lvVHpNU0 Sc/w== 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=iiajaeoMpKyjCcPp3653ZGjiOQQdlLe/jl5bngQsZFY=; b=SrBwlLNyIJ7kRYQ2H7B7jfHCe++fuvL/3ZDkjQyqAOR+3UZne8CWd4u33xZ0TBxcnF uTsPOTHdmm6/xzvIx2YMkUYfmThWlACXH0yJBEPcIBZKnl5s3XQ8T1mHEep79rUBJfnG 8DHSGPeTMrqU/BFcmCkU7HoN38bStkyAkgNZGGPGiWbFOLhi4NIW0SIhB9d7E+HHYO5u J+hjRFZtrFyKtD0GE4gCDPubGrQh8gRN1qPg5TeM5ArEUMDovalqxP0bLmCNuPLYg9FG bx3Tm+v035eBirmoA6XgNfsdFDdQos3wk2RRMiV0oWmJn4b5lVPaUyYkLgozjJfS+3sk drQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nrfDMdUq; 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 v6si1973721jas.16.2021.05.20.03.54.19; Thu, 20 May 2021 03:54:33 -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=nrfDMdUq; 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 S236934AbhETKxg (ORCPT + 99 others); Thu, 20 May 2021 06:53:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:40016 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237421AbhETKiN (ORCPT ); Thu, 20 May 2021 06:38:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D8113613B0; Thu, 20 May 2021 09:54:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504486; bh=Z+zOrTYRiag6oGcrAqPw3MpvSumXZNlYQGt3EfTHQTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nrfDMdUqRvvjXF85nfUtADKlzj+fL4c5k9c84TByUs4jv68eCcWv65/rugZYtza+R YjjeSOzNJQtaIsblAIWfJ3LsMt4naZPx3c99pXS9H44qOerp942d5yoPj+C4xqrgWU cyaClhsJw7jSMJSN13JOEsSSzjd041yXgra9gv44= 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.14 267/323] rtc: ds1307: Fix wday settings for rx8130 Date: Thu, 20 May 2021 11:22:39 +0200 Message-Id: <20210520092129.368352627@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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 8d45d93b1db6..19749ec87b24 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -417,7 +417,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; @@ -465,7 +469,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