On Sat, 22 Apr 2023 at 05:04, Sanjay Sheth <
ssh...@logitech.com> wrote:
> Is there any flags or special handling to let framework know that this is composite device.
Ahh, so the composite update is formed when there are multiple updates
to deploy to multiple sub-devices. I guess in this case we're only
*using* the other device for a specific step rather than deploying
firmware onto it.
> Verbose logs attached to the PullRequest. Will refactor based on input.
So in this case I think we want to add a
plugin_class->device_registered vfunc that gets called for each device
that gets added to the daemon (which can happen in either order). You
can look for the helper device and match against an instance ID or
plugin name there, and on match save this to the plugin private object
(and unref it if not NULL on finalize).
If the device detected in device_registered is the device you're doing
the update on then you can call fu_device_set_proxy() with the
previously detected helper device. e.g. I'd do something like this:
static void
foo_registered(FuPlugin *plugin, FuDevice *device)
{
    if (_is_updatable_device(device)) {
        g_set_object(&self->updatable_device, device);
        fu_device_set_proxy(self->updatable_device,
                    self->helper_device);
    }
    if (_is_helper_device(device)) {
        g_set_object(&self->helper_device, device);
        fu_device_set_proxy(self->updatable_device,
                    self->helper_device);
    }
}
plugin_class->device_registered = foo_registered;
And then when the updatable device needs to use the helper device it
can call fu_device_get_proxy(). Does that help?
Richard.