Re: [PATCH v2] ASoC: cs42xx8-i2c.c: add module device table for of
From: Charles Keepax
Date: Fri Oct 28 2022 - 05:58:11 EST
On Fri, Oct 28, 2022 at 09:50:44AM +0200, Peter Bergin wrote:
> Matching of device in cs42xx8_i2c_probe() is coded with inspiration
> from tlv320aic32x4-i2c.c.
> ---
> + if (i2c->dev.of_node) {
> + const struct of_device_id *oid;
> +
> + oid = of_match_node(cs42xx8_of_match, i2c->dev.of_node);
> + if (!oid)
> + goto err_not_found;
> + drvdata = (struct cs42xx8_driver_data *)oid->data;
> + } else {
> + const struct i2c_device_id *id;
> +
> + id = i2c_match_id(cs42xx8_i2c_id, i2c);
> + if (!id)
> + goto err_not_found;
> + drvdata = (struct cs42xx8_driver_data *)id->driver_data;
> + }
Be worth noting a little more explicitly in the commit message
you updated this logic as part of the move. I would even be
tempted to put it as a separate patch personally.
> +static const struct cs42xx8_driver_data cs42448_data = {
> + .name = "cs42448",
> + .num_adcs = 3,
> +};
> +
> +static const struct cs42xx8_driver_data cs42888_data = {
> + .name = "cs42888",
> + .num_adcs = 2,
> +};
It is probably better to leave these two structures exported from
the primary module. These devices could technically have SPI
support added in the future and it might as well reuse these same
data structures.
Thanks,
Charles