From 1368ceb266990af58a72cdb0e121eb4ff22bde6f Mon Sep 17 00:00:00 2001 From: Istvan Varga Date: Fri, 3 Jun 2011 12:27:30 -0300 Subject: [PATCH] [media] xc4000: fixed frequency error 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 Signed-off-by: Mauro Carvalho Chehab --- drivers/media/common/tuners/xc4000.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/common/tuners/xc4000.c b/drivers/media/common/tuners/xc4000.c index be43a6dfac6c..f50dd6e713f7 100644 --- a/drivers/media/common/tuners/xc4000.c +++ b/drivers/media/common/tuners/xc4000.c @@ -417,8 +417,9 @@ static int xc_get_frequency_error(struct xc4000_priv *priv, u32 *freq_error_hz) 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; }