X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fhwspinlock%2Fhwspinlock_internal.h;h=d26f78b8f214d226de7bf8c1b523257f2956a7e0;hb=b42506c6c820764f26e3036dfd733e0401525c88;hp=69935e6b93e526ab4c8b2d94fa9655dda152b7e5;hpb=bc9bc72e2f9bb07384c00604d1a40d0b5f62be6c;p=pandora-kernel.git 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 @@ #include #include +struct hwspinlock_device; + /** * struct hwspinlock_ops - platform-specific hwspinlock handlers * @@ -39,23 +41,37 @@ struct hwspinlock_ops { /** * struct hwspinlock - this struct represents a single hwspinlock instance - * - * @dev: underlying device, will be used to invoke runtime PM api - * @ops: platform-specific hwspinlock handlers - * @id: a global, unique, system-wide, index of the lock. + * @bank: the hwspinlock_device structure which owns this lock * @lock: initialized and used by hwspinlock core - * @owner: underlying implementation module, used to maintain module ref count - * - * Note: currently simplicity was opted for, but later we can squeeze some - * memory bytes by grouping the dev, ops and owner members in a single - * per-platform struct, and have all hwspinlocks point at it. + * @priv: private data, owned by the underlying platform-specific hwspinlock drv */ struct hwspinlock { + struct hwspinlock_device *bank; + spinlock_t lock; + void *priv; +}; + +/** + * struct hwspinlock_device - a device which usually spans numerous hwspinlocks + * @dev: underlying device, will be used to invoke runtime PM api + * @ops: platform-specific hwspinlock handlers + * @base_id: id index of the first lock in this device + * @num_locks: number of locks in this device + * @lock: dynamically allocated array of 'struct hwspinlock' + */ +struct hwspinlock_device { struct device *dev; const struct hwspinlock_ops *ops; - int id; - spinlock_t lock; - struct module *owner; + int base_id; + int num_locks; + struct hwspinlock lock[0]; }; +static inline int hwlock_to_id(struct hwspinlock *hwlock) +{ + int local_id = hwlock - &hwlock->bank->lock[0]; + + return hwlock->bank->base_id + local_id; +} + #endif /* __HWSPINLOCK_HWSPINLOCK_H */