From patchwork Mon Sep 26 09:54:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 675062 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3sjK802JRmz9s9c for ; Mon, 26 Sep 2016 19:54:56 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b=s5sCyaJ9; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756594AbcIZJye (ORCPT ); Mon, 26 Sep 2016 05:54:34 -0400 Received: from mail-lf0-f45.google.com ([209.85.215.45]:34532 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938951AbcIZJya (ORCPT ); Mon, 26 Sep 2016 05:54:30 -0400 Received: by mail-lf0-f45.google.com with SMTP id y6so136131279lff.1 for ; Mon, 26 Sep 2016 02:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bzowZ9lawNYigJaoA4NuExzpca5IMRLa2oHEiOfZW8Q=; b=s5sCyaJ9ZN9SH/T1CHMpDo30zQN/ZFqYpEarLF1BUN2+ikScSHrTKiAFM4swjZZL0N rMRHpgNQpjLhF4lseJtfrUk5t3ZxVYUlLYiq2GiupLc3UxyHL+sf/F2/XenxqezkSTAw RSANJxkdTBRCBnObwgV7v10h1bsixU5QeoyOrnlkAor8ATHvAzf7d3IU61N1ktVU+ze9 yoxiyblxMqM88kURr+Yf3RcKLa1Qki8sBf/wseHhWQZCB7ROMVm/vY8pvLFZNI3Uo1s/ kVQxZBLz3DsK0fSh5N3gXwrkypaw66w2KITkTSUXVHL+GJL1Y7FdZLFwr68sWjJueYK2 26Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bzowZ9lawNYigJaoA4NuExzpca5IMRLa2oHEiOfZW8Q=; b=bjCHoB7sVtzNLvRrvszyOBkxrerrXgmi1ccAashLuyedC5mobkm2O/dc91B5DNTw+J 02z2anWN8w9qbAa5rFkqBDnzkiBItPE4EGLatPQlkcGfZPsau39GMxyCkzoxs1dsG8Ti nrkDxzEJK1h5fd3oHIh0XRyk7843f0DsC8GgAhWgCzdrUa6eZobeH6wc1xEkJ7aO5LlV aNZtNB8F9qJIHw0AS/RxPHfyEk0ZnNIks8I6V8UM8JsUSj8koN9el105DTj+mjOC6bDk pB07Aczz8PP1wbDOwLgUfE1orIXGzTXJCMWEitYLZTAr2+G+p65FMiqx/3wIWJQogIOQ MpqA== X-Gm-Message-State: AE9vXwOP5IIpTInAEnQcYzhjK8nDYhFg/lk1efZYphQ9uhM8w1BS+crJRnr0Zw01Hn7kJbqo X-Received: by 10.194.178.130 with SMTP id cy2mr17040190wjc.138.1474883669160; Mon, 26 Sep 2016 02:54:29 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id n131sm10373069wmd.3.2016.09.26.02.54.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Sep 2016 02:54:28 -0700 (PDT) From: Bartosz Golaszewski 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 Subject: [PATCH] gpio: pca953x: add a comment explaining the need for a lockdep subclass Date: Mon, 26 Sep 2016 11:54:15 +0200 Message-Id: <1474883655-15824-2-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1474883655-15824-1-git-send-email-bgolaszewski@baylibre.com> References: <1474883655-15824-1-git-send-email-bgolaszewski@baylibre.com> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This is a follow-up to commit 559b46990e76 ("gpio: pca953x: fix an incorrect lockdep warning"). The reason for calling lockdep_set_subclass() in pca953x_probe() is not explained in the code. Add a comment describing the problem, partial solution and required future extensions. Signed-off-by: Bartosz Golaszewski Acked-by: Wolfram Sang --- drivers/gpio/gpio-pca953x.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 018f39c..f306909 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -786,6 +786,22 @@ static int pca953x_probe(struct i2c_client *client, chip->chip_type = PCA_CHIP_TYPE(chip->driver_data); mutex_init(&chip->i2c_lock); + /* + * In case we have an i2c-mux controlled by a GPIO provided by an + * expander using the same driver higher on the device tree, read the + * i2c adapter nesting depth and use the retrieved value as lockdep + * subclass for chip->i2c_lock. + * + * REVISIT: This solution is not complete. It protects us from lockdep + * false positives when the expander controlling the i2c-mux is on + * a different level on the device tree, but not when it's on the same + * level on a different branch (in which case the subclass number + * would be the same). + * + * TODO: Once a correct solution is developed, a similar fix should be + * applied to all other i2c-controlled GPIO expanders (and potentially + * regmap-i2c). + */ lockdep_set_subclass(&chip->i2c_lock, i2c_adapter_depth(client->adapter));