• Maximilian Luz's avatar
    platform/surface: aggregator_registry: Give devices time to set up when connecting · 8145476f
    Maximilian Luz authored
    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: default avatarMaximilian Luz <luzmaximilian@gmail.com>
    Link: https://lore.kernel.org/r/20210405231222.358113-1-luzmaximilian@gmail.comSigned-off-by: default avatarHans de Goede <hdegoede@redhat.com>
    8145476f
surface_aggregator_registry.c 15.8 KB