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: Simon Arlott <simon@fire.lp0.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Simon Arlott 2009-04-23 18:19:02 +01:00 коммит произвёл Greg Kroah-Hartman
Родитель 091bf7624d
Коммит 10107bd04f
1 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -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)
{
return snprintf(buf, PAGE_SIZE, "%d.%02u\n",
value / 100, abs(value) % 100);
if (likely(value >= 0)) {
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)