13#ifndef ZEPHYR_INCLUDE_DRIVERS_HWSPINLOCK_H_
14#define ZEPHYR_INCLUDE_DRIVERS_HWSPINLOCK_H_
38typedef int (*hwspinlock_api_trylock)(
const struct device *dev,
uint32_t id);
44typedef void (*hwspinlock_api_lock)(
const struct device *dev,
uint32_t id);
50typedef void (*hwspinlock_api_unlock)(
const struct device *dev,
uint32_t id);
56typedef uint32_t (*hwspinlock_api_get_max_id)(
const struct device *dev);
58__subsystem
struct hwspinlock_driver_api {
59 hwspinlock_api_trylock trylock;
60 hwspinlock_api_lock lock;
61 hwspinlock_api_unlock unlock;
62 hwspinlock_api_get_max_id get_max_id;
82static inline int z_impl_hwspinlock_trylock(
const struct device *dev,
uint32_t id)
84 const struct hwspinlock_driver_api *api =
85 (
const struct hwspinlock_driver_api *)dev->
api;
87 if (api->trylock ==
NULL) {
91 return api->trylock(dev,
id);
105static inline void z_impl_hwspinlock_lock(
const struct device *dev,
uint32_t id)
107 const struct hwspinlock_driver_api *api =
108 (
const struct hwspinlock_driver_api *)dev->
api;
110 if (api->lock !=
NULL) {
126static inline void z_impl_hwspinlock_unlock(
const struct device *dev,
uint32_t id)
128 const struct hwspinlock_driver_api *api =
129 (
const struct hwspinlock_driver_api *)dev->
api;
131 if (api->unlock !=
NULL) {
132 api->unlock(dev,
id);
149static inline uint32_t z_impl_hwspinlock_get_max_id(
const struct device *dev)
151 const struct hwspinlock_driver_api *api =
152 (
const struct hwspinlock_driver_api *)dev->
api;
154 if (api->get_max_id ==
NULL) {
158 return api->get_max_id(dev);
167#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
#define NULL
Definition iar_missing_defs.h:20
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Runtime device structure (in ROM) per driver instance.
Definition device.h:510
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:516