18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _LIBLOCKDEP_COMMON_H 38c2ecf20Sopenharmony_ci#define _LIBLOCKDEP_COMMON_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <pthread.h> 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#define NR_LOCKDEP_CACHING_CLASSES 2 88c2ecf20Sopenharmony_ci#define MAX_LOCKDEP_SUBCLASSES 8UL 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef CALLER_ADDR0 118c2ecf20Sopenharmony_ci#define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) 128c2ecf20Sopenharmony_ci#endif 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#ifndef _RET_IP_ 158c2ecf20Sopenharmony_ci#define _RET_IP_ CALLER_ADDR0 168c2ecf20Sopenharmony_ci#endif 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#ifndef _THIS_IP_ 198c2ecf20Sopenharmony_ci#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; }) 208c2ecf20Sopenharmony_ci#endif 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cistruct lockdep_subclass_key { 238c2ecf20Sopenharmony_ci char __one_byte; 248c2ecf20Sopenharmony_ci}; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cistruct lock_class_key { 278c2ecf20Sopenharmony_ci struct lockdep_subclass_key subkeys[MAX_LOCKDEP_SUBCLASSES]; 288c2ecf20Sopenharmony_ci}; 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_cistruct lockdep_map { 318c2ecf20Sopenharmony_ci struct lock_class_key *key; 328c2ecf20Sopenharmony_ci struct lock_class *class_cache[NR_LOCKDEP_CACHING_CLASSES]; 338c2ecf20Sopenharmony_ci const char *name; 348c2ecf20Sopenharmony_ci#ifdef CONFIG_LOCK_STAT 358c2ecf20Sopenharmony_ci int cpu; 368c2ecf20Sopenharmony_ci unsigned long ip; 378c2ecf20Sopenharmony_ci#endif 388c2ecf20Sopenharmony_ci}; 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_civoid lockdep_init_map(struct lockdep_map *lock, const char *name, 418c2ecf20Sopenharmony_ci struct lock_class_key *key, int subclass); 428c2ecf20Sopenharmony_civoid lock_acquire(struct lockdep_map *lock, unsigned int subclass, 438c2ecf20Sopenharmony_ci int trylock, int read, int check, 448c2ecf20Sopenharmony_ci struct lockdep_map *nest_lock, unsigned long ip); 458c2ecf20Sopenharmony_civoid lock_release(struct lockdep_map *lock, unsigned long ip); 468c2ecf20Sopenharmony_civoid lockdep_reset_lock(struct lockdep_map *lock); 478c2ecf20Sopenharmony_civoid lockdep_register_key(struct lock_class_key *key); 488c2ecf20Sopenharmony_civoid lockdep_unregister_key(struct lock_class_key *key); 498c2ecf20Sopenharmony_ciextern void debug_check_no_locks_freed(const void *from, unsigned long len); 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#define STATIC_LOCKDEP_MAP_INIT(_name, _key) \ 528c2ecf20Sopenharmony_ci { .name = (_name), .key = (void *)(_key), } 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#endif 55