From 2ed8375f39a952f28f1c3f66933ad5eb2774da9b Mon Sep 17 00:00:00 2001 From: Steve Markgraf Date: Thu, 10 May 2012 21:07:25 +0200 Subject: [PATCH] tuner_e4k: allow frequencies above INT_MAX Signed-off-by: Steve Markgraf --- include/tuner_e4k.h | 2 +- src/tuner_e4k.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/tuner_e4k.h b/include/tuner_e4k.h index 969ef7c..7d4630d 100644 --- a/include/tuner_e4k.h +++ b/include/tuner_e4k.h @@ -199,7 +199,7 @@ int e4k_mixer_gain_set(struct e4k_state *e4k, int8_t value); int e4k_commonmode_set(struct e4k_state *e4k, int8_t value); int e4k_tune_freq(struct e4k_state *e4k, uint32_t freq); int e4k_tune_params(struct e4k_state *e4k, struct e4k_pll_params *p); -int e4k_compute_pll_params(struct e4k_pll_params *oscp, uint32_t fosc, uint32_t intended_flo); +uint32_t e4k_compute_pll_params(struct e4k_pll_params *oscp, uint32_t fosc, uint32_t intended_flo); int e4k_if_filter_bw_get(struct e4k_state *e4k, enum e4k_if_filter filter); int e4k_if_filter_bw_set(struct e4k_state *e4k, enum e4k_if_filter filter, uint32_t bandwidth); diff --git a/src/tuner_e4k.c b/src/tuner_e4k.c index 651c626..bc97399 100644 --- a/src/tuner_e4k.c +++ b/src/tuner_e4k.c @@ -423,7 +423,7 @@ static uint64_t compute_fvco(uint32_t f_osc, uint8_t z, uint16_t x) return fvco; } -static int compute_flo(uint32_t f_osc, uint8_t z, uint16_t x, uint8_t r) +static uint32_t compute_flo(uint32_t f_osc, uint8_t z, uint16_t x, uint8_t r) { uint64_t fvco = compute_fvco(f_osc, z, x); if (fvco == 0) @@ -459,9 +459,9 @@ static int e4k_band_set(struct e4k_state *e4k, enum e4k_band band) * \param[in] fosc Clock input frequency applied to the chip (Hz) * \param[in] intended_flo target tuning frequency (Hz) * \returns actual PLL frequency, as close as possible to intended_flo, - * negative in case of error + * 0 in case of error */ -int e4k_compute_pll_params(struct e4k_pll_params *oscp, uint32_t fosc, uint32_t intended_flo) +uint32_t e4k_compute_pll_params(struct e4k_pll_params *oscp, uint32_t fosc, uint32_t intended_flo) { uint32_t i; uint8_t r = 2; @@ -473,7 +473,7 @@ int e4k_compute_pll_params(struct e4k_pll_params *oscp, uint32_t fosc, uint32_t oscp->r_idx = 0; if (!is_fosc_valid(fosc)) - return -EINVAL; + return 0; for(i = 0; i < ARRAY_SIZE(pll_vars); ++i) { if(intended_flo < pll_vars[i].freq) { @@ -556,13 +556,13 @@ int e4k_tune_params(struct e4k_state *e4k, struct e4k_pll_params *p) */ int e4k_tune_freq(struct e4k_state *e4k, uint32_t freq) { - int rc, i; + uint32_t rc; struct e4k_pll_params p; /* determine PLL parameters */ rc = e4k_compute_pll_params(&p, e4k->vco.fosc, freq); - if (rc < 0) - return rc; + if (!rc) + return -EINVAL; /* actually tune to those parameters */ rc = e4k_tune_params(e4k, &p);