diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2013-05-31 05:21:03 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-06-17 08:32:43 -0400 |
commit | 96bb42b8ab3d4f15b5e98a65c6d8decf36f3f930 (patch) | |
tree | ef33d1bd0118ba6844edf3022d6601d9500e8407 /drivers/media/radio | |
parent | f90842d62b16356a8316528c91d0757a17d3e9e3 (diff) |
[media] radio-sf16fmi: clamp frequency
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/radio')
-rw-r--r-- | drivers/media/radio/radio-sf16fmi.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index 80beda7781bc..9cd0338a3d2b 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c | |||
@@ -55,8 +55,8 @@ static struct fmi fmi_card; | |||
55 | static struct pnp_dev *dev; | 55 | static struct pnp_dev *dev; |
56 | bool pnp_attached; | 56 | bool pnp_attached; |
57 | 57 | ||
58 | #define RSF16_MINFREQ (87 * 16000) | 58 | #define RSF16_MINFREQ (87U * 16000) |
59 | #define RSF16_MAXFREQ (108 * 16000) | 59 | #define RSF16_MAXFREQ (108U * 16000) |
60 | 60 | ||
61 | #define FMI_BIT_TUN_CE (1 << 0) | 61 | #define FMI_BIT_TUN_CE (1 << 0) |
62 | #define FMI_BIT_TUN_CLK (1 << 1) | 62 | #define FMI_BIT_TUN_CLK (1 << 1) |
@@ -155,15 +155,14 @@ static int vidioc_s_frequency(struct file *file, void *priv, | |||
155 | const struct v4l2_frequency *f) | 155 | const struct v4l2_frequency *f) |
156 | { | 156 | { |
157 | struct fmi *fmi = video_drvdata(file); | 157 | struct fmi *fmi = video_drvdata(file); |
158 | unsigned freq = f->frequency; | ||
158 | 159 | ||
159 | if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO) | 160 | if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO) |
160 | return -EINVAL; | 161 | return -EINVAL; |
161 | if (f->frequency < RSF16_MINFREQ || | 162 | clamp(freq, RSF16_MINFREQ, RSF16_MAXFREQ); |
162 | f->frequency > RSF16_MAXFREQ) | ||
163 | return -EINVAL; | ||
164 | /* rounding in steps of 800 to match the freq | 163 | /* rounding in steps of 800 to match the freq |
165 | that will be used */ | 164 | that will be used */ |
166 | lm7000_set_freq((f->frequency / 800) * 800, fmi, fmi_set_pins); | 165 | lm7000_set_freq((freq / 800) * 800, fmi, fmi_set_pins); |
167 | return 0; | 166 | return 0; |
168 | } | 167 | } |
169 | 168 | ||