From patchwork Fri Feb 19 16:54:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 8362961 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 AE21A9F38B for ; Fri, 19 Feb 2016 16:54:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BBB2720524 for ; Fri, 19 Feb 2016 16:54:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8C59C20504 for ; Fri, 19 Feb 2016 16:54:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757098AbcBSQya (ORCPT ); Fri, 19 Feb 2016 11:54:30 -0500 Received: from lists.s-osg.org ([54.187.51.154]:58913 "EHLO lists.s-osg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753794AbcBSQy3 (ORCPT ); Fri, 19 Feb 2016 11:54:29 -0500 Received: from recife.lan (177.43.16.117.dynamic.adsl.gvt.net.br [177.43.16.117]) by lists.s-osg.org (Postfix) with ESMTPSA id D78FE462CE; Fri, 19 Feb 2016 08:54:26 -0800 (PST) Date: Fri, 19 Feb 2016 14:54:23 -0200 From: Mauro Carvalho Chehab To: Benoit Parrot Cc: Hans Verkuil , , , , Hans Verkuil Subject: Re: [Patch v6 3/3] media: ti-vpe: Add CAL v4l2 camera capture driver Message-ID: <20160219145423.49aaa0b9@recife.lan> In-Reply-To: <1452123446-5424-4-git-send-email-bparrot@ti.com> References: <1452123446-5424-1-git-send-email-bparrot@ti.com> <1452123446-5424-4-git-send-email-bparrot@ti.com> Organization: Samsung X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.29; x86_64-redhat-linux-gnu) 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 Em Wed, 6 Jan 2016 17:37:26 -0600 Benoit Parrot escreveu: > The Camera Adaptation Layer (CAL) is a block which consists of a dual > port CSI2/MIPI camera capture engine. > Port #0 can handle CSI2 camera connected to up to 4 data lanes. > Port #1 can handle CSI2 camera connected to up to 2 data lanes. > The driver implements the required API/ioctls to be V4L2 compliant. > Driver supports the following: > - V4L2 API using DMABUF/MMAP buffer access based on videobuf2 api > - Asynchronous sensor sub device registration > - DT support > > Signed-off-by: Benoit Parrot > Signed-off-by: Hans Verkuil > --- ... > +/* timeperframe is arbitrary and continuous */ > +static int cal_enum_frameintervals(struct file *file, void *priv, > + struct v4l2_frmivalenum *fival) > +{ > + struct cal_ctx *ctx = video_drvdata(file); > + const struct cal_fmt *fmt; > + struct v4l2_subdev_frame_size_enum fse; > + 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; > + } > + > + fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; > + fival->discrete.numerator = 1; > + fival->discrete.denominator = 30; > + > + return 0; > +} The above routine is too complex and sounds wrong. Why do you need a loop there, if the loop will either return -EINVAL or be aborted the first time it runs? The way it is, it is just confusing and produces a smatch error: drivers/media/platform/ti-vpe/cal.c:1219 cal_enum_frameintervals() info: ignoring unreachable code. If all you want here is to run the loop once, this patch would do the same, with a clearer logic. ti-vpe/cal: Simplify the logic to avoid confusing smatch drivers/media/platform/ti-vpe/cal.c:1219 cal_enum_frameintervals() info: ignoring unreachable code. This is caused by a very confusing logic that looks like a loop, but it runs only once. Signed-off-by: Mauro Carvalho Chehab --- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c index 35fa1071c5b2..62721ee7b9bc 100644 --- a/drivers/media/platform/ti-vpe/cal.c +++ b/drivers/media/platform/ti-vpe/cal.c @@ -1216,29 +1216,28 @@ static int cal_enum_frameintervals(struct file *file, void *priv, 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; + fse.index = 0; + ret = v4l2_subdev_call(ctx->sensor, pad, enum_frame_size, + NULL, &fse); + if (ret) return -EINVAL; - } fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; fival->discrete.numerator = 1; fival->discrete.denominator = 30; - return 0; + if ((fival->width == fse.max_width) && + (fival->height == fse.max_height)) + return 0; + + if ((fival->width >= fse.min_width) && + (fival->width <= fse.max_width) && + (fival->height >= fse.min_height) && + (fival->height <= fse.max_height)) + return 0; + + return -EINVAL; } /*