Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp361151pxb; Wed, 18 Aug 2021 04:16:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3gpLuLeCz/7sysZ3+7l9XgX2bTsAVB9d4dAzdYt6uDiRfPIkjliAgl4+JeQsSY6IJmgMe X-Received: by 2002:a50:fc96:: with SMTP id f22mr9725656edq.367.1629285396556; Wed, 18 Aug 2021 04:16:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629285396; cv=none; d=google.com; s=arc-20160816; b=NP/oGDrudLomq6MymidHvkx8eeE0fdCm9O6e6Al5lwc4gcyIOyteoqiVixpWeEl8h9 G6m4ipQLbuW1eNRMuUMGgmxQB7HXMZN2FwkS0nw83NX0B3+Cu1gcptJocJclDB1QkWcD ai6RkUI52DAnhdQbf+N/GeectxzYSyNRfuSGVcC+P1vngu0XQ/XSSrEWUmhIHlEJKnfI 9ypTXeakKlsOhqNilEGXQcMTpwrzCfk5s3ziG052OnLxTl3ymM0LtEBV92GK7GgVvnr3 QpCfqFSXzH9TE0ToUTfKcCNHJYTd9dKnLC6gSsTvxHOi6AhZYsr5KtdeKhPeM3bjlnLv Ua1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=FnxZlcHNh8AjNumteNb2bg1rbhuEORhHxtpezLEvZG4=; b=iKCLDZMDQjqphj1+NVd3PCoP8PCkC1YYhXqUjxxHiA1N8i2zyguXLOJWkd0bO+hdRq WqwuWKk2PRvYQ9lOJjFueLrUAb4JGcvQf3yJ2VU6EEXRIgEonLxhbHioEKXlFktLp5g9 yLsqH0NZwP44bEMtwJ4yTSmb1IUaPaFUybg2hQx9ejdOOSgphB6DPt8hWNhsLykfZLAe yDHfLw7vEAqb3urIhb5KKREiOknSsLHTS+uZujy4799hAodDf8FmgtRdAsYMvygjXhtF YN0UBWgX6ZNJH2V70ZbcGlTBkFVi9g4oN1ndjoL8N02I6qVcuTu9lVcy7DzyoTh9mAbu RiOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s4si4924111edd.435.2021.08.18.04.16.11; Wed, 18 Aug 2021 04:16:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235698AbhHRLN2 (ORCPT + 99 others); Wed, 18 Aug 2021 07:13:28 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:50709 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235572AbhHRLMY (ORCPT ); Wed, 18 Aug 2021 07:12:24 -0400 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id AE75960013; Wed, 18 Aug 2021 11:11:48 +0000 (UTC) From: Miquel Raynal To: Jonathan Cameron , Lars-Peter Clausen Cc: Thomas Petazzoni , linux-iio@vger.kernel.org, , Miquel Raynal Subject: [PATCH 13/16] iio: adc: max1027: Prepare re-using the EOC interrupt Date: Wed, 18 Aug 2021 13:11:36 +0200 Message-Id: <20210818111139.330636-14-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210818111139.330636-1-miquel.raynal@bootlin.com> References: <20210818111139.330636-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Right now the driver only has hardware trigger support, which makes use of the End Of Conversion (EOC) interrupt by: - Enabling the external trigger - At completion of the conversion, run a generic handler - Push the data to the IIO subsystem by using the triggered buffer infrastructure, which may not only serve this purpose. In fact, the interrupt will fire for more reasons than just a hardware trigger condition, so make a dedicated interrupt handler which will be enhanced by the upcoming changes to handle more situations. Signed-off-by: Miquel Raynal --- drivers/iio/adc/max1027.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c index 2d6485591761..8d86e77fb5db 100644 --- a/drivers/iio/adc/max1027.c +++ b/drivers/iio/adc/max1027.c @@ -472,6 +472,24 @@ static int max1027_read_scan(struct iio_dev *indio_dev) return 0; } +static irqreturn_t max1027_eoc_irq_handler(int irq, void *private) +{ + struct iio_dev *indio_dev = private; + struct max1027_state *st = iio_priv(indio_dev); + int ret = 0; + + if (st->cnvst_trigger) { + ret = max1027_read_scan(indio_dev); + iio_trigger_notify_done(indio_dev->trig); + } + + if (ret) + dev_err(&indio_dev->dev, + "Cannot read scanned values (%d)\n", ret); + + return IRQ_HANDLED; +} + static irqreturn_t max1027_trigger_handler(int irq, void *private) { struct iio_poll_func *pf = private; @@ -563,11 +581,11 @@ static int max1027_probe(struct spi_device *spi) } ret = devm_request_threaded_irq(&spi->dev, spi->irq, - iio_trigger_generic_data_rdy_poll, + max1027_eoc_irq_handler, NULL, IRQF_TRIGGER_FALLING, spi->dev.driver->name, - st->trig); + indio_dev); if (ret < 0) { dev_err(&indio_dev->dev, "Failed to allocate IRQ.\n"); return ret; -- 2.27.0