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

Commit 1168653d authored by Matt Wagantall's avatar Matt Wagantall Committed by Gerrit - the friendly Code Review server
Browse files

soc: qcom: socinfo: add 'images' sysfs device subnode



Although image information is already available in sysfs,
only root has the ability to write to the select_image node,
a necessary step for reading the CRM, variant and version
info for a specific image. Additionally, multiple clients
cannot safely read the image information without some
caller-side locking to prevent updates of the select_image
node while one of the other files are being read.

Work around this by introducing a new 'images' node that
can be used to dump information about all images without
the need to write to select_image, and make it readable
to non-root.

Change-Id: I71dfda8c7c170b35a66f2f740202a8a79e8b8c0c
Signed-off-by: default avatarMatt Wagantall <mattw@codeaurora.org>
parent 817d2dbc
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -953,6 +953,37 @@ msm_select_image(struct device *dev, struct device_attribute *attr,
	return count;
}

static ssize_t
msm_get_images(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	int pos = 0;
	int image;
	char *image_address;

	image_address = socinfo_get_image_version_base_address();
	if (IS_ERR_OR_NULL(image_address))
		return snprintf(buf, PAGE_SIZE, "Unavailable\n");

	*buf = '\0';
	for (image = 0; image < SMEM_IMAGE_VERSION_BLOCKS_COUNT; image++) {
		if (*image_address == '\0')
			continue;

		pos += snprintf(buf + pos, PAGE_SIZE - pos, "%d:\n",
				image);
		pos += snprintf(buf + pos, PAGE_SIZE - pos, "\tCRM:\t\t%-.75s\n",
				image_address);
		pos += snprintf(buf + pos, PAGE_SIZE - pos, "\tVariant:\t%-.20s\n",
				image_address + SMEM_IMAGE_VERSION_VARIANT_OFFSET);
		pos += snprintf(buf + pos, PAGE_SIZE - pos, "\tVersion:\t%-.32s\n\n",
				image_address + SMEM_IMAGE_VERSION_OEM_OFFSET);

		image_address += SMEM_IMAGE_VERSION_SINGLE_BLOCK_SIZE;
	}

	return pos;
}

static struct device_attribute msm_soc_attr_raw_version =
	__ATTR(raw_version, S_IRUGO, msm_get_raw_version,  NULL);
@@ -1021,6 +1052,9 @@ static struct device_attribute select_image =
	__ATTR(select_image, S_IRUGO | S_IWUSR,
			msm_get_image_number, msm_select_image);

static struct device_attribute images =
	__ATTR(images, S_IRUGO, msm_get_images, NULL);

static void * __init setup_dummy_socinfo(void)
{
	if (early_machine_is_apq8084()) {
@@ -1105,6 +1139,7 @@ static void __init populate_soc_sysfs_files(struct device *msm_soc_device)
	device_create_file(msm_soc_device, &image_variant);
	device_create_file(msm_soc_device, &image_crm_version);
	device_create_file(msm_soc_device, &select_image);
	device_create_file(msm_soc_device, &images);

	switch (socinfo_format) {
	case SOCINFO_VERSION(0, 11):