usb_host: use Expanding reporter for device report

Issue #4596
This commit is contained in:
Alexander Boettcher 2022-08-24 14:27:11 +02:00 committed by Christian Helmuth
parent c333fc6f04
commit adc4d47251

View File

@ -161,12 +161,13 @@ class Root : public Root_component<genode_usb_session>
Signal_handler<Root> _config_handler { _env.ep(), *this,
&Root::_announce_service };
Reporter _config_reporter { _env, "config" };
Reporter _device_reporter { _env, "devices" };
Constructible<Device> _devices[MAX_DEVICES];
List<List_element<genode_usb_session>> _sessions {};
Id_allocator _id_alloc {};
bool _announced { false };
Constructible<Expanding_reporter> _device_reporter {};
List<List_element<genode_usb_session>> _sessions {};
Root(const Root&);
Root & operator=(const Root&);
@ -615,7 +616,10 @@ void ::Root::_report()
{
using Value = String<64>;
Reporter::Xml_generator xml(_device_reporter, [&] () {
if (!_device_reporter.constructed())
return;
_device_reporter->generate([&] (Reporter::Xml_generator &xml) {
_for_each_device([&] (Device & d) {
xml.node("device", [&] {
xml.attribute("label", d.label());
@ -678,7 +682,9 @@ void ::Root::_announce_service()
* Check for report policy, and resp. con-/destruct device reporter
*/
_config.xml().with_sub_node("report", [&] (Xml_node node) {
_device_reporter.enabled(node.attribute_value("devices", false));
_device_reporter.conditional(node.attribute_value("devices", false),
_env, "devices", "devices" );
_config_reporter.enabled(node.attribute_value("config", false));
});