From nobody Sun Sep 14 02:03:54 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D29F6C38142 for ; Fri, 27 Jan 2023 15:02:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233925AbjA0PCE (ORCPT ); Fri, 27 Jan 2023 10:02:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233716AbjA0PB6 (ORCPT ); Fri, 27 Jan 2023 10:01:58 -0500 X-Greylist: delayed 967 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 27 Jan 2023 07:01:57 PST Received: from mx0a-00176a03.pphosted.com (mx0b-00176a03.pphosted.com [67.231.157.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B13E8757B7; Fri, 27 Jan 2023 07:01:57 -0800 (PST) Received: from pps.filterd (m0048299.ppops.net [127.0.0.1]) by m0048299.ppops.net-00176a03. (8.17.1.19/8.17.1.19) with ESMTP id 30R6j4FF008620; Fri, 27 Jan 2023 07:57:19 -0500 From: Ian Ray To: lars@metafoo.de, Michael.Hennerich@analog.com Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, ian.ray@ge.com Subject: [PATCH] drivers: iio: adc: ltc2497: fix LSB shift Date: Fri, 27 Jan 2023 14:57:14 +0200 Message-Id: <20230127125714.44608-1-ian.ray@ge.com> X-Mailer: git-send-email 2.10.1 X-Proofpoint-ORIG-GUID: ZhqMomqWbtzWC2O6rSYnrsrZc8VQYowq X-Proofpoint-GUID: ZhqMomqWbtzWC2O6rSYnrsrZc8VQYowq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-27_08,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 lowpriorityscore=0 bulkscore=0 impostorscore=0 mlxscore=0 phishscore=0 priorityscore=1501 clxscore=1011 suspectscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301270122 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Correct the "sub_lsb" shift for both ltc2497 and ltc2499. An earlier version of the code shifted by 14 but this was a consequence of reading three bytes into a __be32 buffer and using be32_to_cpu(), so eight extra bits needed to be skipped. Now we use get_unaligned_be24() and thus the additional skip is wrong. Fixes 2187cfe ("drivers: iio: adc: ltc2497: LTC2499 support") Signed-off-by: Ian Ray --- drivers/iio/adc/ltc2497.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ltc2497.c b/drivers/iio/adc/ltc2497.c index 17370c5..ec198c6 100644 --- a/drivers/iio/adc/ltc2497.c +++ b/drivers/iio/adc/ltc2497.c @@ -28,7 +28,6 @@ struct ltc2497_driverdata { struct ltc2497core_driverdata common_ddata; struct i2c_client *client; u32 recv_size; - u32 sub_lsb; /* * DMA (thus cache coherency maintenance) may require the * transfer buffers to live in their own cache lines. @@ -65,10 +64,10 @@ static int ltc2497_result_and_measure(struct ltc2497cor= e_driverdata *ddata, * equivalent to a sign extension. */ if (st->recv_size =3D=3D 3) { - *val =3D (get_unaligned_be24(st->data.d8) >> st->sub_lsb) + *val =3D (get_unaligned_be24(st->data.d8) >> 6) - BIT(ddata->chip_info->resolution + 1); } else { - *val =3D (be32_to_cpu(st->data.d32) >> st->sub_lsb) + *val =3D (be32_to_cpu(st->data.d32) >> 6) - BIT(ddata->chip_info->resolution + 1); } =20 @@ -122,7 +121,6 @@ static int ltc2497_probe(struct i2c_client *client) st->common_ddata.chip_info =3D chip_info; =20 resolution =3D chip_info->resolution; - st->sub_lsb =3D 31 - (resolution + 1); st->recv_size =3D BITS_TO_BYTES(resolution) + 1; =20 return ltc2497core_probe(dev, indio_dev); --=20 2.10.1