Skip to content

Commit d98f2b8

Browse files
author
Josuah Demangeon
committed
usb: host: wrap the mutex lock with a helper
Hide the mutex lock details inside a wrapper call, like done for the device stack API. This is not used for the per-device lock of the host stack which use a different mutex lock. Signed-off-by: Josuah Demangeon <[email protected]>
1 parent 1dd1202 commit d98f2b8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

subsys/usb/host/usbh_host.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,24 @@ static inline bool usbd_is_initialized(const struct usbh_context *const uhs_ctx)
3434
return uhs_ctx->status.initialized;
3535
}
3636

37+
/**
38+
* @brief Lock the USB host stack context
39+
*
40+
* @param[in] uhs_ctx Pointer to a host context
41+
*/
42+
static inline void usbh_host_lock(struct usbh_context *const uhs_ctx)
43+
{
44+
k_mutex_lock(&uhs_ctx->mutex, K_FOREVER);
45+
}
46+
47+
/**
48+
* @brief Unlock the USB host stack context
49+
*
50+
* @param[in] uhs_ctx Pointer to a host context
51+
*/
52+
static inline void usbh_host_unlock(struct usbh_context *const uhs_ctx)
53+
{
54+
k_mutex_unlock(&uhs_ctx->mutex);
55+
}
56+
3757
#endif /* ZEPHYR_INCLUDE_USBH_HOST_H */

0 commit comments

Comments
 (0)