From patchwork Wed Oct 19 08:21:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4504 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp202586wrs; Wed, 19 Oct 2022 01:40:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6n7ELsMknOIbPusbClHsQQu9EE2rUKChF2M4vdQ4MuD5xZDTRJUA1GtBrWzLwH5mX+1Ei0 X-Received: by 2002:a17:907:6297:b0:72f:9aad:fcb with SMTP id nd23-20020a170907629700b0072f9aad0fcbmr5752703ejc.161.1666168858503; Wed, 19 Oct 2022 01:40:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666168858; cv=none; d=google.com; s=arc-20160816; b=rc7DO18F0jefgRToKg861g9DKA9lSe26g2zEb8MckQ6SIDBzKDrbIWOyhMFGWFVvkB N20GkVIoZe/A+2PIv7ENukVyT5LDO0ZL0hCL0cMFOYXVVVf+4fS2ng6OzD+9qanZXe6Z QU4F4T6s3fTlbN/hts8T527VO+E0XKh3h093bzS8ARiiODvocDdOKCA7YSzkiJ3v6/AH 0/6SgKGESoZKTJanQiH2rSBIg23eGf3aXoMlOtw0QoUeIo8QJqJeG33XlaowdB2maUCX CcI2Sfg02BQsLxU6FtsYqjpqp1usrqi5KmAeQu8i/wgdDCoD2ItBnUjlwoB4WBmUxT0x lVbg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bUz+5s37sHEm/1PxeiFhL6q43PpNa3f+qJgf9K8KdBU=; b=TBK49O/2i9UIc5FXYrLOuJXeHtNadqzzps9A/33Ik7RdAxZsH8JJhiDWE1hjwhV1Si w37VWIRoc2UkYCwFHye7o3wEw+LQMMPZoQ+mJMq0hTub3t3rSiYI7UKAT7dEXuiiBzo7 iUCeO9Qz6hXkUVy9lWfgv5Tl9OIOIRwn0rlX4zrK1M1v2wdxsWTiYnM7kTZ9VHYiaCBd 5H2dbBpfYWkj5kpBdNrc5Zx6Tc9osB14f7ckUahwynHvzsOi68EhLZHbOgumaMuxxVQt CcqafMRb5phqX7wCpT+NsvwgsXIkNdc1JWlRXxQLJVaSwZ3DmD2oYjR9izLCCFXyaUKp HiEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tbXmONHq; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j20-20020a05640211d400b0045d3ed38ae1si12399421edw.16.2022.10.19.01.40.31; Wed, 19 Oct 2022 01:40: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=@linuxfoundation.org header.s=korg header.b=tbXmONHq; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230215AbiJSIju (ORCPT + 99 others); Wed, 19 Oct 2022 04:39:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbiJSIjB (ORCPT ); Wed, 19 Oct 2022 04:39:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96CBC7E807; Wed, 19 Oct 2022 01:38:36 -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 dfw.source.kernel.org (Postfix) with ESMTPS id A58AB617EC; Wed, 19 Oct 2022 08:38:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99117C433D6; Wed, 19 Oct 2022 08:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168701; bh=fS92YeGgAE7/jfevSZZ9qKCTlZHn8Zq5p+Rkx1Cwmg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tbXmONHqJv0nLqxthGA8ub+lgJWLwVAPBxiMAYdudbb2QeWbRHF4Vu4kVTedPbzbf ee6SH9f4ul3hyZj+L9mjbrwPO9g8S1SdnHxBNGMRFHcetU0Xka+8run5prPVtbyfJQ YjIvu79b4NN8axJFpYES/2E94FtXnmVx/jdSGH9g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Meng Li , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Denys Zagorui , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 6.0 025/862] iio: ltc2497: Fix reading conversion results Date: Wed, 19 Oct 2022 10:21:52 +0200 Message-Id: <20221019083251.107696024@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747104676882106923?= X-GMAIL-MSGID: =?utf-8?q?1747104676882106923?= From: Uwe Kleine-König commit 7f4f1096d5921f5d90547596f9ce80e0b924f887 upstream. After the result of the previous conversion is read the chip automatically starts a new conversion and doesn't accept new i2c transfers until this conversion is completed which makes the function return failure. So add an early return iff the programming of the new address isn't needed. Note this will not fix the problem in general, but all cases that are currently used. Once this changes we get the failure back, but this can be addressed when the need arises. Fixes: 69548b7c2c4f ("iio: adc: ltc2497: split protocol independent part in a separate module ") Reported-by: Meng Li Signed-off-by: Uwe Kleine-König Tested-by: Denys Zagorui Cc: Link: https://lore.kernel.org/r/20220815091647.1523532-1-dzagorui@cisco.com Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/adc/ltc2497.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/drivers/iio/adc/ltc2497.c +++ b/drivers/iio/adc/ltc2497.c @@ -41,6 +41,19 @@ static int ltc2497_result_and_measure(st } *val = (be32_to_cpu(st->buf) >> 14) - (1 << 17); + + /* + * The part started a new conversion at the end of the above i2c + * transfer, so if the address didn't change since the last call + * everything is fine and we can return early. + * If not (which should only happen when some sort of bulk + * conversion is implemented) we have to program the new + * address. Note that this probably fails as the conversion that + * was triggered above is like not complete yet and the two + * operations have to be done in a single transfer. + */ + if (ddata->addr_prev == address) + return 0; } ret = i2c_smbus_write_byte(st->client,