Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6060598rwl; Tue, 4 Apr 2023 07:21:15 -0700 (PDT) X-Google-Smtp-Source: AKy350ZFFYyk0b/HUml3nKgFkFeoQ1dc8Clm6OCOmoXbfKx/Ee65infL+dXrk3ve1kqip9i1Ffk1 X-Received: by 2002:aa7:9f9d:0:b0:62d:b4b3:621a with SMTP id z29-20020aa79f9d000000b0062db4b3621amr2501998pfr.10.1680618075655; Tue, 04 Apr 2023 07:21:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680618075; cv=none; d=google.com; s=arc-20160816; b=K0o7ir5c8yUiN2k2jxhYaiOOCV3hDMoZLkjia7MOxcTAFW6NlmiMWwoEBI7MNsVp42 owzzXP3uoqZgeACct9nLrWfC22hFJ4hKkyVngCV9LKBIL7qYqqBHlwqEzeXegIfatzgq RjKpoxsiZBR1mL3CFYF3CTGjJnbyahkxM2OBrhR8+jrzvT0bkPn3QkspQ1M0sxyVpqbc Ck3fD8Z9nbu3OblwwWMF5sWrzAWokEg/udNq7TY7wDZwEwJHf4kfk+pvuo6mECiULQrE zGNKsETEfnUj/zCZwc39XWV1pUXRqqo16EfV1rX1QCO9LzKW/Wwwb1Co5VOcoVAJOg28 Npxg== 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 :dkim-signature; bh=qDg8gjgCK4cCzQVwhhCZvTIORe+B4i8BW2+BbUTMc8k=; b=fgmJd8B3eMmaHS3rEuige3zyooX5RplpMx93WvYV5uzXDGi/iPmuLZ6kpyQfY3DuPq Ff++zc8mzFYZLufg8udG3Ah0nFreNwoo+Jpi6+0oPIPSJQOG8p0zvjqeDKOzWfiLfhRk PP1Cq3tf20HkcBkQT7QpAB9uQgfNph37BXiycrFHd/o28mbTNMnJ0WwC2yKFZse0RSGH NrYztxRIPaNNwz0FFVnll1hqxVZJMU67CMSIf4BtVi3jgv+XY9SA9J/+d0fVOKl/+Ewm YjQKlt+k4vUGw5KnZ7YQ8Dxqr9AuJ7fmfNd/zw87KSe8R08NwM7a43UcM2eqUmTeLTzP kbpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DiobnlWT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b4-20020a621b04000000b0062565210347si10194235pfb.275.2023.04.04.07.20.56; Tue, 04 Apr 2023 07:21:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DiobnlWT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235816AbjDDOMa (ORCPT + 99 others); Tue, 4 Apr 2023 10:12:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235743AbjDDOMO (ORCPT ); Tue, 4 Apr 2023 10:12:14 -0400 Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA6EF1A8 for ; Tue, 4 Apr 2023 07:12:10 -0700 (PDT) Received: by mail-yb1-xb31.google.com with SMTP id p204so38817543ybc.12 for ; Tue, 04 Apr 2023 07:12:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680617530; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qDg8gjgCK4cCzQVwhhCZvTIORe+B4i8BW2+BbUTMc8k=; b=DiobnlWTCEyBk4WPYFAHKg30bRzkskmSJ72Wcz0czZXBfiyEDWRHKO9j7HFFgmztHX xTXtdNMXXSAw/AMwjYmqyhquuzlygHqo1/eOGOM8k1x+2K95ixzBaZ3AzQVnLBYkVssL is9Dub6pRZJl9zSbNIakbfXudTP0IXFFXRKemRvFcXaYEfRE+jMAgdIu9rqNCsCKcqH+ NH2mMYvnftLWNjIjTz9qQEeVS04uRRKlmWRk2lVyO526Mp6wwBPvwvi7OOh9JxSVRmAv Dq3fsXDYkQoXuTcX4jJE2kPlWqfV+GN7mu/Hnmvpj4yC8MNr7lkMYkVANC/PFdK8DxEG jVTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680617530; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qDg8gjgCK4cCzQVwhhCZvTIORe+B4i8BW2+BbUTMc8k=; b=H+u12//ZGi5OO5TSjkdnRx0yrhP3UgmL+lvC34I81NIYTCI6yhIfhMRe/6bwrq2v1O WG8QaqnIUFT5TZqwmGJxBpyrYaIUdvDZUg+a3DfIkaTu2oAxN9Y4FyhwFbbSBs2P/q+1 oUZ0lEZrpGZcdOYQrw07/7gPX8cJu2j73iFU7oVqR2NqNUNhYsuf01jFKvuNytPAMU2K 7iEjK434DcYEWEwG4E5qo2JajFQKsPecvAtWkQPzYvXUlq8N5dDnynuhVl+kmv9f5kfg FweUAd58qWbl63a9OGjxRXMiqDbKfJqLVxuogjHS4u4rMpvBIy7rKNoDW/WZUk9QbA0w FQfg== X-Gm-Message-State: AAQBX9dHlm5gsmrfnKZW/FiGs4GuxeYuuw2iuTWuJ0mWXmZ9ce/HwdSn A728LGj7mYwjC0KkPt8a515pow== X-Received: by 2002:a25:aa53:0:b0:b05:af93:c3d7 with SMTP id s77-20020a25aa53000000b00b05af93c3d7mr2826487ybi.62.1680617529787; Tue, 04 Apr 2023 07:12:09 -0700 (PDT) Received: from fedora.attlocal.net (69-109-179-158.lightspeed.dybhfl.sbcglobal.net. [69.109.179.158]) by smtp.gmail.com with ESMTPSA id d195-20020a811dcc000000b00545a08184d8sm3202750ywd.104.2023.04.04.07.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 07:12:09 -0700 (PDT) From: William Breathitt Gray To: Jonathan Cameron , Lars-Peter Clausen Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Shevchenko , William Breathitt Gray Subject: [PATCH v4 5/5] iio: addac: stx104: Use regmap_read_poll_timeout() for conversion poll Date: Tue, 4 Apr 2023 10:12:02 -0400 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ADC sample captures take a certain amount of time to complete after initiated; this conversion time range can be anywhere from 5 uSec to 53.68 Seconds depending on the configuration of the Analog Input Frame Timer register. When the conversion is in progress, the ADC Status register CNV bit is high. Utilize regmap_read_poll_timeout() to poll until the ADC conversion is completed (or timeout if more than 53.68 Seconds passes). Suggested-by: Jonathan Cameron Signed-off-by: William Breathitt Gray --- Changes in v4: none drivers/iio/addac/stx104.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/iio/addac/stx104.c b/drivers/iio/addac/stx104.c index f300cce52787..0cdb824b6bb6 100644 --- a/drivers/iio/addac/stx104.c +++ b/drivers/iio/addac/stx104.c @@ -206,19 +206,22 @@ static int stx104_read_raw(struct iio_dev *indio_dev, /* trigger ADC sample capture by writing to the 8-bit * Software Strobe Register and wait for completion + * Range is 5 uSec to 53.68 Seconds in steps of 25 nanoseconds. + * The actual Analog Input Frame Timer time interval is calculated as: + * ai_time_frame_ns = ( AIFT + 1 ) * ( 25 nSec ). + * Where 0 <= AIFT <= 2147483648. */ err = regmap_write(priv->aio_ctl_map, STX104_SOFTWARE_STROBE, 0); if (err) { mutex_unlock(&priv->lock); return err; } - do { - err = regmap_read(priv->aio_ctl_map, STX104_ADC_STATUS, &adc_status); - if (err) { - mutex_unlock(&priv->lock); - return err; - } - } while (u8_get_bits(adc_status, STX104_CNV)); + err = regmap_read_poll_timeout(priv->aio_ctl_map, STX104_ADC_STATUS, adc_status, + !u8_get_bits(adc_status, STX104_CNV), 0, 53687092); + if (err) { + mutex_unlock(&priv->lock); + return err; + } err = regmap_read(priv->aio_data_map, STX104_ADC_DATA, &value); if (err) { -- 2.39.2