Skip to content

Commit 53801d2

Browse files
zonquewsakernel
authored andcommitted
i2c: core: fix lockdep warning for sparsely nested adapter chain
When adapters are chained in a sparse manner (with intermediate MFD devices, for instance) the code currently fails to use the correct subclass for the adapter's bus_lock which leads to false-positive lockdep warnings. Fix this by walking the entire pedigree of the device and count all adapters along the way instead of just checking the immediate parent. Signed-off-by: Daniel Mack <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 702c0dd commit 53801d2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/i2c/i2c-core-base.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,9 +1194,11 @@ static void i2c_adapter_dev_release(struct device *dev)
11941194
unsigned int i2c_adapter_depth(struct i2c_adapter *adapter)
11951195
{
11961196
unsigned int depth = 0;
1197+
struct device *parent;
11971198

1198-
while ((adapter = i2c_parent_is_i2c_adapter(adapter)))
1199-
depth++;
1199+
for (parent = adapter->dev.parent; parent; parent = parent->parent)
1200+
if (parent->type == &i2c_adapter_type)
1201+
depth++;
12001202

12011203
WARN_ONCE(depth >= MAX_LOCKDEP_SUBCLASSES,
12021204
"adapter depth exceeds lockdep subclass limit\n");

0 commit comments

Comments
 (0)