Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp362446pxb; Wed, 18 Aug 2021 04:18:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqy1mpg4l/tMcCh46iSbaQA/mBQ9DTdlwAjsNgIXNt+cOFpyEm2xLEF4o9gKcQR63wknZJ X-Received: by 2002:aa7:d896:: with SMTP id u22mr9482308edq.290.1629285499980; Wed, 18 Aug 2021 04:18:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629285499; cv=none; d=google.com; s=arc-20160816; b=z0QH9kDAmE2g9A3YX4SD/JqnoMYS+2vYPIJw2u01dgoSQ6gFMArG2XSvJ6kw+ncIz3 IS95KqakGEP9QPzG4SNT+yRKbtlUji8y+JRlhqHCmhV77fdu+encKV1Ocku/rbr4GszE JFxsLda8kzO6Jd6h4sdmdDAkatzhm9VAg3CChhjTFqehad9kjkZYD0z3gZS0kQ2Ofoxt 2jCBXNb8ZbgeD0lgubpYQcOTobgRBaWvQMq8pQ50PNGG9ZYK/3FQevFI0uT85O1+XNCu biQ04R+6GCjj9023xND/B3bzXOX+FYws28w6fjHibCaGNTMPCTUUWHt/1+TOCjGsILnT 5qVQ== 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=J3iqOB0Sz/vOdCW9y2I+Og/OYN4NrBK6WXGwgoGj5BA=; b=vmsV2FUr1MRTfmCAjgwozDoWKyYBAd8KYK2hj5S058ublMnzBioBQess4l5D8pl8vg swZZDfqTEu4lP9df3WFp1/8yqwxGqleHlq6lvuM9reFRGrh7XhEZn0m595HTdM48l1P5 IDJbbpZBLHpCVSxw8TtCge3atdcuUoofLdJGAI2NLoyp9aEldEOerg97MEoycuyk3swT 76OapHaa5NDHQ8LjLy/v5IBFEboTf5e2pm+tEO0PJnjMB5kDMnRiSXgL+7Co9PjxGBoa QLD003reuX2TcOzRDBK1Xzg5CoMSt9ugORcovsxJ4KczOwHyBzer3oX7oCUt2zZabDO+ +A2w== 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 dc21si5184339edb.493.2021.08.18.04.17.56; Wed, 18 Aug 2021 04:18:19 -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 S236320AbhHRLOB (ORCPT + 99 others); Wed, 18 Aug 2021 07:14:01 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:43365 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235207AbhHRLMW (ORCPT ); Wed, 18 Aug 2021 07:12:22 -0400 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id B29D76000C; Wed, 18 Aug 2021 11:11:46 +0000 (UTC) From: Miquel Raynal To: Jonathan Cameron , Lars-Peter Clausen Cc: Thomas Petazzoni , linux-iio@vger.kernel.org, , Miquel Raynal Subject: [PATCH 10/16] iio: adc: max1027: Prevent single channel accesses during buffer reads Date: Wed, 18 Aug 2021 13:11:33 +0200 Message-Id: <20210818111139.330636-11-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 When hardware buffers are enabled (the cnvst pin being the trigger), one should not mess with the device state by requesting a single channel read. Prevent it with a iio_buffer_enabled() check. Signed-off-by: Miquel Raynal --- drivers/iio/adc/max1027.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c index 223c9e4abd86..83526f3d7d3a 100644 --- a/drivers/iio/adc/max1027.c +++ b/drivers/iio/adc/max1027.c @@ -335,6 +335,8 @@ static int max1027_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: + if (iio_buffer_enabled(indio_dev)) + return -EBUSY; ret = max1027_read_single_value(indio_dev, chan, val); break; case IIO_CHAN_INFO_SCALE: -- 2.27.0