From nobody Sat Apr 11 02:20:50 2026 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 17DE7C25B08 for ; Wed, 17 Aug 2022 10:57:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239092AbiHQK52 (ORCPT ); Wed, 17 Aug 2022 06:57:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239060AbiHQK5V (ORCPT ); Wed, 17 Aug 2022 06:57:21 -0400 Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [IPv6:2001:4b98:dc4:8::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A657786E7; Wed, 17 Aug 2022 03:57:19 -0700 (PDT) Received: (Authenticated sender: contact@artur-rojek.eu) by mail.gandi.net (Postfix) with ESMTPSA id 35646200004; Wed, 17 Aug 2022 10:57:17 +0000 (UTC) From: Artur Rojek To: Paul Cercueil , Jonathan Cameron , Dmitry Torokhov , Chris Morgan Cc: linux-mips@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, Artur Rojek Subject: [PATCH 1/4] iio/adc: ingenic: fix channel offsets in buffer Date: Wed, 17 Aug 2022 12:56:40 +0200 Message-Id: <20220817105643.95710-2-contact@artur-rojek.eu> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220817105643.95710-1-contact@artur-rojek.eu> References: <20220817105643.95710-1-contact@artur-rojek.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Consumers expect the buffer to only contain enabled channels. While preparing the buffer, the driver also (incorrectly) inserts empty data for disabled channels, causing the enabled channels to appear at wrong offsets. Fix that. Fixes: b96952f498db ("IIO: Ingenic JZ47xx: Add touchscreen mode.") Tested-by: Paul Cercueil Signed-off-by: Artur Rojek Reviewed-by: Andy Shevchenko --- drivers/iio/adc/ingenic-adc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ingenic-adc.c b/drivers/iio/adc/ingenic-adc.c index a7325dbbb99a..5a932c375a89 100644 --- a/drivers/iio/adc/ingenic-adc.c +++ b/drivers/iio/adc/ingenic-adc.c @@ -804,11 +804,10 @@ static irqreturn_t ingenic_adc_irq(int irq, void *dat= a) unsigned int i; u32 tdat[3]; =20 - for (i =3D 0; i < ARRAY_SIZE(tdat); mask >>=3D 2, i++) { + memset(tdat, 0, ARRAY_SIZE(tdat)); + for (i =3D 0; mask && i < ARRAY_SIZE(tdat); mask >>=3D 2) { if (mask & 0x3) - tdat[i] =3D readl(adc->base + JZ_ADC_REG_ADTCH); - else - tdat[i] =3D 0; + tdat[i++] =3D readl(adc->base + JZ_ADC_REG_ADTCH); } =20 iio_push_to_buffers(iio_dev, tdat); --=20 2.37.2