ASoC: tas*: use i2c_match_id and simple i2c probe
authorStephen Kitt <steve@sk2.org>
Fri, 15 Apr 2022 16:06:11 +0000 (18:06 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 25 Apr 2022 12:58:55 +0000 (13:58 +0100)
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>
sound/soc/codecs/tas2562.c
sound/soc/codecs/tas571x.c
sound/soc/codecs/tas5720.c

index 10302552195e1768d15a35d1e28d552d05df6422..e62a3da16aed31ae9556f4981f1d6ca550772b35 100644 (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,
 };
 
index a3e682376946bc07cc235be6d672598e00dac059..dd289774efb26784f4a5243030a4476f538e75ca 100644 (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,
 };
index 9ff644ddb470a61fa15fb7450a0a89224444b03c..17034abef5689f2b338398220e627e9dfc314b84 100644 (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,
 };