From patchwork Sat Jun 20 16:09:08 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Zummo X-Patchwork-Id: 28937 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-yx0-f148.google.com (mail-yx0-f148.google.com [209.85.210.148]) by bilbo.ozlabs.org (Postfix) with ESMTP id 32959B7239 for ; Sun, 21 Jun 2009 02:09:20 +1000 (EST) Received: by mail-yx0-f148.google.com with SMTP id 12so1403887yxe.29 for ; Sat, 20 Jun 2009 09:09:20 -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 :received:from:subject:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:reply-to:sender:precedence :x-google-loop:mailing-list:list-id:list-post:list-help :list-unsubscribe:x-beenthere-env:x-beenthere; bh=MqGyQV31QluAi1W0gOInKyLe1yPYdqz6qG8RzDh1PtI=; b=cQXoGH6hKK+LS1NhqBa/v1jdTAmdcpHJscfFNwiWPBsCyDBJmBab3ostK+013mOD68 QSYTJDGNjo7c11IqxGwm6DlYhiwnvGwZLcw7q9j00nsoJ9NldPdsO0ehpFdUl+Hyk2mi O5xowuY4FM4pW9brLpBe5LjzcmTj1oDszCDQQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:received-spf:authentication-results:from :subject:to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-type:reply-to:sender:precedence:x-google-loop :mailing-list:list-id:list-post:list-help:list-unsubscribe :x-beenthere-env:x-beenthere; b=lOUNqOiBi04Q1ZmHE3BExqdQ7zkf3MhGFjb41Gps6kCCADK8J4aiTnNyPQtVZm119E jqRAS2sMKKo29hoigmsgZvymzP2Sn5outD6w/699fEqUGBsP/e92BXqFCUjIehAIvaIH eRaJkfX2EU3hvXJuCaO3EkvRlnmq30V4FpdZc= Received: by 10.90.54.5 with SMTP id c5mr651206aga.18.1245514150119; Sat, 20 Jun 2009 09:09:10 -0700 (PDT) Received: by 10.177.16.10 with SMTP id t10gr2502yqi.0; Sat, 20 Jun 2009 09:09:10 -0700 (PDT) X-Sender: a.zummo@towertech.it X-Apparently-To: rtc-linux@googlegroups.com Received: by 10.204.56.80 with SMTP id x16mr156584bkg.22.1245514149352; Sat, 20 Jun 2009 09:09:09 -0700 (PDT) Received: from mx0.towertech.it (mx0.towertech.it [213.215.222.73]) by gmr-mx.google.com with SMTP id 13si439375bwz.3.2009.06.20.09.09.09; Sat, 20 Jun 2009 09:09:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of a.zummo@towertech.it designates 213.215.222.73 as permitted sender) client-ip=213.215.222.73; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of a.zummo@towertech.it designates 213.215.222.73 as permitted sender) smtp.mail=a.zummo@towertech.it Received: (qmail 4157 invoked from network); 20 Jun 2009 18:09:08 +0200 Received: from unknown (HELO i1501.lan.towertech.it) (93.39.57.60) by mx0.towertech.it with SMTP; 20 Jun 2009 18:09:08 +0200 From: Alessandro Zummo Subject: [rtc-linux] [PATCH 6/9] bfin: delay IRQ registration until driver is ready To: akpm@linux-foundation.org Cc: rtc-linux@googlegroups.com, Mike Frysinger , Alessandro Zummo Date: Sat, 20 Jun 2009 18:09:08 +0200 Message-ID: <20090620160908.6953.15683.stgit@i1501.lan.towertech.it> In-Reply-To: <20090620160839.6953.41960.stgit@i1501.lan.towertech.it> References: <20090620160839.6953.41960.stgit@i1501.lan.towertech.it> User-Agent: StGIT/0.14.2 Mime-Version: 1.0 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 From: Mike Frysinger 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 Signed-off-by: Alessandro Zummo --- drivers/rtc/rtc-bfin.c | 27 +++++++++++++-------------- 1 files changed, 13 insertions(+), 14 deletions(-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. -~----------~----~----~----~------~----~------~--~--- 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;