Clamp both sampling frequency and RF frequency to valid range to meet V4L2 API spec. It is caller responsibility to check valid ranges using VIDIOC_ENUM_FREQ_BANDS IOCTL. Signed-off-by: Antti Palosaari <crope@xxxxxx> --- drivers/staging/media/msi3101/sdr-msi3101.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/msi3101/sdr-msi3101.c b/drivers/staging/media/msi3101/sdr-msi3101.c index ba37fce..2b812fe 100644 --- a/drivers/staging/media/msi3101/sdr-msi3101.c +++ b/drivers/staging/media/msi3101/sdr-msi3101.c @@ -1779,17 +1779,26 @@ static int msi3101_s_frequency(struct file *file, void *priv, const struct v4l2_frequency *f) { struct msi3101_state *s = video_drvdata(file); - int ret; + int ret, band; dev_dbg(&s->udev->dev, "%s: tuner=%d type=%d frequency=%u\n", __func__, f->tuner, f->type, f->frequency); if (f->tuner == 0) { - s->f_adc = f->frequency; + s->f_adc = clamp_t(unsigned int, f->frequency, + bands_adc[0].rangelow, + bands_adc[0].rangehigh); dev_dbg(&s->udev->dev, "%s: ADC frequency=%u Hz\n", __func__, s->f_adc); ret = msi3101_set_usb_adc(s); } else if (f->tuner == 1) { - s->f_tuner = f->frequency; + #define BAND_RF_0 ((bands_rf[0].rangehigh + bands_rf[1].rangelow) / 2) + if (f->frequency < BAND_RF_0) + band = 0; + else + band = 1; + s->f_tuner = clamp_t(unsigned int, f->frequency, + bands_rf[band].rangelow, + bands_rf[band].rangehigh); dev_dbg(&s->udev->dev, "%s: RF frequency=%u Hz\n", __func__, f->frequency); ret = msi3101_set_tuner(s); -- 1.8.5.3 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html