From patchwork Mon May 22 17:36:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 9741207 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 302086034C for ; Mon, 22 May 2017 17:36:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1753D28521 for ; Mon, 22 May 2017 17:36:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C5D928589; Mon, 22 May 2017 17:36:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAA9028724 for ; Mon, 22 May 2017 17:36:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932791AbdEVRgu (ORCPT ); Mon, 22 May 2017 13:36:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:54330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760367AbdEVRgr (ORCPT ); Mon, 22 May 2017 13:36:47 -0400 Received: from CookieMonster.cookiemonster.local (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C546D239E4; Mon, 22 May 2017 17:36:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C546D239E4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=kbingham@kernel.org From: Kieran Bingham To: sakari.ailus@iki.fi, laurent.pinchart@ideasonboard.com Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, niklas.soderlund@ragnatech.se, kieran.bingham@ideasonboard.com, Kieran Bingham Subject: [PATCH v3 2/2] v4l: async: Match parent devices Date: Mon, 22 May 2017 18:36:38 +0100 Message-Id: <6154c8f092e1cb4f5286c1f11f4a846c821b53d6.1495473356.git-series.kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kieran Bingham Devices supporting multiple endpoints on a single device node must set their subdevice fwnode to the endpoint to allow distinct comparisons. Adapt the match_fwnode call to compare against the provided fwnodes first, but also to search for a comparison against the parent fwnode. This allows notifiers to pass the endpoint for comparison and still support existing subdevices which store their default parent device node. Signed-off-by: Kieran Bingham --- v2: - Added documentation comments - simplified the OF match by adding match_fwnode_of() v3: - Fix comments - Fix sd_parent, and asd_parent usage drivers/media/v4l2-core/v4l2-async.c | 36 ++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index cbd919d4edd2..12c0707851fd 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -41,14 +41,40 @@ static bool match_devname(struct v4l2_subdev *sd, return !strcmp(asd->match.device_name.name, dev_name(sd->dev)); } +/* + * Check whether the two device_node pointers refer to the same OF node. We + * can't compare pointers directly as they can differ if overlays have been + * applied. + */ +static bool match_fwnode_of(struct fwnode_handle *a, struct fwnode_handle *b) +{ + return !of_node_cmp(of_node_full_name(to_of_node(a)), + of_node_full_name(to_of_node(b))); +} + +/* + * As a measure to support drivers which have not been converted to use + * endpoint matching, we also find the parent devices for cross-matching. + * + * When all devices use endpoint matching, this code can be simplified, and the + * parent comparisons can be removed. + */ static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) { - if (!is_of_node(sd->fwnode) || !is_of_node(asd->match.fwnode.fwnode)) - return sd->fwnode == asd->match.fwnode.fwnode; + struct fwnode_handle *asd_fwnode = asd->match.fwnode.fwnode; + struct fwnode_handle *sd_parent, *asd_parent; + + sd_parent = fwnode_graph_get_port_parent(sd->fwnode); + asd_parent = fwnode_graph_get_port_parent(asd_fwnode); + + if (!is_of_node(sd->fwnode) || !is_of_node(asd_fwnode)) + return sd->fwnode == asd_fwnode || + sd_parent == asd_fwnode || + sd->fwnode == asd_parent; - return !of_node_cmp(of_node_full_name(to_of_node(sd->fwnode)), - of_node_full_name( - to_of_node(asd->match.fwnode.fwnode))); + return match_fwnode_of(sd->fwnode, asd_fwnode) || + match_fwnode_of(sd_parent, asd_fwnode) || + match_fwnode_of(sd->fwnode, asd_parent); } static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)