Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 20c4ae1f authored by Matt Wagantall's avatar Matt Wagantall
Browse files

soc: qcom: expose serial_number field via sysfs



socinfo format v0.10 introduced a serial number field, which is
presently only printed at boot, and not made visible via sysfs.
Make it readable from sysfs also.

Change-Id: I523c6cb8829c0dfee31b35913e085cf3996ef21a
Signed-off-by: default avatarMatt Wagantall <mattw@codeaurora.org>
parent 9788fead
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -635,6 +635,14 @@ static uint32_t socinfo_get_foundry_id(void)
		: 0;
}

static uint32_t socinfo_get_serial_number(void)
{
	return socinfo ?
		(socinfo->v0_1.format >= SOCINFO_VERSION(0, 10) ?
			socinfo->v0_10.serial_number : 0)
		: 0;
}

enum pmic_model socinfo_get_pmic_model(void)
{
	return socinfo ?
@@ -773,6 +781,15 @@ msm_get_foundry_id(struct device *dev,
		socinfo_get_foundry_id());
}

static ssize_t
msm_get_serial_number(struct device *dev,
			struct device_attribute *attr,
			char *buf)
{
	return snprintf(buf, PAGE_SIZE, "%u\n",
		socinfo_get_serial_number());
}

static ssize_t
msm_get_pmic_model(struct device *dev,
			struct device_attribute *attr,
@@ -972,6 +989,10 @@ static struct device_attribute msm_soc_attr_foundry_id =
	__ATTR(foundry_id, S_IRUGO,
			msm_get_foundry_id, NULL);

static struct device_attribute msm_soc_attr_serial_number =
	__ATTR(serial_number, S_IRUGO,
			msm_get_serial_number, NULL);

static struct device_attribute msm_soc_attr_pmic_model =
	__ATTR(pmic_model, S_IRUGO,
			msm_get_pmic_model, NULL);
@@ -1069,6 +1090,8 @@ static void __init populate_soc_sysfs_files(struct device *msm_soc_device)

	switch (legacy_format) {
	case SOCINFO_VERSION(0, 10):
		 device_create_file(msm_soc_device,
					&msm_soc_attr_serial_number);
	case SOCINFO_VERSION(0, 9):
		 device_create_file(msm_soc_device,
					&msm_soc_attr_foundry_id);