Skip to content

Commit

Permalink
USB: cxacru: Fix negative dB output
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Simon Arlott authored and Greg Kroah-Hartman committed May 9, 2009
1 parent 091bf76 commit 10107bd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drivers/usb/atm/cxacru.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 10107bd

Please sign in to comment.