diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2011-12-14 23:33:37 +0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-01-03 12:10:06 +0400 |
commit | ca53c5f1ca5c936777caca46b7c716a40682ce83 (patch) | |
tree | 14cc56944d442c8b509b2ad1e9d350617b98cf47 /drivers/pinctrl/core.c | |
parent | 23750196ef472e9249958d5165b0bb292518c710 (diff) | |
download | linux-ca53c5f1ca5c936777caca46b7c716a40682ce83.tar.xz |
pinctrl: conjure names for unnamed pins
If pins with blank names are registered, we assign them names on-the-fly
on the form "PINn" where n is the pin number for that pin on the specific
controller.
Acked-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/core.c')
-rw-r--r-- | drivers/pinctrl/core.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 160fb5aae591..9e32ea311432 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -158,6 +158,8 @@ static void pinctrl_free_pindescs(struct pinctrl_dev *pctldev, if (pindesc != NULL) { radix_tree_delete(&pctldev->pin_desc_tree, pins[i].number); + if (pindesc->dynamic_name) + kfree(pindesc->name); } kfree(pindesc); } @@ -186,13 +188,20 @@ static int pinctrl_register_one_pin(struct pinctrl_dev *pctldev, pindesc->pctldev = pctldev; /* Copy basic pin info */ - pindesc->name = name; + if (pindesc->name) { + pindesc->name = name; + } else { + pindesc->name = kasprintf(GFP_KERNEL, "PIN%u", number); + if (pindesc->name == NULL) + return -ENOMEM; + pindesc->dynamic_name = true; + } spin_lock(&pctldev->pin_desc_tree_lock); radix_tree_insert(&pctldev->pin_desc_tree, number, pindesc); spin_unlock(&pctldev->pin_desc_tree_lock); pr_debug("registered pin %d (%s) on %s\n", - number, name ? name : "(unnamed)", pctldev->desc->name); + number, pindesc->name, pctldev->desc->name); return 0; } |