From patchwork Fri Jan 26 15:06:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Kundr=C3=A1t?= X-Patchwork-Id: 10186975 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7A525601D5 for ; Fri, 26 Jan 2018 20:13:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B49A28A28 for ; Fri, 26 Jan 2018 20:13:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FE6728BA0; Fri, 26 Jan 2018 20:13:32 +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=-5.2 required=2.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 EDEED28A28 for ; Fri, 26 Jan 2018 20:13:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752218AbeAZUNb (ORCPT ); Fri, 26 Jan 2018 15:13:31 -0500 Received: from office2.cesnet.cz ([195.113.144.244]:32880 "EHLO office2.cesnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752118AbeAZUNa (ORCPT ); Fri, 26 Jan 2018 15:13:30 -0500 Received: from localhost (unknown [IPv6:2001:718:1:2c:4c87:d4a8:de7f:541e]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by office2.cesnet.cz (Postfix) with ESMTPSA id 6B51A400068; Fri, 26 Jan 2018 21:13:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cesnet.cz; s=office2; t=1516997609; bh=JIYe0dVz+dmjFooyyhppJAxsyAJeJw5057eMRsz5UAI=; h=Resent-Date:Resent-From:Resent-To:Resent-Cc:In-Reply-To: References:From:Date:Subject:To:Cc; b=lftx9mN4+qmAOWyYkgEgTNFnjDBw5dieDYLOqv2/PH8aI8CUNj/rcs/Sglk0dxHhi sCE489qXpMtyvtD72tWCu5j8p7xQAJ539hIMJnWP2YnQULhMsrriw3hefa35MNg7Py OXhMo+m1oycSwOBWXy6VXuePoI1GswXSaiLl+Ofo= Message-Id: In-Reply-To: References: From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Fri, 26 Jan 2018 16:06:37 +0100 Subject: [PATCH 4/4] pinctrl: mcp23s08: spi: Fix duplicate pinctrl debugfs entries MIME-Version: 1.0 To: linux-gpio@vger.kernel.org Cc: linux-spi@vger.kernel.org, Linus Walleij , Phil Reid , Sebastian Reichel Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is a bit more involved because the pinctrl core so far always assumed that one device (with a unique dev_name) only contains a single pinctrl thing. This is not true for the mcp23s08 driver for chips connected over SPI. They have a "logical address" which means that several chips can share one physical CS signal. A downside of this patch are some possibly ugly names for the debugfs entries, such as "spi1.1-mcp23xxx-pinctrl.2", etc. Signed-off-by: Jan Kundrát --- drivers/pinctrl/core.c | 18 ++++++++++++++++-- drivers/pinctrl/pinctrl-mcp23s08.c | 9 ++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 4c8d5b23e4d0..dc7a77f2f9fe 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -1856,9 +1856,23 @@ static struct dentry *debugfs_root; static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev) { struct dentry *device_root; + const char *debugfs_name; + + if (pctldev->desc->name && + strcmp(dev_name(pctldev->dev), pctldev->desc->name)) { + debugfs_name = devm_kasprintf(pctldev->dev, GFP_KERNEL, + "%s-%s", dev_name(pctldev->dev), + pctldev->desc->name); + if (!debugfs_name) { + pr_warn("failed to determine debugfs dir name for %s\n", + dev_name(pctldev->dev)); + return; + } + } else { + debugfs_name = dev_name(pctldev->dev); + } - device_root = debugfs_create_dir(dev_name(pctldev->dev), - debugfs_root); + device_root = debugfs_create_dir(debugfs_name, debugfs_root); pctldev->device_root = device_root; if (IS_ERR(device_root) || !device_root) { diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c index c76c9d4b26c9..1f3971d02084 100644 --- a/drivers/pinctrl/pinctrl-mcp23s08.c +++ b/drivers/pinctrl/pinctrl-mcp23s08.c @@ -954,7 +954,14 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, goto fail; } - mcp->pinctrl_desc.name = "mcp23xxx-pinctrl"; + if (one_regmap_config) { + mcp->pinctrl_desc.name = devm_kasprintf(dev, GFP_KERNEL, + "mcp23xxx-pinctrl.%d", raw_chip_address); + if (!mcp->pinctrl_desc.name) + return -ENOMEM; + } else { + mcp->pinctrl_desc.name = "mcp23xxx-pinctrl"; + } mcp->pinctrl_desc.pctlops = &mcp_pinctrl_ops; mcp->pinctrl_desc.confops = &mcp_pinconf_ops; mcp->pinctrl_desc.npins = mcp->chip.ngpio;