Received: by 10.223.176.46 with SMTP id f43csp4097728wra; Tue, 23 Jan 2018 04:18:56 -0800 (PST) X-Google-Smtp-Source: AH8x224p+zE5Lrqc8DxTnbMAkPTRytbeUmlD6/toGr2P7dmB1IheGxYJr8jUb3jarCw9XLMp7pql X-Received: by 10.98.160.25 with SMTP id r25mr10411040pfe.218.1516709936265; Tue, 23 Jan 2018 04:18:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516709936; cv=none; d=google.com; s=arc-20160816; b=w7znsyQI7zhDm7wiEtV4wRIXOH82jIVudubJoKisap3kDWEdyOVPkPwfcJKoXjX8lt HaXOqC1l3+M0m33B+GkGJM/o8oAoy+eMSjoBoNLw2RFMgh1i0JTu1g5EB+WE1zN+cDMs 7+H4qxp4+cKe0Px55aUuKBg5Oit1luMvlNJLAeWS2ZQnOtYKKRKonMIHFEOzDti9sI8c cKfK7Cw1MWbYt0B+Z7/6Z7/aR5IK6K8ElRMENZvlp+IwhHwiKv4tBI7o6rb1/5JtS0zn QnaHRv6U7DDPBC1VhNdLTmPBcDstIL8/bLV7nZxICzBEKiCkj/7MkcSX7g0+yO/i7/yC ft2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=c+BmSggxzGJxELGBykPN6+OG+NcdWt6obc0jYGy2MjM=; b=FroNDpjHgHG8Q0ALIkkgwRLIzgVjUyuJ/cXgYNqgqfVsZu52Mphl/KOCoYOERtOynI E5SPszltVCySHKJFOxM4khnBz86SXnoyyCGHQ7QCWm2BvDUTg4Rs8BnQQAu53unq2SwP O6u2h78fP3BvMpWxAyNpluDuh9oel8zwSxv5ruFErWdTkwpelF8+dxXt2MqM+U7xjNrn Ej6zTNxL8oxEclL/v3NYgteKVu7XvInWT8rINKpvxQMt3ogbTTN/Yl8RrBGUFHEGIRRD Ug8WjM26MoU27XqrIjLL22toLq90EIX6NVDzN6K310UgVdZHLuBvKPVYNYC1SMAgpbmN 9gdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u10-v6si4645903plu.505.2018.01.23.04.18.42; Tue, 23 Jan 2018 04:18:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751514AbeAWMSU (ORCPT + 99 others); Tue, 23 Jan 2018 07:18:20 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:34419 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751496AbeAWMSS (ORCPT ); Tue, 23 Jan 2018 07:18:18 -0500 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1edxWk-0004Io-Ty; Tue, 23 Jan 2018 13:18:10 +0100 Received: from mgr by dude.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1edxWi-00052I-QV; Tue, 23 Jan 2018 13:18:08 +0100 From: Michael Grzeschik To: a.zummo@towertech.it, alexandre.belloni@free-electrons.com Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux@roeck-us.net, jdelvare@suse.com, kernel@pengutronix.de, Denis.Osterland@diehl.com Subject: [PATCH 3/4] rtc: isl1208: enable interrupt after context preparation Date: Tue, 23 Jan 2018 13:18:00 +0100 Message-Id: <20180123121801.4214-4-m.grzeschik@pengutronix.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180123121801.4214-1-m.grzeschik@pengutronix.de> References: <20180123121801.4214-1-m.grzeschik@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The interrupt handler got enabled very early. If the interrupt cause is triggering immediately before the context is fully prepared. This can lead to undefined behaviour. Therefor we move the interrupt enable code to the end of the probe function. Signed-off-by: Michael Grzeschik Signed-off-by: Denis Osterland --- drivers/rtc/rtc-isl1208.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c index c8b4953482296..a13a4ba79004d 100644 --- a/drivers/rtc/rtc-isl1208.c +++ b/drivers/rtc/rtc-isl1208.c @@ -635,23 +635,6 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id) if (isl1208_i2c_validate_client(client) < 0) return -ENODEV; - if (client->irq > 0) { - rc = devm_request_threaded_irq(&client->dev, client->irq, NULL, - isl1208_rtc_interrupt, - IRQF_SHARED | IRQF_ONESHOT, - isl1208_driver.driver.name, - client); - if (!rc) { - device_init_wakeup(&client->dev, 1); - enable_irq_wake(client->irq); - } else { - dev_err(&client->dev, - "Unable to request irq %d, no alarm support\n", - client->irq); - client->irq = 0; - } - } - rtc = devm_rtc_device_register(&client->dev, isl1208_driver.driver.name, &isl1208_rtc_ops, THIS_MODULE); @@ -674,6 +657,23 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id) if (rc) return rc; + if (client->irq > 0) { + rc = devm_request_threaded_irq(&client->dev, client->irq, NULL, + isl1208_rtc_interrupt, + IRQF_SHARED | IRQF_ONESHOT, + isl1208_driver.driver.name, + client); + if (!rc) { + device_init_wakeup(&client->dev, 1); + enable_irq_wake(client->irq); + } else { + dev_err(&client->dev, + "Unable to request irq %d, no alarm support\n", + client->irq); + client->irq = 0; + } + } + return 0; } -- 2.11.0