aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-spear.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2012-10-04 20:14:01 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-05 14:05:03 -0400
commita16e8393ac03cc24fd9b838f42823b4242ceac88 (patch)
tree138dac2dc48a180568e90464e561a8bae3237a89 /drivers/rtc/rtc-spear.c
parent7c6a52a090ce7f680077ed42326e11cf17e713dc (diff)
drivers/rtc/rtc-spear.c: fix several error checks
There are several comparisons of a unsigned int to less than zero int spear RTC driver. Such a check will always be true. In all these cases a signed int is assigned to the unsigned variable, which is checked, before. So the right fix is to make the checked variable signed as well. In one case the check can be dropped completely, because all it does it returns 'err' if 'err' is less than zero, otherwise it returns 0. Since in this particular case 'err' is always either 0 or less this is the same as just returning 'err'. The issue has been found using the following coccinelle semantic patch: //<smpl> @@ type T; unsigned T i; @@ ( *i < 0 | *i >= 0 ) //</smpl> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Cc: Viresh Kumar <viresh.kumar@st.com> Cc: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-spear.c')
-rw-r--r--drivers/rtc/rtc-spear.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c
index e2785479113..bb507d23f6c 100644
--- a/drivers/rtc/rtc-spear.c
+++ b/drivers/rtc/rtc-spear.c
@@ -235,7 +235,7 @@ static int spear_rtc_read_time(struct device *dev, struct rtc_time *tm)
235static int spear_rtc_set_time(struct device *dev, struct rtc_time *tm) 235static int spear_rtc_set_time(struct device *dev, struct rtc_time *tm)
236{ 236{
237 struct spear_rtc_config *config = dev_get_drvdata(dev); 237 struct spear_rtc_config *config = dev_get_drvdata(dev);
238 unsigned int time, date, err = 0; 238 unsigned int time, date;
239 239
240 if (tm2bcd(tm) < 0) 240 if (tm2bcd(tm) < 0)
241 return -EINVAL; 241 return -EINVAL;
@@ -247,11 +247,8 @@ static int spear_rtc_set_time(struct device *dev, struct rtc_time *tm)
247 (tm->tm_year << YEAR_SHIFT); 247 (tm->tm_year << YEAR_SHIFT);
248 writel(time, config->ioaddr + TIME_REG); 248 writel(time, config->ioaddr + TIME_REG);
249 writel(date, config->ioaddr + DATE_REG); 249 writel(date, config->ioaddr + DATE_REG);
250 err = is_write_complete(config);
251 if (err < 0)
252 return err;
253 250
254 return 0; 251 return is_write_complete(config);
255} 252}
256 253
257/* 254/*
@@ -295,7 +292,8 @@ static int spear_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
295static int spear_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) 292static int spear_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
296{ 293{
297 struct spear_rtc_config *config = dev_get_drvdata(dev); 294 struct spear_rtc_config *config = dev_get_drvdata(dev);
298 unsigned int time, date, err = 0; 295 unsigned int time, date;
296 int err;
299 297
300 if (tm2bcd(&alm->time) < 0) 298 if (tm2bcd(&alm->time) < 0)
301 return -EINVAL; 299 return -EINVAL;
@@ -357,7 +355,7 @@ static int __devinit spear_rtc_probe(struct platform_device *pdev)
357{ 355{
358 struct resource *res; 356 struct resource *res;
359 struct spear_rtc_config *config; 357 struct spear_rtc_config *config;
360 unsigned int status = 0; 358 int status = 0;
361 int irq; 359 int irq;
362 360
363 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 361 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);