From patchwork Sun Sep 9 19:10:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10593403 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F3DB6CB for ; Sun, 9 Sep 2018 19:11:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FBA829070 for ; Sun, 9 Sep 2018 19:11:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53193291DD; Sun, 9 Sep 2018 19:11:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE20429070 for ; Sun, 9 Sep 2018 19:11:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726795AbeIJACB (ORCPT ); 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) 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-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }