Hi Heikki,
On 10/23/2025 7:36 PM, Heikki Krogerus wrote:
Thank you for your detailed explanation. I noticed that there is a
device_register() action in typec_register_altmode(), so we can just take
advantage of this.
Another thing is that we need to distinguish between different devices in the
notifier callback, as
typec_register_altmode()/typec_register_partner()/typec_register_plug()/typec_register_cable()
may all register devices. Since the data passed in bus_notify() is struct
device *dev, I think we can distinguish them through `dev->type.name`? We may
already have such names, "typec_alternate_mode", "typec_partner", "typec_plug"
in class.c . And then extract these names as macros and put them in the typec
header file.
You don't need to worry about that. Only partner altmodes are bind to
the bus. The device you see in the notifier will always be an altmode.
But in general, if you need to identify the device type, then
you use the device type itself, not the name of the type. It would
require that the device types are exported, but as said, you don't
need to worry about that in this case.
Very insightful! I will try to do this in v8 :)
thanks,
--
Best,
Chaoyi