Skip to content

Commit 9940b29

Browse files
QuzarDCQuzarDC
authored andcommitted
controller: Use mutex_lock_scoped, fix indentation, update copyright.
I'd missed adding copyright for the big threaded callbacks update, figured I should to allow for easier blame.
1 parent 153bf96 commit 9940b29

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

kernel/arch/dreamcast/hardware/maple/controller.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
controller.c
44
Copyright (C) 2002 Megan Potter
5+
Copyright (C) 2024 Donald Haase
56
Copyright (C) 2025 Falco Girgis
67
78
*/
@@ -74,21 +75,20 @@ int __pure cont_has_capabilities(const maple_device_t *cont, uint32_t capabiliti
7475
static void cont_btn_callback_del(cont_callback_params_t *params) {
7576
cont_callback_params_t *c, *n;
7677

77-
mutex_lock(&btn_cbs_mtx);
78+
mutex_lock_scoped(&btn_cbs_mtx);
7879

7980
TAILQ_FOREACH_SAFE(c, &btn_cbs, listent, n) {
8081
if((params == NULL) || ((params->addr == c->addr) &&
8182
(params->btns == c->btns))) {
8283

83-
if((params == NULL) || (params->cb == NULL) ||
84-
(params->cb == c->cb)) {
85-
TAILQ_REMOVE(&btn_cbs, c, listent);
86-
thd_worker_destroy(c->worker);
87-
free(c);
88-
}
84+
if((params == NULL) || (params->cb == NULL) ||
85+
(params->cb == c->cb)) {
86+
TAILQ_REMOVE(&btn_cbs, c, listent);
87+
thd_worker_destroy(c->worker);
88+
free(c);
8989
}
90+
}
9091
}
91-
mutex_unlock(&btn_cbs_mtx);
9292
}
9393

9494
static void cont_btn_cb_thread(void *d) {
@@ -129,15 +129,13 @@ int cont_btn_callback(uint8_t addr, uint32_t btns, cont_btn_callback_t cb) {
129129
return -1;
130130
}
131131

132-
mutex_lock(&btn_cbs_mtx);
132+
mutex_lock_scoped(&btn_cbs_mtx);
133133

134134
if(addr)
135135
TAILQ_INSERT_HEAD(&btn_cbs, params, listent);
136136
else
137137
TAILQ_INSERT_TAIL(&btn_cbs, params, listent);
138138

139-
mutex_unlock(&btn_cbs_mtx);
140-
141139
return 0;
142140
}
143141

0 commit comments

Comments
 (0)