All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] soc: qcom: socinfo: Use GENMASK/FIELD_PREP/GET for SOCINFO ver helpers
@ 2026-12-03 13:18 Konrad Dybcio
  2026-12-04 23:35 ` Bjorn Andersson
  0 siblings, 1 reply; 2+ messages in thread
From: Konrad Dybcio @ 2026-12-03 13:18 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio, Abel Vesa; +Cc: linux-arm-msm, Konrad Dybcio

From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Define the bitfields explicitly and use the compile-time-checked
helpers to improve code hygiene.

Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
---
 include/linux/soc/qcom/socinfo.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/linux/soc/qcom/socinfo.h b/include/linux/soc/qcom/socinfo.h
index ba823a0013c5..0a78decfab97 100644
--- a/include/linux/soc/qcom/socinfo.h
+++ b/include/linux/soc/qcom/socinfo.h
@@ -3,6 +3,7 @@
 #ifndef __QCOM_SOCINFO_H__
 #define __QCOM_SOCINFO_H__
 
+#include <linux/bitfield.h>
 #include <linux/types.h>
 
 /*
@@ -14,13 +15,12 @@
 #define SMEM_SOCINFO_BUILD_ID_LENGTH	32
 #define SMEM_SOCINFO_CHIP_ID_LENGTH	32
 
-/*
- * SoC version type with major number in the upper 16 bits and minor
- * number in the lower 16 bits.
- */
-#define SOCINFO_MAJOR(ver) (((ver) >> 16) & 0xffff)
-#define SOCINFO_MINOR(ver) ((ver) & 0xffff)
-#define SOCINFO_VERSION(maj, min)  ((((maj) & 0xffff) << 16)|((min) & 0xffff))
+#define SOCINFO_VER_MAJOR		GENMASK(31, 16)
+#define SOCINFO_VER_MINOR		GENMASK(15, 0)
+#define SOCINFO_MAJOR(ver)		FIELD_GET(SOCINFO_VER_MAJOR, (ver))
+#define SOCINFO_MINOR(ver)		FIELD_GET(SOCINFO_VER_MINOR, (ver))
+#define SOCINFO_VERSION(maj, min) \
+	(FIELD_PREP(SOCINFO_VER_MAJOR, (maj)) | FIELD_PREP(SOCINFO_VER_MINOR, (min)))
 
 /* Socinfo SMEM item structure */
 struct socinfo {

---
base-commit: d138596e9f822033490b2e577ec2ea64f2aa246c
change-id: 20261203-topic-socinfo_genmask-4cf16cd87d82

Best regards,
--  
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-04 23:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 13:18 [PATCH] soc: qcom: socinfo: Use GENMASK/FIELD_PREP/GET for SOCINFO ver helpers Konrad Dybcio
2026-12-04 23:35 ` Bjorn Andersson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.