[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20220415153817.141364-6-steve@sk2.org>
Date: Fri, 15 Apr 2022 17:38:16 +0200
From: Stephen Kitt <steve@....org>
To: Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>
Cc: Wolfram Sang <wsa@...nel.org>, linux-kernel@...r.kernel.org,
Stephen Kitt <steve@....org>
Subject: [PATCH 5/6] 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@....org>
---
sound/soc/codecs/tas2562.c | 25 +++++++++++++------------
sound/soc/codecs/tas571x.c | 11 +++++++----
sound/soc/codecs/tas5720.c | 21 +++++++++++----------
3 files changed, 31 insertions(+), 26 deletions(-)
diff --git a/sound/soc/codecs/tas2562.c b/sound/soc/codecs/tas2562.c
index 10302552195e..e62a3da16aed 100644
--- a/sound/soc/codecs/tas2562.c
+++ b/sound/soc/codecs/tas2562.c
@@ -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,
};
diff --git a/sound/soc/codecs/tas571x.c b/sound/soc/codecs/tas571x.c
index a3e682376946..dd289774efb2 100644
--- a/sound/soc/codecs/tas571x.c
+++ b/sound/soc/codecs/tas571x.c
@@ -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,
};
diff --git a/sound/soc/codecs/tas5720.c b/sound/soc/codecs/tas5720.c
index 9ff644ddb470..17034abef568 100644
--- a/sound/soc/codecs/tas5720.c
+++ b/sound/soc/codecs/tas5720.c
@@ -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,
};
--
2.27.0
Powered by blists - more mailing lists