[PATCH] cxacru: Fix negative dB output
- From: Simon Arlott <simon@xxxxxxxxxxx>
- Date: Thu, 23 Apr 2009 18:19:02 +0100
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@xxxxxxxxxxx>
---
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 6789089..56802d2 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)
--
1.6.2.2
--
Simon Arlott
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- Follow-Ups:
- Re: [PATCH] cxacru: Fix negative dB output
- From: David Miller
- Re: [PATCH] cxacru: Fix negative dB output
- Prev by Date: Re: [PATCH] It may not be assumed that wake_up(), finish_wait() and co. imply a memory barrier
- Next by Date: Re: [RFC PATCH] fpathconf() for fsync() behavior
- Previous by thread: Grant Award
- Next by thread: Re: [PATCH] cxacru: Fix negative dB output
- Index(es):
Relevant Pages
|
Loading