Re: [PATCH 01/12] drivers: base: Unified device connection lookup

From: Andy Shevchenko
Date: Fri Feb 16 2018 - 06:00:41 EST


On Fri, Feb 16, 2018 at 12:47 PM, Hans de Goede <hdegoede@xxxxxxxxxx> wrote:
> From: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>
>
> Several frameworks - clk, gpio, phy, pmw, etc. - maintain
> lookup tables for describing connections and provide custom
> API for handling them. This introduces a single generic
> lookup table and API for the connections.
>
> The motivation for this commit is centralizing the
> connection lookup, but the goal is to ultimately extract the
> connection descriptions also from firmware by using the
> fwnode_graph_* functions and other mechanisms that are
> available.

> +void *__device_find_connection(struct device *dev, const char *con_id,

> + void *data,
> + void *(*match)(struct devcon *con, int ep,
> + void *data))

Perhaps swap them, since data is dependent parameter to match.

And put match function on one line disregard 80 character limit?

> +/**
> + * struct devcon - Device Connection Descriptor
> + * @endpoint: The names of the two devices connected together
> + * @id: Unique identifier for the connection
> + */
> +struct devcon {
> + const char *endpoint[2];
> + const char *id;
> + struct list_head list;
> +};
> +

> +void *__device_find_connection(struct device *dev, const char *con_id,
> + void *data,
> + void *(*match)(struct devcon *con, int ep,
> + void *data));

Ditto.

> +
> +struct device *device_find_connection(struct device *dev, const char *con_id);
> +
> +#define DEVCON(_ep0, _ep1, _id) { { _ep0, _ep1 }, _id, }

Please use (struct devcon) here to make it possible to do like

struct devcon foo;

foo = DEVCON(...);


--
With Best Regards,
Andy Shevchenko