Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7478877rwi; Mon, 24 Oct 2022 15:29:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM620Q95jFnXnNZWY07Bkt/aPQplRTk4ZWqIm9v7k/zjlxcmt5G0/EV5/60V6g7jFYM7bQ1c X-Received: by 2002:a17:906:ef90:b0:7ab:1b2c:b654 with SMTP id ze16-20020a170906ef9000b007ab1b2cb654mr2503399ejb.627.1666650581345; Mon, 24 Oct 2022 15:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650581; cv=none; d=google.com; s=arc-20160816; b=l45wCUAnLf17CEibbp90FygKndp9ucymt8vxUAag2xb5QvWU5zLtJN6uzlLRTzj0/V 2YMoEiSCWtqVd//3tqYexUqtMBHPMrUcHpQA9LYFsa59AW+KThlf4Htj8bevARnJh45/ LWmqceAoLhVKGs/1yIGYJieOZ6i/GaioVRcYjh7oDWJVXqtGtsaCkpUJYSMMn+Jdk8Wt qgTexEkhHbGdbjHdq7ebsNsmHSMwoEeuzFxGHRpvTQo2+EWEgXyCnLg94W5XMNVjRCuj buO56K/NEMRPxYSfIfEy/xxlKhNOAwzI89NyCb04Re0ZB5Fk820bJ6zZVOcBJwTwpDhq norQ== 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=zXIVv5Mt1Cgvs4hNWwE5onH/MSgPFuGaUG5hKsWlJQ6O70Mv/lBJTPYRJ6PdY8fQZk e6FI/JJrVCc78utY28zHr8F8FTr+rMp6SCnhoFLnW7C4QhH/3sMnTM2NHHLeMKwEzO3W qLc3vlyPQb5hppLHq52mbwuDyUtQPTQ/N7iwUGPh2hgfhfwkV48qztgSSmwt2brj8gYn /qQ+h5dEXXwiI3uYK4aNSjz/wW6OGxn4xMQcg/pHejN2ehMsTMM8BeF4nRPNcKlloMss qKddjJ5iGAjQiW+QEuBWfMzcEoJAHSQcyBA0PLvdY9wX5kyDS8ZLaN6ZczIVHneGMO3y xAJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k79026Wl; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a170906708900b0078d8614e809si791247ejk.504.2022.10.24.15.29.16; Mon, 24 Oct 2022 15:29:41 -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=k79026Wl; 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 S231314AbiJXVnl (ORCPT + 99 others); Mon, 24 Oct 2022 17:43:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230115AbiJXVnM (ORCPT ); Mon, 24 Oct 2022 17:43:12 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C39052E7B92; Mon, 24 Oct 2022 12:53:42 -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 860ADB81186; Mon, 24 Oct 2022 12:16:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE044C433C1; Mon, 24 Oct 2022 12:16:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613784; bh=fS92YeGgAE7/jfevSZZ9qKCTlZHn8Zq5p+Rkx1Cwmg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k79026WlTHzFCYKrjT841Bw+Vyh3BYTn9YUe+qWpoPhBm/wU/ivpLp80sYBGJhIkB CQ1wquyqJGfUFSWg2HgfjN0JzFor+3uWsbci5XcIg12AsZlEFeu0PVqfMJieHuQeIp Vwa6+mFoM33XDTblu4qLpydMxAtbOWZlanPb/LBE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Meng Li , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Denys Zagorui , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.10 013/390] iio: ltc2497: Fix reading conversion results Date: Mon, 24 Oct 2022 13:26:50 +0200 Message-Id: <20221024113023.115390994@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 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 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,