From patchwork Fri Dec 7 20:28:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10718815 X-Patchwork-Delegate: horms@verge.net.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35EE714E2 for ; Fri, 7 Dec 2018 20:29:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F89B2D704 for ; Fri, 7 Dec 2018 20:29:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D82E2DABD; Fri, 7 Dec 2018 20:29:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C0532D704 for ; Fri, 7 Dec 2018 20:29:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726047AbeLGU3F (ORCPT ); Fri, 7 Dec 2018 15:29:05 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:32906 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbeLGU3F (ORCPT ); Fri, 7 Dec 2018 15:29:05 -0500 Received: by mail-wr1-f67.google.com with SMTP id c14so5001484wrr.0 for ; Fri, 07 Dec 2018 12:29:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=WDVG6voduasP42cwv2/jCe1Drp8mfo4Vn8e2dcve1V4=; b=Oiml8qolI0resv+O8MKOatC6brBLUyWWj+J/5EZaYgE/diQMUzlaGoAnw/4E4wpXjf vN1aQtFqLVNNlk74eJmfG12EzYXr3fQRaKh2YFDQYk960vbEH2YwZbYzfoi+2lY/NJ+Z zMQqHSBZlwKlZN2WtJQ2NzvY/D9+Vml0Q+B24fi8u5qxmufeCwXvdimZHBGj32TeCUrl 3CaiOEfh1g+t4Mfsms5yNevyLKZdlmlOX1kjfazkzbUl7yEI0Eil8LEQAZ/re4bRYN6j nwng2F5kEF7HIfU7NWW/ENGeZg7C/WvQp0advnVYKDU5CeBg/8XxPgCPn01gsGTCAK5w kt3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=WDVG6voduasP42cwv2/jCe1Drp8mfo4Vn8e2dcve1V4=; b=A5e+MB86dY/9wvjL7wp8ZDdpt0q75v0DpnPXN9aQhosAH+uMkbwrU875f9Vgbj/in2 /QOkwO5m8xKuE/vn+qyAcsXIh1iO0t5zt7bOvRQ1Q2Eteag+w7pBY23icjKJdDk6RhV4 HrRpCM3Wd4saEI2JBSIZeIVyKF8TrYosmP8qfH+c/bYDMjbid4THKDLZMS5zSlTtrxaC Le6QW5hS1NKuLtGFnHMWvhZaRZnlbeAv/wIYS+C3Ymh1/mordZ7h6Sqh1q095NApHNkx NU8/vSXwQkNKi3ZBvlixZHPUnY0O6juI+kSID+WE2E1zb8B0PkYzQZGxz8PFesn70hR4 Q+hg== X-Gm-Message-State: AA+aEWbUxOqef9F2ZRVOTmobccTrnOgcCmoXAXth5MBmWLw9YgFndKQu TAxb3xbEAxMzcrTfAY7KxBc= X-Google-Smtp-Source: AFSGD/VSkMkKvpfeiFs3dy3xjSAboYYR4ZmEVNcog9CPdTUFggRPqrJ/cNbJ0bG18f1V+Zw5jARO2Q== X-Received: by 2002:adf:dfd1:: with SMTP id q17mr3125635wrn.27.1544214543649; Fri, 07 Dec 2018 12:29:03 -0800 (PST) Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz. [86.49.110.70]) by smtp.gmail.com with ESMTPSA id v1sm5683409wrw.90.2018.12.07.12.29.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Dec 2018 12:29:02 -0800 (PST) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-arm-kernel@lists.infradead.org Cc: Marek Vasut , Geert Uytterhoeven , Kuninori Morimoto , Simon Horman , Wolfram Sang , Yoshihiro Shimoda , linux-renesas-soc@vger.kernel.org Subject: [PATCH] ARM: shmobile: Fix R-Car Gen2 regulator quirk Date: Fri, 7 Dec 2018 21:28:58 +0100 Message-Id: <20181207202858.17129-1-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.18.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The quirk code currently detects all compatible I2C chips with a shared IRQ line on all I2C busses, adds them into a list, and registers a bus notifier. For every chip for which the bus notifier triggers, the quirk code performs I2C transfer on that I2C bus for all addresses in the list. The problem is that this may generate transfers to non-existing chips on systems with multiple I2C busses. This patch adds a check to verify that the I2C bus to which the chip with shared IRQ is attached to matches the I2C bus of the chip which triggered the bus notifier and only starts the I2C transfer if they match. Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Kuninori Morimoto Cc: Simon Horman Cc: Wolfram Sang Cc: Yoshihiro Shimoda Cc: linux-renesas-soc@vger.kernel.org Reviewed-by: Simon Horman Tested-by: Nguyen Viet Dung --- arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c index d4774d8ff997..f78e5348bd4c 100644 --- a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c +++ b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c @@ -40,6 +40,7 @@ struct regulator_quirk { struct list_head list; const struct of_device_id *id; + struct device_node *np; struct of_phandle_args irq_args; struct i2c_msg i2c_msg; bool shared; /* IRQ line is shared */ @@ -102,6 +103,9 @@ static int regulator_quirk_notify(struct notifier_block *nb, if (!pos->shared) continue; + if (pos->np->parent != client->dev.parent->of_node) + continue; + dev_info(&client->dev, "clearing %s@0x%02x interrupts\n", pos->id->compatible, pos->i2c_msg.addr); @@ -167,6 +171,7 @@ static int __init rcar_gen2_regulator_quirk(void) memcpy(&quirk->i2c_msg, id->data, sizeof(quirk->i2c_msg)); quirk->id = id; + quirk->np = np; quirk->i2c_msg.addr = addr; ret = of_irq_parse_one(np, 0, argsa);