From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DBFF434FF7B; Fri, 21 Nov 2025 13:42:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763732522; cv=none; b=i7SvXR1rGrYZM4LjzzNRONdKuEzjBnU0scLFa6Q2q9VCJwqa6xRtOYNmAKHug2CMBIJVabDxdwI67r9eVJUPUlaExsv+NMrjS/0mTi7ASrVJPRG/pJFzsr4QFfgNkRvGO/QfXpXYMSjmU1s6r1QGEppWV2qDPDQN+ALRYj/a4Fc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763732522; c=relaxed/simple; bh=jf5GRE085B6Acpnj2cuHI8JLzNBmWu3XuFZocEK2VBE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Atg+o6CvWTbthKvK0gFRAbhreXYLOGgcRZM0ozNq5MLEME/L/3lpYPxeye8hhgyf2j9A2ZJgcexMvBsQkyiv0I60mYSmaoYSmIgnD3L7xM+BgwLb2OAUilD3k2zqcQLt9/j+hf++ydu/cVXe4iieVjoic7JqGchiDRGtyFb0T8E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bYVJTdfw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="bYVJTdfw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60982C4CEF1; Fri, 21 Nov 2025 13:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1763732521; bh=jf5GRE085B6Acpnj2cuHI8JLzNBmWu3XuFZocEK2VBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bYVJTdfwrbkKUtlmQzx7VZzA3LUIVT6aOlpip0/7+REC+4Xuyb0hrvZRw9HDYQBxi 8fDdVFiRAu8dGHuM/mKVPm15laybwBeB6NgfWgsRQZ2NYkvywbp/E25zCMhLJdCWEM awAD9xpp+erzL1abLuBWK7x8x3wXnApkmZiTSjmE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Rodrigo Gobbi , David Lechner , Jonathan Cameron , Sasha Levin Subject: [PATCH 6.6 150/529] iio: adc: spear_adc: mask SPEAR_ADC_STATUS channel and avg sample before setting register Date: Fri, 21 Nov 2025 14:07:29 +0100 Message-ID: <20251121130236.357517941@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251121130230.985163914@linuxfoundation.org> References: <20251121130230.985163914@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rodrigo Gobbi [ Upstream commit d75c7021c08e8ae3f311ef2464dca0eaf75fab9f ] avg sample info is a bit field coded inside the following bits: 5,6,7 and 8 of a device status register. Channel num info the same, but over bits: 1, 2 and 3. Mask both values in order to avoid touching other register bits, since the first info (avg sample), came from DT. Signed-off-by: Rodrigo Gobbi Reviewed-by: David Lechner Link: https://patch.msgid.link/20250717221559.158872-1-rodrigo.gobbi.7@gmail.com Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/adc/spear_adc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/spear_adc.c b/drivers/iio/adc/spear_adc.c index ad54ef7981090..602ed05552bfd 100644 --- a/drivers/iio/adc/spear_adc.c +++ b/drivers/iio/adc/spear_adc.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -29,9 +30,9 @@ /* Bit definitions for SPEAR_ADC_STATUS */ #define SPEAR_ADC_STATUS_START_CONVERSION BIT(0) -#define SPEAR_ADC_STATUS_CHANNEL_NUM(x) ((x) << 1) +#define SPEAR_ADC_STATUS_CHANNEL_NUM_MASK GENMASK(3, 1) #define SPEAR_ADC_STATUS_ADC_ENABLE BIT(4) -#define SPEAR_ADC_STATUS_AVG_SAMPLE(x) ((x) << 5) +#define SPEAR_ADC_STATUS_AVG_SAMPLE_MASK GENMASK(8, 5) #define SPEAR_ADC_STATUS_VREF_INTERNAL BIT(9) #define SPEAR_ADC_DATA_MASK 0x03ff @@ -157,8 +158,8 @@ static int spear_adc_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_RAW: mutex_lock(&st->lock); - status = SPEAR_ADC_STATUS_CHANNEL_NUM(chan->channel) | - SPEAR_ADC_STATUS_AVG_SAMPLE(st->avg_samples) | + status = FIELD_PREP(SPEAR_ADC_STATUS_CHANNEL_NUM_MASK, chan->channel) | + FIELD_PREP(SPEAR_ADC_STATUS_AVG_SAMPLE_MASK, st->avg_samples) | SPEAR_ADC_STATUS_START_CONVERSION | SPEAR_ADC_STATUS_ADC_ENABLE; if (st->vref_external == 0) -- 2.51.0