From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bartosz Golaszewski Subject: [PATCH v2 3/4] i2c: add a warning to i2c_adapter_depth() Date: Fri, 16 Sep 2016 18:02:44 +0200 Message-ID: <1474041765-17818-4-git-send-email-bgolaszewski@baylibre.com> References: <1474041765-17818-1-git-send-email-bgolaszewski@baylibre.com> Return-path: Received: from mail-wm0-f41.google.com ([74.125.82.41]:36900 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964957AbcIPQDK (ORCPT ); Fri, 16 Sep 2016 12:03:10 -0400 Received: by mail-wm0-f41.google.com with SMTP id k186so49853884wmd.0 for ; Fri, 16 Sep 2016 09:03:09 -0700 (PDT) In-Reply-To: <1474041765-17818-1-git-send-email-bgolaszewski@baylibre.com> Sender: linux-i2c-owner@vger.kernel.org List-Id: linux-i2c@vger.kernel.org To: Linus Walleij , Alexandre Courbot , Andy Shevchenko , Vignesh R , Yong Li , Geert Uytterhoeven , Peter Zijlstra , Ingo Molnar , Wolfram Sang , Peter Rosin Cc: linux-i2c , linux-gpio , LKML , Bartosz Golaszewski This routine is only used together with lockdep for nested locking. The number of lock subclasses is limited to 8 as defined in lockdep.h Emit a warning if the adapter depth exceeds the maximum number of lockdep subclasses. Signed-off-by: Bartosz Golaszewski --- drivers/i2c/i2c-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index c9b8df8..75cefa8 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -1342,6 +1342,9 @@ unsigned int i2c_adapter_depth(struct i2c_adapter *adapter) while ((adapter = i2c_parent_is_i2c_adapter(adapter))) depth++; + WARN_ONCE(depth >= MAX_LOCKDEP_SUBCLASSES, + "adapter depth exceeds lockdep subclass limit\n"); + return depth; } EXPORT_SYMBOL_GPL(i2c_adapter_depth); -- 2.7.4