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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'hwlock-v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux

Pull hwspinlock updates from Bjorn Andersson:
"Drop a few unused functions from the hwspinlock framework"

* tag 'hwlock-v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux:
hwspinlock: Remove unused hwspin_lock_get_id()
hwspinlock: Remove unused (devm_)hwspin_lock_request()

+1 -168
+1 -56
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 ··· 301 312 Doing so is considered a bug (there is no protection against this). 302 313 This function will never sleep. 303 314 304 - :: 305 - 306 - int hwspin_lock_get_id(struct hwspinlock *hwlock); 307 - 308 - Retrieve id number of a given hwspinlock. This is needed when an 309 - hwspinlock is dynamically assigned: before it can be used to achieve 310 - mutual exclusion with a remote cpu, the id number should be communicated 311 - to the remote task with which we want to synchronize. 312 - 313 - Returns the hwspinlock id number, or -EINVAL if hwlock is null. 314 - 315 315 Typical usage 316 316 ============= 317 317 ··· 309 331 #include <linux/hwspinlock.h> 310 332 #include <linux/err.h> 311 333 312 - int hwspinlock_example1(void) 313 - { 314 - struct hwspinlock *hwlock; 315 - int ret; 316 - 317 - /* dynamically assign a hwspinlock */ 318 - hwlock = hwspin_lock_request(); 319 - if (!hwlock) 320 - ... 321 - 322 - id = hwspin_lock_get_id(hwlock); 323 - /* probably need to communicate id to a remote processor now */ 324 - 325 - /* take the lock, spin for 1 sec if it's already taken */ 326 - ret = hwspin_lock_timeout(hwlock, 1000); 327 - if (ret) 328 - ... 329 - 330 - /* 331 - * we took the lock, do our thing now, but do NOT sleep 332 - */ 333 - 334 - /* release the lock */ 335 - hwspin_unlock(hwlock); 336 - 337 - /* free the lock */ 338 - ret = hwspin_lock_free(hwlock); 339 - if (ret) 340 - ... 341 - 342 - return ret; 343 - } 344 - 345 - int hwspinlock_example2(void) 334 + int hwspinlock_example(void) 346 335 { 347 336 struct hwspinlock *hwlock; 348 337 int ret;
-94
drivers/hwspinlock/hwspinlock_core.c
··· 710 710 } 711 711 712 712 /** 713 - * hwspin_lock_get_id() - retrieve id number of a given hwspinlock 714 - * @hwlock: a valid hwspinlock instance 715 - * 716 - * Returns: the id number of a given @hwlock, or -EINVAL if @hwlock is invalid. 717 - */ 718 - int hwspin_lock_get_id(struct hwspinlock *hwlock) 719 - { 720 - if (!hwlock) { 721 - pr_err("invalid hwlock\n"); 722 - return -EINVAL; 723 - } 724 - 725 - return hwlock_to_id(hwlock); 726 - } 727 - EXPORT_SYMBOL_GPL(hwspin_lock_get_id); 728 - 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 713 * hwspin_lock_request_specific() - request for a specific hwspinlock 774 714 * @id: index of the specific hwspinlock that is requested 775 715 * ··· 851 911 return ret; 852 912 } 853 913 EXPORT_SYMBOL_GPL(devm_hwspin_lock_free); 854 - 855 - /** 856 - * devm_hwspin_lock_request() - request an hwspinlock for a managed device 857 - * @dev: the device to request an hwspinlock 858 - * 859 - * This function should be called by users of the hwspinlock device, 860 - * in order to dynamically assign them an unused hwspinlock. 861 - * Usually the user of this lock will then have to communicate the lock's id 862 - * to the remote core before it can be used for synchronization (to get the 863 - * id of a given hwlock, use hwspin_lock_get_id()). 864 - * 865 - * Should be called from a process context (might sleep) 866 - * 867 - * Returns: the address of the assigned hwspinlock, or %NULL on error 868 - */ 869 - struct hwspinlock *devm_hwspin_lock_request(struct device *dev) 870 - { 871 - struct hwspinlock **ptr, *hwlock; 872 - 873 - ptr = devres_alloc(devm_hwspin_lock_release, sizeof(*ptr), GFP_KERNEL); 874 - if (!ptr) 875 - return NULL; 876 - 877 - hwlock = hwspin_lock_request(); 878 - if (hwlock) { 879 - *ptr = hwlock; 880 - devres_add(dev, ptr); 881 - } else { 882 - devres_free(ptr); 883 - } 884 - 885 - return hwlock; 886 - } 887 - EXPORT_SYMBOL_GPL(devm_hwspin_lock_request); 888 914 889 915 /** 890 916 * devm_hwspin_lock_request_specific() - request for a specific hwspinlock for
-18
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); 65 - int hwspin_lock_get_id(struct hwspinlock *hwlock); 66 64 int __hwspin_lock_timeout(struct hwspinlock *, unsigned int, int, 67 65 unsigned long *); 68 66 int __hwspin_trylock(struct hwspinlock *, int, unsigned long *); ··· 68 70 int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name); 69 71 int hwspin_lock_bust(struct hwspinlock *hwlock, unsigned int id); 70 72 int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock); 71 - struct hwspinlock *devm_hwspin_lock_request(struct device *dev); 72 73 struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev, 73 74 unsigned int id); 74 75 int devm_hwspin_lock_unregister(struct device *dev, ··· 92 95 * Note: ERR_PTR(-ENODEV) will still be considered a success for NULL-checking 93 96 * users. Others, which care, can still check this with IS_ERR. 94 97 */ 95 - static inline struct hwspinlock *hwspin_lock_request(void) 96 - { 97 - return ERR_PTR(-ENODEV); 98 - } 99 - 100 98 static inline struct hwspinlock *hwspin_lock_request_specific(unsigned int id) 101 99 { 102 100 return ERR_PTR(-ENODEV); ··· 130 138 return 0; 131 139 } 132 140 133 - static inline int hwspin_lock_get_id(struct hwspinlock *hwlock) 134 - { 135 - return 0; 136 - } 137 - 138 141 static inline 139 142 int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name) 140 143 { ··· 140 153 int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock) 141 154 { 142 155 return 0; 143 - } 144 - 145 - static inline struct hwspinlock *devm_hwspin_lock_request(struct device *dev) 146 - { 147 - return ERR_PTR(-ENODEV); 148 156 } 149 157 150 158 static inline