Re: [PATCH 4/5] usb: typec: port-mapper: Convert to the component framework

Heikki Krogerus
2021-12-08T11:23:46Z

On Tue, Dec 07, 2021 at 05:46:06PM +0200, Andy Shevchenko wrote:
> On Tue, Dec 07, 2021 at 05:37:56PM +0300, Heikki Krogerus wrote:
> > Instead of trying to keep track of the connections to the
> > USB Type-C connectors separately, letting the component
> > framework take care of that.
> >
> > From now on every USB Type-C connector will register itself
> > as "aggregate" - component master - and anything that can be
> > connected to it can then simply register itself as a generic
> > component.
> >
> > The matching of the components and the connector shall rely
> > on ACPI _PLD initially. Before registering itself as the
> > aggregate, the connector will check the list of other
> > devices that share the same ACPI _PLD with it, and add a
> > component match entry for each one of them. Because only
> > ACPI is supported for now, the driver shall only be build
> > when ACPI is supported.
> >
> > This removes the need for the custom API that the driver
> > exposed. The components and the connector can therefore
> > exist completely independently of each other. The order in
> > which they are registered, as well as are they modules or
> > not, is now irrelevant.
>
> ...
>
> > +static int typec_port_compare(struct device *dev, void *fwnode)
> > {
>
> > + return dev_fwnode(dev) == fwnode;
> > }
>
> NIH device_match_fwnode()
>
> ...
>
> > + /* Component match for every device that shares the same _PLD. */
> > + list_for_each_entry(adev, &location->devices, location_list) {
>
> > + if (adev == ACPI_COMPANION(&con->dev))
>
> device_match_acpi_dev()

Ah, both look like great helpers. I'll this in v2. Thanks.

--
heikki