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

Commit 10107bd0 authored by Simon Arlott's avatar Simon Arlott Committed by Greg Kroah-Hartman
Browse files

USB: cxacru: Fix negative dB output



Values of dB between -0.99 and -0.01 will be output with the wrong
sign. This converts the negative value to positive and outputs it
with a "-" prefix.

Signed-off-by: default avatarSimon Arlott <simon@fire.lp0.eu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 091bf762
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -227,8 +227,14 @@ static ssize_t cxacru_sysfs_showattr_s8(s8 value, char *buf)


static ssize_t cxacru_sysfs_showattr_dB(s16 value, char *buf)
static ssize_t cxacru_sysfs_showattr_dB(s16 value, char *buf)
{
{
	return snprintf(buf, PAGE_SIZE, "%d.%02u\n",
	if (likely(value >= 0)) {
					value / 100, abs(value) % 100);
		return snprintf(buf, PAGE_SIZE, "%u.%02u\n",
					value / 100, value % 100);
	} else {
		value = -value;
		return snprintf(buf, PAGE_SIZE, "-%u.%02u\n",
					value / 100, value % 100);
	}
}
}


static ssize_t cxacru_sysfs_showattr_bool(u32 value, char *buf)
static ssize_t cxacru_sysfs_showattr_bool(u32 value, char *buf)