From patchwork Sat Oct 22 07:18:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7142 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1087551wrr; Sat, 22 Oct 2022 00:36:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4YuEexaJhprqDJly21ihhmDRCPdAktMaaNAI5+YzgDtzQYR+op6TaigP3Pr57cpqP6mSjo X-Received: by 2002:a17:907:62a1:b0:781:b320:90c0 with SMTP id nd33-20020a17090762a100b00781b32090c0mr17825611ejc.255.1666424216893; Sat, 22 Oct 2022 00:36:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424216; cv=none; d=google.com; s=arc-20160816; b=qQrBVasj2ulgtHJddYi26RRaco4knLuWeSXGqQQPo6rJXGkMNmAyKFkDqTk7kxwTc5 6nmUUoSGBmj2reg9zc4fn9lzJHxzNxbaCcZ/oR7OOqYCw3RhdQjTqOzu1z+nIyyy0qC6 prKY3tMNGfjIC0/PtLtvpCB3cX6FpWlFhCrKaBYOkYUmN3kRk+agITj4qKYJUVPcvIWp IwL6cDZXKaxLC77w/z6wsF3n8LCGTj62rPBxDGUq6deABJxrs/f6yBa3LxiUdBQP1O9W NkIbo7Fu+Yhr8kTvKWO6/cRJwV4AXI/zhUB9ss5UgipZTwQkeaT36NRmQ451JcWfl9rP aj/Q== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hg3-20020a1709072cc300b00790058488dcsi3798806ejc.48.2022.10.22.00.36.32; Sat, 22 Oct 2022 00:36: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=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_Kleine-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747372439819679878?= X-GMAIL-MSGID: =?utf-8?q?1747372439819679878?= 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,