driver: load driver file by alias only

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-08-12 20:54:27 -04:00
commit 20905ec95f
Signed by: michaelsshaw
GPG key ID: 5A5E0FB20708A9E7
6 changed files with 69 additions and 39 deletions

View file

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <kernel/common.h>
#include <kernel/slab.h>
#include <kernel/mtx.h>
#include <lib/hashchain.h>
#include <lib/math.h>
#include <lib/string.h>
@ -61,21 +62,20 @@ int ht_insert(ht_t *ht, const char *key, void *value)
ht_entry_t *entry = ht->buckets[idx];
while (entry) {
if (strcmp(entry->key, key) == 0) {
entry->ptr = value;
return 0;
if (!strcmp(entry->key, key)) {
return -EEXIST;
}
entry = entry->next;
}
entry = kzalloc(sizeof(ht_entry_t), ALLOC_KERN);
if (!entry)
return -1;
return -ENOMEM;
entry->key = strdup(key);
if (!entry->key) {
kfree(entry);
return -1;
return -ENOMEM;
}
entry->ptr = value;
@ -126,3 +126,13 @@ int ht_delete(ht_t *ht, const char *key)
return -1;
}
void ht_lock(ht_t *ht)
{
mtx_lock(&ht->lock);
}
void ht_unlock(ht_t *ht)
{
mtx_unlock(&ht->lock);
}