Skip to content

Commit 988e687

Browse files
skittbroonie
authored andcommitted
ASoC: tlv320*: 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. In the context of an i2c probe, i2c_match_id with the module id table and the probed client never returns null, so removing the null check on the i2c_device_id pointer is safe. 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-7-steve@sk2.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 55116b3 commit 988e687

4 files changed

Lines changed: 47 additions & 42 deletions

File tree

sound/soc/codecs/tlv320adc3xxx.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,11 +1337,18 @@ static const struct snd_soc_component_driver soc_component_dev_adc3xxx = {
13371337
.num_dapm_routes = ARRAY_SIZE(adc3xxx_intercon),
13381338
};
13391339

1340-
static int adc3xxx_i2c_probe(struct i2c_client *i2c,
1341-
const struct i2c_device_id *id)
1340+
static const struct i2c_device_id adc3xxx_i2c_id[] = {
1341+
{ "tlv320adc3001", ADC3001 },
1342+
{ "tlv320adc3101", ADC3101 },
1343+
{}
1344+
};
1345+
MODULE_DEVICE_TABLE(i2c, adc3xxx_i2c_id);
1346+
1347+
static int adc3xxx_i2c_probe(struct i2c_client *i2c)
13421348
{
13431349
struct device *dev = &i2c->dev;
13441350
struct adc3xxx *adc3xxx = NULL;
1351+
const struct i2c_device_id *id;
13451352
int ret;
13461353

13471354
adc3xxx = devm_kzalloc(dev, sizeof(struct adc3xxx), GFP_KERNEL);
@@ -1394,6 +1401,7 @@ static int adc3xxx_i2c_probe(struct i2c_client *i2c,
13941401

13951402
i2c_set_clientdata(i2c, adc3xxx);
13961403

1404+
id = i2c_match_id(adc3xxx_i2c_id, i2c);
13971405
adc3xxx->type = id->driver_data;
13981406

13991407
/* Reset codec chip */
@@ -1436,19 +1444,12 @@ static const struct of_device_id tlv320adc3xxx_of_match[] = {
14361444
};
14371445
MODULE_DEVICE_TABLE(of, tlv320adc3xxx_of_match);
14381446

1439-
static const struct i2c_device_id adc3xxx_i2c_id[] = {
1440-
{ "tlv320adc3001", ADC3001 },
1441-
{ "tlv320adc3101", ADC3101 },
1442-
{}
1443-
};
1444-
MODULE_DEVICE_TABLE(i2c, adc3xxx_i2c_id);
1445-
14461447
static struct i2c_driver adc3xxx_i2c_driver = {
14471448
.driver = {
14481449
.name = "tlv320adc3xxx-codec",
14491450
.of_match_table = tlv320adc3xxx_of_match,
14501451
},
1451-
.probe = adc3xxx_i2c_probe,
1452+
.probe_new = adc3xxx_i2c_probe,
14521453
.remove = adc3xxx_i2c_remove,
14531454
.id_table = adc3xxx_i2c_id,
14541455
};

sound/soc/codecs/tlv320aic31xx.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,11 +1628,24 @@ static void aic31xx_configure_ocmv(struct aic31xx_priv *priv)
16281628
}
16291629
}
16301630

1631-
static int aic31xx_i2c_probe(struct i2c_client *i2c,
1632-
const struct i2c_device_id *id)
1631+
static const struct i2c_device_id aic31xx_i2c_id[] = {
1632+
{ "tlv320aic310x", AIC3100 },
1633+
{ "tlv320aic311x", AIC3110 },
1634+
{ "tlv320aic3100", AIC3100 },
1635+
{ "tlv320aic3110", AIC3110 },
1636+
{ "tlv320aic3120", AIC3120 },
1637+
{ "tlv320aic3111", AIC3111 },
1638+
{ "tlv320dac3100", DAC3100 },
1639+
{ "tlv320dac3101", DAC3101 },
1640+
{ }
1641+
};
1642+
MODULE_DEVICE_TABLE(i2c, aic31xx_i2c_id);
1643+
1644+
static int aic31xx_i2c_probe(struct i2c_client *i2c)
16331645
{
16341646
struct aic31xx_priv *aic31xx;
16351647
unsigned int micbias_value = MICBIAS_2_0V;
1648+
const struct i2c_device_id *id = i2c_match_id(aic31xx_i2c_id, i2c);
16361649
int i, ret;
16371650

16381651
dev_dbg(&i2c->dev, "## %s: %s codec_type = %d\n", __func__,
@@ -1729,26 +1742,13 @@ static int aic31xx_i2c_probe(struct i2c_client *i2c,
17291742
ARRAY_SIZE(aic31xx_dai_driver));
17301743
}
17311744

1732-
static const struct i2c_device_id aic31xx_i2c_id[] = {
1733-
{ "tlv320aic310x", AIC3100 },
1734-
{ "tlv320aic311x", AIC3110 },
1735-
{ "tlv320aic3100", AIC3100 },
1736-
{ "tlv320aic3110", AIC3110 },
1737-
{ "tlv320aic3120", AIC3120 },
1738-
{ "tlv320aic3111", AIC3111 },
1739-
{ "tlv320dac3100", DAC3100 },
1740-
{ "tlv320dac3101", DAC3101 },
1741-
{ }
1742-
};
1743-
MODULE_DEVICE_TABLE(i2c, aic31xx_i2c_id);
1744-
17451745
static struct i2c_driver aic31xx_i2c_driver = {
17461746
.driver = {
17471747
.name = "tlv320aic31xx-codec",
17481748
.of_match_table = of_match_ptr(tlv320aic31xx_of_match),
17491749
.acpi_match_table = ACPI_PTR(aic31xx_acpi_match),
17501750
},
1751-
.probe = aic31xx_i2c_probe,
1751+
.probe_new = aic31xx_i2c_probe,
17521752
.id_table = aic31xx_i2c_id,
17531753
};
17541754
module_i2c_driver(aic31xx_i2c_driver);

sound/soc/codecs/tlv320aic32x4-i2c.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
#include "tlv320aic32x4.h"
1818

1919
static const struct of_device_id aic32x4_of_id[];
20+
static const struct i2c_device_id aic32x4_i2c_id[];
2021

21-
static int aic32x4_i2c_probe(struct i2c_client *i2c,
22-
const struct i2c_device_id *id)
22+
static int aic32x4_i2c_probe(struct i2c_client *i2c)
2323
{
2424
struct regmap *regmap;
2525
struct regmap_config config;
@@ -35,7 +35,10 @@ static int aic32x4_i2c_probe(struct i2c_client *i2c,
3535

3636
oid = of_match_node(aic32x4_of_id, i2c->dev.of_node);
3737
dev_set_drvdata(&i2c->dev, (void *)oid->data);
38-
} else if (id) {
38+
} else {
39+
const struct i2c_device_id *id;
40+
41+
id = i2c_match_id(aic32x4_i2c_id, i2c);
3942
dev_set_drvdata(&i2c->dev, (void *)id->driver_data);
4043
}
4144

@@ -70,7 +73,7 @@ static struct i2c_driver aic32x4_i2c_driver = {
7073
.name = "tlv320aic32x4",
7174
.of_match_table = aic32x4_of_id,
7275
},
73-
.probe = aic32x4_i2c_probe,
76+
.probe_new = aic32x4_i2c_probe,
7477
.remove = aic32x4_i2c_remove,
7578
.id_table = aic32x4_i2c_id,
7679
};

sound/soc/codecs/tlv320aic3x-i2c.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,21 @@
1717

1818
#include "tlv320aic3x.h"
1919

20-
static int aic3x_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
20+
static const struct i2c_device_id aic3x_i2c_id[] = {
21+
{ "tlv320aic3x", AIC3X_MODEL_3X },
22+
{ "tlv320aic33", AIC3X_MODEL_33 },
23+
{ "tlv320aic3007", AIC3X_MODEL_3007 },
24+
{ "tlv320aic3104", AIC3X_MODEL_3104 },
25+
{ "tlv320aic3106", AIC3X_MODEL_3106 },
26+
{ }
27+
};
28+
MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id);
29+
30+
static int aic3x_i2c_probe(struct i2c_client *i2c)
2131
{
2232
struct regmap *regmap;
2333
struct regmap_config config;
34+
const struct i2c_device_id *id = i2c_match_id(aic3x_i2c_id, i2c);
2435

2536
config = aic3x_regmap;
2637
config.reg_bits = 8;
@@ -37,16 +48,6 @@ static int aic3x_i2c_remove(struct i2c_client *i2c)
3748
return 0;
3849
}
3950

40-
static const struct i2c_device_id aic3x_i2c_id[] = {
41-
{ "tlv320aic3x", AIC3X_MODEL_3X },
42-
{ "tlv320aic33", AIC3X_MODEL_33 },
43-
{ "tlv320aic3007", AIC3X_MODEL_3007 },
44-
{ "tlv320aic3104", AIC3X_MODEL_3104 },
45-
{ "tlv320aic3106", AIC3X_MODEL_3106 },
46-
{ }
47-
};
48-
MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id);
49-
5051
static const struct of_device_id aic3x_of_id[] = {
5152
{ .compatible = "ti,tlv320aic3x", },
5253
{ .compatible = "ti,tlv320aic33" },
@@ -62,7 +63,7 @@ static struct i2c_driver aic3x_i2c_driver = {
6263
.name = "tlv320aic3x",
6364
.of_match_table = aic3x_of_id,
6465
},
65-
.probe = aic3x_i2c_probe,
66+
.probe_new = aic3x_i2c_probe,
6667
.remove = aic3x_i2c_remove,
6768
.id_table = aic3x_i2c_id,
6869
};

0 commit comments

Comments
 (0)