From patchwork Tue May 26 10:13:11 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 27642 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from wa-out-1516.google.com (wa-out-1516.google.com [209.85.146.165]) by bilbo.ozlabs.org (Postfix) with ESMTP id E29D6B7069 for ; Tue, 26 May 2009 20:13:22 +1000 (EST) Received: by wa-out-1516.google.com with SMTP id c2so1601217waa.1 for ; Tue, 26 May 2009 03:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:received:x-sender:x-apparently-to :received:received:received-spf:authentication-results:received:from :to:cc:subject:date:message-id:x-mailer:in-reply-to:references :reply-to:sender:precedence:x-google-loop:mailing-list:list-id :list-post:list-help:list-unsubscribe:x-beenthere-env:x-beenthere; bh=Ilok7M0/ZC3gf7iVkqK14rTV2ontQUEPWO7MkXwmKZ4=; b=gh1veRMzJSVRv+TAb++FzBxptU51xk4DiJ8uVrSThsE4gHLG8zH6woMR2C140UVcQd A0FCXA+ijN/90Dg6AXHd6Bz+aJUxvFKYi+qX8bpGOXysZXKVr1Cl1K9V+NtX9ThwIPeu oY0GULAYLuN3U+SIlCjhOc0ntsWBcvDLbIyjc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:received-spf:authentication-results:from :to:cc:subject:date:message-id:x-mailer:in-reply-to:references :reply-to:sender:precedence:x-google-loop:mailing-list:list-id :list-post:list-help:list-unsubscribe:x-beenthere-env:x-beenthere; b=F9+dWASxAU4qq6s5Jg29ok/UYIEGxvUUauwmp9t3mlCdxhqSJPKwUzcqSYo1tlKpUx nFrTYGzDCn6X6iCgxKQcf9G6cIi+yzHx6i7v2jYsXLCxDoK31ikd8sEecGiaYoc6ip98 y9f7SW0hkdashVhPElHuK+L/IuUSIIRsouIfI= Received: by 10.114.57.1 with SMTP id f1mr1320189waa.13.1243332793651; Tue, 26 May 2009 03:13:13 -0700 (PDT) Received: by 10.106.241.10 with SMTP id o10gr2415prh.0; Tue, 26 May 2009 03:13:13 -0700 (PDT) X-Sender: vapier@gentoo.org X-Apparently-To: rtc-linux@googlegroups.com Received: by 10.114.103.1 with SMTP id a1mr1666913wac.18.1243332793296; Tue, 26 May 2009 03:13:13 -0700 (PDT) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by gmr-mx.google.com with ESMTP id 18si463446pzk.2.2009.05.26.03.13.13; Tue, 26 May 2009 03:13:13 -0700 (PDT) Received-SPF: pass (google.com: domain of vapier@gentoo.org designates 140.211.166.183 as permitted sender) client-ip=140.211.166.183; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of vapier@gentoo.org designates 140.211.166.183 as permitted sender) smtp.mail=vapier@gentoo.org Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 9604E65D5C; Tue, 26 May 2009 10:13:12 +0000 (UTC) From: Mike Frysinger To: rtc-linux@googlegroups.com Cc: uclinux-dist-devel@blackfin.uclinux.org Subject: [rtc-linux] [PATCH 2/2] drivers/rtc: rtc-bfin: delay IRQ registration until driver is ready Date: Tue, 26 May 2009 06:13:11 -0400 Message-Id: <1243332791-21614-2-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.6.3.1 In-Reply-To: <1243332791-21614-1-git-send-email-vapier@gentoo.org> References: <1243332791-21614-1-git-send-email-vapier@gentoo.org> Reply-To: rtc-linux@googlegroups.com Sender: rtc-linux@googlegroups.com Precedence: bulk X-Google-Loop: groups Mailing-List: list rtc-linux@googlegroups.com; contact rtc-linux+owner@googlegroups.com List-Id: List-Post: List-Help: List-Unsubscribe: , X-BeenThere-Env: rtc-linux@googlegroups.com X-BeenThere: rtc-linux@googlegroups.com Make sure we do not actually request the RTC IRQ until the device driver is fully ready to handle and process any interrupt. This way a spurious interrupt won't crash the system (which may happen if the bootloader was poking the RTC right before booting Linux). Signed-off-by: Mike Frysinger --- drivers/rtc/rtc-bfin.c | 27 +++++++++++++-------------- 1 files changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c index abad9f6..697a22b 100644 --- a/drivers/rtc/rtc-bfin.c +++ b/drivers/rtc/rtc-bfin.c @@ -1,8 +1,8 @@ /* * Blackfin On-Chip Real Time Clock Driver - * Supports BF52[257]/BF53[123]/BF53[467]/BF54[24789] + * Supports BF51x/BF52x/BF53[123]/BF53[467]/BF54x * - * Copyright 2004-2008 Analog Devices Inc. + * Copyright 2004-2009 Analog Devices Inc. * * Enter bugs at http://blackfin.uclinux.org/ * @@ -363,7 +363,7 @@ static int __devinit bfin_rtc_probe(struct platform_device *pdev) struct bfin_rtc *rtc; struct device *dev = &pdev->dev; int ret = 0; - unsigned long timeout; + unsigned long timeout = jiffies + HZ; dev_dbg_stamp(dev); @@ -374,31 +374,30 @@ static int __devinit bfin_rtc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, rtc); device_init_wakeup(dev, 1); + /* Register our RTC with the RTC framework */ + rtc->rtc_dev = rtc_device_register(pdev->name, dev, &bfin_rtc_ops, THIS_MODULE); + if (unlikely(IS_ERR(rtc->rtc_dev))) { + ret = PTR_ERR(rtc->rtc_dev); + goto err; + } + /* Grab the IRQ and init the hardware */ ret = request_irq(IRQ_RTC, bfin_rtc_interrupt, 0, pdev->name, dev); if (unlikely(ret)) - goto err; + goto err_reg; /* sometimes the bootloader touched things, but the write complete was not * enabled, so let's just do a quick timeout here since the IRQ will not fire ... */ - timeout = jiffies + HZ; while (bfin_read_RTC_ISTAT() & RTC_ISTAT_WRITE_PENDING) if (time_after(jiffies, timeout)) break; bfin_rtc_reset(dev, RTC_ISTAT_WRITE_COMPLETE); bfin_write_RTC_SWCNT(0); - /* Register our RTC with the RTC framework */ - rtc->rtc_dev = rtc_device_register(pdev->name, dev, &bfin_rtc_ops, THIS_MODULE); - if (unlikely(IS_ERR(rtc->rtc_dev))) { - ret = PTR_ERR(rtc->rtc_dev); - goto err_irq; - } - return 0; - err_irq: - free_irq(IRQ_RTC, dev); + err_reg: + rtc_device_unregister(rtc->rtc_dev); err: kfree(rtc); return ret;