Skip to content

Commit e9a3682

Browse files
Dr. David Alan Gilbertandersson
authored andcommitted
hwspinlock: Remove unused (devm_)hwspin_lock_request()
devm_hwspin_lock_request() was added by 2018's commit 4f1acd7 ("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>
1 parent a64dcfb commit e9a3682

File tree

3 files changed

+1
-134
lines changed

3 files changed

+1
-134
lines changed

Documentation/locking/hwspinlock.rst

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,6 @@ independent, drivers.
3838
User API
3939
========
4040

41-
::
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-
5241
::
5342

5443
struct hwspinlock *hwspin_lock_request_specific(unsigned int id);
@@ -331,40 +320,7 @@ Typical usage
331320
#include <linux/hwspinlock.h>
332321
#include <linux/err.h>
333322

334-
int hwspinlock_example1(void)
335-
{
336-
struct hwspinlock *hwlock;
337-
int ret;
338-
339-
/* dynamically assign a hwspinlock */
340-
hwlock = hwspin_lock_request();
341-
if (!hwlock)
342-
...
343-
344-
id = hwspin_lock_get_id(hwlock);
345-
/* probably need to communicate id to a remote processor now */
346-
347-
/* take the lock, spin for 1 sec if it's already taken */
348-
ret = hwspin_lock_timeout(hwlock, 1000);
349-
if (ret)
350-
...
351-
352-
/*
353-
* we took the lock, do our thing now, but do NOT sleep
354-
*/
355-
356-
/* release the lock */
357-
hwspin_unlock(hwlock);
358-
359-
/* free the lock */
360-
ret = hwspin_lock_free(hwlock);
361-
if (ret)
362-
...
363-
364-
return ret;
365-
}
366-
367-
int hwspinlock_example2(void)
323+
int hwspinlock_example(void)
368324
{
369325
struct hwspinlock *hwlock;
370326
int ret;

drivers/hwspinlock/hwspinlock_core.c

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -726,49 +726,6 @@ int hwspin_lock_get_id(struct hwspinlock *hwlock)
726726
}
727727
EXPORT_SYMBOL_GPL(hwspin_lock_get_id);
728728

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-
772729
/**
773730
* hwspin_lock_request_specific() - request for a specific hwspinlock
774731
* @id: index of the specific hwspinlock that is requested
@@ -912,40 +869,6 @@ int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock)
912869
}
913870
EXPORT_SYMBOL_GPL(devm_hwspin_lock_free);
914871

915-
/**
916-
* devm_hwspin_lock_request() - request an hwspinlock for a managed device
917-
* @dev: the device to request an hwspinlock
918-
*
919-
* This function should be called by users of the hwspinlock device,
920-
* in order to dynamically assign them an unused hwspinlock.
921-
* Usually the user of this lock will then have to communicate the lock's id
922-
* to the remote core before it can be used for synchronization (to get the
923-
* id of a given hwlock, use hwspin_lock_get_id()).
924-
*
925-
* Should be called from a process context (might sleep)
926-
*
927-
* Returns: the address of the assigned hwspinlock, or %NULL on error
928-
*/
929-
struct hwspinlock *devm_hwspin_lock_request(struct device *dev)
930-
{
931-
struct hwspinlock **ptr, *hwlock;
932-
933-
ptr = devres_alloc(devm_hwspin_lock_release, sizeof(*ptr), GFP_KERNEL);
934-
if (!ptr)
935-
return NULL;
936-
937-
hwlock = hwspin_lock_request();
938-
if (hwlock) {
939-
*ptr = hwlock;
940-
devres_add(dev, ptr);
941-
} else {
942-
devres_free(ptr);
943-
}
944-
945-
return hwlock;
946-
}
947-
EXPORT_SYMBOL_GPL(devm_hwspin_lock_request);
948-
949872
/**
950873
* devm_hwspin_lock_request_specific() - request for a specific hwspinlock for
951874
* a managed device

include/linux/hwspinlock.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ struct hwspinlock_pdata {
5858
int hwspin_lock_register(struct hwspinlock_device *bank, struct device *dev,
5959
const struct hwspinlock_ops *ops, int base_id, int num_locks);
6060
int hwspin_lock_unregister(struct hwspinlock_device *bank);
61-
struct hwspinlock *hwspin_lock_request(void);
6261
struct hwspinlock *hwspin_lock_request_specific(unsigned int id);
6362
int hwspin_lock_free(struct hwspinlock *hwlock);
6463
int of_hwspin_lock_get_id(struct device_node *np, int index);
@@ -70,7 +69,6 @@ void __hwspin_unlock(struct hwspinlock *, int, unsigned long *);
7069
int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name);
7170
int hwspin_lock_bust(struct hwspinlock *hwlock, unsigned int id);
7271
int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock);
73-
struct hwspinlock *devm_hwspin_lock_request(struct device *dev);
7472
struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev,
7573
unsigned int id);
7674
int devm_hwspin_lock_unregister(struct device *dev,
@@ -95,11 +93,6 @@ int devm_hwspin_lock_register(struct device *dev,
9593
* Note: ERR_PTR(-ENODEV) will still be considered a success for NULL-checking
9694
* users. Others, which care, can still check this with IS_ERR.
9795
*/
98-
static inline struct hwspinlock *hwspin_lock_request(void)
99-
{
100-
return ERR_PTR(-ENODEV);
101-
}
102-
10396
static inline struct hwspinlock *hwspin_lock_request_specific(unsigned int id)
10497
{
10598
return ERR_PTR(-ENODEV);
@@ -155,11 +148,6 @@ int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock)
155148
return 0;
156149
}
157150

158-
static inline struct hwspinlock *devm_hwspin_lock_request(struct device *dev)
159-
{
160-
return ERR_PTR(-ENODEV);
161-
}
162-
163151
static inline
164152
struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev,
165153
unsigned int id)

0 commit comments

Comments
 (0)