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)
84 return api->trylock(dev,
id);
98static inline void z_impl_hwspinlock_lock(
const struct device *dev,
uint32_t id)
100 const struct hwspinlock_driver_api *api =
101 (
const struct hwspinlock_driver_api *)dev->
api;
103 if (api->lock != NULL)
118static inline void z_impl_hwspinlock_unlock(
const struct device *dev,
uint32_t id)
120 const struct hwspinlock_driver_api *api =
121 (
const struct hwspinlock_driver_api *)dev->
api;
123 if (api->unlock != NULL)
124 api->unlock(dev,
id);
140static inline uint32_t z_impl_hwspinlock_get_max_id(
const struct device *dev)
142 const struct hwspinlock_driver_api *api =
143 (
const struct hwspinlock_driver_api *)dev->
api;
145 if (api->get_max_id == NULL)
148 return api->get_max_id(dev);
157#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