platform/surface: aggregator_registry: Give devices time to set up when connecting
authorMaximilian Luz <luzmaximilian@gmail.com>
Mon, 5 Apr 2021 23:12:22 +0000 (01:12 +0200)
committerHans de Goede <hdegoede@redhat.com>
Wed, 7 Apr 2021 17:47:23 +0000 (19:47 +0200)
commit8145476fc782541996282387d28ab99ffe7ff0ef
treefd5a2f8ec21efedb1a199d7f610091bdd8ff5bb7
parent1ea602e4171b8c5967ab35f6e9113007abb14429
platform/surface: aggregator_registry: Give devices time to set up when connecting

Sometimes, the "base connected" event that we rely on to (re-)attach the
device connected to the base is sent a bit too early. When this happens,
some devices may not be completely ready yet.

Specifically, the battery has been observed to report zero-values for
things like full charge capacity, which, however, is only loaded once
when the driver for that device probes. This can thus result in battery
readings being unavailable.

As we cannot easily and reliably discern between devices that are not
ready yet and devices that are not connected (i.e. will never be ready),
delay adding these devices. This should give them enough time to set up.

The delay is set to 2.5 seconds, which should give us a good safety
margin based on testing and still be fairly responsive for users.

To achieve that delay switch to updating via a delayed work struct,
which means that we can also get rid of some locking.

Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Link: https://lore.kernel.org/r/20210405231222.358113-1-luzmaximilian@gmail.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/surface/surface_aggregator_registry.c