diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2013-04-09 00:25:05 +0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-04-15 02:53:17 +0400 |
commit | b387754d7256b1fa3610ed8a85f9274df49d1178 (patch) | |
tree | 51ea64cac39f5c4e4a419ab32d48c323310f75e0 /drivers/media/radio | |
parent | 55b2a312c29695520f813e61d668318169895ba7 (diff) | |
download | linux-b387754d7256b1fa3610ed8a85f9274df49d1178.tar.xz |
[media] radio-si4713: fix g/s_frequency
- check for invalid modulators.
- clamp frequency to valid range.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
Tested-by: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/radio')
-rw-r--r-- | drivers/media/radio/si4713-i2c.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/media/radio/si4713-i2c.c b/drivers/media/radio/si4713-i2c.c index 1cb9a2e7f683..56c9241ee7fb 100644 --- a/drivers/media/radio/si4713-i2c.c +++ b/drivers/media/radio/si4713-i2c.c @@ -1261,6 +1261,7 @@ static int si4713_setup(struct si4713_device *sdev) rval |= si4713_set_rds_radio_text(sdev, tmp->rds_info.radio_text); /* Device procedure needs to set frequency first */ + f.tuner = 0; f.frequency = tmp->frequency ? tmp->frequency : DEFAULT_FREQUENCY; f.frequency = si4713_to_v4l2(f.frequency); rval |= si4713_s_frequency(&sdev->sd, &f); @@ -1852,7 +1853,8 @@ static int si4713_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f) struct si4713_device *sdev = to_si4713_device(sd); int rval = 0; - f->type = V4L2_TUNER_RADIO; + if (f->tuner) + return -EINVAL; if (sdev->power_state) { u16 freq; @@ -1877,9 +1879,11 @@ static int si4713_s_frequency(struct v4l2_subdev *sd, const struct v4l2_frequenc int rval = 0; u16 frequency = v4l2_to_si4713(f->frequency); + if (f->tuner) + return -EINVAL; + /* Check frequency range */ - if (frequency < FREQ_RANGE_LOW || frequency > FREQ_RANGE_HIGH) - return -EDOM; + frequency = clamp_t(u16, frequency, FREQ_RANGE_LOW, FREQ_RANGE_HIGH); if (sdev->power_state) { rval = si4713_tx_tune_freq(sdev, frequency); |