Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3906185rwi; Sat, 22 Oct 2022 01:59:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7uYgxnVyh6i6Ekd6IVKOjTe4GRKmyUb7HiJshGMSk0OETOGEStaoX5Zjj/4SV4bWpkguI7 X-Received: by 2002:a17:902:da90:b0:185:5537:f388 with SMTP id j16-20020a170902da9000b001855537f388mr24323588plx.113.1666429179878; Sat, 22 Oct 2022 01:59:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666429179; cv=none; d=google.com; s=arc-20160816; b=Pm3BzvMZwGVM0t2RqgDfHSKb+FcDkVc0oBbQyC/my90raJGdjgjTkI3p1zBR+WGIak kcOJkVJofhAwGFxndXkzMJbCT727iYL7WR66zaIcUJXHCkZMKM66Q4OFkYj7W3l4Ji3q hMK7EOOpH/Tnp3WnkWxxLOGpby3FpG+AWgwfM1yIKoXceRQi5yyGSAOe3g6F3bDSgfAP xcETah/YFTGwlsKbhc9LPXdKRjAxxHPzJonkjF0fAK3tNEoNNPaRlQdBkvSiorC1vrmR 9xQk9kuscBHRYPi8fRKY4Uy8JLH0pAgXyk6BK6+7ikK4lDDU8lg/qUPGPzG9FMehv/Nr OmXA== 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=XIVElLACNb0qzCGk04e5JOs8XZOt8kDW5ILmrt5QSCP43cQjmpInnfvPT2OGZVtOfH bFpJYEKmvq5SbvAwyox9JHCcjdSTxEUCsV2YWbcRTfPbTgjBZ1OqDN6KclNMg5tFWzjD GUMRKJkUviMSF5emJ17BAIEuNsj4QX0LLK65bZ9XnIMKl5bOAUI3BmIJ1ofEngQNDStX PiLfqJazvZ4yFAV9gHGc/20zW539ZYDU2Nl26T6O/16jwPGbokJPAdaMA37sqa/7eUj9 z/G69pJyefks0B7mBZdf6Au6nridgSILvp9NjNFXrv7yH3od+KlsF9K2SuIvMB0O/kQp h5QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LqXu0+XA; 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 b13-20020a6541cd000000b00439ce36e9d3si28142848pgq.570.2022.10.22.01.59.25; Sat, 22 Oct 2022 01:59:39 -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=LqXu0+XA; 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 S230302AbiJVHfl (ORCPT + 99 others); Sat, 22 Oct 2022 03:35:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230134AbiJVHfI (ORCPT ); Sat, 22 Oct 2022 03:35:08 -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 47D6F48A23; Sat, 22 Oct 2022 00:34:40 -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 C3BF3B82DB2; Sat, 22 Oct 2022 07:34:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3367C433C1; Sat, 22 Oct 2022 07:34:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424077; bh=fS92YeGgAE7/jfevSZZ9qKCTlZHn8Zq5p+Rkx1Cwmg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LqXu0+XA+vTGrN4aFGUfldbVNn+YNxZnPv3+RUqKoE4meQpbaZQMdpRqzl+0biyDK NK/UBU8gq8E/V7AkatpiT3cQxvHwh+rf7zJPklXesj4go2YzshvT8B3iiJQSqwMePr O8+XK/7PcnXNKVa1whFkkOUdn/OoV5LkhBa0SjNc= 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.19 020/717] iio: ltc2497: Fix reading conversion results Date: Sat, 22 Oct 2022 09:18:19 +0200 Message-Id: <20221022072418.654044047@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@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.3 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,