From patchwork Mon Oct 24 11:26:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10329 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp668858wru; Mon, 24 Oct 2022 14:55:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM63Na/iD/TMQX74OiRXNtVmmc8V83Na7PyJgxE+UDFH6aCx5khUmgeTAwPeQH/pdRLlsH4N X-Received: by 2002:a17:906:2a93:b0:78d:b87e:6aab with SMTP id l19-20020a1709062a9300b0078db87e6aabmr29409559eje.157.1666648556510; Mon, 24 Oct 2022 14:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666648556; cv=none; d=google.com; s=arc-20160816; b=fMfzrKMRE3yxvCZIT5PNo1ccr1apoVYdCxZImwzqU8NBdPe+8cFoOVw1qv0A/Tvgis wpBwzC74II3yl1fNWkxjW/XIjPTPPDQcGt8tWbwSIjYH2DdtEPA94I1X71LZns3m4GmY /LB0pzGibB7tosJ6MQQ/ZvgmKznI2kaCzi2kh13EaMyhoKWJveCoILe2T3I0VbQLnVRY 1epMwO6yeGBw1y3SZRrWYUKY0jom/Ny7B0RJkZJ/ePvHDy5MuDpE/mtxbIU82I5SGkoz g3L0BtdnGvtuCa28B9LJ3g+V9GWHEmaWXLAB9QpNXXxy9+TZxxScCN+9eypRfkyN8vya P/rA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb42-20020a1709076daa00b0077b2e822b8fsi1022494ejc.76.2022.10.24.14.55.33; Mon, 24 Oct 2022 14:55:56 -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_Kleine-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747607676305304941?= X-GMAIL-MSGID: =?utf-8?q?1747607676305304941?= 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,