diff mbox

XC4000: fixed frequency error

Message ID 4DE8FD62.406@mailbox.hu (mailing list archive)
State Accepted
Headers show

Commit Message

istvan_v@mailbox.hu June 3, 2011, 3:27 p.m. UTC
The xc_get_frequency_error() function reported the frequency error
incorrectly. The data read from the hardware is a signed integer, in
15625 Hz units. The attached patch fixes the bug.

Signed-off-by: Istvan Varga <istvan_v@mailbox.hu>
diff mbox

Patch

diff -uNr xc4000_orig/drivers/media/common/tuners/xc4000.c xc4000/drivers/media/common/tuners/xc4000.c
--- xc4000_orig/drivers/media/common/tuners/xc4000.c	2011-06-03 17:09:54.000000000 +0200
+++ xc4000/drivers/media/common/tuners/xc4000.c	2011-06-03 17:14:12.000000000 +0200
@@ -418,8 +418,9 @@ 
 	if (result != XC_RESULT_SUCCESS)
 		return result;
 
-	tmp = (u32)regData;
-	(*freq_error_hz) = (tmp * 15625) / 1000;
+	tmp = (u32)regData & 0xFFFFU;
+	tmp = (tmp < 0x8000U ? tmp : 0x10000U - tmp);
+	(*freq_error_hz) = tmp * 15625;
 	return result;
 }