From patchwork Tue Oct 3 12:08:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 729122 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B406E7544F for ; Tue, 3 Oct 2023 12:08:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232139AbjJCMIf (ORCPT ); Tue, 3 Oct 2023 08:08:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232136AbjJCMIf (ORCPT ); Tue, 3 Oct 2023 08:08:35 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E0BAA6 for ; Tue, 3 Oct 2023 05:08:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696334912; x=1727870912; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4U3b8j9YsSgrHGAWBd9E2mlW5dgfuStmvj2uthNMFm4=; b=nJtDxSAdygQBGLkyLcuM3PVK1eilw7WQhnhsIa3vxTe0KH+ZCnTLfPVu Btv2/L52UPqv7CHdCDSiCAC7UORgsdCqkp0eE5MdrYtHHyQtao4I7sBJ5 QOaRYmwJwgJrVCA7U2xKNhm3bvzi9vnnAM8Ev4aIODJdJG0cKPV+XsPGh QvqY0AdI0HkEQAiC7KwS0Uu5doxRkxMGjF5LyGPprTDQl6auHg2eS9rYe Tosu1ULObDX7hQy9D5PTRXPlwe5FBo/ZpOfzT5KdMXghhkrbrTp5EigPl 2F/EeQnsbhxsCbityJR1kdx8rUFJE6qS0VP+NTSJQi5Ey5xpmK2qDhMu/ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="385681535" X-IronPort-AV: E=Sophos;i="6.03,197,1694761200"; d="scan'208";a="385681535" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Oct 2023 05:08:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="780285924" X-IronPort-AV: E=Sophos;i="6.03,197,1694761200"; d="scan'208";a="780285924" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Oct 2023 05:08:29 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id AB1A2120A57; Tue, 3 Oct 2023 15:08:25 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" Subject: [PATCH v6 18/28] media: uapi: Allow a larger number of routes than there's room for Date: Tue, 3 Oct 2023 15:08:03 +0300 Message-Id: <20231003120813.77726-9-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003115237.76828-1-sakari.ailus@linux.intel.com> References: <20231003115237.76828-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org On VIDIOC_SUBDEV_[GS]_ROUTING, only return as many routes back to the user as there's room. Do not consider it an error if more routes existed. Simply inform the user there are more routes. Signed-off-by: Sakari Ailus --- .../userspace-api/media/v4l/vidioc-subdev-g-routing.rst | 4 ---- drivers/media/v4l2-core/v4l2-subdev.c | 8 ++------ 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst index ced53ea5f23c..99d3c15fd759 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst @@ -145,10 +145,6 @@ On success 0 is returned, on error -1 and the ``errno`` variable is set appropriately. The generic error codes are described at the :ref:`Generic Error Codes ` chapter. -ENOSPC - The application provided ``num_routes`` is not big enough to contain - all the available routes the subdevice exposes. - EINVAL The sink or source pad identifiers reference a non-existing pad, or reference pads of different types (ie. the sink_pad identifiers refers to a source pad). diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index 9a34e13dfd96..dd48e7e549fb 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -956,14 +956,10 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, krouting = &state->routing; - if (routing->len_routes < krouting->num_routes) { - routing->num_routes = krouting->num_routes; - return -ENOSPC; - } - memcpy((struct v4l2_subdev_route *)(uintptr_t)routing->routes, krouting->routes, - krouting->num_routes * sizeof(*krouting->routes)); + min(krouting->num_routes, routing->len_routes) * + sizeof(*krouting->routes)); routing->num_routes = krouting->num_routes; return 0;