Skip to content

Commit c447739

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 9f1d92a commit c447739

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

subsys/usb/host/usbh_api.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ int usbh_init(struct usbh_context *uhs_ctx)
1515
{
1616
int ret;
1717

18-
k_mutex_lock(&uhs_ctx->mutex, K_FOREVER);
18+
usbh_host_lock(uhs_ctx);
1919

2020
if (!device_is_ready(uhs_ctx->dev)) {
2121
LOG_ERR("USB host controller is not ready");
@@ -32,15 +32,15 @@ int usbh_init(struct usbh_context *uhs_ctx)
3232
ret = usbh_init_device_intl(uhs_ctx);
3333

3434
init_exit:
35-
k_mutex_unlock(&uhs_ctx->mutex);
35+
usbh_host_unlock(uhs_ctx);
3636
return ret;
3737
}
3838

3939
int usbh_enable(struct usbh_context *uhs_ctx)
4040
{
4141
int ret;
4242

43-
k_mutex_lock(&uhs_ctx->mutex, K_FOREVER);
43+
usbh_host_lock(uhs_ctx);
4444

4545
if (!uhc_is_initialized(uhs_ctx->dev)) {
4646
LOG_WRN("USB host controller is not initialized");
@@ -61,7 +61,7 @@ int usbh_enable(struct usbh_context *uhs_ctx)
6161
}
6262

6363
enable_exit:
64-
k_mutex_unlock(&uhs_ctx->mutex);
64+
usbh_host_unlock(uhs_ctx);
6565
return ret;
6666
}
6767

@@ -74,14 +74,14 @@ int usbh_disable(struct usbh_context *uhs_ctx)
7474
return 0;
7575
}
7676

77-
k_mutex_lock(&uhs_ctx->mutex, K_FOREVER);
77+
usbh_host_lock(uhs_ctx);
7878

7979
ret = uhc_disable(uhs_ctx->dev);
8080
if (ret) {
8181
LOG_ERR("Failed to disable USB controller");
8282
}
8383

84-
k_mutex_unlock(&uhs_ctx->mutex);
84+
usbh_host_unlock(uhs_ctx);
8585

8686
return 0;
8787
}
@@ -90,14 +90,14 @@ int usbh_shutdown(struct usbh_context *const uhs_ctx)
9090
{
9191
int ret;
9292

93-
k_mutex_lock(&uhs_ctx->mutex, K_FOREVER);
93+
usbh_host_lock(uhs_ctx);
9494

9595
ret = uhc_shutdown(uhs_ctx->dev);
9696
if (ret) {
9797
LOG_ERR("Failed to shutdown USB device");
9898
}
9999

100-
k_mutex_unlock(&uhs_ctx->mutex);
100+
usbh_host_unlock(uhs_ctx);
101101

102102
return ret;
103103
}

0 commit comments

Comments
 (0)