From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=68.232.153.233 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796195141; b=4HuzfxiQ93Bf4vRaPgir+5Z/kKRv2uvjwoSMTngz8hSD2/DiSs3UalTcmIzofmbNC2t/ BauE3i6Xd8dOUUWT2yWFSfjWrrlBe4NL0eGYW47nJB343mW1BV0f9XNLqOwNGJTPj1y6I lqTQRGLhlVRzojOk9+4MM8W6Byfi9O6e2v22I/cYoibb4uWEXuzY7G2KKEu/2PnC4NV8G AKZsKN2Ti1PaWkeFdK0rmMt5GaiEv9YXxambDXtVzbGlk5bMEpd91vS2qlhT8P/xSxQlE B82mpCsXabukdujl3PlqvqptG+p1LK+fOQWcXqQ9cvWXNoMm2o04TCfuJsUylLF1Hvg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796195141; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-Amp-Result:Received:Received:Received:From:To:CC: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type; bh=3wUfbiRsyUhX63Tk7S9W8oLk7WNsI0k0X+uresJbCuY=; b=s0JPwoKBAgXyHjIzhKfy1KoD94qxwPuDgmnNDILjx3sy/+rvVJKa38ebevZqtvMC38B4 w8U4jeqQqNDXZrQGAkM75pOPpUsEuN78nG0GnKqx7/V8Yy7yQKS2WZivi4nABy7gTsxvM CYzHOErT4pZ1kQUfmRH3M2BqA+OM5XIf0W92Vpy7UClc+R/rJy6fYwpd7Ek9E4oKuVJ/M oV2sn5Mn9qYLyrtqf4SsYAsvY+2obTQH+dYfGJsU9e1ggmL9IkkGtpeA2KcA4N30JedBM 4MVZ7j6+D6D8uJiXLhdk6yqYMXWHqQ5173TwK5rxS/8D622y3moCakP7aKwtDgbzmzg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=nycUUHfQ; arc=none smtp.remote-ip=68.232.153.233 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2778606A31A; Wed, 2 Dec 2026 07:05:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E2778606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=nycUUHfQ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1796195140; x=1827731140; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+ARe9LooocXp6IWkFnhiEDtGm1oUQvXnb7TS5rkTzaI=; b=nycUUHfQC9CNkygFwA0HHQ1owzphCdHwBoyNdVTNlLO0g+MQnpddz5+A uMcHgDWcLPQa2ZY+qVa/Gy76awc4xllPYngeMXzZUwF07D1w7zyp6pSO0 ZUulQ4/Nrgf8HpMjcp7Nnu/0ne6HOB00RIRF/644MfdvaJ8Y80D8qr1iA c/XBs6ty5U50nXR2RJ8fNTppOx/yjKeCuQ2uT7Xq6Yf9KtUMJrTrq2n5X b8MNsf/TgWAwuG1RZXnjIDtBAKDDu/Z+6cahQ2UIsjgNFK7IkRh6Yf0X2 tJPZzOc2tDIABpOGDCeOsWPORZ511KMlCtsQOntP2TUspA8SAEBeEtOqj A==; X-CSE-ConnectionGUID: zLZCT/TbRWafS0UhOIiLSQ== X-CSE-MsgGUID: gS+i52vJQDqcz5+RJOFh2w== X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="78212717" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 00:05:40 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.87.151) by chn-vm-ex1.mchp-main.com (10.10.87.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.57; Wed, 2 Dec 2026 00:05:39 -0700 Received: from che-ll-i67070a.microchip.com (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Wed, 2 Dec 2026 00:05:34 -0700 From: Varshini Rajendran To: Jonathan Cameron , Srinivas Kandagatla , Claudiu Beznea CC: Eugen Hristev , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , "Nicolas Ferre" , Alexandre Belloni , , , , , Subject: [PATCH v7 06/18] iio: adc: at91-sama5d2_adc: add condition to validate calibration data Date: Wed, 2 Dec 2026 12:34:44 +0530 Message-ID: <20261202070458.87970-7-varshini.rajendran@microchip.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261202070458.87970-1-varshini.rajendran@microchip.com> References: <20261202070458.87970-1-varshini.rajendran@microchip.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain Add additional condition to validate the calibration data read from the NVMEM cell using the TAG of the packet. Signed-off-by: Varshini Rajendran --- drivers/iio/adc/at91-sama5d2_adc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index 24746a916be5..01132aaf6dca 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -445,6 +445,9 @@ static const struct at91_adc_reg_layout sama7g5_layout = { #define at91_adc_writel(st, reg, val) \ writel_relaxed(val, (st)->base + (st)->soc_info.platform->layout->reg) +/* Temperature calibration tag "ACST" in ASCII */ +#define AT91_TEMP_CALIB_TAG_ACST 0x41435354 + /** * struct at91_adc_temp_calib_layout - temperature calibration packet layout * @tag_idx: index of Packet tag in the NVMEM cell buffer @@ -2297,7 +2300,8 @@ static int at91_adc_temp_sensor_init(struct at91_adc_state *st, return dev_err_probe(dev, PTR_ERR(buf), "Failed to read calibration data!\n"); - if (len < layout->min_len * sizeof(*buf)) { + if (len < layout->min_len * sizeof(*buf) || + buf[layout->tag_idx] != AT91_TEMP_CALIB_TAG_ACST) { dev_err(dev, "Invalid calibration data!\n"); return -EINVAL; } -- 2.43.0