forked from archlinuxarm/PKGBUILDs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
core/linux-nyan/v2-i2c-of-Try-to-find-an-I2C-adapter-matching-the-parent.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
From patchwork Fri Jan 25 13:11:42 2019 | ||
Content-Type: text/plain; charset="utf-8" | ||
MIME-Version: 1.0 | ||
Content-Transfer-Encoding: 7bit | ||
Subject: [v2] i2c: of: Try to find an I2C adapter matching the parent | ||
X-Patchwork-Submitter: Thierry Reding <thierry.reding@gmail.com> | ||
X-Patchwork-Id: 1031073 | ||
Message-Id: <20190125131142.26837-1-thierry.reding@gmail.com> | ||
To: Wolfram Sang <wsa@the-dreams.de> | ||
Cc: Rob Herring <robh+dt@kernel.org>, Lucas Stach <l.stach@pengutronix.de>, | ||
Andrzej Hajda <a.hajda@samsung.com>, Vlado Plaga <rechner@vlado-do.de>, | ||
Tristan Bastian <tristan-c.bastian@gmx.de>, | ||
linux-i2c@vger.kernel.org, dri-devel@lists.freedesktop.org, | ||
linux-tegra@vger.kernel.org | ||
Date: Fri, 25 Jan 2019 14:11:42 +0100 | ||
From: Thierry Reding <thierry.reding@gmail.com> | ||
List-Id: <linux-i2c.vger.kernel.org> | ||
|
||
From: Thierry Reding <treding@nvidia.com> | ||
|
||
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 <treding@nvidia.com> | ||
Tested-by: Tristan Bastian <tristan-c.bastian@gmx.de> | ||
Tested-by: Tristan Bastian <tristan-c.bastian@gmx.de> | ||
--- | ||
Changes in v2: | ||
- check for both device and parent device tree nodes for each device | ||
instead of looping through the list of devices twice | ||
|
||
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; | ||
|