Skip to content

Commit 7d4eca7

Browse files
committed
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()
2 parents 29d9983 + fec04ed commit 7d4eca7

File tree

3 files changed

+1
-168
lines changed

3 files changed

+1
-168
lines changed

Documentation/locking/hwspinlock.rst

Lines changed: 1 addition & 56 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);
@@ -312,17 +301,6 @@ The caller should **never** unlock an hwspinlock which is already unlocked.
312301
Doing so is considered a bug (there is no protection against this).
313302
This function will never sleep.
314303

315-
::
316-
317-
int hwspin_lock_get_id(struct hwspinlock *hwlock);
318-
319-
Retrieve id number of a given hwspinlock. This is needed when an
320-
hwspinlock is dynamically assigned: before it can be used to achieve
321-
mutual exclusion with a remote cpu, the id number should be communicated
322-
to the remote task with which we want to synchronize.
323-
324-
Returns the hwspinlock id number, or -EINVAL if hwlock is null.
325-
326304
Typical usage
327305
=============
328306

@@ -331,40 +309,7 @@ Typical usage
331309
#include <linux/hwspinlock.h>
332310
#include <linux/err.h>
333311

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)
312+
int hwspinlock_example(void)
368313
{
369314
struct hwspinlock *hwlock;
370315
int ret;

drivers/hwspinlock/hwspinlock_core.c

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -709,66 +709,6 @@ static int __hwspin_lock_request(struct hwspinlock *hwlock)
709709
return ret;
710710
}
711711

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-
772712
/**
773713
* hwspin_lock_request_specific() - request for a specific hwspinlock
774714
* @id: index of the specific hwspinlock that is requested
@@ -912,40 +852,6 @@ int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock)
912852
}
913853
EXPORT_SYMBOL_GPL(devm_hwspin_lock_free);
914854

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-
949855
/**
950856
* devm_hwspin_lock_request_specific() - request for a specific hwspinlock for
951857
* a managed device

include/linux/hwspinlock.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,16 @@ 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);
65-
int hwspin_lock_get_id(struct hwspinlock *hwlock);
6664
int __hwspin_lock_timeout(struct hwspinlock *, unsigned int, int,
6765
unsigned long *);
6866
int __hwspin_trylock(struct hwspinlock *, int, unsigned long *);
6967
void __hwspin_unlock(struct hwspinlock *, int, unsigned long *);
7068
int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name);
7169
int hwspin_lock_bust(struct hwspinlock *hwlock, unsigned int id);
7270
int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock);
73-
struct hwspinlock *devm_hwspin_lock_request(struct device *dev);
7471
struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev,
7572
unsigned int id);
7673
int devm_hwspin_lock_unregister(struct device *dev,
@@ -95,11 +92,6 @@ int devm_hwspin_lock_register(struct device *dev,
9592
* Note: ERR_PTR(-ENODEV) will still be considered a success for NULL-checking
9693
* users. Others, which care, can still check this with IS_ERR.
9794
*/
98-
static inline struct hwspinlock *hwspin_lock_request(void)
99-
{
100-
return ERR_PTR(-ENODEV);
101-
}
102-
10395
static inline struct hwspinlock *hwspin_lock_request_specific(unsigned int id)
10496
{
10597
return ERR_PTR(-ENODEV);
@@ -138,11 +130,6 @@ static inline int of_hwspin_lock_get_id(struct device_node *np, int index)
138130
return 0;
139131
}
140132

141-
static inline int hwspin_lock_get_id(struct hwspinlock *hwlock)
142-
{
143-
return 0;
144-
}
145-
146133
static inline
147134
int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name)
148135
{
@@ -155,11 +142,6 @@ int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock)
155142
return 0;
156143
}
157144

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

0 commit comments

Comments
 (0)