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

Commit 385dbf30 authored by Jack Pham's avatar Jack Pham
Browse files

usb: pd: Update some sysfs entries to return hex values



Update several of the PD 3.0 related sysfs entries to return a
hexadecimal string of the byte data returned instead of decimal.
For the messages that correspond to non-extended messages, these
data objects should be printed as '0x1234ABCD' to ease human
translation to binary. For extended messages the payloads contain
fields of single or multi-byte values, so it's easiest to return
a string of hex bytes.

Change-Id: I436e90d9b5b472362ae39050dd775363db46207c
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent a19e1f5a
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -3686,8 +3686,12 @@ static ssize_t get_src_cap_ext_show(struct device *dev,
		return ret;

	for (i = 0; i < PD_SRC_CAP_EXT_DB_LEN; i++)
		len += snprintf(buf + len, PAGE_SIZE - len, "%d\n",
			pd->src_cap_ext_db[i]);
		len += snprintf(buf + len, PAGE_SIZE - len, "%s0x%02x",
				i ? " " : "", pd->src_cap_ext_db[i]);

	buf[len++] = '\n';
	buf[len] = '\0';

	return len;
}
static DEVICE_ATTR_RO(get_src_cap_ext);
@@ -3705,7 +3709,7 @@ static ssize_t get_pps_status_show(struct device *dev,
	if (ret)
		return ret;

	return snprintf(buf, PAGE_SIZE, "%d\n", pd->pps_status_db);
	return snprintf(buf, PAGE_SIZE, "0x%08x\n", pd->pps_status_db);
}
static DEVICE_ATTR_RO(get_pps_status);

@@ -3747,8 +3751,12 @@ static ssize_t get_battery_cap_show(struct device *dev,
		return -EINVAL;

	for (i = 0; i < PD_BATTERY_CAP_DB_LEN; i++)
		len += snprintf(buf + len, PAGE_SIZE - len, "%d\n",
			pd->battery_cap_db[i]);
		len += snprintf(buf + len, PAGE_SIZE - len, "%s0x%02x",
				i ? " " : "", pd->battery_cap_db[i]);

	buf[len++] = '\n';
	buf[len] = '\0';

	return len;
}
static DEVICE_ATTR_RW(get_battery_cap);
@@ -3779,7 +3787,7 @@ static ssize_t get_battery_status_show(struct device *dev,
	if (pd->get_battery_status_db == -EINVAL)
		return -EINVAL;

	return snprintf(buf, PAGE_SIZE, "%d\n", pd->battery_sts_dobj);
	return snprintf(buf, PAGE_SIZE, "0x%08x\n", pd->battery_sts_dobj);
}
static DEVICE_ATTR_RW(get_battery_status);