diff options
Diffstat (limited to 'drivers/hwspinlock/hwspinlock_internal.h')
-rw-r--r-- | drivers/hwspinlock/hwspinlock_internal.h | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/drivers/hwspinlock/hwspinlock_internal.h b/drivers/hwspinlock/hwspinlock_internal.h index fb25830c2ee7..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 | ||
24 | struct hwspinlock_device; | ||
25 | |||
24 | /** | 26 | /** |
25 | * struct hwspinlock_ops - platform-specific hwspinlock handlers | 27 | * struct hwspinlock_ops - platform-specific hwspinlock handlers |
26 | * | 28 | * |
@@ -39,21 +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 | * | 46 | * @priv: private data, owned by the underlying platform-specific hwspinlock drv |
48 | * Note: currently simplicity was opted for, but later we can squeeze some | ||
49 | * memory bytes by grouping dev, ops in a single | ||
50 | * per-platform struct, and have all hwspinlocks point at it. | ||
51 | */ | 47 | */ |
52 | struct hwspinlock { | 48 | struct 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 | */ | ||
62 | struct hwspinlock_device { | ||
53 | struct device *dev; | 63 | struct device *dev; |
54 | const struct hwspinlock_ops *ops; | 64 | const struct hwspinlock_ops *ops; |
55 | int id; | 65 | int base_id; |
56 | spinlock_t lock; | 66 | int num_locks; |
67 | struct hwspinlock lock[0]; | ||
57 | }; | 68 | }; |
58 | 69 | ||
70 | static 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 | |||
59 | #endif /* __HWSPINLOCK_HWSPINLOCK_H */ | 77 | #endif /* __HWSPINLOCK_HWSPINLOCK_H */ |