Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2022505imm; Fri, 7 Sep 2018 09:37:17 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda/jPC8kgaaVQ/dpOX9+FG7lIJLLABKRRHKppAvaHopfYm/jjfcuKOvUmNPaKRSzqvBRhrY X-Received: by 2002:a17:902:4a:: with SMTP id 68-v6mr8653275pla.276.1536338237313; Fri, 07 Sep 2018 09:37:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536338237; cv=none; d=google.com; s=arc-20160816; b=g6ZoBtCIM7Mv9s+B9BY2213bHtI3acipr9YWmXQKz28H11veXe8lWDFGXf/v4vBuVp mga1It/+Ne5VO/xyEPUCGOVVySlNwo6kGZNMuTqYuEiX5nlO++6Z4Ft0YE2DNlqUk3vj Neyr40k4W8THAj7AczEc2W5Bjqn20W8Q+4ug55wEBepEqyIw5/LtX6jYc5894tlSEXmk Rs17guPZCvpuAGhtjyTNCWuazVInQI4/DeJyT0wOaFlbR67YAlLdqIcjvEpLVrfwkApe 36Kd5aZpdtUhxvevocFsPMJrCTmvQkD33LZcOesRkKBgPOSsxlBG+5VKZfhZ5qbr7RjV JjXA== 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=evYImewvXSyFqkcqilzjdqqUI2Ld7qPsEpfYsnODn3DCSP8itBW2eZkAbwdVJ0n4rc dSjeSuThwC/b5OpkqjttnIBUjoKIWqjGhw+Czay0w0sL/LzWDkJkNziRrqmvnDry9xgn Qh6JHi//zuqk1ShtRrghcVHwCRQXajPqNQh2IYJ6hnY+9wyFRwkUakDqpteht4zZ7Gm3 PI1R0Id5Ep64pfgKKDZJ5UCifa4WZYbk6DsrdTGmZHFUA2OwX1bvIMm/JA5LWDwlll+y Uk+p9hLEsTCxJMX2UsoQoqPvWXkfPhCdI+3IVbSjiU0EdnZHHBzVV2OSNIFnPjywmcsl yf3A== 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 t70-v6si8480134pgd.561.2018.09.07.09.37.02; Fri, 07 Sep 2018 09:37:17 -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 S1726605AbeIGVQe (ORCPT + 99 others); Fri, 7 Sep 2018 17:16:34 -0400 Received: from leonov.paulk.fr ([185.233.101.22]:60444 "EHLO leonov.paulk.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725999AbeIGVQe (ORCPT ); Fri, 7 Sep 2018 17:16:34 -0400 Received: from gagarine.paulk.fr (gagarine [192.168.1.127]) by leonov.paulk.fr (Postfix) with ESMTPS id 3803EC025F; Fri, 7 Sep 2018 18:34:51 +0200 (CEST) Received: by gagarine.paulk.fr (Postfix, from userid 114) id A5080C0F69; Fri, 7 Sep 2018 18:34:49 +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 BA84EC0F5E; Fri, 7 Sep 2018 18:33:55 +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 , linux-sunxi@googlegroups.com, Randy Li , Hans Verkuil , Ezequiel Garcia , Tomasz Figa , Alexandre Courbot , Philipp Zabel , Laurent Pinchart , Sakari Ailus , Thomas Petazzoni , Paul Kocialkowski Subject: [PATCH 1/2] media: cedrus: Fix error reporting in request validation Date: Fri, 7 Sep 2018 18:33:46 +0200 Message-Id: <20180907163347.32312-2-contact@paulk.fr> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907163347.32312-1-contact@paulk.fr> References: <20180907163347.32312-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