From: Pantelis Koukousoulas Date: Thu, 28 Dec 2006 02:06:54 +0000 (-0300) Subject: V4L/DVB (5036): Pvrusb2: Fix for min/max control value checking X-Git-Tag: v2.6.21-rc2~66^2~164 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fcb5b3ef758ca78461d390dc07bed5a4667c521;p=linux-2.6 V4L/DVB (5036): Pvrusb2: Fix for min/max control value checking In the previous patch we exploited the get_{min,max}_value facility to adjust min/max allowable frequencies on the fly, depending on tuner mode. Unfortunately, this facility was not used inside the *sym_to_val() function that translates what we echo to sysfs, which means we got an -ERANGE despite asking for a frequency between what we read to be min/max. This patch corrects this small omission. Signed-off-by: Pantelis Koukousoulas Signed-off-by: Mike Isely Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c index c77de859cc..5c9cf1523e 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c +++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c @@ -498,10 +498,19 @@ int pvr2_ctrl_sym_to_value(struct pvr2_ctrl *cptr, LOCK_TAKE(cptr->hdw->big_lock); do { if (cptr->info->type == pvr2_ctl_int) { ret = parse_token(ptr,len,valptr,NULL,0); - if ((ret >= 0) && - ((*valptr < cptr->info->def.type_int.min_value) || - (*valptr > cptr->info->def.type_int.max_value))) { - ret = -ERANGE; + if (ret >= 0) { + int min, max; + min = cptr->info->def.type_int.min_value; + if (cptr->info->get_min_value) { + cptr->info->get_min_value(cptr,&min); + } + max = cptr->info->def.type_int.max_value; + if (cptr->info->get_max_value) { + cptr->info->get_max_value(cptr,&max); + } + if ((*valptr < min) || (*valptr > max)) { + ret = -ERANGE; + } } if (maskptr) *maskptr = ~0; } else if (cptr->info->type == pvr2_ctl_bool) {