Skip to content

Commit 8ca29e3

Browse files
committed
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. Signed-off-by: Daniel Mack <[email protected]>
1 parent d22d494 commit 8ca29e3

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
@@ -1189,9 +1189,11 @@ static void i2c_adapter_dev_release(struct device *dev)
11891189
unsigned int i2c_adapter_depth(struct i2c_adapter *adapter)
11901190
{
11911191
unsigned int depth = 0;
1192+
struct device *parent;
11921193

1193-
while ((adapter = i2c_parent_is_i2c_adapter(adapter)))
1194-
depth++;
1194+
for (parent = adapter->dev.parent; parent; parent = parent->parent)
1195+
if (parent->type == &i2c_adapter_type)
1196+
depth++;
11951197

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

0 commit comments

Comments
 (0)