diff options
author | Baolin Wang <baolin.wang@linaro.org> | 2018-06-22 04:08:58 -0400 |
---|---|---|
committer | Bjorn Andersson <bjorn.andersson@linaro.org> | 2018-06-26 16:27:22 -0400 |
commit | 5560f70cad996e7d90d1c141bcbca0df214eefc9 (patch) | |
tree | 4f53b895271a5699eb86b9b6fa6c254b9d976aeb | |
parent | ce397d215ccd07b8ae3f71db689aedb85d56ab40 (diff) |
hwspinlock: Add one new API to support getting a specific hwlock by the name
The hardware spinlock binding already supplied the 'hwlock-names' property
to match and get a specific hwlock, but did not supply one API for users
to get a specific hwlock by the hwlock name. So this patch introduces one
API to support this requirement.
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
-rw-r--r-- | drivers/hwspinlock/hwspinlock_core.c | 29 | ||||
-rw-r--r-- | include/linux/hwspinlock.h | 7 |
2 files changed, 36 insertions, 0 deletions
diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c index d16e6a3d38e8..bea358604bb2 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c | |||
@@ -367,6 +367,35 @@ out: | |||
367 | } | 367 | } |
368 | EXPORT_SYMBOL_GPL(of_hwspin_lock_get_id); | 368 | EXPORT_SYMBOL_GPL(of_hwspin_lock_get_id); |
369 | 369 | ||
370 | /** | ||
371 | * of_hwspin_lock_get_id_byname() - get lock id for an specified hwlock name | ||
372 | * @np: device node from which to request the specific hwlock | ||
373 | * @name: hwlock name | ||
374 | * | ||
375 | * This function provides a means for DT users of the hwspinlock module to | ||
376 | * get the global lock id of a specific hwspinlock using the specified name of | ||
377 | * the hwspinlock device, so that it can be requested using the normal | ||
378 | * hwspin_lock_request_specific() API. | ||
379 | * | ||
380 | * Returns the global lock id number on success, -EPROBE_DEFER if the hwspinlock | ||
381 | * device is not yet registered, -EINVAL on invalid args specifier value or an | ||
382 | * appropriate error as returned from the OF parsing of the DT client node. | ||
383 | */ | ||
384 | int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name) | ||
385 | { | ||
386 | int index; | ||
387 | |||
388 | if (!name) | ||
389 | return -EINVAL; | ||
390 | |||
391 | index = of_property_match_string(np, "hwlock-names", name); | ||
392 | if (index < 0) | ||
393 | return index; | ||
394 | |||
395 | return of_hwspin_lock_get_id(np, index); | ||
396 | } | ||
397 | EXPORT_SYMBOL_GPL(of_hwspin_lock_get_id_byname); | ||
398 | |||
370 | static int hwspin_lock_register_single(struct hwspinlock *hwlock, int id) | 399 | static int hwspin_lock_register_single(struct hwspinlock *hwlock, int id) |
371 | { | 400 | { |
372 | struct hwspinlock *tmp; | 401 | struct hwspinlock *tmp; |
diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h index 57537e67b468..2b6f389a3133 100644 --- a/include/linux/hwspinlock.h +++ b/include/linux/hwspinlock.h | |||
@@ -66,6 +66,7 @@ int __hwspin_lock_timeout(struct hwspinlock *, unsigned int, int, | |||
66 | unsigned long *); | 66 | unsigned long *); |
67 | int __hwspin_trylock(struct hwspinlock *, int, unsigned long *); | 67 | int __hwspin_trylock(struct hwspinlock *, int, unsigned long *); |
68 | void __hwspin_unlock(struct hwspinlock *, int, unsigned long *); | 68 | void __hwspin_unlock(struct hwspinlock *, int, unsigned long *); |
69 | int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name); | ||
69 | 70 | ||
70 | #else /* !CONFIG_HWSPINLOCK */ | 71 | #else /* !CONFIG_HWSPINLOCK */ |
71 | 72 | ||
@@ -125,6 +126,12 @@ static inline int hwspin_lock_get_id(struct hwspinlock *hwlock) | |||
125 | return 0; | 126 | return 0; |
126 | } | 127 | } |
127 | 128 | ||
129 | static inline | ||
130 | int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name) | ||
131 | { | ||
132 | return 0; | ||
133 | } | ||
134 | |||
128 | #endif /* !CONFIG_HWSPINLOCK */ | 135 | #endif /* !CONFIG_HWSPINLOCK */ |
129 | 136 | ||
130 | /** | 137 | /** |