From: alexandre.belloni@bootlin.com
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 02/12] rtc: ds1511: drop useless computation
Date: Wed, 28 Feb 2024 00:04:17 +0100 [thread overview]
Message-ID: <20240227230431.1837717-2-alexandre.belloni@bootlin.com> (raw)
In-Reply-To: <20240227230431.1837717-1-alexandre.belloni@bootlin.com>
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
All the callers of ds1511_rtc_set_time will use the same epoch for tm_year
which is defined as the number of years minus 1900 since POSIX.1-2001.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-ds1511.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c
index 87c52d20d31a..a646bcf9cd56 100644
--- a/drivers/rtc/rtc-ds1511.c
+++ b/drivers/rtc/rtc-ds1511.c
@@ -166,24 +166,13 @@ ds1511_wdog_disable(void)
}
#endif
-/*
- * set the rtc chip's idea of the time.
- * stupidly, some callers call with year unmolested;
- * and some call with year = year - 1900. thanks.
- */
static int ds1511_rtc_set_time(struct device *dev, struct rtc_time *rtc_tm)
{
u8 mon, day, dow, hrs, min, sec, yrs, cen;
unsigned long flags;
- /*
- * won't have to change this for a while
- */
- if (rtc_tm->tm_year < 1900)
- rtc_tm->tm_year += 1900;
-
yrs = rtc_tm->tm_year % 100;
- cen = rtc_tm->tm_year / 100;
+ cen = 19 + rtc_tm->tm_year / 100;
mon = rtc_tm->tm_mon + 1; /* tm_mon starts at zero */
day = rtc_tm->tm_mday;
dow = rtc_tm->tm_wday & 0x7; /* automatic BCD */
--
2.43.0
next prev parent reply other threads:[~2024-02-27 23:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-27 23:04 [PATCH 01/12] rtc: ds1511: drop useless checks alexandre.belloni
2024-02-27 23:04 ` alexandre.belloni [this message]
2024-02-27 23:04 ` [PATCH 03/12] rtc: ds1511: drop dead code alexandre.belloni
2024-02-27 23:04 ` [PATCH 04/12] rtc: ds1511: drop useless enum alexandre.belloni
2024-02-27 23:04 ` [PATCH 05/12] rtc: ds1511: fix function definition alexandre.belloni
2024-02-27 23:04 ` [PATCH 06/12] rtc: ds1511: remove incomplete UIE support alexandre.belloni
2024-02-27 23:04 ` [PATCH 07/12] rtc: ds1511: remove ds1511_rtc_update_alarm alexandre.belloni
2024-02-27 23:04 ` [PATCH 08/12] rtc: ds1511: let the core know when alarm are not supported alexandre.belloni
2024-02-27 23:04 ` [PATCH 09/12] rtc: ds1511: remove partial alarm support alexandre.belloni
2024-02-27 23:04 ` [PATCH 10/12] rtc: ds1511: implement ds1511_rtc_read_alarm properly alexandre.belloni
2024-02-27 23:04 ` [PATCH 11/12] rtc: ds1511: rename pdata alexandre.belloni
2024-02-27 23:04 ` [PATCH 12/12] rtc: ds1511: drop inline/noinline hints alexandre.belloni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240227230431.1837717-2-alexandre.belloni@bootlin.com \
--to=alexandre.belloni@bootlin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).