summaryrefslogtreecommitdiff
path: root/drivers/pinctrl/core.c
diff options
context:
space:
mode:
authorJan Kundrát <jan.kundrat@cesnet.cz>2018-01-26 18:06:37 +0300
committerLinus Walleij <linus.walleij@linaro.org>2018-02-12 12:47:24 +0300
commit1781af563aef66c2eb7cda65d754d2228321a260 (patch)
treee5a80f9cc589b9ab0c5788b83a35f4ba1eedd7a4 /drivers/pinctrl/core.c
parented231751413d4f33403f0bf0d5a957b41824f940 (diff)
downloadlinux-1781af563aef66c2eb7cda65d754d2228321a260.tar.xz
pinctrl: mcp23s08: spi: Fix duplicate pinctrl debugfs entries
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 <jan.kundrat@cesnet.cz> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/core.c')
-rw-r--r--drivers/pinctrl/core.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 2c0dbfcff3e6..d2b0329bc98a 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -1866,9 +1866,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) {