Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp361216pxb; Wed, 18 Aug 2021 04:16:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKZHfkSxl65oV/FvjiU29eXfeCOX3QhuAoJQP7pMpJetDX0MUVg7TR1dIQfIXBS+ScaM1J X-Received: by 2002:a50:fc8e:: with SMTP id f14mr9541161edq.349.1629285400640; Wed, 18 Aug 2021 04:16:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629285400; cv=none; d=google.com; s=arc-20160816; b=oLbE/Rps/906aeZ1UKVCgm9I4W4ub9pIW6pdhg91TVfFOtTf8Xmvte75qgXc736bNj H8moscwDFVCJSm6ELWxQOZjxU9ZancTaDEBMUorNkPhIF70t5bfyIHzYmsx2xMKRkwL0 O6/5Rg1j+6sulokHTWhxHJhvMa4+frsFI+j1P3Ah9IclK9plwC5H7Qi660aQPgjxIztT y1XAHXwja+4H7KYA6q50xPihXD67wiR/vFd44ezN87V4ZgnnxdwWdGsaav5vmzY8L/5T c/LkfP9fjdOxLvklhk2hb+eCARj+XusCYdEO9AtTdnSE/LbBWiFZdcZkKRz5+nE57gFx m98g== 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=2Kx79ucbrPML3nsL3yZ5zl4404qvkwm3LgEpKNkJg98=; b=uQcQpY3IPuBuCJTaeF9Jxv4Jsy1/jemK1ALxjV/gExPtOHMe120QSAwRnL1gzRNred xYD7iImj3i+4TskhA/UKsbobhW06vFEjZvU6vlLQD7Ukek/OWsgDQ9t5DIpf40v1XNaF ZJVQc8PamAi3DgvC0kinTjUrbuGFmsyXojMcGrNmI07WzZbbMM2LUYnJNincKbZqvPcn StAZ6/KFKiTFGZgVo+jXfoJPlCCqQkSCuwvcCUzsYDNxpQGfNlnwO/56cwXhjSUiaWA6 zzieA6vskk6UwZws5b7ZlVqUdTSu8TDh6KYeQQl5s1OeV5RMt4xSGr5LyYBZC22QoHAY WMdw== 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 z6si6004415edp.269.2021.08.18.04.16.17; Wed, 18 Aug 2021 04:16:40 -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 S235943AbhHRLNc (ORCPT + 99 others); Wed, 18 Aug 2021 07:13:32 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:57015 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235649AbhHRLM0 (ORCPT ); Wed, 18 Aug 2021 07:12:26 -0400 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id AD88B60016; Wed, 18 Aug 2021 11:11:50 +0000 (UTC) From: Miquel Raynal To: Jonathan Cameron , Lars-Peter Clausen Cc: Thomas Petazzoni , linux-iio@vger.kernel.org, , Miquel Raynal Subject: [PATCH 16/16] iio: adc: max1027: Enable software triggers to be used without IRQ Date: Wed, 18 Aug 2021 13:11:39 +0200 Message-Id: <20210818111139.330636-17-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 Software triggers do not need a device IRQ to work. As opposed to hardware triggers which need it to yield the data to the IIO core, software triggers run a dedicated thread which does all the tasks on their behalf. Then, the end of conversion status may either come from an interrupt or from a sufficient enough extra delay. IRQs are not mandatory so move the triggered buffer setup out of the IRQ condition. Signed-off-by: Miquel Raynal --- drivers/iio/adc/max1027.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c index bb437e43adaf..e767437a578e 100644 --- a/drivers/iio/adc/max1027.c +++ b/drivers/iio/adc/max1027.c @@ -567,16 +567,18 @@ static int max1027_probe(struct spi_device *spi) if (!st->buffer) return -ENOMEM; + /* Enable triggered buffers */ + ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, + &iio_pollfunc_store_time, + &max1027_trigger_handler, + NULL); + if (ret < 0) { + dev_err(&indio_dev->dev, "Failed to setup buffer\n"); + return ret; + } + + /* If there is an EOC interrupt, enable the hardware trigger (cnvst) */ if (spi->irq) { - ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, - &iio_pollfunc_store_time, - &max1027_trigger_handler, - NULL); - if (ret < 0) { - dev_err(&indio_dev->dev, "Failed to setup buffer\n"); - return ret; - } - st->trig = devm_iio_trigger_alloc(&spi->dev, "%s-trigger", indio_dev->name); if (st->trig == NULL) { -- 2.27.0