Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751922AbaJITNW (ORCPT ); Thu, 9 Oct 2014 15:13:22 -0400 Received: from mail-la0-f46.google.com ([209.85.215.46]:47891 "EHLO mail-la0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751306AbaJITMa (ORCPT ); Thu, 9 Oct 2014 15:12:30 -0400 X-Google-Original-Sender: From: Johan Hovold To: Alessandro Zummo , Tony Lindgren , =?UTF-8?q?Beno=C3=AEt=20Cousson?= Cc: Andrew Morton , Felipe Balbi , Lokesh Vutla , Guenter Roeck , Colin Foe-Parker , AnilKumar Ch , nsekhar@ti.com, t-kristo@ti.com, j-keerthy@ti.com, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 03/12] rtc: omap: fix class-device registration Date: Thu, 9 Oct 2014 21:06:25 +0200 Message-Id: <1412881594-25678-4-git-send-email-johan@kernel.org> X-Mailer: git-send-email 2.0.4 In-Reply-To: <1412881594-25678-1-git-send-email-johan@kernel.org> References: <1412881594-25678-1-git-send-email-johan@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make sure not to register the class device until after it has been configured and interrupt handlers registered at probe. Currently, the device is not fully configured (e.g. 24-hour mode) when the class device is registered, something which involves driver callbacks for example to read the current time. This reordering also prevents user space from enabling an alarm before an interrupt handler has been registered. Note that the interrupts are now registered using the platform-device rather than class-device name. Signed-off-by: Johan Hovold --- drivers/rtc/rtc-omap.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 828cb9983cc2..2eca141e784e 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c @@ -147,8 +147,9 @@ static void rtc_wait_not_busy(void) /* now we have ~15 usec to read/write various registers */ } -static irqreturn_t rtc_irq(int irq, void *rtc) +static irqreturn_t rtc_irq(int irq, void *dev_id) { + struct rtc_device *rtc = platform_get_drvdata(dev_id); unsigned long events = 0; u8 irq_data; @@ -164,7 +165,8 @@ static irqreturn_t rtc_irq(int irq, void *rtc) if (irq_data & OMAP_RTC_STATUS_1S_EVENT) events |= RTC_IRQF | RTC_UF; - rtc_update_irq(rtc, 1, events); + if (rtc) + rtc_update_irq(rtc, 1, events); return IRQ_HANDLED; } @@ -416,17 +418,6 @@ static int __init omap_rtc_probe(struct platform_device *pdev) rtc_writel(KICK1_VALUE, OMAP_RTC_KICK1_REG); } - device_init_wakeup(&pdev->dev, true); - - rtc = devm_rtc_device_register(&pdev->dev, pdev->name, - &omap_rtc_ops, THIS_MODULE); - if (IS_ERR(rtc)) { - pr_debug("%s: can't register RTC device, err %ld\n", - pdev->name, PTR_ERR(rtc)); - goto fail0; - } - platform_set_drvdata(pdev, rtc); - /* clear pending irqs, and set 1/second periodic, * which we'll use instead of update irqs */ @@ -450,14 +441,14 @@ static int __init omap_rtc_probe(struct platform_device *pdev) /* handle periodic and alarm irqs */ if (devm_request_irq(&pdev->dev, omap_rtc_timer, rtc_irq, 0, - dev_name(&rtc->dev), rtc)) { + dev_name(&pdev->dev), pdev)) { pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n", pdev->name, omap_rtc_timer); goto fail0; } if ((omap_rtc_timer != omap_rtc_alarm) && (devm_request_irq(&pdev->dev, omap_rtc_alarm, rtc_irq, 0, - dev_name(&rtc->dev), rtc))) { + dev_name(&pdev->dev), pdev))) { pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n", pdev->name, omap_rtc_alarm); goto fail0; @@ -492,6 +483,17 @@ static int __init omap_rtc_probe(struct platform_device *pdev) if (reg != new_ctrl) rtc_write(new_ctrl, OMAP_RTC_CTRL_REG); + device_init_wakeup(&pdev->dev, true); + + rtc = devm_rtc_device_register(&pdev->dev, pdev->name, + &omap_rtc_ops, THIS_MODULE); + if (IS_ERR(rtc)) { + pr_debug("%s: can't register RTC device, err %ld\n", + pdev->name, PTR_ERR(rtc)); + goto fail0; + } + platform_set_drvdata(pdev, rtc); + return 0; fail0: -- 2.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/