From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 024823D5251 for ; Fri, 6 Feb 2026 13:13:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770383625; cv=none; b=poRMhKSGXX8cywL+cLWUTF36G6ZtDVa/TrUBV/bYhiY+Uxz+2Wp4nhGHp9Y5li6OlqLfX8JXmlObxhU7rokeW9JfGpTA7di31Uiwj4WQfGHJIT5ctPkZ2ER0e5wNGAgtx3gEjKxhoI8SBtUJ5avb4TxCG0+n9u2ssrf+j86sJno= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770383625; c=relaxed/simple; bh=OlTLK0CqCzBB4WeAVR7jvxv1ulQBxGgpjsvrv0hIQjY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=quUcP0WUbgC9TszYM/XgqF8TT+/J8HxyvCOeqepTl8A3y6C4NmmNwBG8ZWJH9wsKm1qWW6QzlvqLIp2oR0TtnmiIwGAG6+XnwnJXFSChpWsZ15i7YFjNwYhWWZfemfWpMy8CFnqpquM7ZvTpXuYrFqJ04Su12bBuHGBPa5Swowg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DYBaPHyc; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DYBaPHyc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770383625; x=1801919625; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OlTLK0CqCzBB4WeAVR7jvxv1ulQBxGgpjsvrv0hIQjY=; b=DYBaPHyc7uoofqUA0K8AUmljgquoCUHxJ0feSzwHtqjI68qXmDB8e+8W Of9yB2TDnen9leXT3D7bmMjSeumu0Tvu8EkrDNzIVlPRehbObp88YVK1P tZIRBirYcixfHgVjh+6Sre5B69EuXRYACljJIjOCrvIcfX73wL8crJXuR /783fE3rwiak/ND5NU4CxzWmMmiWQMcNDMendmW1RFe+RuYNWprFHPYbA N970eQRfpfJrYknmHFzi2Mt49C4LtJO/JcvwdcdzlQ7Rq4w9WeuhEDc1Y Gc0TEeIv3KVi1kPUthMBtdr9A5/TC8ZelOVX57NTn36mmIKeRSno2RCPt Q==; X-CSE-ConnectionGUID: Q7r0QhZNRH6lMBdrdWhcZQ== X-CSE-MsgGUID: QDA86rGaQbOdWkAy8QEZow== X-IronPort-AV: E=McAfee;i="6800,10657,11693"; a="75441213" X-IronPort-AV: E=Sophos;i="6.21,276,1763452800"; d="scan'208";a="75441213" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2026 05:13:44 -0800 X-CSE-ConnectionGUID: CcpaKBhNTLusrGCWpJUwaA== X-CSE-MsgGUID: W95HVvsBSZahG/tp32gzPQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,276,1763452800"; d="scan'208";a="215391295" Received: from vpanait-mobl.ger.corp.intel.com (HELO kekkonen.fi.intel.com) ([10.245.244.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2026 05:13:38 -0800 Received: from punajuuri.localdomain (unknown [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 6BAF6121E18; Fri, 06 Feb 2026 15:13:40 +0200 (EET) Received: from sailus by punajuuri.localdomain with local (Exim 4.98.2) (envelope-from ) id 1voLeL-00000005TsK-1DkB; Fri, 06 Feb 2026 15:13:29 +0200 Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo From: Sakari Ailus To: linux-media@vger.kernel.org Cc: hans@jjverkuil.nl, laurent.pinchart@ideasonboard.com, Prabhakar , Kate Hsuan , Alexander Shiyan , Dave Stevenson , Tommaso Merciai , Benjamin Mugnier , Sylvain Petinot , Christophe JAILLET , Julien Massot , Naushir Patuck , "Yan, Dongcheng" , "Cao, Bingbu" , "Qiu, Tian Shu" , Stefan Klug , Mirela Rabulea , =?UTF-8?q?Andr=C3=A9=20Apitzsch?= , Heimir Thor Sverrisson , Kieran Bingham , Mehdi Djait , Ricardo Ribalda Delgado , Hans de Goede , Jacopo Mondi , Tomi Valkeinen , David Plowman , "Yu, Ong Hock" , "Ng, Khai Wen" Subject: [PATCH 05/13] media: v4l2-subdev: Refactor returning routes Date: Fri, 6 Feb 2026 15:13:22 +0200 Message-ID: <20260206131329.1306429-6-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260206131329.1306429-1-sakari.ailus@linux.intel.com> References: <20260206131329.1306429-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Refactor returning the routes by adding a new function that essentially does a memcopy and sets the number of the number of the routes in the routing table. Signed-off-by: Sakari Ailus --- drivers/media/v4l2-core/v4l2-subdev.c | 40 +++++++++++++++------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index b2105c34478e..8a433d074587 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -629,6 +629,19 @@ subdev_ioctl_get_state(struct v4l2_subdev *sd, struct v4l2_subdev_fh *subdev_fh, v4l2_subdev_get_unlocked_active_state(sd); } +static void subdev_copy_fix_routes(struct v4l2_subdev_routing *routing, + const struct v4l2_subdev_route *src, + u32 copy_routes, u32 num_routes) +{ + struct v4l2_subdev_route *routes = + (struct v4l2_subdev_route *)(uintptr_t)routing->routes; + + for (u32 i = 0; i < copy_routes; i++) + routes[i] = src[i]; + + routing->num_routes = num_routes; +} + static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, struct v4l2_subdev_state *state) { @@ -1000,7 +1013,6 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, case VIDIOC_SUBDEV_G_ROUTING: { struct v4l2_subdev_routing *routing = arg; - struct v4l2_subdev_krouting *krouting; if (!v4l2_subdev_enable_streams_api) return -ENOIOCTLCMD; @@ -1013,13 +1025,9 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, memset(routing->reserved, 0, sizeof(routing->reserved)); - krouting = &state->routing; - - memcpy((struct v4l2_subdev_route *)(uintptr_t)routing->routes, - krouting->routes, - min(krouting->num_routes, routing->len_routes) * - sizeof(*krouting->routes)); - routing->num_routes = krouting->num_routes; + subdev_copy_fix_routes(routing, state->routing.routes, + routing->len_routes, + state->routing.num_routes); return 0; } @@ -1090,11 +1098,9 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, * the routing table. */ if (!v4l2_subdev_has_op(sd, pad, set_routing)) { - memcpy((struct v4l2_subdev_route *)(uintptr_t)routing->routes, - state->routing.routes, - min(state->routing.num_routes, routing->len_routes) * - sizeof(*state->routing.routes)); - routing->num_routes = state->routing.num_routes; + subdev_copy_fix_routes(routing, state->routing.routes, + routing->len_routes, + state->routing.num_routes); return 0; } @@ -1108,11 +1114,9 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, if (rval < 0) return rval; - memcpy((struct v4l2_subdev_route *)(uintptr_t)routing->routes, - state->routing.routes, - min(state->routing.num_routes, routing->len_routes) * - sizeof(*state->routing.routes)); - routing->num_routes = state->routing.num_routes; + subdev_copy_fix_routes(routing, state->routing.routes, + routing->len_routes, + state->routing.num_routes); return 0; } -- 2.47.3