Add ACPI IDs for tas5720 and tas5722 and use device match API
to determine the variant.

Signed-off-by: Nikolaus Voss <nikolaus.v...@loewensteinmedical.de>
---
 sound/soc/codecs/tas5720.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/tas5720.c b/sound/soc/codecs/tas5720.c
index b2e897f094b4..e3f85926cac4 100644
--- a/sound/soc/codecs/tas5720.c
+++ b/sound/soc/codecs/tas5720.c
@@ -7,6 +7,7 @@
  * Author: Andreas Dannenberg <dannenb...@ti.com>
  */
 
+#include <linux/acpi.h>
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/device.h>
@@ -631,7 +632,9 @@ static int tas5720_probe(struct i2c_client *client,
 
        data->tas5720_client = client;
 
-       data->variant = (const struct tas5720_variant *)id->driver_data;
+       data->variant = device_get_match_data(&client->dev);
+       if (!data->variant)
+               data->variant = (const struct tas5720_variant *)id->driver_data;
 
        data->regmap = devm_regmap_init_i2c(client, data->variant->reg_config);
        if (IS_ERR(data->regmap)) {
@@ -687,10 +690,20 @@ static const struct of_device_id tas5720_of_match[] = {
 MODULE_DEVICE_TABLE(of, tas5720_of_match);
 #endif
 
+#if IS_ENABLED(CONFIG_ACPI)
+static const struct acpi_device_id tas5720_acpi_match[] = {
+       { "10TI5720", (kernel_ulong_t)&tas5720 },
+       { "10TI5722", (kernel_ulong_t)&tas5722 },
+       { }
+};
+MODULE_DEVICE_TABLE(acpi, tas5720_acpi_match);
+#endif
+
 static struct i2c_driver tas5720_i2c_driver = {
        .driver = {
                .name = "tas5720",
                .of_match_table = of_match_ptr(tas5720_of_match),
+               .acpi_match_table = ACPI_PTR(tas5720_acpi_match),
        },
        .probe = tas5720_probe,
        .id_table = tas5720_id,
-- 
2.17.1

Reply via email to