diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2011-12-14 14:33:37 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-01-03 03:10:06 -0500 |
commit | ca53c5f1ca5c936777caca46b7c716a40682ce83 (patch) | |
tree | 14cc56944d442c8b509b2ad1e9d350617b98cf47 | |
parent | 23750196ef472e9249958d5165b0bb292518c710 (diff) |
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>
-rw-r--r-- | drivers/pinctrl/core.c | 13 | ||||
-rw-r--r-- | drivers/pinctrl/core.h | 2 |
2 files changed, 13 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, | |||
158 | if (pindesc != NULL) { | 158 | if (pindesc != NULL) { |
159 | radix_tree_delete(&pctldev->pin_desc_tree, | 159 | radix_tree_delete(&pctldev->pin_desc_tree, |
160 | pins[i].number); | 160 | pins[i].number); |
161 | if (pindesc->dynamic_name) | ||
162 | kfree(pindesc->name); | ||
161 | } | 163 | } |
162 | kfree(pindesc); | 164 | kfree(pindesc); |
163 | } | 165 | } |
@@ -186,13 +188,20 @@ static int pinctrl_register_one_pin(struct pinctrl_dev *pctldev, | |||
186 | pindesc->pctldev = pctldev; | 188 | pindesc->pctldev = pctldev; |
187 | 189 | ||
188 | /* Copy basic pin info */ | 190 | /* Copy basic pin info */ |
189 | pindesc->name = name; | 191 | if (pindesc->name) { |
192 | pindesc->name = name; | ||
193 | } else { | ||
194 | pindesc->name = kasprintf(GFP_KERNEL, "PIN%u", number); | ||
195 | if (pindesc->name == NULL) | ||
196 | return -ENOMEM; | ||
197 | pindesc->dynamic_name = true; | ||
198 | } | ||
190 | 199 | ||
191 | spin_lock(&pctldev->pin_desc_tree_lock); | 200 | spin_lock(&pctldev->pin_desc_tree_lock); |
192 | radix_tree_insert(&pctldev->pin_desc_tree, number, pindesc); | 201 | radix_tree_insert(&pctldev->pin_desc_tree, number, pindesc); |
193 | spin_unlock(&pctldev->pin_desc_tree_lock); | 202 | spin_unlock(&pctldev->pin_desc_tree_lock); |
194 | pr_debug("registered pin %d (%s) on %s\n", | 203 | pr_debug("registered pin %d (%s) on %s\n", |
195 | number, name ? name : "(unnamed)", pctldev->desc->name); | 204 | number, pindesc->name, pctldev->desc->name); |
196 | return 0; | 205 | return 0; |
197 | } | 206 | } |
198 | 207 | ||
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h index 5375582566a5..177a3310547f 100644 --- a/drivers/pinctrl/core.h +++ b/drivers/pinctrl/core.h | |||
@@ -52,6 +52,7 @@ struct pinctrl_dev { | |||
52 | * @pctldev: corresponding pin control device | 52 | * @pctldev: corresponding pin control device |
53 | * @name: a name for the pin, e.g. the name of the pin/pad/finger on a | 53 | * @name: a name for the pin, e.g. the name of the pin/pad/finger on a |
54 | * datasheet or such | 54 | * datasheet or such |
55 | * @dynamic_name: if the name of this pin was dynamically allocated | ||
55 | * @lock: a lock to protect the descriptor structure | 56 | * @lock: a lock to protect the descriptor structure |
56 | * @mux_requested: whether the pin is already requested by pinmux or not | 57 | * @mux_requested: whether the pin is already requested by pinmux or not |
57 | * @mux_function: a named muxing function for the pin that will be passed to | 58 | * @mux_function: a named muxing function for the pin that will be passed to |
@@ -60,6 +61,7 @@ struct pinctrl_dev { | |||
60 | struct pin_desc { | 61 | struct pin_desc { |
61 | struct pinctrl_dev *pctldev; | 62 | struct pinctrl_dev *pctldev; |
62 | const char *name; | 63 | const char *name; |
64 | bool dynamic_name; | ||
63 | spinlock_t lock; | 65 | spinlock_t lock; |
64 | /* These fields only added when supporting pinmux drivers */ | 66 | /* These fields only added when supporting pinmux drivers */ |
65 | #ifdef CONFIG_PINMUX | 67 | #ifdef CONFIG_PINMUX |