Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4858682rwb; Tue, 6 Sep 2022 14:01:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Dtrrc5tqSMfAD6dX4LDUV13FKDxxXr/bNFcPm1nrQeuEzAL4jlr1ofDHzkPQ1Z6rtNuNr X-Received: by 2002:a65:6b8a:0:b0:42b:1eca:eef1 with SMTP id d10-20020a656b8a000000b0042b1ecaeef1mr433673pgw.205.1662498118892; Tue, 06 Sep 2022 14:01:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662498118; cv=none; d=google.com; s=arc-20160816; b=ogboB7jf0JWSUy1dEwJXg4BXpohSUGHDI3s9h9+ae41J11JQMR5MsZLmKG3xjyrJhq V6ZS8q8jjsMuI3wiAApmGgWIEdIZDbojIcCRmnqpgfnZNCup9ei65lo6+PCmxsWtoQ9f Eta0svHS8BGGOZh79xkhyMmybbOME/ZF7ZyQwxlUWyUoFquewJ+s44E+2RBPlgcoXr0p D6m8vQMAu2NTvlxtSmJOi9dNy7Gk+na3hayMB3Jjp0dtjesYAiE5UF+3/gtes5Qglomj lqdtQWyEcgdT2mh/D+AAzUHDruNFAlFkZButAwXT21weaG/ugczTa9H+2fIdwBVP6tAd mmpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=DZ0dxIN9tQK5jdKb/Xo71csBd9+xaWx/Qph+h8QMcik=; b=e1wEwJIdo4LabzSqko7JWVLi+771GBIckBF0zXCOlxFLUab5Xjp5biFzToyhYrMyiy oy1sodQpF+LlQO4roRPXyqc/2R/fhGwZY4MVMLW2nIg6L2jjvKIoQvSc+4bmLYxWzZwg +CzMhVaE51HTsUGCqtY5AT5FFZRaT3KZVyhfFJVuLI4D9AigLCODjwr1ZqfAEIPZKSsk iTsJzxpOhESfINT3I6OvvJVtPAtooa4a5jQ49RmMucR3O364R7WX43L4dKFBv2eWZcex Zh1U86p4SZcle3lCab4s7QZi3U+45SZO9jyLRHRK2A+OD2jDeeiXnMaYF94UrEb85GEi PLHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bJkWA3f3; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z1-20020a1709028f8100b001733a212ccfsi13580501plo.330.2022.09.06.14.01.38; Tue, 06 Sep 2022 14:01:58 -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=@gmail.com header.s=20210112 header.b=bJkWA3f3; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230149AbiIFUhH (ORCPT + 99 others); Tue, 6 Sep 2022 16:37:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229829AbiIFUhG (ORCPT ); Tue, 6 Sep 2022 16:37:06 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B993285AA4; Tue, 6 Sep 2022 13:37:05 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id b9so9121785qka.2; Tue, 06 Sep 2022 13:37:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=DZ0dxIN9tQK5jdKb/Xo71csBd9+xaWx/Qph+h8QMcik=; b=bJkWA3f3zbGryciCNoKYUZlQ8sPDE+uuaOiPCWFKDnPVPKv0wE7qYv5u+fHKMffuZJ VFdcDtR2OzCOOfHo0KXJgnO0tdOtWCWbzMD1ElXi2F9YaOdDwPggx+dQL0k8BRLGIjOZ vOli4dJgZdMHMWwwbMXWkGtAm/5LhFPJ2fZXkjLn2dJ+C28NmnNMGMfWNG0g8/yW/KHk muDpL8HhnNz3ndKUfiEstOy49yG8uhY9raY4CjLf2YIQEOJy6UR0kiWPjGc8RKzzfhBP LVU8BzBddM9aE+hr2f58b/n5MH0OXT0yEdYbVDQ2cR0bsdII352N110l2obNfhvELGBj YBKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=DZ0dxIN9tQK5jdKb/Xo71csBd9+xaWx/Qph+h8QMcik=; b=qWYTorenEWGpdzFXiILBsZkKTIaV+MyG7tZQ25EZLprUpvQ5SI49X8utHFeAm29oyP mtTKGlJy7ZLzrxczdDuumMBKxzh1/aaDTW6plN37vapJJI5PPxGfU7Vq1V25AhhQ36EV EAdysjWcBclHnqn919+3oe5CBlwArpwq6FAs4FiS4SHzPgVhHxt2AJ9SF375pzxbkGSb atNLN/ce8MyQbAnX9ucnI8Qg9/K3VklOYGSPxJfhQ84zq8cUdVknfZlE6KSbF+vB5+sg fOu8Uer50dds0DoKEapiNixYqNiuzltOjUMd2Zj0IJ2ryug14vMxhoYHDZpVACSQdQnn 6hhg== X-Gm-Message-State: ACgBeo3aUKtRK/J4lgDxoBdKUOTSZ9HPLl3IAWoFPOJvOaNckO5D/Xux g9O1UtG5RdFT5hMYNQut+RlBoAhBbtv+ILh2PKs= X-Received: by 2002:ae9:e311:0:b0:6ba:e711:fb27 with SMTP id v17-20020ae9e311000000b006bae711fb27mr384530qkf.320.1662496624827; Tue, 06 Sep 2022 13:37:04 -0700 (PDT) MIME-Version: 1.0 References: <20220906200535.1919398-1-eajames@linux.ibm.com> <20220906200535.1919398-3-eajames@linux.ibm.com> In-Reply-To: <20220906200535.1919398-3-eajames@linux.ibm.com> From: Andy Shevchenko Date: Tue, 6 Sep 2022 23:36:28 +0300 Message-ID: Subject: Re: [PATCH v6 2/2] iio: pressure: dps310: Reset chip after timeout To: Eddie James Cc: Jonathan Cameron , Lars-Peter Clausen , linux-iio , Linux Kernel Mailing List , Joel Stanley Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Tue, Sep 6, 2022 at 11:05 PM Eddie James wrote: > > The DPS310 chip has been observed to get "stuck" such that pressure > and temperature measurements are never indicated as "ready" in the > MEAS_CFG register. The only solution is to reset the device and try > again. In order to avoid continual failures, use a boolean flag to > only try the reset after timeout once if errors persist. If the previous patch is a dependency to this one, you need to use its Subject in a Cc: stable@ tag as it's pointed out in the documentation. Otherwise, Fixes go first in the series. ... > +static int dps310_reset_reinit(struct dps310_data *data) > +{ > + int rc; > + > + rc = dps310_reset_wait(data); > + if (rc) > + return rc; > + rc = dps310_startup(data); > + if (rc) > + return rc; > + > + return 0; Can be simply return _startup(...); > +} ... Can it be a helper here? int dps310_get_ready_status(data, ready_bit, timeout) { sleep = ... int ready; return regmap_read_poll_timeout(...); } > +static int dps310_ready(struct dps310_data *data, int ready_bit, int timeout) > +{ > + int rc; > + int ready; > + int sleep = DPS310_POLL_SLEEP_US(timeout); > + rc = regmap_read_poll_timeout(data->regmap, DPS310_MEAS_CFG, ready, ready & ready_bit, > + sleep, timeout); rc = dps310_get_ready_status(...); > + if (rc) { > + if (rc == -ETIMEDOUT && !data->timeout_recovery_failed) { > + int rc2; > + > + /* Reset and reinitialize the chip. */ > + rc2 = dps310_reset_reinit(data); > + if (rc2) { > + data->timeout_recovery_failed = true; > + } else { > + /* Try again to get sensor ready status. */ > + rc2 = regmap_read_poll_timeout(data->regmap, DPS310_MEAS_CFG, > + ready, ready & ready_bit, sleep, > + timeout); rc2 = dps310_get_ready_status(...); > + if (rc2) > + data->timeout_recovery_failed = true; > + else > + return 0; > + } > + } > + > + return rc; > + } > + > + data->timeout_recovery_failed = false; > + return 0; > +} -- With Best Regards, Andy Shevchenko