From patchwork Fri Apr 2 18:45:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12181405 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06DA4C43460 for ; Fri, 2 Apr 2021 18:47:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D688061165 for ; Fri, 2 Apr 2021 18:47:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229722AbhDBSrq (ORCPT ); Fri, 2 Apr 2021 14:47:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:59782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231149AbhDBSrq (ORCPT ); Fri, 2 Apr 2021 14:47:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 42BCF61163; Fri, 2 Apr 2021 18:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617389264; bh=F5DJLUEddjefE0vfPGumnLhU2dCP5adrDt+DWAnO6WM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t5pqJSLuFH0XcuaGdgaz6CNMgw2IqYWEqzMqrhZp6mAbBnXQbXMthegnBbySLXifP cDNdb/LyOrdlFLK2dytoD5iW76wCl4xZezSDrQkbEcjMRSwhh6kLCgXgWQk06aZhEn FD5oihX9ReYvaL+3fbLZ7cpRFEI01YHFQHWa/gn4IIac5umUO4iqNUays12HrITeak OiurqtlmjMYySx6vjHvs+4msR3hEwc4QloOoJAG6felSDUOESXW9l+25Bf+ByE5lMG cAr2bw3sU/+3kuWazLNQiz6r/Mpuo0ch/w3Glwx6luCa2VfTSKp2YDhXL996Gds1nN b7hWwY21GvY0Q== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Barry Song , Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH 1/7] iio:adc:ad7766: Use new IRQF_NO_AUTOEN to reduce boilerplate Date: Fri, 2 Apr 2021 19:45:38 +0100 Message-Id: <20210402184544.488862-2-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210402184544.488862-1-jic23@kernel.org> References: <20210402184544.488862-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron As iio_poll_trigger() is safe against spurious interrupts when the trigger is not enabled, this is not a fix despite looking like a race. It is nice to simplify the code however so the interrupt is never enabled in the first place. Signed-off-by: Jonathan Cameron Cc: Lars-Peter Clausen Reviewed-by: Barry Song --- drivers/iio/adc/ad7766.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/ad7766.c b/drivers/iio/adc/ad7766.c index 829a3426f235..1e41759f3ee5 100644 --- a/drivers/iio/adc/ad7766.c +++ b/drivers/iio/adc/ad7766.c @@ -255,18 +255,17 @@ static int ad7766_probe(struct spi_device *spi) ad7766->trig->ops = &ad7766_trigger_ops; iio_trigger_set_drvdata(ad7766->trig, ad7766); - ret = devm_request_irq(&spi->dev, spi->irq, ad7766_irq, - IRQF_TRIGGER_FALLING, dev_name(&spi->dev), - ad7766->trig); - if (ret < 0) - return ret; - /* * The device generates interrupts as long as it is powered up. * Some platforms might not allow the option to power it down so - * disable the interrupt to avoid extra load on the system + * don't enable the interrupt to avoid extra load on the system */ - disable_irq(spi->irq); + ret = devm_request_irq(&spi->dev, spi->irq, ad7766_irq, + IRQF_TRIGGER_FALLING | IRQF_NO_AUTOEN, + dev_name(&spi->dev), + ad7766->trig); + if (ret < 0) + return ret; ret = devm_iio_trigger_register(&spi->dev, ad7766->trig); if (ret) From patchwork Fri Apr 2 18:45:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12181407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2E53C433B4 for ; Fri, 2 Apr 2021 18:47:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD0D261166 for ; Fri, 2 Apr 2021 18:47:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231443AbhDBSrr (ORCPT ); Fri, 2 Apr 2021 14:47:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:59794 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231149AbhDBSrr (ORCPT ); Fri, 2 Apr 2021 14:47:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F13BB61164; Fri, 2 Apr 2021 18:47:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617389265; bh=uOJdjmzfcNjl5H10qT6HFOCrKm91lAWpHVnh7oG1Ybc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mJySNRwDOHHGmwJe77JHpzm8h0lmF0WRp1+OvlMu2Lvse4vQmBuapvqeWGLIzv7jP aQZ/7DhCAixveuqQCskb+lDDf56Gx1wPa/lh7t9CREoKf11gvAmTWvoh935dMW4U1j 18O3Jlwfz8Up0a5lVP1+dH5n2cShze2NJD6nn0xTCisrB7I2Funs03mkiW1y/VxCVZ 4xYlJv8QkcsuhbP0B7yTvq7ixfZXhEeBk2g61zptTu0aOP5YDSEEo+l1+hFxykt99O s7UJenaGfOOcBcyKpb24CHsAeVgP6TXqelOVUI6AIiWgegtYn3y8bXn7Ih1el277zD vCBXJz8gxhlQA== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Barry Song , Jonathan Cameron , Krzysztof Kozlowski Subject: [PATCH 2/7] iio:adc:exynos-adc: Use new IRQF_NO_AUTOEN flag rather than separate irq_disable() Date: Fri, 2 Apr 2021 19:45:39 +0100 Message-Id: <20210402184544.488862-3-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210402184544.488862-1-jic23@kernel.org> References: <20210402184544.488862-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Disabling an irq before the driver has actually atempted to request it may work, but is definitely not as clean as just requesting it as normal but with the auto enable disabled. Signed-off-by: Jonathan Cameron Cc: Krzysztof Kozlowski Reviewed-by: Barry Song Reviewed-by: Krzysztof Kozlowski --- drivers/iio/adc/exynos_adc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c index 784c10deeb1a..8c98d8c9ab1f 100644 --- a/drivers/iio/adc/exynos_adc.c +++ b/drivers/iio/adc/exynos_adc.c @@ -778,9 +778,9 @@ static int exynos_adc_ts_init(struct exynos_adc *info) return ret; } - disable_irq(info->tsirq); ret = request_threaded_irq(info->tsirq, NULL, exynos_ts_isr, - IRQF_ONESHOT, "touchscreen", info); + IRQF_ONESHOT | IRQF_NO_AUTOEN, + "touchscreen", info); if (ret) input_unregister_device(info->input); From patchwork Fri Apr 2 18:45:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12181409 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90EC4C433ED for ; Fri, 2 Apr 2021 18:47:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 65C9861166 for ; Fri, 2 Apr 2021 18:47:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231149AbhDBSru (ORCPT ); Fri, 2 Apr 2021 14:47:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:59804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231462AbhDBSrt (ORCPT ); Fri, 2 Apr 2021 14:47:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9893761151; Fri, 2 Apr 2021 18:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617389268; bh=S4oG72TbJDDFDuf16qz3CrczaERMvPOwJ7VUOi2FjwI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hgLDqODon7HjoLDvehRC1nnJwEG8wvX6OBdmMDr7S4KBdLylNtLIk6k0Coxw4qJ6R KxlKkl9ZkWhmyIEa2yF0K8oVfO7dlms00GQWJDnvvBZXQDhAqleMutTuBl+eneeto+ FG2/wTnse3/0O6PEdCFRMiX5mWnVug4f9QHLoulOhvB51GP/QYBz+ydSLe0etIHjSI kI/ogB2mmRobTEUGGewo+A7votaRrlM8QicxChOn579L9JceE1mZoIaTa6V1BUeTMY IGj3leCSD/YJprROJljOUZtp7fnPbw6yau7Op/wD33+6kbyECCucQpQex7Tpn6wU6O pHzDQg91/1QOQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Barry Song , Jonathan Cameron , Alexandre Belloni Subject: [PATCH 3/7] iio:adc:nau7802: Use IRQF_NO_AUTOEN instead of request then disable Date: Fri, 2 Apr 2021 19:45:40 +0100 Message-Id: <20210402184544.488862-4-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210402184544.488862-1-jic23@kernel.org> References: <20210402184544.488862-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Whilst a race during interrupt enabling is probably not a problem, it is better to not enable the interrupt at all. The new IRQF_NO_AUTOEN flag allows us to do that. Signed-off-by: Jonathan Cameron Cc: Alexandre Belloni Reviewed-by: Barry Song --- drivers/iio/adc/nau7802.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c index 07c85434b568..bb70b51d25b1 100644 --- a/drivers/iio/adc/nau7802.c +++ b/drivers/iio/adc/nau7802.c @@ -498,7 +498,8 @@ static int nau7802_probe(struct i2c_client *client, ret = request_threaded_irq(client->irq, NULL, nau7802_eoc_trigger, - IRQF_TRIGGER_HIGH | IRQF_ONESHOT, + IRQF_TRIGGER_HIGH | IRQF_ONESHOT | + IRQF_NO_AUTOEN, client->dev.driver->name, indio_dev); if (ret) { @@ -513,8 +514,7 @@ static int nau7802_probe(struct i2c_client *client, dev_info(&client->dev, "Failed to allocate IRQ, using polling mode\n"); client->irq = 0; - } else - disable_irq(client->irq); + } } if (!client->irq) { From patchwork Fri Apr 2 18:45:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12181411 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04CEDC433B4 for ; Fri, 2 Apr 2021 18:47:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D4E8261164 for ; Fri, 2 Apr 2021 18:47:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231462AbhDBSrw (ORCPT ); Fri, 2 Apr 2021 14:47:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:59814 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231577AbhDBSrw (ORCPT ); Fri, 2 Apr 2021 14:47:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 14B0161165; Fri, 2 Apr 2021 18:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617389270; bh=v/LYvSH89yZ1xU15oxNGe9W7Dqxs2TkiUTMAZ9JOKiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C4Wfnphl2df3TULWa/i+A1CSjPQlTIuAK4OsXXjYxhIw7YFCb0b4P3pHZLlvhuzzx 3dDXsuDXRUjidHLeDrTOt50U2L1nNYO/D0OH1eXYDxsWE6s0bjYH5+hEy49OJa+W12 pgtyCAUKN0E6xUH4AxE6+N6TBAncaoR89bz4hG++db1VE38ghyW64NP4SyVO+f6vIq eLF2YQ2Ok3HI6bE4A/cErQQsiKEMlGNJUrOSBfPb6Y+J1ftssusE7skcPTngDq9Cgo MMY4VQdAuYeWF+speLnXN7nKfBuo1ksGukHwid3RCydICg79kp0TS4ceQacGQVnp6H wst8ElMRwi9Cg== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Barry Song , Jonathan Cameron , Maxime Ripard Subject: [PATCH 4/7] iio:adc:sun4i-gpadc: Use new IRQF_NO_AUTOEN flag instead of request then disable Date: Fri, 2 Apr 2021 19:45:41 +0100 Message-Id: <20210402184544.488862-5-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210402184544.488862-1-jic23@kernel.org> References: <20210402184544.488862-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron This new flag ensures a requested irq is not autoenabled, thus removing the need for the disable_irq() that follows and closing off any chance of spurious interrupts. Signed-off-by: Jonathan Cameron Cc: Maxime Ripard Reviewed-by: Barry Song --- drivers/iio/adc/sun4i-gpadc-iio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index 99b43f28e879..2d393a4dfff6 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -470,7 +470,8 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name, } *irq = ret; - ret = devm_request_any_context_irq(&pdev->dev, *irq, handler, 0, + ret = devm_request_any_context_irq(&pdev->dev, *irq, handler, + IRQF_NO_AUTOEN, devname, info); if (ret < 0) { dev_err(&pdev->dev, "could not request %s interrupt: %d\n", @@ -478,7 +479,6 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name, return ret; } - disable_irq(*irq); atomic_set(atomic, 0); return 0; From patchwork Fri Apr 2 18:45:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12181413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C484C433B4 for ; Fri, 2 Apr 2021 18:47:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4594861166 for ; Fri, 2 Apr 2021 18:47:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234275AbhDBSry (ORCPT ); Fri, 2 Apr 2021 14:47:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:59824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235984AbhDBSry (ORCPT ); Fri, 2 Apr 2021 14:47:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9F74361151; Fri, 2 Apr 2021 18:47:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617389273; bh=zYKZZTERA99i0KEMqsxBjYL6dtr3DGCWTOfkshaW+J0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BWI2qE+rXJnucqHBeRuxG0nfRXEDstDBjwPca/1PN6ATbk5AwnIVDNLehT3wN1WH3 gdl25JUOxnvNlTC/mHOgQ8rh7dIATTbPkbpxs5DrOOUGrzcpjkgwfYel5xa7GemwDi woj80rTLZb1SmlAVvC+2Mqz07u1yeU9dY4WdwfPgw7T7oDoNcXo8TdsGZB3RoY1Hju A/JHvSc0tOxSwMfcnkWN6hqg/HWv8dYAGfdoCLjDpiFke6M76WYuUEvccZklBvbPkq MqhSjNRAz7p8zTaqOgkre6+j1+0k1jvktj+v9mYHJWxwASHgA5m+L2EbUZrpEWwsrA CujwcazSaMDVQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Barry Song , Jonathan Cameron , Tomasz Duszynski Subject: [PATCH 5/7] iio:chemical:scd30: Use IRQF_NO_AUTOEN to avoid irq request then disable Date: Fri, 2 Apr 2021 19:45:42 +0100 Message-Id: <20210402184544.488862-6-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210402184544.488862-1-jic23@kernel.org> References: <20210402184544.488862-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron This new flag cleanly avoids the need for a dance where we request the interrupt only to immediately disabling it by ensuring it is not auto-enabled in the first place. Signed-off-by: Jonathan Cameron Cc: Tomasz Duszynski Reviewed-by: Barry Song --- drivers/iio/chemical/scd30_core.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/iio/chemical/scd30_core.c b/drivers/iio/chemical/scd30_core.c index 261c277ac4a5..d89f117dd0ef 100644 --- a/drivers/iio/chemical/scd30_core.c +++ b/drivers/iio/chemical/scd30_core.c @@ -655,19 +655,19 @@ static int scd30_setup_trigger(struct iio_dev *indio_dev) indio_dev->trig = iio_trigger_get(trig); + /* + * Interrupt is enabled just before taking a fresh measurement + * and disabled afterwards. This means we need to ensure it is not + * enabled here to keep calls to enable/disable balanced. + */ ret = devm_request_threaded_irq(dev, state->irq, scd30_irq_handler, - scd30_irq_thread_handler, IRQF_TRIGGER_HIGH | IRQF_ONESHOT, + scd30_irq_thread_handler, + IRQF_TRIGGER_HIGH | IRQF_ONESHOT | + IRQF_NO_AUTOEN, indio_dev->name, indio_dev); if (ret) dev_err(dev, "failed to request irq\n"); - /* - * Interrupt is enabled just before taking a fresh measurement - * and disabled afterwards. This means we need to disable it here - * to keep calls to enable/disable balanced. - */ - disable_irq(state->irq); - return ret; } From patchwork Fri Apr 2 18:45:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12181415 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B562AC433B4 for ; Fri, 2 Apr 2021 18:47:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C32561163 for ; Fri, 2 Apr 2021 18:47:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231577AbhDBSr7 (ORCPT ); Fri, 2 Apr 2021 14:47:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:59838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235984AbhDBSr5 (ORCPT ); Fri, 2 Apr 2021 14:47:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E121F61165; Fri, 2 Apr 2021 18:47:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617389276; bh=CFKEc8jc9gcci7Nas4wpWCdX7cSyWVcn93Il6hm6K88=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UK7qJiTPFAk2kpcexFfXngYtyBBOJG6v10y/44wX9wIWlKEzM+k3oaqjA2mHLZfbm zHkjTBtbX7YQIClD1khvKLuDclHYkPWG5KOJdr1zR59s5OkL9CmltlRvQgC5HIKucs FLl1ne/1aaX9qfOWi0u01Sj8qbRc3OjJDeXESqsQN5XOTvGS2cBIZ6wXvQq4CLueBO L/HsAf+sHmvZdO/+iF5j+htOkumWdPotCoNtcr8NLH4FOWY39UcWCqI3+JXBpc+3lE r845cAuma7FiAwCwEkNZJfeE10WHFmMS6IfC9dvNsgyfICVKNp5rPKeePYAro1L3Ne Aac2J41ZJa9mA== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Barry Song , Jonathan Cameron , Alexandru Ardelean , Nuno Sa Subject: [PATCH 6/7] iio:imu:adis: Use IRQF_NO_AUTOEN instead of irq request then disable Date: Fri, 2 Apr 2021 19:45:43 +0100 Message-Id: <20210402184544.488862-7-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210402184544.488862-1-jic23@kernel.org> References: <20210402184544.488862-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron This is a bit involved as the adis library code already has some sanity checking of the flags of the requested irq that we need to ensure is happy to pass through the IRQF_NO_AUTOEN flag untouched. Using this flag avoids us autoenabling the irq in the adis16460 and adis16475 drivers which cover parts that don't have any means of masking the interrupt on the device end. Note, compile tested only! Signed-off-by: Jonathan Cameron Cc: Alexandru Ardelean Cc: Nuno Sa Reviewed-by: Barry Song Reviewed-by: Nuno Sa --- drivers/iio/imu/adis16460.c | 4 ++-- drivers/iio/imu/adis16475.c | 5 +++-- drivers/iio/imu/adis_trigger.c | 11 ++++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/iio/imu/adis16460.c b/drivers/iio/imu/adis16460.c index 74a161e39733..73bf45e859b8 100644 --- a/drivers/iio/imu/adis16460.c +++ b/drivers/iio/imu/adis16460.c @@ -403,12 +403,12 @@ static int adis16460_probe(struct spi_device *spi) if (ret) return ret; + /* We cannot mask the interrupt, so ensure it isn't auto enabled */ + st->adis.irq_flag |= IRQF_NO_AUTOEN; ret = devm_adis_setup_buffer_and_trigger(&st->adis, indio_dev, NULL); if (ret) return ret; - adis16460_enable_irq(&st->adis, 0); - ret = __adis_initial_startup(&st->adis); if (ret) return ret; diff --git a/drivers/iio/imu/adis16475.c b/drivers/iio/imu/adis16475.c index 8f6bea4b6608..1de62fc79e0f 100644 --- a/drivers/iio/imu/adis16475.c +++ b/drivers/iio/imu/adis16475.c @@ -1258,6 +1258,9 @@ static int adis16475_config_irq_pin(struct adis16475 *st) return -EINVAL; } + /* We cannot mask the interrupt so ensure it's not enabled at request */ + st->adis.irq_flag |= IRQF_NO_AUTOEN; + val = ADIS16475_MSG_CTRL_DR_POL(polarity); ret = __adis_update_bits(&st->adis, ADIS16475_REG_MSG_CTRL, ADIS16475_MSG_CTRL_DR_POL_MASK, val); @@ -1362,8 +1365,6 @@ static int adis16475_probe(struct spi_device *spi) if (ret) return ret; - adis16475_enable_irq(&st->adis, false); - ret = devm_iio_device_register(&spi->dev, indio_dev); if (ret) return ret; diff --git a/drivers/iio/imu/adis_trigger.c b/drivers/iio/imu/adis_trigger.c index 0f29e56200af..39b50d6fdb6a 100644 --- a/drivers/iio/imu/adis_trigger.c +++ b/drivers/iio/imu/adis_trigger.c @@ -29,18 +29,19 @@ static const struct iio_trigger_ops adis_trigger_ops = { static int adis_validate_irq_flag(struct adis *adis) { + unsigned long direction = adis->irq_flag & IRQF_TRIGGER_MASK; /* * Typically this devices have data ready either on the rising edge or * on the falling edge of the data ready pin. This checks enforces that * one of those is set in the drivers... It defaults to - * IRQF_TRIGGER_RISING for backward compatibility wiht devices that + * IRQF_TRIGGER_RISING for backward compatibility with devices that * don't support changing the pin polarity. */ - if (!adis->irq_flag) { - adis->irq_flag = IRQF_TRIGGER_RISING; + if (!direction) { + adis->irq_flag |= IRQF_TRIGGER_RISING; return 0; - } else if (adis->irq_flag != IRQF_TRIGGER_RISING && - adis->irq_flag != IRQF_TRIGGER_FALLING) { + } else if (direction != IRQF_TRIGGER_RISING && + direction != IRQF_TRIGGER_FALLING) { dev_err(&adis->spi->dev, "Invalid IRQ mask: %08lx\n", adis->irq_flag); return -EINVAL; From patchwork Fri Apr 2 18:45:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12181417 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1AF5C433ED for ; Fri, 2 Apr 2021 18:48:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BDEC561163 for ; Fri, 2 Apr 2021 18:48:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235659AbhDBSsB (ORCPT ); Fri, 2 Apr 2021 14:48:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:59852 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235984AbhDBSsA (ORCPT ); Fri, 2 Apr 2021 14:48:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2A439610F7; Fri, 2 Apr 2021 18:47:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617389279; bh=LO3OK5SaKTZNyAqTbR8Q2YS2+sAo08q4vqxQkYNhS8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N1UMKctfk1fBs1za06fBw/D22ob+3RoqfiA68/3zmf/UVaVH0oxw9Hy5JC8zuu7Se hLdT2FEvY6IiDGhSUqlABYJOV8vaKGqoC9ix/+Dcey6gnVIPs68Poh+kZoa9FlW/j/ xjwZdgd5owrsl8jYeeyyV5VW3p6iQ4dWlxKtjOzNMb+vD5Z4PyXQ70NE0XXpwbzgxB Vd+LGRINIbIW/NYFw6BYevCuPuYEEX3r0i15elpLls5/g7KBPOGutS9MzVrVrcagWe UZEtScBD91BpDrJObb/+vmFmjurGyVskxdkrbUN1DPO29xoigXItHf1BJIscGp1YGj nWBohCm3B6gQA== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Barry Song , Jonathan Cameron , Lars-Peter Clausen , Alexandru Ardelean Subject: [PATCH 7/7] iio:adc:ad_sigma_delta: Use IRQF_NO_AUTOEN rather than request and disable Date: Fri, 2 Apr 2021 19:45:44 +0100 Message-Id: <20210402184544.488862-8-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210402184544.488862-1-jic23@kernel.org> References: <20210402184544.488862-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron These devices are not able to mask the signal used as a data ready interrupt. As such they previously requested the irq then immediately disabled it. Now we can avoid the potential of a spurious interrupt by avoiding the irq being auto enabled in the first place. I'm not sure how this code could have been called with the irq already disabled, so I believe the conditional would always have been true and have removed it. Signed-off-by: Jonathan Cameron Cc: Lars-Peter Clausen Cc: Alexandru Ardelean --- drivers/iio/adc/ad_sigma_delta.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c index 9289812c0a94..e777ec718973 100644 --- a/drivers/iio/adc/ad_sigma_delta.c +++ b/drivers/iio/adc/ad_sigma_delta.c @@ -485,18 +485,15 @@ static int ad_sd_probe_trigger(struct iio_dev *indio_dev) sigma_delta->trig->ops = &ad_sd_trigger_ops; init_completion(&sigma_delta->completion); + sigma_delta->irq_dis = true; ret = request_irq(sigma_delta->spi->irq, ad_sd_data_rdy_trig_poll, - sigma_delta->info->irq_flags, + sigma_delta->info->irq_flags | IRQF_NO_AUTOEN, indio_dev->name, sigma_delta); if (ret) goto error_free_trig; - if (!sigma_delta->irq_dis) { - sigma_delta->irq_dis = true; - disable_irq_nosync(sigma_delta->spi->irq); - } iio_trigger_set_drvdata(sigma_delta->trig, sigma_delta); ret = iio_trigger_register(sigma_delta->trig);