mirror of
https://github.com/genodelabs/genode.git
synced 2025-03-25 21:38:25 +00:00
parent
87e90d640f
commit
cd8b436566
@ -33,11 +33,14 @@ struct Driver
|
||||
{
|
||||
Lx::Task task;
|
||||
Genode::Signal_handler<Task> handler;
|
||||
bool handling_signal { false };
|
||||
|
||||
void handle_signal()
|
||||
{
|
||||
task.unblock();
|
||||
handling_signal = true;
|
||||
Lx::scheduler().schedule();
|
||||
handling_signal = false;
|
||||
}
|
||||
|
||||
template <typename... ARGS>
|
||||
@ -56,6 +59,7 @@ struct Driver
|
||||
Genode::Allocator_avl &alloc;
|
||||
Task state_task;
|
||||
Task urb_task;
|
||||
|
||||
Usb::Connection usb { env, &alloc, label.string(),
|
||||
512 * 1024, state_task.handler };
|
||||
usb_device * udev = nullptr;
|
||||
@ -70,6 +74,7 @@ struct Driver
|
||||
void unregister_device();
|
||||
void probe_interface(usb_interface *, usb_device_id *);
|
||||
void remove_interface(usb_interface *);
|
||||
bool deinit();
|
||||
};
|
||||
|
||||
struct Devices : Genode::List<Device::Le>
|
||||
|
@ -142,7 +142,14 @@ Driver::Device::Device(Driver & driver, Label label)
|
||||
Driver::Device::~Device()
|
||||
{
|
||||
driver.devices.remove(&le);
|
||||
}
|
||||
|
||||
|
||||
bool Driver::Device::deinit()
|
||||
{
|
||||
if (udev) unregister_device();
|
||||
|
||||
return !udev && !state_task.handling_signal && !urb_task.handling_signal;
|
||||
}
|
||||
|
||||
|
||||
@ -228,7 +235,9 @@ void Driver::scan_report()
|
||||
};
|
||||
|
||||
devices.for_each([&] (Device & d) {
|
||||
if (!d.updated) destroy(heap, &d); });
|
||||
if (!d.updated && d.deinit())
|
||||
destroy(heap, &d);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user