7#ifndef ZEPHYR_INCLUDE_DRIVERS_HWSPINLOCK_H_
8#define ZEPHYR_INCLUDE_DRIVERS_HWSPINLOCK_H_
32typedef int (*hwspinlock_api_trylock)(
const struct device *dev,
uint32_t id);
38typedef void (*hwspinlock_api_lock)(
const struct device *dev,
uint32_t id);
44typedef void (*hwspinlock_api_unlock)(
const struct device *dev,
uint32_t id);
50typedef uint32_t (*hwspinlock_api_get_max_id)(
const struct device *dev);
52__subsystem
struct hwspinlock_driver_api {
53 hwspinlock_api_trylock trylock;
54 hwspinlock_api_lock lock;
55 hwspinlock_api_unlock unlock;
56 hwspinlock_api_get_max_id get_max_id;
76static inline int z_impl_hwspinlock_trylock(
const struct device *dev,
uint32_t id)
78 const struct hwspinlock_driver_api *api =
79 (
const struct hwspinlock_driver_api *)dev->
api;
81 if (api->trylock == NULL) {
85 return api->trylock(dev,
id);
99static inline void z_impl_hwspinlock_lock(
const struct device *dev,
uint32_t id)
101 const struct hwspinlock_driver_api *api =
102 (
const struct hwspinlock_driver_api *)dev->
api;
104 if (api->lock != NULL) {
120static inline void z_impl_hwspinlock_unlock(
const struct device *dev,
uint32_t id)
122 const struct hwspinlock_driver_api *api =
123 (
const struct hwspinlock_driver_api *)dev->
api;
125 if (api->unlock != NULL) {
126 api->unlock(dev,
id);
143static inline uint32_t z_impl_hwspinlock_get_max_id(
const struct device *dev)
145 const struct hwspinlock_driver_api *api =
146 (
const struct hwspinlock_driver_api *)dev->
api;
148 if (api->get_max_id == NULL) {
152 return api->get_max_id(dev);
161#include <zephyr/syscalls/hwspinlock.h>
void hwspinlock_lock(const struct device *dev, uint32_t id)
Lock HW spinlock.
int hwspinlock_trylock(const struct device *dev, uint32_t id)
Try to lock HW spinlock.
void hwspinlock_unlock(const struct device *dev, uint32_t id)
Try to unlock HW spinlock.
uint32_t hwspinlock_get_max_id(const struct device *dev)
Get HW spinlock max ID.
#define ENOSYS
Function not implemented.
Definition errno.h:82
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Runtime device structure (in ROM) per driver instance.
Definition device.h:403
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:409