From patchwork Sat Jun 23 11:43:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devendra Naga X-Patchwork-Id: 166754 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-vb0-f56.google.com (mail-vb0-f56.google.com [209.85.212.56]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id F064DB6F9F for ; Sat, 23 Jun 2012 21:44:21 +1000 (EST) Received: by vbbfa15 with SMTP id fa15sf2637629vbb.11 for ; Sat, 23 Jun 2012 04:44:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=mime-version:x-beenthere:received-spf:from:to:cc:subject:date :message-id:x-mailer:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=jveDnVI+CLu25njhxGbN/8y5GWUSVUG9zUtuKP1ljY8=; b=PiTM2vmjk7h1TnHcm9W6Fy2lEeoLRMloAXnlrknOnQy/uy91WSdgOrv/9n8c2d6HwL HZnMZQfPq/5SSwdGM0zEYdDroGpljdYm5Sf30a8rwiE8QyyuDVCBqkdM8o08N2kV3cZC dc2bwQRWThtmWLphmTGUhmH93KTj6rF/gdHD8= Received: by 10.68.229.132 with SMTP id sq4mr1513476pbc.18.1340451858647; Sat, 23 Jun 2012 04:44:18 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.68.227.136 with SMTP id sa8ls9131825pbc.8.gmail; Sat, 23 Jun 2012 04:44:18 -0700 (PDT) Received: by 10.68.238.65 with SMTP id vi1mr6977185pbc.7.1340451858298; Sat, 23 Jun 2012 04:44:18 -0700 (PDT) Received: by 10.68.238.65 with SMTP id vi1mr6977184pbc.7.1340451858289; Sat, 23 Jun 2012 04:44:18 -0700 (PDT) Received: from mail-pz0-f48.google.com (mail-pz0-f48.google.com [209.85.210.48]) by gmr-mx.google.com with ESMTPS id iq5si2094631pbc.1.2012.06.23.04.44.18 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 23 Jun 2012 04:44:18 -0700 (PDT) Received-SPF: pass (google.com: domain of devendra.aaru@gmail.com designates 209.85.210.48 as permitted sender) client-ip=209.85.210.48; Received: by dadz8 with SMTP id z8so3782810dad.7 for ; Sat, 23 Jun 2012 04:44:18 -0700 (PDT) Received: by 10.68.238.232 with SMTP id vn8mr19733664pbc.78.1340451858088; Sat, 23 Jun 2012 04:44:18 -0700 (PDT) Received: from devendra.savarinetworks.com ([203.123.187.226]) by mx.google.com with ESMTPS id ny4sm2122915pbb.57.2012.06.23.04.44.14 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 23 Jun 2012 04:44:17 -0700 (PDT) From: Devendra Naga To: Andrew Morton , Alessandro Zummo , Rajeev KUMAR , Viresh Kumar , spear-devel@list.st.com, rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org Cc: Devendra Naga Subject: [rtc-linux] [PATCH] rtc/rtc-spear: remove unnecessary check against rtc_valid_tm and tm2bcd Date: Sat, 23 Jun 2012 17:13:59 +0530 Message-Id: <1340451839-30623-1-git-send-email-devendra.aaru@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-Original-Sender: devendra.aaru@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of devendra.aaru@gmail.com designates 209.85.210.48 as permitted sender) smtp.mail=devendra.aaru@gmail.com; dkim=pass header.i=@gmail.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , 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 Acked-By: Rajeev Kumar --- 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);