Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp378981rwa; Sat, 20 Aug 2022 05:43:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR4sxWJwZcTL2yF3lCtkTtKcgrDxhiijp9LdZuLroq5QGoATsEPXyqCyroUvM1SkNfLoAIly X-Received: by 2002:a17:902:efd2:b0:172:b0a5:fd79 with SMTP id ja18-20020a170902efd200b00172b0a5fd79mr12150398plb.87.1660999385416; Sat, 20 Aug 2022 05:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660999385; cv=none; d=google.com; s=arc-20160816; b=nZabSUFEdjg9yeB9l/7Ugw9ZP1Qo+XdyOlpWtEbrTugzfoEor7JAyQY+uIB6J8/WS0 5TGgdvvPUBKWRPZB31XvVp43XV6NIc7orzk2TiGljp+h7TUUTaCex8lVDJB8DTqVec2W Nqxibhq8hOpHo4hLuwCX5LRFYkIFU642cvvdsn0zCzOf4r2c3Mg9ZhtZgwT9yixEqT5/ TnyLCFSOmtjjQCU+tHD21UpGFQmi8pUtNvb+Blvjx9DzaetvgmKYD3V+6d7KrFzqn4zp TmQ/BTEjWQYqVqHRsR33RO23yja6CcP1kPDt1rqNPPkR7vGUS/NfSI7laK63zfRKrrFL x0rg== 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:subject:cc:to:from:date :dkim-signature; bh=HbxjaeOPo/pYBLVfwH2IjVoJ9oqkqYTL9TnX3+uJXx0=; b=yNWiZYFGMvG3zpStpsrMlpxIEkIW0ojBH48U6mD9DUwpOHgOvRjKHqlSiFYBPUwayd KMVcbTSWkb+9aTqHAlHARH0Kx5IAJ/i4N8iIgWlOzg/je6/HWoikJqoh3ZO+j7FuDMSJ df1CNShIv8bFGcfO52EprokDEZbPRIAN7IOiGqych9WcYCebcXlerzXsYCggHbYBj+YM VtyYwYQxE8/HYcjNqu2Bzl2s3T7zGp3C4TiAxYRjfdYIcxLJ1fLLIxC6LdolEP5eR5+7 CJqwzBjSWES+Fint8p37kT31hYn7yudPMPSCfrqEu8q2iVPVl4brJlYdMbkgQk9qIju+ +R3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Uobzz6hG; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020a17090301c700b0016f16417f6dsi5566956plh.16.2022.08.20.05.42.49; Sat, 20 Aug 2022 05:43:05 -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=@kernel.org header.s=k20201202 header.b=Uobzz6hG; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345327AbiHTLwU (ORCPT + 99 others); Sat, 20 Aug 2022 07:52:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241030AbiHTLwP (ORCPT ); Sat, 20 Aug 2022 07:52:15 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0AF49E2C8; Sat, 20 Aug 2022 04:52:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7CDC3B80B92; Sat, 20 Aug 2022 11:52:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CE46C433C1; Sat, 20 Aug 2022 11:52:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660996332; bh=EHHFSu4yACtrEkdzmPcb5OuIYaJ/erGqHqabiAFd4n0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Uobzz6hGYwNST4mLp+32zhAK6hBM2uMuPL0tYHoaXf0VUw/lzTlKYbYBEwAIGG5s8 /vL9/34IUQoabbZ4/veM5PwU3SyN5rbMs0Mz2sefrt+/34t+6ENNsKzv8bhuZenELl zUCZUKQdpFGSFl+ppucXaF3Lmn3ZDvxL2yRPzU7SJ2+uy7zHWoC6iiRqL5uN+Y6k1Z eimAJsPvYMXo/c7OMoKd4vYV9B/vPYbyt2Y8BzIppm0iAfG3PoWDGT2a6mKurNo//g UiqtAHhUizVfXi984+qDb/74ClB7njfQmhdHuH/LNFAEIWHR+0RMklLaEEnhvmTb+f 9pH+tXiyWvRBw== Date: Sat, 20 Aug 2022 13:02:48 +0100 From: Jonathan Cameron To: Andy Shevchenko Cc: Eddie James , Lars-Peter Clausen , linux-iio , Linux Kernel Mailing List , Joel Stanley Subject: Re: [PATCH v5 2/2] iio: pressure: dps310: Reset chip if MEAS_CFG is corrupt Message-ID: <20220820130248.7773a6b3@jic23-huawei> In-Reply-To: References: <20220815145705.203017-1-eajames@linux.ibm.com> <20220815145705.203017-3-eajames@linux.ibm.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Thu, 18 Aug 2022 23:16:55 +0300 Andy Shevchenko wrote: > On Mon, Aug 15, 2022 at 5:57 PM Eddie James wrote: > > > > Corruption of the MEAS_CFG register has been observed soon after > > system boot. In order to recover this scenario, check MEAS_CFG if > > measurement isn't ready, and if it's incorrect, reset the DPS310 > > and execute the startup procedure. > > ... > > > + * Called with lock held. Returns a negative value on error, a positive value > > + * when the device is not ready, and zero when the device is ready. > > Can we have > > #define DPS310_DEVICE_NOT_READY 1 > > (or anonymous enum) and return it instead of abstract 1 or any other > positive number? Perhaps make it even clearer by returning the need to wait via another parameter rather than this being (probably) the only place in driver with a postive rc. bool reset_done; rc = dps310_check_reset_meas_cfg(data, DPS310_TMP_RDY, &reset_done); if (reset_done) { } > > ... > > > + rc = dps310_check_reset_meas_cfg(data, DPS310_TMP_RDY); > > if (rc < 0) > > goto done; > > > > + if (rc > 0) { > > + rate = dps310_get_temp_samp_freq(data); > > + timeout = DPS310_POLL_TIMEOUT_US(rate); > > + > > + /* > > + * Poll for sensor readiness; base the timeout upon the sample > > + * rate. > > + */ > > + rc = regmap_read_poll_timeout(data->regmap, DPS310_MEAS_CFG, > > + ready, ready & DPS310_TMP_RDY, > > + DPS310_POLL_SLEEP_US(timeout), > > + timeout); > > + if (rc) > > + goto done; > > + } > > But have you tried to make a helper that takes a pointer to the > respective function? >