diff options
author | Simon Arlott <simon@fire.lp0.eu> | 2009-04-27 12:22:15 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-04-27 12:22:15 +0200 |
commit | 0456b4f8b742006c2b79fcbe6b0736aa1ad39180 (patch) | |
tree | 9e978b37ff9bc2c42875c0f8f1dfe890d6f47548 /drivers/usb/atm/cxacru.c | |
parent | pasemi_mac: mac_to_intf() error not noticed (diff) | |
download | linux-0456b4f8b742006c2b79fcbe6b0736aa1ad39180.tar.xz linux-0456b4f8b742006c2b79fcbe6b0736aa1ad39180.zip |
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: David S. Miller <davem@davemloft.net>
Diffstat (limited to '')
-rw-r--r-- | drivers/usb/atm/cxacru.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c index 6789089e2461..56802d2e994b 100644 --- a/drivers/usb/atm/cxacru.c +++ b/drivers/usb/atm/cxacru.c @@ -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) |