Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1242345pxa; Thu, 13 Aug 2020 04:25:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4LS0GSJuyekfoMYSfEdbKbOzcR8NpUAEdmTXCg45R4UGyUkZymrSQF24DAEmZI60/Vh2J X-Received: by 2002:a50:b701:: with SMTP id g1mr4359018ede.197.1597317943407; Thu, 13 Aug 2020 04:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597317943; cv=none; d=google.com; s=arc-20160816; b=WC2GOfJAFRCu9uS1Mjm55Kb5Gpfgjx37jfvRXoG+LS4/bmHPAN4nTH5YxrSMvfHYYX 48Den2EE/S1ClamC4n1s9MuhIH76iTmQIDh9zid0YBm5eXg0BCM9aWm/3EqGohc1c7Bb 4SRmugKVk5Jw8wiEUwFd/RRS1O1olFKYQ3JzHEIeq19kXH7HpHU5gQxjiwEuKeCN8YyC WT0QtvPfNBlthXCf7f2pr8PRtQrYor7pBPS0XkUjrbxPwqHWIqHflxH6r3UzgjAkx8E3 7YkVpWEd/usVlEyRMeV1Xc58Fc07YZu+YbWPm7X9yHN3/JsN2UC/jix3FluMLJr0mVjv N2WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/zriuZjSj9xj6/8fSPTT22Tss8liWtUy8xFTyXoU7yc=; b=PpIJU9E656LkqHzRxpKQVXQiSJjMXLMZHubIRPgpEA4cefbwAQlF3zFZ7/sUDk1myG 4IKrKC5ErqZDHQAMYI4xIlaG0OEq5/gvHP/BXYhzsnLUnP4wH80ukJakquNXVOwUCeBw 6FsYe2QbiGcmHlARBs6R+TB/Uyq0JdIORlIYuKgHHr+/bNI0TWPk+JYxv8Ex5ZMXUMFY vqajw2d5suWEGddJYOzyOt1vusv8vI0AkXmZKWoifJJqSyLA6VoqVuh1VwaCHefiNh/c 7PYcOZBSiAJ80xMRgXAuZpizWkjabXNUikqYvWojGMg/48vKeKUWaxIjSoFpi2t8pA2I EwCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RACy3nGs; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dc26si3216707edb.203.2020.08.13.04.25.20; Thu, 13 Aug 2020 04:25:43 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RACy3nGs; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726564AbgHMLYk (ORCPT + 99 others); Thu, 13 Aug 2020 07:24:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726100AbgHMLYj (ORCPT ); Thu, 13 Aug 2020 07:24:39 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A51F5C061757; Thu, 13 Aug 2020 04:24:39 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id u20so2673939pfn.0; Thu, 13 Aug 2020 04:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/zriuZjSj9xj6/8fSPTT22Tss8liWtUy8xFTyXoU7yc=; b=RACy3nGsdFg0Fh3cY1pec6ZHDW/idUPIscW7C7rGAtfhfrk2GlEu8kdWw8GDTL/G/Y rVdyGUPjUVFmoEhwXIr9z8/k38tx4oN6Ut4CFvLnGAh3rUh002GwkI19Nhc1qYZ+uzQy kJn89akKBKKHXmtgHaW8l8/ExET1IIekAdK9+IE/abe+2LLEpIFKX8/MpUTbz0k8B60S NrMBsmzNjXEYhtnK7YKITD4cptUUgXOnx70nPvxWy5yias6o2/3Al8HeoRAGD52fYVei rw70CEvdwLEzp9I4hnM0ydJ+mFUgCeAZaF3AcQYspu+XRMPRbiHqfOR7pI5gX77lW5EI ZBnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/zriuZjSj9xj6/8fSPTT22Tss8liWtUy8xFTyXoU7yc=; b=PpKiva4s5uaHttXjXMcXZTSWLxkeW8Ju4Tsvl+YLQG7mPys/Gs2hj7U576IqD1NHYF kkujU8dzADy2h9sj9+kJI+rZMxVs4NodOwtP0dF4LGL4fjsm+akt95BPbW1LlvToxz9s XiN+S5pq7egbsz4pgwNmhmLdEFwSCUQXPWLJBV8ElhNYrvCgMFh06PCXMLZiWiX7MNcq R9IeCtsvYadId82zwC6BWyzvSHTchJ0J8K4Bb+TAaMxZEWkmZ/6lzL+AEzj8T9NJlk7t a4ZnEyyvY0pMpeUw/0x1KDNiGh7ZYkS42TxMfJPPDycz0rqkMpi1nFQnW7x8b3o4qD4d W26g== X-Gm-Message-State: AOAM532kDnqswv3IybmSNFlWv+NOl1p2S2TfPPCIb1Rb2q8h7M1MhiZ2 st5Jg24YTbwPMA2n0SUg4sGdaL+V42MTTrBd9bNHQWT9zts= X-Received: by 2002:a63:f24a:: with SMTP id d10mr3188515pgk.4.1597317879199; Thu, 13 Aug 2020 04:24:39 -0700 (PDT) MIME-Version: 1.0 References: <20200813075125.4949-1-cmo@melexis.com> <20200813075125.4949-4-cmo@melexis.com> In-Reply-To: From: Andy Shevchenko Date: Thu, 13 Aug 2020 14:24:23 +0300 Message-ID: Subject: Re: [PATCH v5 3/5] iio:temperature:mlx90632: Convert polling while loop to do-while To: Crt Mori Cc: Jonathan Cameron , linux-iio , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 13, 2020 at 2:14 PM Crt Mori wrote: > > On Thu, 13 Aug 2020 at 13:03, Andy Shevchenko wrote: > > > > On Thu, Aug 13, 2020 at 10:53 AM Crt Mori wrote: > > > > > > Reduce number of lines and improve readability to convert polling while > > > loops to do-while. The iopoll.h interface was not used, because we > > > require more than 20ms timeout, because time for sensor to perform a > > > measurement is around 10ms and it needs to perform measurements for each > > > channel (which currently is 3). > > > > I don't see how it prevents using iopoll.h. It uses usleep_range() > > under the hood in the same way you did here, but open coded. > > > > One loop is indeed 10ms and that is not the problem, the problem is > that timeout is at least 3 calls of this data ready (3 channels), so > that is at minimum 30ms of timeout, or it could even be 4 in worse > case scenario and that is outside of the range for usleep to measure. > So in case of the other loop, where we wait 200ms for channel refresh > it is also out of scope. Timeout should be in number of tries or in > msleep range if you ask me. I still didn't buy it. You have in both cases usleep_range(). Why in your case it's okay and in regmap_read_poll_timeout() is not? > > ... > > > > > - while (tries-- > 0) { > > > + do { > > > ret = regmap_read(data->regmap, MLX90632_REG_STATUS, > > > ®_status); > > > if (ret < 0) > > > return ret; > > > - if (reg_status & MLX90632_STAT_DATA_RDY) > > > - break; > > > usleep_range(10000, 11000); > > > - } > > > + } while (!(reg_status & MLX90632_STAT_DATA_RDY) && tries--); > > > > > > if (tries < 0) { > > > dev_err(&data->client->dev, "data not ready"); -- With Best Regards, Andy Shevchenko