All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hyogi Gim <ciogenis@gmail.com>
To: a.zummo@towertech.it, akpm@linux-foundation.org, john.stultz@linaro.org
Cc: rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org
Subject: [PATCH] drivers/rtc/interface.c: check the validation of rtc_time in __rtc_read_time
Date: Wed, 8 Oct 2014 11:05:29 +0900	[thread overview]
Message-ID: <20141008020529.GA21464@lge.com> (raw)

Some of rtc devices always return '0' when rtc_class_ops.read_time is called.
So if rtc_time isn't verified in callback, rtc interface cannot know whether
rtc_time is valid.

Check rtc_time by using 'rtc_valid_tm' in '__rtc_read_time'. And add the
message for debugging.

Signed-off-by: Hyogi Gim <hyogi.gim@lge.com>
---
 drivers/rtc/interface.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 5b2717f..818ea97 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -30,6 +30,14 @@ static int __rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm)
 	else {
 		memset(tm, 0, sizeof(struct rtc_time));
 		err = rtc->ops->read_time(rtc->dev.parent, tm);
+		if (err < 0) {
+			dev_err(&rtc->dev, "read_time: fail to read\n");
+			return err;
+		}
+
+		err = rtc_valid_tm(tm);
+		if (err < 0)
+			dev_err(&rtc->dev, "read_time: rtc_time isn't valid\n");
 	}
 	return err;
 }
-- 
1.8.3.2


             reply	other threads:[~2014-10-08  2:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-08  2:05 Hyogi Gim [this message]
2014-10-14 22:21 ` [PATCH] drivers/rtc/interface.c: check the validation of rtc_time in __rtc_read_time Andrew Morton
2014-11-21  2:10   ` Hyogi Gim

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=20141008020529.GA21464@lge.com \
    --to=ciogenis@gmail.com \
    --cc=a.zummo@towertech.it \
    --cc=akpm@linux-foundation.org \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rtc-linux@googlegroups.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.