1
0
mirror of https://github.com/torvalds/linux.git synced 2025-04-12 06:49:52 +00:00

hwspinlock updates for v6.15

Drop a few unused functions from the hwspinlock framework.
 -----BEGIN PGP SIGNATURE-----
 
 iQJJBAABCAAzFiEEBd4DzF816k8JZtUlCx85Pw2ZrcUFAmfm2aAVHGFuZGVyc3Nv
 bkBrZXJuZWwub3JnAAoJEAsfOT8Nma3FuaEP/1HcAyFY4DaMZBvOWFiTgFpr0k50
 m6hERW3JBC/67oib7xMRG8orNhLoUQIrBlylz/lxUNXbo4sR0t8TpB2v4Urk+P36
 ub1GggnTcFA+3GC9vm2ji3d5jg8VSXdM30cJlQZHEZ3KYAufFAog/epX4Dzmd6Vn
 SdtxQLZ4gyZ2FtEI6mQ2TINSQDrKUdSmuqgt8WhXQ9oMjc249paQkNuXVUsunWMJ
 Ag9t0ht8Jhhl7F8QFADXty7lYtgio+1xn7Sm58F+rkzee/v4I5kka3YGzhN2EBC/
 VD/XYauG7/zuw2nzYzUTMYud6h1Bpc9pIRmh/m4r+vfjCadX5VRm726qrJQOBDyq
 Xb+5fm6jtlFnKGvD/amGpL52IdHuD3Vrhtw1NFJdzh4f8IaTakY7Qlk/Cs78uI7Z
 qas1EyfoAQQRajrVV2v7hjIi18h3TAJMRqXyFl4N6S2JJ2WkRzFzdQOfoyz/Zlwc
 txJZLtqvgoJXq5eU0UQmKodWwU4ksPXw0zz7GD+eKDD+gEwAvp5sloSgSEyzhhuw
 /QSlZXrAu6NBScmt1OC6IPjAkph/eTrICUVUZAG7gylx5gcVlMTqon0+NGtcn+wp
 tEHdiPzIRyI9qIxIFDWzSgvVrwNDQXNiXPc/yG0bCm5iP00NAp/1HyQtchFMW2sg
 rMNMuQIFiTt4n8qq
 =1rM7
 -----END PGP SIGNATURE-----

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()
This commit is contained in:
Linus Torvalds 2025-03-29 17:17:01 -07:00
commit 7d4eca7ac5
3 changed files with 1 additions and 168 deletions
Documentation/locking
drivers/hwspinlock
include/linux

@ -38,17 +38,6 @@ independent, drivers.
User API
========
::
struct hwspinlock *hwspin_lock_request(void);
Dynamically assign an hwspinlock and return its address, or NULL
in case an unused hwspinlock isn't available. Users of this
API will usually want to communicate the lock's id to the remote core
before it can be used to achieve synchronization.
Should be called from a process context (might sleep).
::
struct hwspinlock *hwspin_lock_request_specific(unsigned int id);
@ -312,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
=============
@ -331,40 +309,7 @@ Typical usage
#include <linux/hwspinlock.h>
#include <linux/err.h>
int hwspinlock_example1(void)
{
struct hwspinlock *hwlock;
int ret;
/* dynamically assign a hwspinlock */
hwlock = hwspin_lock_request();
if (!hwlock)
...
id = hwspin_lock_get_id(hwlock);
/* probably need to communicate id to a remote processor now */
/* take the lock, spin for 1 sec if it's already taken */
ret = hwspin_lock_timeout(hwlock, 1000);
if (ret)
...
/*
* we took the lock, do our thing now, but do NOT sleep
*/
/* release the lock */
hwspin_unlock(hwlock);
/* free the lock */
ret = hwspin_lock_free(hwlock);
if (ret)
...
return ret;
}
int hwspinlock_example2(void)
int hwspinlock_example(void)
{
struct hwspinlock *hwlock;
int ret;

@ -709,66 +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() - 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 +852,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

@ -58,11 +58,9 @@ struct hwspinlock_pdata {
int hwspin_lock_register(struct hwspinlock_device *bank, struct device *dev,
const struct hwspinlock_ops *ops, int base_id, int num_locks);
int hwspin_lock_unregister(struct hwspinlock_device *bank);
struct hwspinlock *hwspin_lock_request(void);
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 *);
@ -70,7 +68,6 @@ void __hwspin_unlock(struct hwspinlock *, int, unsigned long *);
int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name);
int hwspin_lock_bust(struct hwspinlock *hwlock, unsigned int id);
int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock);
struct hwspinlock *devm_hwspin_lock_request(struct device *dev);
struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev,
unsigned int id);
int devm_hwspin_lock_unregister(struct device *dev,
@ -95,11 +92,6 @@ int devm_hwspin_lock_register(struct device *dev,
* Note: ERR_PTR(-ENODEV) will still be considered a success for NULL-checking
* users. Others, which care, can still check this with IS_ERR.
*/
static inline struct hwspinlock *hwspin_lock_request(void)
{
return ERR_PTR(-ENODEV);
}
static inline struct hwspinlock *hwspin_lock_request_specific(unsigned int id)
{
return ERR_PTR(-ENODEV);
@ -138,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)
{
@ -155,11 +142,6 @@ int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock)
return 0;
}
static inline struct hwspinlock *devm_hwspin_lock_request(struct device *dev)
{
return ERR_PTR(-ENODEV);
}
static inline
struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev,
unsigned int id)