blob: 975f6768204f95fe202e8264a4e52c01314069c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
/* Copyright (C) 2026 Richard Qin */
/*
* drivers/base/bus.cc — bus_type registration.
*
* Mirrors Linux drivers/base/bus.c. Trivial in this iteration:
* initialize the device/driver lists and the per-bus spinlock.
*
* Reference: docs/specs/storage_stack.md §4.3
*/
#include <lume/device.h>
#include <lume/klog.h>
#include <lume/kprintf.h>
#include <lume/errno.h>
int bus_register(bus_type* bus)
{
if (bus == nullptr || bus->name == nullptr) {
return -EINVAL;
}
if (bus->registered) {
return 0;
}
bus->devices.init();
bus->drivers.init();
bus->lock.init(bus->name);
bus->registered = true;
kprintf("[bus] '%s' registered\n", bus->name);
return 0;
}
|