From: Devendra Naga <devendra.aaru@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Alessandro Zummo <a.zummo@towertech.it>,
Rajeev KUMAR <rajeev-dlh.kumar@st.com>,
Viresh Kumar <viresh.linux@gmail.com>,
spear-devel@list.st.com, rtc-linux@googlegroups.com,
linux-kernel@vger.kernel.org
Cc: Devendra Naga <devendra.aaru@gmail.com>
Subject: [PATCH] rtc/rtc-spear: remove unnecessary check against rtc_valid_tm and tm2bcd
Date: Sat, 23 Jun 2012 17:13:59 +0530 [thread overview]
Message-ID: <1340451839-30623-1-git-send-email-devendra.aaru@gmail.com> (raw)
rtc_valid_tm is always return
-EINVAL if the time doesn't represent a valid date and time and 0 if its.
so we can simply do rtc_valid_tm(tm) rather doing rtc_valid_tm(tm) != 0 checking.
and also tm2bcd() does return -EINVAL if the time doesn't represent a valid date and time
and 0 if its.
and also removing err because is_write_complete will return -EIO if our write to the
RTC registers didn't happen and 0 if its.
Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
---
This is only tested by compiling the code with arm-linux-gcc
/bin/arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (crosstool-NG linaro-1.13.1-2012.05-20120523 - Linaro GCC 2012.05) 4.7.1 20120514 (prerelease)
drivers/rtc/rtc-spear.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c
index e278547..eb7d399 100644
--- a/drivers/rtc/rtc-spear.c
+++ b/drivers/rtc/rtc-spear.c
@@ -172,7 +172,7 @@ static irqreturn_t spear_rtc_irq(int irq, void *dev_id)
static int tm2bcd(struct rtc_time *tm)
{
- if (rtc_valid_tm(tm) != 0)
+ if (rtc_valid_tm(tm))
return -EINVAL;
tm->tm_sec = bin2bcd(tm->tm_sec);
tm->tm_min = bin2bcd(tm->tm_min);
@@ -235,9 +235,9 @@ static int spear_rtc_read_time(struct device *dev, struct rtc_time *tm)
static int spear_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
struct spear_rtc_config *config = dev_get_drvdata(dev);
- unsigned int time, date, err = 0;
+ unsigned int time, date;
- if (tm2bcd(tm) < 0)
+ if (tm2bcd(tm))
return -EINVAL;
rtc_wait_not_busy(config);
@@ -247,11 +247,8 @@ static int spear_rtc_set_time(struct device *dev, struct rtc_time *tm)
(tm->tm_year << YEAR_SHIFT);
writel(time, config->ioaddr + TIME_REG);
writel(date, config->ioaddr + DATE_REG);
- err = is_write_complete(config);
- if (err < 0)
- return err;
- return 0;
+ return is_write_complete(config);
}
/*
@@ -297,7 +294,7 @@ static int spear_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
struct spear_rtc_config *config = dev_get_drvdata(dev);
unsigned int time, date, err = 0;
- if (tm2bcd(&alm->time) < 0)
+ if (tm2bcd(&alm->time))
return -EINVAL;
rtc_wait_not_busy(config);
--
1.7.9.5
next reply other threads:[~2012-06-23 11:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-23 11:43 Devendra Naga [this message]
2012-06-25 8:18 ` [PATCH] rtc/rtc-spear: remove unnecessary check against rtc_valid_tm and tm2bcd viresh kumar
2012-06-26 9:34 ` devendra.aaru
2012-06-25 8:19 ` Rajeev kumar
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=1340451839-30623-1-git-send-email-devendra.aaru@gmail.com \
--to=devendra.aaru@gmail.com \
--cc=a.zummo@towertech.it \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rajeev-dlh.kumar@st.com \
--cc=rtc-linux@googlegroups.com \
--cc=spear-devel@list.st.com \
--cc=viresh.linux@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox