From patchwork Sun Jan 17 18:29:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12025641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A7BCC433DB for ; Sun, 17 Jan 2021 18:32:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 656F2224DE for ; Sun, 17 Jan 2021 18:32:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729864AbhAQSc0 (ORCPT ); Sun, 17 Jan 2021 13:32:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729861AbhAQScZ (ORCPT ); Sun, 17 Jan 2021 13:32:25 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90A41C061575 for ; Sun, 17 Jan 2021 10:31:44 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id C79821F44A5B From: Ezequiel Garcia To: linux-media@vger.kernel.org, Hans Verkuil Cc: kernel@collabora.com, Laurent Pinchart , Sakari Ailus , Kieran Bingham , Jacopo Mondi , =?utf-8?q?Niklas_S=C3=B6derlund?= , Mickael Guene , Helen Koike , Dafna Hirschfeld , Hugues Fruchet , Nicolas Ferre , Yong Zhi , Sylwester Nawrocki , Maxime Ripard , Robert Foss , Philipp Zabel , Ezequiel Garcia , Jacopo Mondi Subject: [PATCH v2 06/14] media: cadence: Use v4l2_async_notifier_add_fwnode_remote_subdev Date: Sun, 17 Jan 2021 15:29:43 -0300 Message-Id: <20210117182956.41298-12-ezequiel@collabora.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210117182956.41298-1-ezequiel@collabora.com> References: <20210117182956.41298-1-ezequiel@collabora.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The use of v4l2_async_notifier_add_subdev will be discouraged. Drivers are instead encouraged to use a helper such as v4l2_async_notifier_add_fwnode_remote_subdev. This fixes a misuse of the API, as v4l2_async_notifier_add_subdev should get a kmalloc'ed struct v4l2_async_subdev, removing some boilerplate code while at it. Use the appropriate helper v4l2_async_notifier_add_fwnode_remote_subdev, which handles the needed setup, instead of open-coding it. Signed-off-by: Ezequiel Garcia Reviewed-by: Jacopo Mondi --- drivers/media/platform/cadence/cdns-csi2rx.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index be9ec59774d6..7d299cacef8c 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -81,7 +81,6 @@ struct csi2rx_priv { struct media_pad pads[CSI2RX_PAD_MAX]; /* Remote source */ - struct v4l2_async_subdev asd; struct v4l2_subdev *source_subdev; int source_pad; }; @@ -362,6 +361,7 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx, static int csi2rx_parse_dt(struct csi2rx_priv *csi2rx) { struct v4l2_fwnode_endpoint v4l2_ep = { .bus_type = 0 }; + struct v4l2_async_subdev *asd; struct fwnode_handle *fwh; struct device_node *ep; int ret; @@ -395,17 +395,13 @@ static int csi2rx_parse_dt(struct csi2rx_priv *csi2rx) return -EINVAL; } - csi2rx->asd.match.fwnode = fwnode_graph_get_remote_port_parent(fwh); - csi2rx->asd.match_type = V4L2_ASYNC_MATCH_FWNODE; - of_node_put(ep); - v4l2_async_notifier_init(&csi2rx->notifier); - ret = v4l2_async_notifier_add_subdev(&csi2rx->notifier, &csi2rx->asd); - if (ret) { - fwnode_handle_put(csi2rx->asd.match.fwnode); - return ret; - } + asd = v4l2_async_notifier_add_fwnode_remote_subdev(&csi2rx->notifier, + fwh, sizeof(*asd)); + of_node_put(ep); + if (IS_ERR(asd)) + return PTR_ERR(asd); csi2rx->notifier.ops = &csi2rx_notifier_ops;