Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp528700lql; Mon, 11 Mar 2024 09:31:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUvTPWJpFz9Qeiec/Nrq4XTXXqS8cWQPRR+MsSQuN7UWooW0orrM5KVEvltW8fLEVXXM82BhEJxlh/u7u2UpcbPzd78r7XNT1NMO/hRHQ== X-Google-Smtp-Source: AGHT+IEineMqwwL92E5sJY4V1lHD6pt4jcgiLq6VA2R6ahn2DiN3HrlrBallFdvLZpuYteSxaQdP X-Received: by 2002:a17:90b:4b01:b0:29b:efcb:7e7c with SMTP id lx1-20020a17090b4b0100b0029befcb7e7cmr957308pjb.24.1710174686619; Mon, 11 Mar 2024 09:31:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710174686; cv=pass; d=google.com; s=arc-20160816; b=Ljo2cYYFPmiZBIbGESSVG2h2zpdw4/IKNctOpYIhxK1VxUJ9/sD18WvWlpXf7OaXvL 2t92tUz4bNge37PMeirkN20Jd6dkO1XNlfJV9rmZjQ+6Cy5n7L7WCproFoqd5t46V3I8 On3KiJFncrd5tJmslfHmfQQnfo1xDtppkXKD3Y1yMuooiIBbar7LbYcD/JUZ2QNfdZfv h9XJGGA+JyTMJ6Jw8xAZLgdAbncaDab111OmrTjquM18gy6asl/VLJpMwflfpDkFLhiN eS0nf4Tc0EQj153RV8TTC11CaJIgL9KmEgF00hXbmZGLjOm8x6epsIeL4tl6JW4AkRG2 6/pQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Fz+FWvrcKcTv16JX/4rIFVS9wfxLnJCR/qRfWEpLaNk=; fh=umRMpSMDd+I74n+altEthn4zbTLW+3rnwVtAHUffV6I=; b=wQlTt1mJ903c692e9PXV9H/JDyfRT8tk+6Dta9BM+2LYFTsmS/ogZye+wUHlVyJh+/ aMzD1aIQDqL6KoQ5zk5nJBnvpSwYQyXF80Mn3D45KdK0MEST6dNSS7WRUUTml6HWRWaO Vy8fctRrrDevIN7PEMYD2q20CDIhqDrMRAhcz32iSsmOAUnoJejM2eQzNt7W9q4oidaX lthJL6cX2zWlEWZ7TNmREbMPDajNQiuZtxk0OgpJ2Vs4n8c1WZw29II5pg0aYeQ/wk7N voIgr3sWabzAV6Y1DJm4iIJ6QLdY2hcIjttdSgtCI2Pkt+EacwXd0JEBojAyBvIQpyk6 bmJA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=RDPLo44s; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-99242-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99242-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b17-20020a630c11000000b005c65d0dd9a0si5194738pgl.503.2024.03.11.09.31.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:31:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99242-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=RDPLo44s; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-99242-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99242-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 497FB282D59 for ; Mon, 11 Mar 2024 16:31:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 118AE51C59; Mon, 11 Mar 2024 16:28:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="RDPLo44s" Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7CE7481A6 for ; Mon, 11 Mar 2024 16:28:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710174526; cv=none; b=T2AWzYKSRZEu3vXHtrufXyez8AqTS2TKvwohKgxKmGqr/smufonJSZ2+Bu4tkj1DYnzEPqklXwPRp+xv0dG/1jBZnTaz2mqkA44/uyrBI2NMyqhf30u7OMrp29m3pV+gOC0ThDtc/RYfRfen2jPpPjk3FYfCm423S9ZG4F6Tyjs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710174526; c=relaxed/simple; bh=BOe/URe3IpcizYmw7Op+xPHG8Hus1zm8G3nNk6OMm1k=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=L8nBwiDs91XPdFyDpzmwZIq5+xbuqCAiOKq9bN9f9Y4RkFhe204aE6BoqmqsyWabDV2sFkDePYnyD2B3v2bHATwuOXTl/P3UzLQiV9yu9HzNYVoW44HfNQ/HgfMcsXiDU+cKkfq4Z3kbq/mumsVw8EgmIhuSTVJYJ7lYwZ+GDvU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=RDPLo44s; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1710174519; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Fz+FWvrcKcTv16JX/4rIFVS9wfxLnJCR/qRfWEpLaNk=; b=RDPLo44sQaeMkdNhTv6N0tAMk2tGBUxNZLmt3ZalRc47ltWKJOh7MOtOHuM2AK/IIUtWKm MqjCWr/HAbThPLudVpfzuo6UojtXF2Qwh51ka8asfAs3n9KrVhxNJ0k1rJucqUrwJQto1y VIpnvPeAog6M3OEJ0GMmYBre8yFruG0= From: Sean Anderson To: Jonathan Cameron , linux-iio@vger.kernel.org Cc: Conall O'Griofa , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Lars-Peter Clausen , Sean Anderson Subject: [PATCH] iio: xilinx-ams: Don't include ams_ctrl_channels in scan_mask Date: Mon, 11 Mar 2024 12:28:00 -0400 Message-Id: <20240311162800.11074-1-sean.anderson@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT ams_enable_channel_sequence constructs a "scan_mask" for all the PS and PL channels. This works out fine, since scan_index for these channels is less than 64. However, it also includes the ams_ctrl_channels, where scan_index is greater than 64, triggering undefined behavior. Since we don't need these channels anyway, just exclude them. Fixes: d5c70627a794 ("iio: adc: Add Xilinx AMS driver") Signed-off-by: Sean Anderson --- drivers/iio/adc/xilinx-ams.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/xilinx-ams.c b/drivers/iio/adc/xilinx-ams.c index a55396c1f8b2..4de7ce598e4d 100644 --- a/drivers/iio/adc/xilinx-ams.c +++ b/drivers/iio/adc/xilinx-ams.c @@ -414,8 +414,12 @@ static void ams_enable_channel_sequence(struct iio_dev *indio_dev) /* Run calibration of PS & PL as part of the sequence */ scan_mask = BIT(0) | BIT(AMS_PS_SEQ_MAX); - for (i = 0; i < indio_dev->num_channels; i++) - scan_mask |= BIT_ULL(indio_dev->channels[i].scan_index); + for (i = 0; i < indio_dev->num_channels; i++) { + const struct iio_chan_spec *chan = &indio_dev->channels[i]; + + if (chan->scan_index < AMS_CTRL_SEQ_BASE) + scan_mask |= BIT_ULL(chan->scan_index); + } if (ams->ps_base) { /* put sysmon in a soft reset to change the sequence */ -- 2.35.1.1320.gc452695387.dirty