From mboxrd@z Thu Jan 1 00:00:00 1970 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 0274BC433FE for ; Wed, 12 Oct 2022 06:58:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229675AbiJLG6l (ORCPT ); Wed, 12 Oct 2022 02:58:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229563AbiJLG6g (ORCPT ); Wed, 12 Oct 2022 02:58:36 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C73380F6B for ; Tue, 11 Oct 2022 23:58:35 -0700 (PDT) Received: from [192.168.1.15] (91-158-154-79.elisa-laajakaista.fi [91.158.154.79]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CC7704DB; Wed, 12 Oct 2022 08:58:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1665557913; bh=8hpf6+tVLIYURAQ7ar755YT3AIL7GD8obcRAVtJDFuY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=TBwccPGGEgSx9iXVIpJURbsLOKJ01GQuz0k9AkmVyCGfPqpDY4NtThq6sTx+9iRxm amZCsuFx6gIiJ+UCKb5IFx5IdxgATLZhT/KwQx0gX4/vnpBhGGM7QCK4R9bOdulA6a Rdo4g0Ozis5JQ3zpiYRZMlqH60KdlYH5/5ua7iyg= Message-ID: <9cdae272-e73b-9acb-2011-dfb6884a033a@ideasonboard.com> Date: Wed, 12 Oct 2022 09:58:30 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v15 07/19] media: subdev: add v4l2_subdev_set_routing helper() Content-Language: en-US To: Yunke Cao Cc: linux-media@vger.kernel.org, sakari.ailus@linux.intel.com, Jacopo Mondi , Laurent Pinchart , niklas.soderlund+renesas@ragnatech.se, Mauro Carvalho Chehab , Hans Verkuil , Kishon Vijay Abraham , satish.nagireddy@getcruise.com, Tomasz Figa References: <20221003121852.616745-1-tomi.valkeinen@ideasonboard.com> <20221003121852.616745-8-tomi.valkeinen@ideasonboard.com> From: Tomi Valkeinen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org On 12/10/2022 09:22, Yunke Cao wrote: > Hi Tomi, > > On Wed, Oct 12, 2022 at 2:03 PM Tomi Valkeinen > wrote: >> >> Add a helper function to set the subdev routing. The helper can be used >> from subdev driver's set_routing op to store the routing table. >> >> Signed-off-by: Tomi Valkeinen >> Reviewed-by: Hans Verkuil >> --- >> drivers/media/v4l2-core/v4l2-subdev.c | 31 +++++++++++++++++++++++++++ >> include/media/v4l2-subdev.h | 16 ++++++++++++++ >> 2 files changed, 47 insertions(+) >> >> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c >> index fff17b8536fc..3ae4f39a50e4 100644 >> --- a/drivers/media/v4l2-core/v4l2-subdev.c >> +++ b/drivers/media/v4l2-core/v4l2-subdev.c >> @@ -12,6 +12,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -1181,6 +1182,36 @@ int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, >> } >> EXPORT_SYMBOL_GPL(v4l2_subdev_get_fmt); >> >> +int v4l2_subdev_set_routing(struct v4l2_subdev *sd, >> + struct v4l2_subdev_state *state, >> + const struct v4l2_subdev_krouting *routing) >> +{ >> + struct v4l2_subdev_krouting *dst = &state->routing; >> + const struct v4l2_subdev_krouting *src = routing; >> + struct v4l2_subdev_krouting new_routing = { 0 }; >> + size_t bytes; >> + >> + if (unlikely(check_mul_overflow(src->num_routes, sizeof(*src->routes), > > Do we need to cast (size_t)src->num_routes here? > My compiler is complaining: > ./include/linux/overflow.h:85:22: error: comparison of distinct > pointer types lacks a cast [-Werror] > 85 | (void) (&__a == &__b); \ > Yes, I think we should do that. Thanks! I need to remember to compile with other compilers than arm32 too =). Tomi