Skip to content

Commit

Permalink
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: David S. Miller <davem@davemloft.net>
  • Loading branch information
Simon Arlott authored and David S. Miller committed Apr 27, 2009
1 parent 15b8e19 commit 0456b4f
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 0456b4f

Please sign in to comment.