![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 */ 0002 /* 0003 * Hardware spinlocks internal header 0004 * 0005 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com 0006 * 0007 * Contact: Ohad Ben-Cohen <ohad@wizery.com> 0008 */ 0009 0010 #ifndef __HWSPINLOCK_HWSPINLOCK_H 0011 #define __HWSPINLOCK_HWSPINLOCK_H 0012 0013 #include <linux/spinlock.h> 0014 #include <linux/device.h> 0015 0016 struct hwspinlock_device; 0017 0018 /** 0019 * struct hwspinlock_ops - platform-specific hwspinlock handlers 0020 * 0021 * @trylock: make a single attempt to take the lock. returns 0 on 0022 * failure and true on success. may _not_ sleep. 0023 * @unlock: release the lock. always succeed. may _not_ sleep. 0024 * @relax: optional, platform-specific relax handler, called by hwspinlock 0025 * core while spinning on a lock, between two successive 0026 * invocations of @trylock. may _not_ sleep. 0027 */ 0028 struct hwspinlock_ops { 0029 int (*trylock)(struct hwspinlock *lock); 0030 void (*unlock)(struct hwspinlock *lock); 0031 void (*relax)(struct hwspinlock *lock); 0032 }; 0033 0034 /** 0035 * struct hwspinlock - this struct represents a single hwspinlock instance 0036 * @bank: the hwspinlock_device structure which owns this lock 0037 * @lock: initialized and used by hwspinlock core 0038 * @priv: private data, owned by the underlying platform-specific hwspinlock drv 0039 */ 0040 struct hwspinlock { 0041 struct hwspinlock_device *bank; 0042 spinlock_t lock; 0043 void *priv; 0044 }; 0045 0046 /** 0047 * struct hwspinlock_device - a device which usually spans numerous hwspinlocks 0048 * @dev: underlying device, will be used to invoke runtime PM api 0049 * @ops: platform-specific hwspinlock handlers 0050 * @base_id: id index of the first lock in this device 0051 * @num_locks: number of locks in this device 0052 * @lock: dynamically allocated array of 'struct hwspinlock' 0053 */ 0054 struct hwspinlock_device { 0055 struct device *dev; 0056 const struct hwspinlock_ops *ops; 0057 int base_id; 0058 int num_locks; 0059 struct hwspinlock lock[]; 0060 }; 0061 0062 static inline int hwlock_to_id(struct hwspinlock *hwlock) 0063 { 0064 int local_id = hwlock - &hwlock->bank->lock[0]; 0065 0066 return hwlock->bank->base_id + local_id; 0067 } 0068 0069 #endif /* __HWSPINLOCK_HWSPINLOCK_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |