Skip to content
  • Tanu Kaskinen's avatar
    bluetooth: Refactor device validity management · de0d803e
    Tanu Kaskinen authored
    There are several intertwined changes that I couldn't separate into
    nicer commits. This is mostly just refactoring, but this also fixes
    a bug: the old code set the device valid in parse_device_properties()
    even if the device's adapter was invalid (had NULL address).
    
    To improve the clarity of the code, I split the device_info_valid
    variable into two booleans: properties_received and valid.
    
    I added function device_update_valid() that checks all conditions that
    affect the device validity. The function can then be called from any
    place where something changes that potentially affects the device
    validity. However, currently the only validity-affecting thing that
    can change is the device adapter, so device_update_valid() is only
    called from set_device_adapter().
    
    I added the aforementioned set_device_adapter() function so that
    whenever the adapter is set, the device validity gets updated
    automatically.
    
    The new properties_received variable allowed me to remove the
    is_property_update function parameters.
    de0d803e