Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <linux@treblig.org>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Link: https://lore.kernel.org/r/20241027205445.239108-1-linux@treblig.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Dr. David Alan Gilbert and committed by
Bjorn Andersson
e9a3682d a64dcfb4

+1 -134
+1 -45
Documentation/locking/hwspinlock.rst
··· 40 40 41 41 :: 42 42 43 - struct hwspinlock *hwspin_lock_request(void); 44 - 45 - Dynamically assign an hwspinlock and return its address, or NULL 46 - in case an unused hwspinlock isn't available. Users of this 47 - API will usually want to communicate the lock's id to the remote core 48 - before it can be used to achieve synchronization. 49 - 50 - Should be called from a process context (might sleep). 51 - 52 - :: 53 - 54 43 struct hwspinlock *hwspin_lock_request_specific(unsigned int id); 55 44 56 45 Assign a specific hwspinlock id and return its address, or NULL ··· 320 331 #include <linux/hwspinlock.h> 321 332 #include <linux/err.h> 322 333 323 - int hwspinlock_example1(void) 324 - { 325 - struct hwspinlock *hwlock; 326 - int ret; 327 - 328 - /* dynamically assign a hwspinlock */ 329 - hwlock = hwspin_lock_request(); 330 - if (!hwlock) 331 - ... 332 - 333 - id = hwspin_lock_get_id(hwlock); 334 - /* probably need to communicate id to a remote processor now */ 335 - 336 - /* take the lock, spin for 1 sec if it's already taken */ 337 - ret = hwspin_lock_timeout(hwlock, 1000); 338 - if (ret) 339 - ... 340 - 341 - /* 342 - * we took the lock, do our thing now, but do NOT sleep 343 - */ 344 - 345 - /* release the lock */ 346 - hwspin_unlock(hwlock); 347 - 348 - /* free the lock */ 349 - ret = hwspin_lock_free(hwlock); 350 - if (ret) 351 - ... 352 - 353 - return ret; 354 - } 355 - 356 - int hwspinlock_example2(void) 334 + int hwspinlock_example(void) 357 335 { 358 336 struct hwspinlock *hwlock; 359 337 int ret;
-77
drivers/hwspinlock/hwspinlock_core.c
··· 727 727 EXPORT_SYMBOL_GPL(hwspin_lock_get_id); 728 728 729 729 /** 730 - * hwspin_lock_request() - request an hwspinlock 731 - * 732 - * This function should be called by users of the hwspinlock device, 733 - * in order to dynamically assign them an unused hwspinlock. 734 - * Usually the user of this lock will then have to communicate the lock's id 735 - * to the remote core before it can be used for synchronization (to get the 736 - * id of a given hwlock, use hwspin_lock_get_id()). 737 - * 738 - * Should be called from a process context (might sleep) 739 - * 740 - * Returns: the address of the assigned hwspinlock, or %NULL on error 741 - */ 742 - struct hwspinlock *hwspin_lock_request(void) 743 - { 744 - struct hwspinlock *hwlock; 745 - int ret; 746 - 747 - mutex_lock(&hwspinlock_tree_lock); 748 - 749 - /* look for an unused lock */ 750 - ret = radix_tree_gang_lookup_tag(&hwspinlock_tree, (void **)&hwlock, 751 - 0, 1, HWSPINLOCK_UNUSED); 752 - if (ret == 0) { 753 - pr_warn("a free hwspinlock is not available\n"); 754 - hwlock = NULL; 755 - goto out; 756 - } 757 - 758 - /* sanity check that should never fail */ 759 - WARN_ON(ret > 1); 760 - 761 - /* mark as used and power up */ 762 - ret = __hwspin_lock_request(hwlock); 763 - if (ret < 0) 764 - hwlock = NULL; 765 - 766 - out: 767 - mutex_unlock(&hwspinlock_tree_lock); 768 - return hwlock; 769 - } 770 - EXPORT_SYMBOL_GPL(hwspin_lock_request); 771 - 772 - /** 773 730 * hwspin_lock_request_specific() - request for a specific hwspinlock 774 731 * @id: index of the specific hwspinlock that is requested 775 732 * ··· 868 911 return ret; 869 912 } 870 913 EXPORT_SYMBOL_GPL(devm_hwspin_lock_free); 871 - 872 - /** 873 - * devm_hwspin_lock_request() - request an hwspinlock for a managed device 874 - * @dev: the device to request an hwspinlock 875 - * 876 - * This function should be called by users of the hwspinlock device, 877 - * in order to dynamically assign them an unused hwspinlock. 878 - * Usually the user of this lock will then have to communicate the lock's id 879 - * to the remote core before it can be used for synchronization (to get the 880 - * id of a given hwlock, use hwspin_lock_get_id()). 881 - * 882 - * Should be called from a process context (might sleep) 883 - * 884 - * Returns: the address of the assigned hwspinlock, or %NULL on error 885 - */ 886 - struct hwspinlock *devm_hwspin_lock_request(struct device *dev) 887 - { 888 - struct hwspinlock **ptr, *hwlock; 889 - 890 - ptr = devres_alloc(devm_hwspin_lock_release, sizeof(*ptr), GFP_KERNEL); 891 - if (!ptr) 892 - return NULL; 893 - 894 - hwlock = hwspin_lock_request(); 895 - if (hwlock) { 896 - *ptr = hwlock; 897 - devres_add(dev, ptr); 898 - } else { 899 - devres_free(ptr); 900 - } 901 - 902 - return hwlock; 903 - } 904 - EXPORT_SYMBOL_GPL(devm_hwspin_lock_request); 905 914 906 915 /** 907 916 * devm_hwspin_lock_request_specific() - request for a specific hwspinlock for
-12
include/linux/hwspinlock.h
··· 58 58 int hwspin_lock_register(struct hwspinlock_device *bank, struct device *dev, 59 59 const struct hwspinlock_ops *ops, int base_id, int num_locks); 60 60 int hwspin_lock_unregister(struct hwspinlock_device *bank); 61 - struct hwspinlock *hwspin_lock_request(void); 62 61 struct hwspinlock *hwspin_lock_request_specific(unsigned int id); 63 62 int hwspin_lock_free(struct hwspinlock *hwlock); 64 63 int of_hwspin_lock_get_id(struct device_node *np, int index); ··· 69 70 int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name); 70 71 int hwspin_lock_bust(struct hwspinlock *hwlock, unsigned int id); 71 72 int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock); 72 - struct hwspinlock *devm_hwspin_lock_request(struct device *dev); 73 73 struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev, 74 74 unsigned int id); 75 75 int devm_hwspin_lock_unregister(struct device *dev, ··· 93 95 * Note: ERR_PTR(-ENODEV) will still be considered a success for NULL-checking 94 96 * users. Others, which care, can still check this with IS_ERR. 95 97 */ 96 - static inline struct hwspinlock *hwspin_lock_request(void) 97 - { 98 - return ERR_PTR(-ENODEV); 99 - } 100 - 101 98 static inline struct hwspinlock *hwspin_lock_request_specific(unsigned int id) 102 99 { 103 100 return ERR_PTR(-ENODEV); ··· 146 153 int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock) 147 154 { 148 155 return 0; 149 - } 150 - 151 - static inline struct hwspinlock *devm_hwspin_lock_request(struct device *dev) 152 - { 153 - return ERR_PTR(-ENODEV); 154 156 } 155 157 156 158 static inline