Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1011926yba; Thu, 4 Apr 2019 02:23:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzrrr9l0Oe4Buho58wODBcqObV1EXQVnWlhLmEeSrERzjqHSEn/KsXNLOTFTDdurn9yNVwU X-Received: by 2002:a17:902:2c01:: with SMTP id m1mr5219616plb.186.1554369821863; Thu, 04 Apr 2019 02:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554369821; cv=none; d=google.com; s=arc-20160816; b=lFUUctLLgJdvswZmUGaqF9jD0q4KyGtouf2y4flhQF+jt0HSwiXiwZoNk5GCCbgXjw HV0S2tVWyhtTiebKOPLzKcunJ2CKPXrVODPzIbPmeRLWoUkOk9hC6qAbEM4MRC6tsZ6D axeq6CDy+NVBP9YYJ/rYqXuPoyLnr0Mh9isxumixL7nkkeDQC3kcFTw6pLBfrnTLVwhU 9Bh+ZajFSUg+2j5Q6oPBwWm+K2Cw62E1nuyQDz3EJ0fKJq6jUI2FjqgxI5BVrDzY6/B2 UlNXEWDMIMsE5q7Uq7gKEpY1QUVT5nKM0n+Y4lBUex7KGyXhXdkko8ikihm3vWNORzCA NsKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YcjZqWAL4yI1b5nyIY93sh10ome/jZ/R8DiVGOs+oA4=; b=QiYSypyR1WjaAaMSL+z1cnMSTVzm4GqlkObwoSX9yK1PIa5vwSQep8f0P5C81e/tPv LydVB8peACNHD4AqDpGcywd0xcxt5IsPCyiPzGhB+KtgguYJaFMcUfvw/TNegcR3JEK5 OfLoDf3f6Z11Iudw8FBe30+daUIuuu0y2m6N3AHw4KzyEJcB5xwaC7vzYFT36S4zUinb pukNqfJtijZ9gbVRmDT2eUo9p+p+7nHYikknk+3hru0M/RuxtHxFCI2Z0t8na/jTTSUd Uu/2e091co8oXNct1quOWjvF2xvjaLm4uAodDL9sZ35rxPYiCXikzIJiybYzQvZlyJbg fEBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=J0VpeJ6a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cm17si17185826plb.139.2019.04.04.02.23.26; Thu, 04 Apr 2019 02:23:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=J0VpeJ6a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387969AbfDDJP6 (ORCPT + 99 others); Thu, 4 Apr 2019 05:15:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:57108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387557AbfDDJP4 (ORCPT ); Thu, 4 Apr 2019 05:15:56 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F07122075E; Thu, 4 Apr 2019 09:15:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554369355; bh=1QFjPgMqdXg/E+tk0d9TepEzoUCaRSpt7CGPlpKt3Vw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J0VpeJ6aoFp6r7ktfG3VbbUYtRIefnyAb97pfgjec95gX1e6jUcjPLu4s4JSBuEYH 36VScR0a7GqiqDrcPrG7bRxsivU5mZwumEVjeAOqOL3CrnznvBLSNPl+s4i5BraiBL KAUVkVIl/uItIdPv5lTTaatCpA0TRIqqg0PHR054= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thierry Reding , Tristan Bastian , Wolfram Sang , Sasha Levin Subject: [PATCH 5.0 170/246] i2c: of: Try to find an I2C adapter matching the parent Date: Thu, 4 Apr 2019 10:47:50 +0200 Message-Id: <20190404084625.128642593@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084619.236418459@linuxfoundation.org> References: <20190404084619.236418459@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 5.0-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit e814e688413aabd7b0d75e2a8ed1caa472951dec ] If an I2C adapter doesn't match the provided device tree node, also try matching the parent's device tree node. This allows finding an adapter based on the device node of the parent device that was used to register it. This fixes a regression on Tegra124-based Chromebooks (Nyan) where the eDP controller registers an I2C adapter that is used to read to EDID. After commit 993a815dcbb2 ("dt-bindings: panel: Add missing .txt suffix") this stopped working because the I2C adapter could no longer be found. The approach in this patch fixes the regression without introducing the issues that the above commit solved. Fixes: 17ab7806de0c ("drm: don't link DP aux i2c adapter to the hardware device node") Signed-off-by: Thierry Reding Tested-by: Tristan Bastian Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/i2c-core-of.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c index 6cb7ad608bcd..0f01cdba9d2c 100644 --- a/drivers/i2c/i2c-core-of.c +++ b/drivers/i2c/i2c-core-of.c @@ -121,6 +121,17 @@ static int of_dev_node_match(struct device *dev, void *data) return dev->of_node == data; } +static int of_dev_or_parent_node_match(struct device *dev, void *data) +{ + if (dev->of_node == data) + return 1; + + if (dev->parent) + return dev->parent->of_node == data; + + return 0; +} + /* must call put_device() when done with returned i2c_client device */ struct i2c_client *of_find_i2c_device_by_node(struct device_node *node) { @@ -145,7 +156,8 @@ struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node) struct device *dev; struct i2c_adapter *adapter; - dev = bus_find_device(&i2c_bus_type, NULL, node, of_dev_node_match); + dev = bus_find_device(&i2c_bus_type, NULL, node, + of_dev_or_parent_node_match); if (!dev) return NULL; -- 2.19.1