From e9a3682d17d5afee697fc95d3fa342d740767fad Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Sun, 27 Oct 2024 20:54:45 +0000 Subject: hwspinlock: Remove unused (devm_)hwspin_lock_request() devm_hwspin_lock_request() was added by 2018's commit 4f1acd758b08 ("hwspinlock: Add devm_xxx() APIs to request/free hwlock") however, it's never been used, everyone uses the devm_hwspin_lock_request_specific() call instead. Remove it. Similarly, the none-devm variant isn't used. Remove it, and the referring documentation. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Baolin Wang Link: https://lore.kernel.org/r/20241027205445.239108-1-linux@treblig.org Signed-off-by: Bjorn Andersson --- drivers/hwspinlock/hwspinlock_core.c | 77 ------------------------------------ 1 file changed, 77 deletions(-) (limited to 'drivers') diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c index 6505261e6068..f000432ce21d 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -726,49 +726,6 @@ int hwspin_lock_get_id(struct hwspinlock *hwlock) } EXPORT_SYMBOL_GPL(hwspin_lock_get_id); -/** - * hwspin_lock_request() - request an hwspinlock - * - * This function should be called by users of the hwspinlock device, - * in order to dynamically assign them an unused hwspinlock. - * Usually the user of this lock will then have to communicate the lock's id - * to the remote core before it can be used for synchronization (to get the - * id of a given hwlock, use hwspin_lock_get_id()). - * - * Should be called from a process context (might sleep) - * - * Returns: the address of the assigned hwspinlock, or %NULL on error - */ -struct hwspinlock *hwspin_lock_request(void) -{ - struct hwspinlock *hwlock; - int ret; - - mutex_lock(&hwspinlock_tree_lock); - - /* look for an unused lock */ - ret = radix_tree_gang_lookup_tag(&hwspinlock_tree, (void **)&hwlock, - 0, 1, HWSPINLOCK_UNUSED); - if (ret == 0) { - pr_warn("a free hwspinlock is not available\n"); - hwlock = NULL; - goto out; - } - - /* sanity check that should never fail */ - WARN_ON(ret > 1); - - /* mark as used and power up */ - ret = __hwspin_lock_request(hwlock); - if (ret < 0) - hwlock = NULL; - -out: - mutex_unlock(&hwspinlock_tree_lock); - return hwlock; -} -EXPORT_SYMBOL_GPL(hwspin_lock_request); - /** * hwspin_lock_request_specific() - request for a specific hwspinlock * @id: index of the specific hwspinlock that is requested @@ -912,40 +869,6 @@ int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock) } EXPORT_SYMBOL_GPL(devm_hwspin_lock_free); -/** - * devm_hwspin_lock_request() - request an hwspinlock for a managed device - * @dev: the device to request an hwspinlock - * - * This function should be called by users of the hwspinlock device, - * in order to dynamically assign them an unused hwspinlock. - * Usually the user of this lock will then have to communicate the lock's id - * to the remote core before it can be used for synchronization (to get the - * id of a given hwlock, use hwspin_lock_get_id()). - * - * Should be called from a process context (might sleep) - * - * Returns: the address of the assigned hwspinlock, or %NULL on error - */ -struct hwspinlock *devm_hwspin_lock_request(struct device *dev) -{ - struct hwspinlock **ptr, *hwlock; - - ptr = devres_alloc(devm_hwspin_lock_release, sizeof(*ptr), GFP_KERNEL); - if (!ptr) - return NULL; - - hwlock = hwspin_lock_request(); - if (hwlock) { - *ptr = hwlock; - devres_add(dev, ptr); - } else { - devres_free(ptr); - } - - return hwlock; -} -EXPORT_SYMBOL_GPL(devm_hwspin_lock_request); - /** * devm_hwspin_lock_request_specific() - request for a specific hwspinlock for * a managed device -- cgit v1.2.3-59-g8ed1b From fec04edb74126f21ac628c7be763c97deb49f69d Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Sun, 15 Dec 2024 02:20:23 +0000 Subject: hwspinlock: Remove unused hwspin_lock_get_id() hwspin_lock_get_id() has been unused since the original 2011 commit bd9a4c7df256 ("drivers: hwspinlock: add framework") Remove it and the corresponding docs. Note that the of_hwspin_lock_get_id() version is still in use, so leave that alone. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Baolin Wang Link: https://lore.kernel.org/r/20241215022023.181435-1-linux@treblig.org Signed-off-by: Bjorn Andersson --- Documentation/locking/hwspinlock.rst | 11 ----------- drivers/hwspinlock/hwspinlock_core.c | 17 ----------------- include/linux/hwspinlock.h | 6 ------ 3 files changed, 34 deletions(-) (limited to 'drivers') diff --git a/Documentation/locking/hwspinlock.rst b/Documentation/locking/hwspinlock.rst index d482422d7a38..a737c702a7d1 100644 --- a/Documentation/locking/hwspinlock.rst +++ b/Documentation/locking/hwspinlock.rst @@ -301,17 +301,6 @@ The caller should **never** unlock an hwspinlock which is already unlocked. Doing so is considered a bug (there is no protection against this). This function will never sleep. -:: - - int hwspin_lock_get_id(struct hwspinlock *hwlock); - -Retrieve id number of a given hwspinlock. This is needed when an -hwspinlock is dynamically assigned: before it can be used to achieve -mutual exclusion with a remote cpu, the id number should be communicated -to the remote task with which we want to synchronize. - -Returns the hwspinlock id number, or -EINVAL if hwlock is null. - Typical usage ============= diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c index f000432ce21d..cc8e952a6772 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -709,23 +709,6 @@ static int __hwspin_lock_request(struct hwspinlock *hwlock) return ret; } -/** - * hwspin_lock_get_id() - retrieve id number of a given hwspinlock - * @hwlock: a valid hwspinlock instance - * - * Returns: the id number of a given @hwlock, or -EINVAL if @hwlock is invalid. - */ -int hwspin_lock_get_id(struct hwspinlock *hwlock) -{ - if (!hwlock) { - pr_err("invalid hwlock\n"); - return -EINVAL; - } - - return hwlock_to_id(hwlock); -} -EXPORT_SYMBOL_GPL(hwspin_lock_get_id); - /** * hwspin_lock_request_specific() - request for a specific hwspinlock * @id: index of the specific hwspinlock that is requested diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h index 2f32d768dfd9..f35b42e8c5de 100644 --- a/include/linux/hwspinlock.h +++ b/include/linux/hwspinlock.h @@ -61,7 +61,6 @@ int hwspin_lock_unregister(struct hwspinlock_device *bank); struct hwspinlock *hwspin_lock_request_specific(unsigned int id); int hwspin_lock_free(struct hwspinlock *hwlock); int of_hwspin_lock_get_id(struct device_node *np, int index); -int hwspin_lock_get_id(struct hwspinlock *hwlock); int __hwspin_lock_timeout(struct hwspinlock *, unsigned int, int, unsigned long *); int __hwspin_trylock(struct hwspinlock *, int, unsigned long *); @@ -131,11 +130,6 @@ static inline int of_hwspin_lock_get_id(struct device_node *np, int index) return 0; } -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) { -- cgit v1.2.3-59-g8ed1b