* [PATCH] cxacru: Fix negative dB output
@ 2009-04-23 17:19 Simon Arlott
2009-04-27 10:22 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Simon Arlott @ 2009-04-23 17:19 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Linux Kernel Mailing List, netdev
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>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] cxacru: Fix negative dB output
2009-04-23 17:19 [PATCH] cxacru: Fix negative dB output Simon Arlott
@ 2009-04-27 10:22 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2009-04-27 10:22 UTC (permalink / raw)
To: simon; +Cc: gregkh, linux-kernel, netdev
From: Simon Arlott <simon@fire.lp0.eu>
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@fire.lp0.eu>
Applied to net-next-2.6, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-04-27 10:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-23 17:19 [PATCH] cxacru: Fix negative dB output Simon Arlott
2009-04-27 10:22 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).