1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:28:12 +00:00

USB: Store devices in globally accessible array

USB Devices are now stored so that they may be later retrieved and
operated on (i.e, fetching their assigned device address via
ProcFS)
This commit is contained in:
Jesse Buhagiar 2021-06-08 00:08:41 +10:00 committed by Ali Mohammad Pur
parent 0e680cb17a
commit 7b42146f33
4 changed files with 38 additions and 7 deletions

View file

@ -16,13 +16,13 @@ static u32 s_next_usb_address = 1; // Next address we hand out to a device once
namespace Kernel::USB {
KResultOr<NonnullOwnPtr<Device>> Device::try_create(PortNumber port, DeviceSpeed speed)
KResultOr<NonnullRefPtr<Device>> Device::try_create(PortNumber port, DeviceSpeed speed)
{
auto pipe_or_error = Pipe::try_create_pipe(Pipe::Type::Control, Pipe::Direction::Bidirectional, 0, 8, 0);
if (pipe_or_error.is_error())
return pipe_or_error.error();
auto device = adopt_own_if_nonnull(new Device(port, speed, pipe_or_error.release_value()));
auto device = adopt_ref_if_nonnull(new Device(port, speed, pipe_or_error.release_value()));
if (!device)
return ENOMEM;