Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1022494yba; Thu, 4 Apr 2019 02:38:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4C0yjDiFSEPgV1JG2jFRapyQRb/9i+hkhLCmh5i2C0xs3CYoeuHus93OHJ/Yryiuq9ZFB X-Received: by 2002:a65:518b:: with SMTP id h11mr4844426pgq.41.1554370692764; Thu, 04 Apr 2019 02:38:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554370692; cv=none; d=google.com; s=arc-20160816; b=LcxorGO6HZUruVQMQ8IlLOfA+/JT8UDREDzBsa6AvPnk7hcq9yhBDXMFd5OumtXNCh xVUgVpLalGCAqeGByVH1rSbX3wVprEtRjL61fK6f0/J/XCXWsl+vv9HQLLTlPUP997lu TuRw0z6m9niSpK9aGTIft7bM5zLxOcHc1dNKobYtEqo/3IK0E+MhHGFeR6tkZB3/Z+LI vR/vV9k+/IvNNGDzxaVScaAXB+9IVu2lPahdRgQbV2Klz9oHiw2KJTYVScrxZA3uxWUt t/VcK3Anj8YaC3hFLwTvo/w2sA2PxiFn2AF/Ewmh/odM+tBYwGnU8pzuH+xOjY8G9v7E khjg== 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=ujklriOBk0YXRKxsvuvW+cX8QA1ZCZp5snRw3G6rxfY=; b=CSNgSHgfczRCtWP1yMTDd75kTiDKvAIsKAteFhnHinacuB1lyj5pvYYjSSiBnh6eGK DFGV8WF2g/QOeMgb8clySfSyGkn9EIBkWF81X1LADW/hh73C+PLd3JcXSc1VCuIcRgsb wTFxeCrU5ffAFD+wgj9UVSzYC45l0+VC/q0zaueb1HvyAUDxKEqL+rGlNdhNrOCOpDeV 9UtD3q4kzlpIVxGI3gFWEJXDZ7yhN79B2BihUHxMP8D/5FMcTCtCXtHKBl96wDgogapj DzwdHKqZbVzuDmo61LOU+RUACF4rj+Ctbg7cXH4FL7u/xS3CS3kodOsnyPT3kaJtqCtG OB0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KgiietFj; 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 l37si16493476plb.173.2019.04.04.02.37.57; Thu, 04 Apr 2019 02:38:12 -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=KgiietFj; 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 S1731695AbfDDJFX (ORCPT + 99 others); Thu, 4 Apr 2019 05:05:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:43362 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732126AbfDDJFU (ORCPT ); Thu, 4 Apr 2019 05:05:20 -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 4B8A121741; Thu, 4 Apr 2019 09:05:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368719; bh=sYiXaetmFzKT4ZVuK2gso+n3K12dYqioNeoNFKYIuhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KgiietFjrPiB3RO2F8yyyevoYWdCPWLHtYpQLs7jgyvtA08E4amHs7eh2yW+3OWGC LmmRw2yk/VdxwGWpwwEAR9O65quTzCwtK8mthNl5jHTYpw0pQylQ4gFTooXIbQH68x ubx/YnMPQwYoW+3nYdagthPig5IzrTYsPZfKLuqA= 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 4.19 128/187] i2c: of: Try to find an I2C adapter matching the parent Date: Thu, 4 Apr 2019 10:47:45 +0200 Message-Id: <20190404084609.246668450@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@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 4.19-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