All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <uwe@kleine-koenig.org>
To: stable@vger.kernel.org
Cc: Martin Michlmayr <tbm@cyrius.com>, peter <ptrbucr3075@gmail.com>,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	debian-kernel@lists.debian.org
Subject: [PATCH 2/4] rtc: s35390a: make sure all members in the output are set
Date: Mon,  3 Apr 2017 23:32:38 +0200	[thread overview]
Message-ID: <20170403213240.3856-3-uwe@kleine-koenig.org> (raw)
In-Reply-To: <20170403213240.3856-1-uwe@kleine-koenig.org>

The rtc core calls the .read_alarm with all fields initialized to 0. As
the s35390a driver doesn't touch some fields the returned date is
interpreted as a date in January 1900. So make sure all fields are set
to -1; some of them are then overwritten with the right data depending
on the hardware state.

In mainline this is done by commit d68778b80dd7 ("rtc: initialize output
parameter for read alarm to "uninitialized"") in the core. This is
considered to dangerous for stable as it might have side effects for
other rtc drivers that might for example rely on alarm->time.tm_sec
being initialized to 0.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
---
 drivers/rtc/rtc-s35390a.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
index 6507a01cf9ad..47b88bbe4ce7 100644
--- a/drivers/rtc/rtc-s35390a.c
+++ b/drivers/rtc/rtc-s35390a.c
@@ -267,6 +267,20 @@ static int s35390a_read_alarm(struct i2c_client *client, struct rtc_wkalrm *alm)
 	char buf[3], sts;
 	int i, err;
 
+	/*
+	 * initialize all members to -1 to signal the core that they are not
+	 * defined by the hardware.
+	 */
+	alm->time.tm_sec = -1;
+	alm->time.tm_min = -1;
+	alm->time.tm_hour = -1;
+	alm->time.tm_mday = -1;
+	alm->time.tm_mon = -1;
+	alm->time.tm_year = -1;
+	alm->time.tm_wday = -1;
+	alm->time.tm_yday = -1;
+	alm->time.tm_isdst = -1;
+
 	err = s35390a_get_reg(s35390a, S35390A_CMD_STATUS2, &sts, sizeof(sts));
 	if (err < 0)
 		return err;
-- 
2.11.0

  parent reply	other threads:[~2017-04-03 21:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170211085837.1592.22809.reportbug@PBU-NAS-0002.fritz.box>
     [not found] ` <20170316011047.GA6157@jirafa.cyrius.com>
     [not found]   ` <20170316084507.4e6s52abcoakvhcn@perseus.defre.kleine-koenig.org>
     [not found]     ` <001d01d29e3b$10aa9700$31ffc500$@gmail.com>
2017-03-16  9:54       ` AW: Bug#854854: qcontrol: reboot/poweroff Uwe Kleine-König
2017-04-03 21:32     ` [PATCH 0/4] rtc: s35390a: add fixes from v4.8-rc1 to stable Uwe Kleine-König
2017-04-03 21:32       ` [PATCH 1/4] rtc: s35390a: fix reading out alarm Uwe Kleine-König
2017-04-03 21:32       ` Uwe Kleine-König [this message]
2017-04-06  7:45         ` Patch "rtc: s35390a: make sure all members in the output are set" has been added to the 4.4-stable tree gregkh
2017-04-03 21:32       ` [PATCH 3/4] rtc: s35390a: implement reset routine as suggested by the reference Uwe Kleine-König
2017-04-03 21:32       ` [PATCH 4/4] rtc: s35390a: improve irq handling Uwe Kleine-König

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=20170403213240.3856-3-uwe@kleine-koenig.org \
    --to=uwe@kleine-koenig.org \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=debian-kernel@lists.debian.org \
    --cc=ptrbucr3075@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=tbm@cyrius.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.