From patchwork Sun Oct 24 17:12:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 12580361 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77C16C433F5 for ; Sun, 24 Oct 2021 17:13:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 503A360F0F for ; Sun, 24 Oct 2021 17:13:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231731AbhJXRPh (ORCPT ); Sun, 24 Oct 2021 13:15:37 -0400 Received: from www381.your-server.de ([78.46.137.84]:54156 "EHLO www381.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231658AbhJXRPg (ORCPT ); Sun, 24 Oct 2021 13:15:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=Dwzu+VCYET1CP10+5+7RkGGIT/ZdlZtPJzTzWAcQDyY=; b=CVAgeXH3FxM3ntESJ+IVqvuUAN ZNSrBuGKC53TsiWjc0g7+WwJzN3nvGIQnKPeHSEYiN1DQlc0BPrvi4PxV76BkTCh6Qg3/FNa+an8i 88GyYwMf/0kg+M/Bgkk9JKpLnGhJ43Ta8fJ9efiXz9AsTl084x+zzZyUrLWFt6TRMWPQ3Y80kOTUu gZ96nXe7RrS5GeXhTZ5UDkbrhP3FmUA0hwGwAipotKOaZZC4qS9bCwMYnLOg0fSOks7vKYEVtrtYx n3tGD2MEvCjhV6/Svaj8v0udiD6CrK7B7H2t/jt/2uinJ8+99bzLKUVygBmdNcrgmDf1JcDEZjn1e 4YklpJAw==; Received: from sslproxy06.your-server.de ([78.46.172.3]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1meh3Y-000BgR-Vz; Sun, 24 Oct 2021 19:13:13 +0200 Received: from [82.135.83.71] (helo=lars-desktop.fritz.box) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1meh3Y-000VNB-Qd; Sun, 24 Oct 2021 19:13:12 +0200 From: Lars-Peter Clausen To: Jonathan Cameron Cc: Tiberiu Breana , Linus Walleij , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, Lars-Peter Clausen Subject: [PATCH 1/3] iio: ltr501: Don't return error code in trigger handler Date: Sun, 24 Oct 2021 19:12:49 +0200 Message-Id: <20211024171251.22896-1-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.103.3/26332/Sun Oct 24 10:18:48 2021) Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org IIO trigger handlers need to return one of the irqreturn_t values. Returning an error code is not supported. The ltr501 interrupt handler gets this right for most error paths, but there is one case where it returns the error code. In addition for this particular case the trigger handler does not call `iio_trigger_notify_done()`. Which when not done keeps the triggered disabled forever. Modify the code so that the function returns a valid irqreturn_t value as well as calling `iio_trigger_notify_done()` on all exit paths. Fixes: 2690be905123 ("iio: Add Lite-On ltr501 ambient light / proximity sensor driver") Signed-off-by: Lars-Peter Clausen --- drivers/iio/light/ltr501.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index 7e51aaac0bf8..b2983b1a9ed1 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -1275,7 +1275,7 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p) ret = regmap_bulk_read(data->regmap, LTR501_ALS_DATA1, als_buf, sizeof(als_buf)); if (ret < 0) - return ret; + goto done; if (test_bit(0, indio_dev->active_scan_mask)) scan.channels[j++] = le16_to_cpu(als_buf[1]); if (test_bit(1, indio_dev->active_scan_mask)) From patchwork Sun Oct 24 17:12:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 12580363 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3300C4332F for ; Sun, 24 Oct 2021 17:13:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C402560F57 for ; Sun, 24 Oct 2021 17:13:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231482AbhJXRPh (ORCPT ); Sun, 24 Oct 2021 13:15:37 -0400 Received: from www381.your-server.de ([78.46.137.84]:54152 "EHLO www381.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231730AbhJXRPg (ORCPT ); Sun, 24 Oct 2021 13:15:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=IaMYS+cLpglLi8ceKKvHbWr24RAnA38Ao+XpmQ0jPww=; b=LSW0B6pxjLlvE/HwoCFYp0rIw8 DzFPduYznCYdGKOc38TNn1Ytn62r/XQamHn3hnwIBGF+aKnNLu/aHOwlOnz/HBxFcjqLOD5JAMunS bAkf+AVkiC1G3KYrsn0FvTvzYszrZ54VJOVw0BnXgBc1qqOLlMxyMD74s2jVzLoE32m4says034kD qDv5tupktOnvC50P6JXz2uYhH/eYIVCdqKyi92xq4ouEuT2p72IsqVOAVjrCYGTudHoJtBsVvb79l hKH6PR4oZC3GF79VXyozbX2hkt1vDT/gM0eAUH+T+HGTXpBZB4eWYUW+9JDGsxyfhpnF4efYe5GdP UG7fVlSQ==; Received: from sslproxy06.your-server.de ([78.46.172.3]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1meh3Z-000BgS-1f; Sun, 24 Oct 2021 19:13:13 +0200 Received: from [82.135.83.71] (helo=lars-desktop.fritz.box) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1meh3Y-000VNB-Sl; Sun, 24 Oct 2021 19:13:12 +0200 From: Lars-Peter Clausen To: Jonathan Cameron Cc: Tiberiu Breana , Linus Walleij , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, Lars-Peter Clausen Subject: [PATCH 2/3] iio: kxsd9: Don't return error code in trigger handler Date: Sun, 24 Oct 2021 19:12:50 +0200 Message-Id: <20211024171251.22896-2-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211024171251.22896-1-lars@metafoo.de> References: <20211024171251.22896-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.103.3/26332/Sun Oct 24 10:18:48 2021) Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org IIO trigger handlers need to return one of the irqreturn_t values. Returning an error code is not supported. The kxsd9 interrupt handler returns an error code if reading the data registers fails. In addition when exiting due to an error the trigger handler does not call `iio_trigger_notify_done()`. Which when not done keeps the triggered disabled forever. Modify the code so that the function returns a valid irqreturn_t value as well as calling `iio_trigger_notify_done()` on all exit paths. Since we can't return the error code make sure to at least log it as part of the error message. Fixes: 0427a106a98a ("iio: accel: kxsd9: Add triggered buffer handling") Signed-off-by: Lars-Peter Clausen Reviewed-by: Linus Walleij --- drivers/iio/accel/kxsd9.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c index 2faf85ca996e..552eba5e8b4f 100644 --- a/drivers/iio/accel/kxsd9.c +++ b/drivers/iio/accel/kxsd9.c @@ -224,14 +224,14 @@ static irqreturn_t kxsd9_trigger_handler(int irq, void *p) hw_values.chan, sizeof(hw_values.chan)); if (ret) { - dev_err(st->dev, - "error reading data\n"); - return ret; + dev_err(st->dev, "error reading data: %d\n", ret); + goto out; } iio_push_to_buffers_with_timestamp(indio_dev, &hw_values, iio_get_time_ns(indio_dev)); +out: iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; From patchwork Sun Oct 24 17:12:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 12580359 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 931DAC433FE for ; Sun, 24 Oct 2021 17:13:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 777A060F57 for ; Sun, 24 Oct 2021 17:13:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231658AbhJXRPh (ORCPT ); Sun, 24 Oct 2021 13:15:37 -0400 Received: from www381.your-server.de ([78.46.137.84]:54146 "EHLO www381.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231482AbhJXRPg (ORCPT ); Sun, 24 Oct 2021 13:15:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=WveDC516dlSgTwW/gTzbmeRKMFSyidxrCwfrreoF/1Y=; b=VUH0NsW1c9AdC2nbKj9kkuASpV DlFYqZhpx6PKgcFYKs9RKfIeANczM+gIqT0RK2Xi8jCaX9YylsONxfQJZKxwvpP6bX92TaMonecJI l62xmLHVmvhXbO9iknnpbzxsUy+OXTf+yyLnIjIimUTg5Zi+MFGHthlnxK6VMEUVa628sX31Yhi7v uHXOmnsEgRdrs05+N+dQx7ple23tDXLUOwIW57YhnQCkU8aA0eJV5eGl9vXoHDA256Wrlyx8wNCJt 04TZxecp4U2eDGmdRgYJNDjfeQ77UCt//xP/bY8W9lGVdelgWHQOQTBgRcCYmXM9xQJmgvyu+fsUh JqmdUKeA==; Received: from sslproxy06.your-server.de ([78.46.172.3]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1meh3Z-000BgT-3u; Sun, 24 Oct 2021 19:13:13 +0200 Received: from [82.135.83.71] (helo=lars-desktop.fritz.box) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1meh3Y-000VNB-Uz; Sun, 24 Oct 2021 19:13:12 +0200 From: Lars-Peter Clausen To: Jonathan Cameron Cc: Tiberiu Breana , Linus Walleij , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, Lars-Peter Clausen Subject: [PATCH 3/3] iio: stk3310: Don't return error code in interrupt handler Date: Sun, 24 Oct 2021 19:12:51 +0200 Message-Id: <20211024171251.22896-3-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211024171251.22896-1-lars@metafoo.de> References: <20211024171251.22896-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.103.3/26332/Sun Oct 24 10:18:48 2021) Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Interrupt handlers must return one of the irqreturn_t values. Returning a error code is not supported. The stk3310 event interrupt handler returns an error code when reading the flags register fails. Fix the implementation to always return an irqreturn_t value. Fixes: 3dd477acbdd1 ("iio: light: Add threshold interrupt support for STK3310") Signed-off-by: Lars-Peter Clausen --- drivers/iio/light/stk3310.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c index 07e91846307c..fc63856ed54d 100644 --- a/drivers/iio/light/stk3310.c +++ b/drivers/iio/light/stk3310.c @@ -546,9 +546,8 @@ static irqreturn_t stk3310_irq_event_handler(int irq, void *private) mutex_lock(&data->lock); ret = regmap_field_read(data->reg_flag_nf, &dir); if (ret < 0) { - dev_err(&data->client->dev, "register read failed\n"); - mutex_unlock(&data->lock); - return ret; + dev_err(&data->client->dev, "register read failed: %d\n", ret); + goto out; } event = IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 1, IIO_EV_TYPE_THRESH, @@ -560,6 +559,7 @@ static irqreturn_t stk3310_irq_event_handler(int irq, void *private) ret = regmap_field_write(data->reg_flag_psint, 0); if (ret < 0) dev_err(&data->client->dev, "failed to reset interrupts\n"); +out: mutex_unlock(&data->lock); return IRQ_HANDLED;