aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwspinlock/hwspinlock_internal.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-11-03 11:05:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-11-03 11:05:35 -0400
commit3f8ddb032afa729d4bad1bf2965d3ec068de6b72 (patch)
treef2467d1160ee8cd4016fb77c09d0f1f4c768e5fe /drivers/hwspinlock/hwspinlock_internal.h
parent30307c69d59b14723fbf8a524847b302388c702d (diff)
parent8b37fcfc9b3400b647748783a2cafff67793e0ad (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ohad/hwspinlock
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ohad/hwspinlock: hwspinlock: add MAINTAINERS entries hwspinlock/omap: omap_hwspinlock_remove should be __devexit hwspinlock/u8500: add hwspinlock driver hwspinlock/core: register a bank of hwspinlocks in a single API call hwspinlock/core: remove stubs for register/unregister hwspinlock/core: use a mutex to protect the radix tree hwspinlock/core/omap: fix id issues on multiple hwspinlock devices hwspinlock/omap: simplify allocation scheme hwspinlock/core: simplify 'owner' handling hwspinlock/core: simplify Kconfig Fix up trivial conflicts (addition of omap_hwspinlock_pdata, removal of omap_spinlock_latency) in arch/arm/mach-omap2/hwspinlock.c Also, do an "evil merge" to fix a compile error in omap_hsmmc.c which for some reason was reported in the same email thread as the "please pull hwspinlock changes".
Diffstat (limited to 'drivers/hwspinlock/hwspinlock_internal.h')
-rw-r--r--drivers/hwspinlock/hwspinlock_internal.h40
1 files changed, 28 insertions, 12 deletions
diff --git a/drivers/hwspinlock/hwspinlock_internal.h b/drivers/hwspinlock/hwspinlock_internal.h
index 69935e6b93e5..d26f78b8f214 100644
--- a/drivers/hwspinlock/hwspinlock_internal.h
+++ b/drivers/hwspinlock/hwspinlock_internal.h
@@ -21,6 +21,8 @@
21#include <linux/spinlock.h> 21#include <linux/spinlock.h>
22#include <linux/device.h> 22#include <linux/device.h>
23 23
24struct hwspinlock_device;
25
24/** 26/**
25 * struct hwspinlock_ops - platform-specific hwspinlock handlers 27 * struct hwspinlock_ops - platform-specific hwspinlock handlers
26 * 28 *
@@ -39,23 +41,37 @@ struct hwspinlock_ops {
39 41
40/** 42/**
41 * struct hwspinlock - this struct represents a single hwspinlock instance 43 * struct hwspinlock - this struct represents a single hwspinlock instance
42 * 44 * @bank: the hwspinlock_device structure which owns this lock
43 * @dev: underlying device, will be used to invoke runtime PM api
44 * @ops: platform-specific hwspinlock handlers
45 * @id: a global, unique, system-wide, index of the lock.
46 * @lock: initialized and used by hwspinlock core 45 * @lock: initialized and used by hwspinlock core
47 * @owner: underlying implementation module, used to maintain module ref count 46 * @priv: private data, owned by the underlying platform-specific hwspinlock drv
48 *
49 * Note: currently simplicity was opted for, but later we can squeeze some
50 * memory bytes by grouping the dev, ops and owner members in a single
51 * per-platform struct, and have all hwspinlocks point at it.
52 */ 47 */
53struct hwspinlock { 48struct hwspinlock {
49 struct hwspinlock_device *bank;
50 spinlock_t lock;
51 void *priv;
52};
53
54/**
55 * struct hwspinlock_device - a device which usually spans numerous hwspinlocks
56 * @dev: underlying device, will be used to invoke runtime PM api
57 * @ops: platform-specific hwspinlock handlers
58 * @base_id: id index of the first lock in this device
59 * @num_locks: number of locks in this device
60 * @lock: dynamically allocated array of 'struct hwspinlock'
61 */
62struct hwspinlock_device {
54 struct device *dev; 63 struct device *dev;
55 const struct hwspinlock_ops *ops; 64 const struct hwspinlock_ops *ops;
56 int id; 65 int base_id;
57 spinlock_t lock; 66 int num_locks;
58 struct module *owner; 67 struct hwspinlock lock[0];
59}; 68};
60 69
70static inline int hwlock_to_id(struct hwspinlock *hwlock)
71{
72 int local_id = hwlock - &hwlock->bank->lock[0];
73
74 return hwlock->bank->base_id + local_id;
75}
76
61#endif /* __HWSPINLOCK_HWSPINLOCK_H */ 77#endif /* __HWSPINLOCK_HWSPINLOCK_H */