aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/hwspinlock.h
diff options
context:
space:
mode:
authorOhad Ben-Cohen <ohad@wizery.com>2011-09-06 08:39:21 -0400
committerOhad Ben-Cohen <ohad@wizery.com>2011-09-21 12:45:34 -0400
commit300bab9770e2bd10262bcc78e7249fdce2c74b38 (patch)
tree5c23d7dce82b96fa177ea7c854de7f4b36992c80 /include/linux/hwspinlock.h
parentc536abfdf5227987b8a72ff955b64e62fd58fe91 (diff)
hwspinlock/core: register a bank of hwspinlocks in a single API call
Hardware Spinlock devices usually contain numerous locks (known devices today support between 32 to 256 locks). Originally hwspinlock core required drivers to register (and later, when needed, unregister) each lock separately. That worked, but required hwspinlocks drivers to do a bit extra work when they were probed/removed. This patch changes hwspin_lock_{un}register() to allow a bank of hwspinlocks to be {un}registered in a single invocation. A new 'struct hwspinlock_device', which contains an array of 'struct hwspinlock's is now being passed to the core upon registration (so instead of wrapping each struct hwspinlock, a priv member has been added to allow drivers to piggyback their private data with each hwspinlock). While at it, several per-lock members were moved to be per-device: 1. struct device *dev 2. struct hwspinlock_ops *ops In addition, now that the array of locks is handled by the core, there's no reason to maintain a per-lock 'int id' member: the id of the lock anyway equals to its index in the bank's array plus the bank's base_id. Remove this per-lock id member too, and instead use a simple pointers arithmetic to derive it. As a result of this change, hwspinlocks drivers are now simpler and smaller (about %20 code reduction) and the memory footprint of the hwspinlock framework is reduced. Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Diffstat (limited to 'include/linux/hwspinlock.h')
-rw-r--r--include/linux/hwspinlock.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h
index c246522a9551..08a2fee40659 100644
--- a/include/linux/hwspinlock.h
+++ b/include/linux/hwspinlock.h
@@ -20,12 +20,15 @@
20 20
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/sched.h> 22#include <linux/sched.h>
23#include <linux/device.h>
23 24
24/* hwspinlock mode argument */ 25/* hwspinlock mode argument */
25#define HWLOCK_IRQSTATE 0x01 /* Disable interrupts, save state */ 26#define HWLOCK_IRQSTATE 0x01 /* Disable interrupts, save state */
26#define HWLOCK_IRQ 0x02 /* Disable interrupts, don't save state */ 27#define HWLOCK_IRQ 0x02 /* Disable interrupts, don't save state */
27 28
28struct hwspinlock; 29struct hwspinlock;
30struct hwspinlock_device;
31struct hwspinlock_ops;
29 32
30/** 33/**
31 * struct hwspinlock_pdata - platform data for hwspinlock drivers 34 * struct hwspinlock_pdata - platform data for hwspinlock drivers
@@ -57,8 +60,9 @@ struct hwspinlock_pdata {
57 60
58#if defined(CONFIG_HWSPINLOCK) || defined(CONFIG_HWSPINLOCK_MODULE) 61#if defined(CONFIG_HWSPINLOCK) || defined(CONFIG_HWSPINLOCK_MODULE)
59 62
60int hwspin_lock_register(struct hwspinlock *lock); 63int hwspin_lock_register(struct hwspinlock_device *bank, struct device *dev,
61struct hwspinlock *hwspin_lock_unregister(unsigned int id); 64 const struct hwspinlock_ops *ops, int base_id, int num_locks);
65int hwspin_lock_unregister(struct hwspinlock_device *bank);
62struct hwspinlock *hwspin_lock_request(void); 66struct hwspinlock *hwspin_lock_request(void);
63struct hwspinlock *hwspin_lock_request_specific(unsigned int id); 67struct hwspinlock *hwspin_lock_request_specific(unsigned int id);
64int hwspin_lock_free(struct hwspinlock *hwlock); 68int hwspin_lock_free(struct hwspinlock *hwlock);