]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
hwspinlock: Add one new API to support getting a specific hwlock by the name
authorBaolin Wang <baolin.wang@linaro.org>
Fri, 22 Jun 2018 08:08:58 +0000 (16:08 +0800)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Tue, 26 Jun 2018 20:27:22 +0000 (13:27 -0700)
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>
drivers/hwspinlock/hwspinlock_core.c
include/linux/hwspinlock.h

index d16e6a3d38e8028b44b46322ede6a70d76769c96..bea358604bb220ecdab96ac317a7b462988f7699 100644 (file)
@@ -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;
index 57537e67b468c82d1c20a5150c0cf1e1f64f52ca..2b6f389a3133a7376c4d741594e0b6634707f561 100644 (file)
@@ -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 */
 
 /**