ASoC: tas*: use i2c_match_id and simple i2c probe

As part of the ongoing i2c transition to the simple probe
("probe_new"), this patch uses i2c_match_id to retrieve the
driver_data for the probed device. The id parameter is thus no longer
necessary and the simple probe can be used instead.

The i2c id tables are moved up before the probe function, as
suggested by Wolfram Sang, except where the existing code already had
a declaration for the of_device_id table.

Signed-off-by: Stephen Kitt <steve@sk2.org>
Link: https://lore.kernel.org/r/20220415160613.148882-6-steve@sk2.org
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Stephen Kitt 2022-04-15 18:06:11 +02:00 committed by Mark Brown
parent 3577a8a0ac
commit 55116b39e5
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
3 changed files with 31 additions and 26 deletions

View File

@ -754,17 +754,27 @@ static int tas2562_parse_dt(struct tas2562_data *tas2562)
return ret;
}
static int tas2562_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static const struct i2c_device_id tas2562_id[] = {
{ "tas2562", TAS2562 },
{ "tas2563", TAS2563 },
{ "tas2564", TAS2564 },
{ "tas2110", TAS2110 },
{ }
};
MODULE_DEVICE_TABLE(i2c, tas2562_id);
static int tas2562_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct tas2562_data *data;
int ret;
const struct i2c_device_id *id;
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
id = i2c_match_id(tas2562_id, client);
data->client = client;
data->dev = &client->dev;
data->model_id = id->driver_data;
@ -792,15 +802,6 @@ static int tas2562_probe(struct i2c_client *client,
}
static const struct i2c_device_id tas2562_id[] = {
{ "tas2562", TAS2562 },
{ "tas2563", TAS2563 },
{ "tas2564", TAS2564 },
{ "tas2110", TAS2110 },
{ }
};
MODULE_DEVICE_TABLE(i2c, tas2562_id);
#ifdef CONFIG_OF
static const struct of_device_id tas2562_of_match[] = {
{ .compatible = "ti,tas2562", },
@ -817,7 +818,7 @@ static struct i2c_driver tas2562_i2c_driver = {
.name = "tas2562",
.of_match_table = of_match_ptr(tas2562_of_match),
},
.probe = tas2562_probe,
.probe_new = tas2562_probe,
.id_table = tas2562_id,
};

View File

@ -774,9 +774,9 @@ static struct snd_soc_dai_driver tas571x_dai = {
};
static const struct of_device_id tas571x_of_match[] __maybe_unused;
static const struct i2c_device_id tas571x_i2c_id[];
static int tas571x_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int tas571x_i2c_probe(struct i2c_client *client)
{
struct tas571x_private *priv;
struct device *dev = &client->dev;
@ -791,8 +791,11 @@ static int tas571x_i2c_probe(struct i2c_client *client,
of_id = of_match_device(tas571x_of_match, dev);
if (of_id)
priv->chip = of_id->data;
else
else {
const struct i2c_device_id *id =
i2c_match_id(tas571x_i2c_id, client);
priv->chip = (void *) id->driver_data;
}
priv->mclk = devm_clk_get(dev, "mclk");
if (IS_ERR(priv->mclk) && PTR_ERR(priv->mclk) != -ENOENT) {
@ -914,7 +917,7 @@ static struct i2c_driver tas571x_i2c_driver = {
.name = "tas571x",
.of_match_table = of_match_ptr(tas571x_of_match),
},
.probe = tas571x_i2c_probe,
.probe_new = tas571x_i2c_probe,
.remove = tas571x_i2c_remove,
.id_table = tas571x_i2c_id,
};

View File

@ -633,12 +633,19 @@ static struct snd_soc_dai_driver tas5720_dai[] = {
},
};
static int tas5720_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static const struct i2c_device_id tas5720_id[] = {
{ "tas5720", TAS5720 },
{ "tas5722", TAS5722 },
{ }
};
MODULE_DEVICE_TABLE(i2c, tas5720_id);
static int tas5720_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct tas5720_data *data;
const struct regmap_config *regmap_config;
const struct i2c_device_id *id;
int ret;
int i;
@ -646,6 +653,7 @@ static int tas5720_probe(struct i2c_client *client,
if (!data)
return -ENOMEM;
id = i2c_match_id(tas5720_id, client);
data->tas5720_client = client;
data->devtype = id->driver_data;
@ -704,13 +712,6 @@ static int tas5720_probe(struct i2c_client *client,
return 0;
}
static const struct i2c_device_id tas5720_id[] = {
{ "tas5720", TAS5720 },
{ "tas5722", TAS5722 },
{ }
};
MODULE_DEVICE_TABLE(i2c, tas5720_id);
#if IS_ENABLED(CONFIG_OF)
static const struct of_device_id tas5720_of_match[] = {
{ .compatible = "ti,tas5720", },
@ -725,7 +726,7 @@ static struct i2c_driver tas5720_i2c_driver = {
.name = "tas5720",
.of_match_table = of_match_ptr(tas5720_of_match),
},
.probe = tas5720_probe,
.probe_new = tas5720_probe,
.id_table = tas5720_id,
};