list: change locking discipline

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-08-12 14:50:47 -04:00
commit 071a5651e0
Signed by: michaelsshaw
GPG key ID: 5A5E0FB20708A9E7
11 changed files with 61 additions and 15 deletions

View file

@ -15,6 +15,8 @@ struct driver *driver_register(const char *name, u32 type, void *init, void *dei
struct driver *driver = NULL;
list_lock(&pending_drivers);
list_item_t *item = pending_drivers.head;
while (item) {
struct driver *d = item->ptr;
@ -26,6 +28,8 @@ struct driver *driver_register(const char *name, u32 type, void *init, void *dei
item = item->next;
}
list_unlock(&pending_drivers);
if (!driver) {
driver = kzalloc(sizeof(struct driver), ALLOC_KERN);
strncpy(driver->name, name, sizeof(driver->name) - 1);

View file

@ -260,7 +260,9 @@ static int elf_load(const char *name, const char *file, size_t fsize)
d->base = base;
d->size = total;
d->n_users = 1;
list_lock(&pending_drivers);
list_insert(&pending_drivers, d);
list_unlock(&pending_drivers);
}
}

View file

@ -33,7 +33,9 @@ struct tty *tty_tee_create(const char *name)
struct tty *ret = tty_create(name, list);
if (!ret) {
list_lock(list);
list_destroy(list);
list_unlock(list);
kfree(list);
return NULL;
}
@ -49,7 +51,9 @@ void tty_tee_add(struct tty *tee, struct tty *child)
return;
list_t *list = tee->priv;
list_lock(list);
list_insert(list, child);
list_unlock(list);
}
void tty_tee_remove(struct tty *tee, struct tty *child)
@ -58,13 +62,18 @@ void tty_tee_remove(struct tty *tee, struct tty *child)
if (!list)
return;
list_lock(list);
list_item_t *item = list->head;
while (item) {
if (item->ptr == child) {
list_remove(item);
list_unlock(list);
return;
}
item = item->next;
}
list_unlock(list);
}