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: 77014 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp1081635qgf; Mon, 26 Sep 2016 02:54:46 -0700 (PDT) X-Received: by 10.66.1.71 with SMTP id 7mr36496285pak.168.1474883685995; Mon, 26 Sep 2016 02:54:45 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r195si24500388pfr.240.2016.09.26.02.54.45; Mon, 26 Sep 2016 02:54:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758497AbcIZJyf (ORCPT + 27 others); Mon, 26 Sep 2016 05:54:35 -0400 Received: from mail-wm0-f43.google.com ([74.125.82.43]:35495 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936503AbcIZJya (ORCPT ); Mon, 26 Sep 2016 05:54:30 -0400 Received: by mail-wm0-f43.google.com with SMTP id l132so142192949wmf.0 for ; Mon, 26 Sep 2016 02:54:29 -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=R2Xkmm4SIpgojGphQrpxMJFUcVyRkDi4qyvR21WzRTLrUbJWSVUQRRF6U4FhOx+cIQ 5V5pS49bmXMwpLWRuQVXfi/qgHpSLuicjsV8o6NuUyTNMcncyfkO6+5xuSvz+1V+/qdQ AIxwImXpBVjm/h1fXzbPhYh4YvH3eneZnyRwEhmGj9iM9eccqqVIhe9qSKMt0iFb8phk +fYv1q1Mdd5xLNrYU33fqmcA0fzN9nlerhMTKo76k/+YEVxcyau3MaIWueBDs+SHb1MY ug7ehwMKySaC06G16TQfPDKrRF2BlmMjEquaDe68OJYRCoN8RNJ7PvDrkf+owBP8PO5+ RKbg== X-Gm-Message-State: AE9vXwMubxW+U7Wy9W24Ni2/QPw3KUm/57bxHWxG9NwU+zySB2egZFH5iXa1IIrmf35xQXoX 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- drivers/gpio/gpio-pca953x.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.7.4 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));