ASoC: cs42xx8-i2c: Simplify probe()
authorBiju Das <biju.das.jz@bp.renesas.com>
Mon, 28 Aug 2023 17:48:56 +0000 (18:48 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 11 Sep 2023 00:30:01 +0000 (01:30 +0100)
Simplify probe() by replacing of_match_device->i2c_get_match_data() and
extend matching support for ID table. Also replace
dev_err()->dev_err_probe() to simplify the code.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230828174856.122559-1-biju.das.jz@bp.renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/cs42xx8-i2c.c

index a422472820fb76b4c5ac6150a21515e704d20f42..9028c0f0fe777685026d340cb801e4ed6bbf9fda 100644 (file)
 
 #include "cs42xx8.h"
 
-static const struct of_device_id cs42xx8_of_match[];
-
 static int cs42xx8_i2c_probe(struct i2c_client *i2c)
 {
        int ret;
        struct cs42xx8_driver_data *drvdata;
-       const struct of_device_id *of_id;
-
-       of_id = of_match_device(cs42xx8_of_match, &i2c->dev);
-       if (!of_id) {
-               dev_err(&i2c->dev, "failed to find driver data\n");
-               return -EINVAL;
-       }
 
-       drvdata = (struct cs42xx8_driver_data *)of_id->data;
+       drvdata = (struct cs42xx8_driver_data *)i2c_get_match_data(i2c);
+       if (!drvdata)
+               return dev_err_probe(&i2c->dev, -EINVAL,
+                                    "failed to find driver data\n");
 
        ret = cs42xx8_probe(&i2c->dev,
                devm_regmap_init_i2c(i2c, &cs42xx8_regmap_config), drvdata);