All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/8] hwspinlock: Add one new API to support getting a specific hwlock by the name
@ 2018-06-22  8:08 Baolin Wang
  2018-06-22  8:08 ` [PATCH 2/8] hwspinlock: Add devm_xxx() APIs to request/free hwlock Baolin Wang
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Baolin Wang @ 2018-06-22  8:08 UTC (permalink / raw)
  To: ohad, bjorn.andersson, broonie
  Cc: baolin.wang, linux-spi, linux-remoteproc, linux-kernel

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>
---
 drivers/hwspinlock/hwspinlock_core.c |   29 +++++++++++++++++++++++++++++
 include/linux/hwspinlock.h           |    7 +++++++
 2 files changed, 36 insertions(+)

diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c
index d16e6a3..bea3586 100644
--- a/drivers/hwspinlock/hwspinlock_core.c
+++ b/drivers/hwspinlock/hwspinlock_core.c
@@ -367,6 +367,35 @@ int of_hwspin_lock_get_id(struct device_node *np, int index)
 }
 EXPORT_SYMBOL_GPL(of_hwspin_lock_get_id);
 
+/**
+ * of_hwspin_lock_get_id_byname() - get lock id for an specified hwlock name
+ * @np: device node from which to request the specific hwlock
+ * @name: hwlock name
+ *
+ * This function provides a means for DT users of the hwspinlock module to
+ * get the global lock id of a specific hwspinlock using the specified name of
+ * the hwspinlock device, so that it can be requested using the normal
+ * hwspin_lock_request_specific() API.
+ *
+ * Returns the global lock id number on success, -EPROBE_DEFER if the hwspinlock
+ * device is not yet registered, -EINVAL on invalid args specifier value or an
+ * appropriate error as returned from the OF parsing of the DT client node.
+ */
+int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name)
+{
+	int index;
+
+	if (!name)
+		return -EINVAL;
+
+	index = of_property_match_string(np, "hwlock-names", name);
+	if (index < 0)
+		return index;
+
+	return of_hwspin_lock_get_id(np, index);
+}
+EXPORT_SYMBOL_GPL(of_hwspin_lock_get_id_byname);
+
 static int hwspin_lock_register_single(struct hwspinlock *hwlock, int id)
 {
 	struct hwspinlock *tmp;
diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h
index 57537e6..2b6f389 100644
--- a/include/linux/hwspinlock.h
+++ b/include/linux/hwspinlock.h
@@ -66,6 +66,7 @@ int __hwspin_lock_timeout(struct hwspinlock *, unsigned int, int,
 							unsigned long *);
 int __hwspin_trylock(struct hwspinlock *, int, unsigned long *);
 void __hwspin_unlock(struct hwspinlock *, int, unsigned long *);
+int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name);
 
 #else /* !CONFIG_HWSPINLOCK */
 
@@ -125,6 +126,12 @@ static inline int hwspin_lock_get_id(struct hwspinlock *hwlock)
 	return 0;
 }
 
+static inline
+int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name)
+{
+	return 0;
+}
+
 #endif /* !CONFIG_HWSPINLOCK */
 
 /**
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-06-27  2:18 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-22  8:08 [PATCH 1/8] hwspinlock: Add one new API to support getting a specific hwlock by the name Baolin Wang
2018-06-22  8:08 ` [PATCH 2/8] hwspinlock: Add devm_xxx() APIs to request/free hwlock Baolin Wang
2018-06-22  8:09 ` [PATCH 3/8] hwspinlock: Add devm_xxx() APIs to register/unregister one hwlock controller Baolin Wang
2018-06-22  8:09 ` [PATCH 4/8] hwspinlock: Remove redundant config Baolin Wang
2018-06-22  8:09 ` [PATCH 5/8] hwspinlock: Fix one comment mistake Baolin Wang
2018-06-22  8:09 ` [PATCH 6/8] hwspinlock: sprd: Use devm_hwspin_lock_register() Baolin Wang
2018-06-26 20:51   ` Bjorn Andersson
2018-06-27  2:17     ` Baolin Wang
2018-06-22  8:09 ` [PATCH 7/8] spi: sprd: Replace of_hwspin_lock_get_id() with of_hwspin_lock_get_id_byname() Baolin Wang
2018-06-25 12:47   ` Mark Brown
2018-06-22  8:09 ` [PATCH 8/8] spi: sprd: Change to use devm_hwspin_lock_request_specific() Baolin Wang
2018-06-25 12:47   ` Mark Brown
2018-06-26 20:54 ` [PATCH 1/8] hwspinlock: Add one new API to support getting a specific hwlock by the name Bjorn Andersson
2018-06-26 20:54   ` Bjorn Andersson
2018-06-27  2:18   ` Baolin Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.