From patchwork Tue Jun 28 08:43:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 641416 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-lf0-x238.google.com (mail-lf0-x238.google.com [IPv6:2a00:1450:4010:c07::238]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rdzqf4GM4z9sD5 for ; Tue, 28 Jun 2016 18:43:58 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b=LOaojLho; dkim-atps=neutral Received: by mail-lf0-x238.google.com with SMTP id l102sf3933435lfi.1 for ; Tue, 28 Jun 2016 01:43:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=wT1hw9+5CWscV37OF0s33fakufIWYf5UZYRfcXsYDEU=; b=LOaojLhoouuk2P6Vun2c29tC7l6uruXL9DQcWVOutXYxjXICFCL1R47Lj8A6mXq3Sg 6LaRwEV8CmayH1SHMF/fuxzCMkfBRMX7ue9mLKkwUQfWIpEGdEfCx3r9zM9spIDu9iXA +XsFn02wnNgIGPHsHggJWeZrIAY2lmB/BbEzuOEYs1uqvxcNKEJXWMii1q7TnraAODgD FN0HAMkCaUGYLFQSiG4Cy+eN6gANztBudX6isPRf0+AjS86SDbYnNLSvWBX/kbqi+x3P nWqsaAcBiVodHn16l+L6vWKcbLlSczrsa3NSCVLxBTfdWDdL0FDilYkEAVmYxbfnMY/c jJ3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=sender:x-gm-message-state:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=wT1hw9+5CWscV37OF0s33fakufIWYf5UZYRfcXsYDEU=; b=T6ZCPRCGYyI9RV03AWteTJROQFojYu18S7M4Nx1TMqL66hO/Med9Guz1LwRskHvckp k5aFZ53lX3QLNpE3m2j7hu8jWcvvmfxCiMkr+bO6PnqOvh1l/Efx559b7g4mz0Q/iTxq 8i23yNsNU2bmbS5OUkcXJPVBUb6NpTpmi82m8wOCyF4dQGsKCeCqi30IE3qSWVPSJVUR KwrNG7zDlbnKB6XW1rWSuWqO2fayMlmoQW88vIthLqkBKSUjV67C44tVi6LBkAyQzK3h euImJqg40CsijYj8oyCwxqQLi7XbgPDSLUJcqn9nVz6oxYw35AjTH8mMbL5R0z56R0hc p+4Q== Sender: rtc-linux@googlegroups.com X-Gm-Message-State: ALyK8tK+CspNOrUFat9o7QZg89gZWxT9Qwu+IHafjbXGn221PWiIsBCX6MFXVWbbB0uPDA== X-Received: by 10.46.9.3 with SMTP id 3mr4973ljj.1.1467103434652; Tue, 28 Jun 2016 01:43:54 -0700 (PDT) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.25.156.200 with SMTP id f191ls444384lfe.26.gmail; Tue, 28 Jun 2016 01:43:54 -0700 (PDT) X-Received: by 10.25.80.7 with SMTP id e7mr279043lfb.7.1467103434141; Tue, 28 Jun 2016 01:43:54 -0700 (PDT) Received: from arcturus.kleine-koenig.org (arcturus.kleine-koenig.org. [78.47.169.190]) by gmr-mx.google.com with ESMTPS id f10si734967wmg.2.2016.06.28.01.43.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jun 2016 01:43:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of uwe@kleine-koenig.org designates 78.47.169.190 as permitted sender) client-ip=78.47.169.190; Received: by arcturus.kleine-koenig.org (Postfix, from userid 1000) id AEC38AD8D5; Tue, 28 Jun 2016 10:43:53 +0200 (CEST) From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: Alessandro Zummo , Alexandre Belloni , rtc-linux@googlegroups.com Subject: [rtc-linux] [PATCH 4/4] rtc: sh: don't validate alarm time provided to .set_alarm Date: Tue, 28 Jun 2016 10:43:48 +0200 Message-Id: <1467103428-19047-4-git-send-email-uwe@kleine-koenig.org> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1467103428-19047-1-git-send-email-uwe@kleine-koenig.org> References: <1467103428-19047-1-git-send-email-uwe@kleine-koenig.org> MIME-Version: 1.0 X-Original-Sender: uwe@kleine-koenig.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of uwe@kleine-koenig.org designates 78.47.169.190 as permitted sender) smtp.mailfrom=uwe@kleine-koenig.org Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: rtc-linux@googlegroups.com X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , The rtc core doesn't give broken dates to a driver's .set_alarm callback, so there should be no need for validation. Signed-off-by: Uwe Kleine-König --- drivers/rtc/rtc-sh.c | 41 +---------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index 676949be777e..17b6235d67a5 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c @@ -499,52 +499,13 @@ static inline void sh_rtc_write_alarm_value(struct sh_rtc *rtc, writeb(bin2bcd(value) | AR_ENB, rtc->regbase + reg_off); } -static int sh_rtc_check_alarm(struct rtc_time *tm) -{ - /* - * The original rtc says anything > 0xc0 is "don't care" or "match - * all" - most users use 0xff but rtc-dev uses -1 for the same thing. - * The original rtc doesn't support years - some things use -1 and - * some 0xffff. We use -1 to make out tests easier. - */ - if (tm->tm_year == 0xffff) - tm->tm_year = -1; - if (tm->tm_mon >= 0xff) - tm->tm_mon = -1; - if (tm->tm_mday >= 0xff) - tm->tm_mday = -1; - if (tm->tm_wday >= 0xff) - tm->tm_wday = -1; - if (tm->tm_hour >= 0xff) - tm->tm_hour = -1; - if (tm->tm_min >= 0xff) - tm->tm_min = -1; - if (tm->tm_sec >= 0xff) - tm->tm_sec = -1; - - if (tm->tm_year > 9999 || - tm->tm_mon >= 12 || - tm->tm_mday == 0 || tm->tm_mday >= 32 || - tm->tm_wday >= 7 || - tm->tm_hour >= 24 || - tm->tm_min >= 60 || - tm->tm_sec >= 60) - return -EINVAL; - - return 0; -} - static int sh_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) { struct platform_device *pdev = to_platform_device(dev); struct sh_rtc *rtc = platform_get_drvdata(pdev); unsigned int rcr1; struct rtc_time *tm = &wkalrm->time; - int mon, err; - - err = sh_rtc_check_alarm(tm); - if (unlikely(err < 0)) - return err; + int mon; spin_lock_irq(&rtc->lock);