From patchwork Fri Feb 19 19:24:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benoit Parrot X-Patchwork-Id: 8363531 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 10C019F372 for ; Fri, 19 Feb 2016 19:25:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3B71820534 for ; Fri, 19 Feb 2016 19:25:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4951320531 for ; Fri, 19 Feb 2016 19:25:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1948829AbcBSTYu (ORCPT ); Fri, 19 Feb 2016 14:24:50 -0500 Received: from bear.ext.ti.com ([192.94.94.41]:50077 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1948232AbcBSTYu (ORCPT ); Fri, 19 Feb 2016 14:24:50 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id u1JJOnao031821; Fri, 19 Feb 2016 13:24:49 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id u1JJOnGU004095; Fri, 19 Feb 2016 13:24:49 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.224.2; Fri, 19 Feb 2016 13:24:48 -0600 Received: from tct7400.am.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id u1JJOn0f021632; Fri, 19 Feb 2016 13:24:49 -0600 From: Benoit Parrot To: Hans Verkuil CC: , Subject: [Patch] media: ti-vpe: cal: Fix unreachable code in enum_frame_interval Date: Fri, 19 Feb 2016 13:24:45 -0600 Message-ID: <1455909885-22830-1-git-send-email-bparrot@ti.com> X-Mailer: git-send-email 2.7.1.287.g4943984 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As reported, the current cal_enum_frameintervals() is confusing and does not have the intended behavior. Fix this by re-implementing to properly propagate the enum_frame_interval request to the subdevice. Reported-by: Dan Carpenter Reported-by: Mauro Carvalho Chehab Signed-off-by: Benoit Parrot --- drivers/media/platform/ti-vpe/cal.c | 40 +++++++++++-------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c index 35fa1071c5b2..76d81b61ecb3 100644 --- a/drivers/media/platform/ti-vpe/cal.c +++ b/drivers/media/platform/ti-vpe/cal.c @@ -1201,42 +1201,26 @@ static int cal_enum_frameintervals(struct file *file, void *priv, { struct cal_ctx *ctx = video_drvdata(file); const struct cal_fmt *fmt; - struct v4l2_subdev_frame_size_enum fse; + struct v4l2_subdev_frame_interval_enum fie = { + .index = fival->index, + .width = fival->width, + .height = fival->height, + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + }; int ret; - if (fival->index) - return -EINVAL; - fmt = find_format_by_pix(ctx, fival->pixel_format); if (!fmt) return -EINVAL; - /* check for valid width/height */ ret = 0; - fse.pad = 0; - fse.code = fmt->code; - fse.which = V4L2_SUBDEV_FORMAT_ACTIVE; - for (fse.index = 0; ; fse.index++) { - ret = v4l2_subdev_call(ctx->sensor, pad, enum_frame_size, - NULL, &fse); - if (ret) - return -EINVAL; - - if ((fival->width == fse.max_width) && - (fival->height == fse.max_height)) - break; - else if ((fival->width >= fse.min_width) && - (fival->width <= fse.max_width) && - (fival->height >= fse.min_height) && - (fival->height <= fse.max_height)) - break; - - return -EINVAL; - } - + fie.code = fmt->code; + ret = v4l2_subdev_call(ctx->sensor, pad, enum_frame_interval, + NULL, &fie); + if (ret) + return ret; fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; - fival->discrete.numerator = 1; - fival->discrete.denominator = 30; + fival->discrete = fie.interval; return 0; }