Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp360701pxb; Wed, 18 Aug 2021 04:15:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpzfhodCEVCF2B+xFehdJyYAGN/KAkbHvPj62KbxpkRq/dCsgc66ORBYHVoRFg80v3LG3n X-Received: by 2002:a17:906:af4f:: with SMTP id ly15mr9316666ejb.175.1629285352929; Wed, 18 Aug 2021 04:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629285352; cv=none; d=google.com; s=arc-20160816; b=tra31yVUwukcDpuSAQztMW1tBrBW2CxvyYJQrqW/LmCBswhjxC1A7oPCa4a8cpyPiA jYVYJSlgAv9CComcHPZCoiBOny2qtIRlqUCsw0ZLKCoGP5tAPahK+9+iFjHsnbKqxTbq 35M63nzQncZ3YwfS3YnYJEgzFZTlr9q+K9hm1qnjfygRC1qyjldZoWuljFk4q1CXRmd8 fS4qdvIylzu51fNckOa6DvQVAtJvhnmjimSF00jgxkrarVG7pHUU6ciAcDI0+gV1Tked kF0qGBFXrTYwY9o+rI9p/i+/98P1WHrpDorKuIzULAVcWyo3O3p7ctvwIqPGf1SaOOza 4kJA== 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=yUdcd9QmRWcGCf9FYbzZjWOuLqo8ej0kZG94uJt7/mI=; b=yKAspSXUoB3mMJkT9srX7i0fuGMjKzkoPSYj1LgmRw+tWRqZ5jyZax4aw6Al+i2gqj y7TPhNe+MDKXORq/TLC+rd7LFQyqtyMTsgI/cjujOCljZf5GT6NP2VporR0D8QfG/39x HJni0i50nPKlo2UcaGLnpGU2yskQzFlhoUmi5Fd7WPu4+uigsuzqS2epSSYze+R+cpNe p5WEa/3zM/hb/FcvyQ7bmfO/gLaXQwoNQBeLcGEC3EaU8gQ7PuK+i/7fxsVevrTohWeV 4Nloha2FO5Onjj3UAHEcP5vznc5/coobZ5q8WomMRH/Aq7+BrR9YjyhZm50S8TzX/IoK EsCA== 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 w16si5801904ejb.337.2021.08.18.04.15.29; Wed, 18 Aug 2021 04:15:52 -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 S236353AbhHRLNk (ORCPT + 99 others); Wed, 18 Aug 2021 07:13:40 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:39539 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235629AbhHRLMZ (ORCPT ); Wed, 18 Aug 2021 07:12:25 -0400 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 037786000A; Wed, 18 Aug 2021 11:11:49 +0000 (UTC) From: Miquel Raynal To: Jonathan Cameron , Lars-Peter Clausen Cc: Thomas Petazzoni , linux-iio@vger.kernel.org, , Miquel Raynal Subject: [PATCH 15/16] iio: adc: max1027: Support software triggers Date: Wed, 18 Aug 2021 13:11:38 +0200 Message-Id: <20210818111139.330636-16-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 Now that max1027_trigger_handler() has been freed from handling hardware triggers EOC situations, we can use it for what it has been designed in the first place: trigger software originated conversions. In other words, when userspace initiates a conversion with a sysfs trigger or a hrtimer trigger, we must do all configuration steps, ie: 1- Configuring the trigger 2- Configuring the channels to scan 3- Starting the conversion (actually done automatically by step 2 in this case) 4- Waiting for the conversion to end 5- Retrieving the data from the ADC 6- Push the data to the IIO core and notify it Add the missing steps to this helper and drop the trigger verification hook otherwise software triggers would simply not be accepted at all. Signed-off-by: Miquel Raynal --- drivers/iio/adc/max1027.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c index 8c5995ae59f2..bb437e43adaf 100644 --- a/drivers/iio/adc/max1027.c +++ b/drivers/iio/adc/max1027.c @@ -413,17 +413,6 @@ static int max1027_debugfs_reg_access(struct iio_dev *indio_dev, return spi_write(st->spi, val, 1); } -static int max1027_validate_trigger(struct iio_dev *indio_dev, - struct iio_trigger *trig) -{ - struct max1027_state *st = iio_priv(indio_dev); - - if (st->trig != trig) - return -EINVAL; - - return 0; -} - static int max1027_set_cnvst_trigger_state(struct iio_trigger *trig, bool state) { struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); @@ -512,7 +501,21 @@ static irqreturn_t max1027_trigger_handler(int irq, void *private) pr_debug("%s(irq=%d, private=0x%p)\n", __func__, irq, private); + ret = max1027_configure_trigger(indio_dev); + if (ret) + goto out; + + ret = max1027_configure_chans_to_scan(indio_dev); + if (ret) + goto out; + + ret = max1027_wait_eoc(indio_dev); + if (ret) + goto out; + ret = max1027_read_scan(indio_dev); + +out: if (ret) dev_err(&indio_dev->dev, "Cannot read scanned values (%d)\n", ret); @@ -529,7 +532,6 @@ static const struct iio_trigger_ops max1027_trigger_ops = { static const struct iio_info max1027_info = { .read_raw = &max1027_read_raw, - .validate_trigger = &max1027_validate_trigger, .debugfs_reg_access = &max1027_debugfs_reg_access, }; -- 2.27.0