Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1945465imm; Sun, 9 Sep 2018 12:13:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYCnXgu5B+n1honvfKdwupSc4E83sT7zU+XiCM7WAm3/+kzE5mBO4pEC7ZlpTjIMdggCRUN X-Received: by 2002:a63:4306:: with SMTP id q6-v6mr19204143pga.181.1536520391556; Sun, 09 Sep 2018 12:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536520391; cv=none; d=google.com; s=arc-20160816; b=dg/JujWov1+tcbCi9+QcG+AIQdK8OKeLHpGYbF35LVYngM38esWNAt/GhYsWLrb2x3 l9TgTpzqTpCyv8HNrkTUcSkoY4mNVTp7NbanTkGjYcDFqoduwShyqC8I3kfHQ5OXFG24 AAps5UCZESFlx+vbwPXNUoF4mwod7uKdb8oWOQJAlfG28Hir24QKHFB1FeDl+fkSFMJB VjhnWAxRS3d2W+UWNyWTML4BHuyZt5Bk6dZu+kSSE/QtPTxrVqgk3N5lV29idxsBdHUU c1M6pAsJ9vwpLfg+CNFFHYQ7A1pzFN7DYUpx6FTyvD8fNqsahz5tmjFJQu5kr0DrWDfO 8TKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=v6IL41zEP3PUg2fNLWGtM36Queh3KB0V9ww/r1GDvbE=; b=cIYKSYAuDcJwXAtBlq9D0N8sqZdOFrBSHE3z8kQqf4eIfszSnrTq86cGlz3UEVDHAI BqMzJdavmaioJ2M3oIyuSpZKzjXw0wp7+Jj4dBO2PFPVzlF2BDHvAomkprV5AhRwFVys m7BioUVD2szFGDClhEseupcysCJrLeF/OYv7Cf/urp5ktd6xERSTleFPTYq4O36gjSTG ao0/9Zx9ZFuBcoqf0NCtL2ej2/54lUHvUoMAK9HioZ27JamrEuzwf0WeBtnkeqdpbpEJ jKXpbOL/LuoBXAzVzGx4PJIo484AgYgs0W4U3dV93USFXs+QARc4LC95iocuPtSHP2yq eoQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i3-v6si13924569plb.44.2018.09.09.12.12.56; Sun, 09 Sep 2018 12:13:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726843AbeIJACB (ORCPT + 99 others); Sun, 9 Sep 2018 20:02:01 -0400 Received: from leonov.paulk.fr ([185.233.101.22]:44736 "EHLO leonov.paulk.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726599AbeIJACB (ORCPT ); Sun, 9 Sep 2018 20:02:01 -0400 Received: from gagarine.paulk.fr (gagarine [192.168.1.127]) by leonov.paulk.fr (Postfix) with ESMTPS id 6516DC0262; Sun, 9 Sep 2018 21:11:21 +0200 (CEST) Received: by gagarine.paulk.fr (Postfix, from userid 114) id DEC38C0FF9; Sun, 9 Sep 2018 21:11:19 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on gagarine.paulk.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.1 Received: from localhost.localdomain (collins [192.168.1.129]) by gagarine.paulk.fr (Postfix) with ESMTP id D2B81C0FE9; Sun, 9 Sep 2018 21:10:20 +0200 (CEST) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-arm-kernel@lists.infradead.org Cc: Maxime Ripard , Paul Kocialkowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Chen-Yu Tsai , Thomas Petazzoni , linux-sunxi@googlegroups.com, Randy Li , Hans Verkuil , Ezequiel Garcia , Tomasz Figa , Alexandre Courbot , Philipp Zabel , Laurent Pinchart , Sakari Ailus , Paul Kocialkowski Subject: [PATCH v2 1/4] media: cedrus: Fix error reporting in request validation Date: Sun, 9 Sep 2018 21:10:12 +0200 Message-Id: <20180909191015.20902-2-contact@paulk.fr> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180909191015.20902-1-contact@paulk.fr> References: <20180909191015.20902-1-contact@paulk.fr> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This fixes error reporting by using the appropriate logging helpers and return codes, while introducing new messages when there are not enough or too many buffers associated with the request. Signed-off-by: Paul Kocialkowski --- drivers/staging/media/sunxi/cedrus/cedrus.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index 09ab1b732c31..0a9363c7db06 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -105,10 +105,19 @@ static int cedrus_request_validate(struct media_request *req) struct v4l2_ctrl_handler *parent_hdl, *hdl; struct cedrus_ctx *ctx = NULL; struct v4l2_ctrl *ctrl_test; + unsigned int count; unsigned int i; - if (vb2_request_buffer_cnt(req) != 1) + count = vb2_request_buffer_cnt(req); + if (!count) { + v4l2_info(&ctx->dev->v4l2_dev, + "No buffer was provided with the request\n"); return -ENOENT; + } else if (count > 1) { + v4l2_info(&ctx->dev->v4l2_dev, + "More than one buffer was provided with the request\n"); + return -EINVAL; + } list_for_each_entry(obj, &req->objects, list) { struct vb2_buffer *vb; @@ -128,7 +137,7 @@ static int cedrus_request_validate(struct media_request *req) hdl = v4l2_ctrl_request_hdl_find(req, parent_hdl); if (!hdl) { - v4l2_err(&ctx->dev->v4l2_dev, "Missing codec control(s)\n"); + v4l2_info(&ctx->dev->v4l2_dev, "Missing codec control(s)\n"); return -ENOENT; } @@ -140,7 +149,7 @@ static int cedrus_request_validate(struct media_request *req) ctrl_test = v4l2_ctrl_request_hdl_ctrl_find(hdl, cedrus_controls[i].id); if (!ctrl_test) { - v4l2_err(&ctx->dev->v4l2_dev, + v4l2_info(&ctx->dev->v4l2_dev, "Missing required codec control\n"); return -ENOENT; } -- 2.18.0