diff options
author | Stephen Kitt <steve@sk2.org> | 2022-04-15 18:06:12 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2022-04-25 14:58:56 +0200 |
commit | 988e6870c86cce7999f55133197fddfe7e2795d2 (patch) | |
tree | a297ca3512e82b14ec94c603cd7a46ce58ad6f62 /sound/soc/codecs/tlv320adc3xxx.c | |
parent | ASoC: tas*: use i2c_match_id and simple i2c probe (diff) | |
download | linux-988e6870c86cce7999f55133197fddfe7e2795d2.tar.xz linux-988e6870c86cce7999f55133197fddfe7e2795d2.zip |
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>
Diffstat (limited to 'sound/soc/codecs/tlv320adc3xxx.c')
-rw-r--r-- | sound/soc/codecs/tlv320adc3xxx.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/sound/soc/codecs/tlv320adc3xxx.c b/sound/soc/codecs/tlv320adc3xxx.c index ae18982ac310..a5e9f80cfa32 100644 --- a/sound/soc/codecs/tlv320adc3xxx.c +++ b/sound/soc/codecs/tlv320adc3xxx.c @@ -1337,11 +1337,18 @@ static const struct snd_soc_component_driver soc_component_dev_adc3xxx = { .num_dapm_routes = ARRAY_SIZE(adc3xxx_intercon), }; -static int adc3xxx_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) +static const struct i2c_device_id adc3xxx_i2c_id[] = { + { "tlv320adc3001", ADC3001 }, + { "tlv320adc3101", ADC3101 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, adc3xxx_i2c_id); + +static int adc3xxx_i2c_probe(struct i2c_client *i2c) { struct device *dev = &i2c->dev; struct adc3xxx *adc3xxx = NULL; + const struct i2c_device_id *id; int ret; adc3xxx = devm_kzalloc(dev, sizeof(struct adc3xxx), GFP_KERNEL); @@ -1394,6 +1401,7 @@ static int adc3xxx_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, adc3xxx); + id = i2c_match_id(adc3xxx_i2c_id, i2c); adc3xxx->type = id->driver_data; /* Reset codec chip */ @@ -1436,19 +1444,12 @@ static const struct of_device_id tlv320adc3xxx_of_match[] = { }; MODULE_DEVICE_TABLE(of, tlv320adc3xxx_of_match); -static const struct i2c_device_id adc3xxx_i2c_id[] = { - { "tlv320adc3001", ADC3001 }, - { "tlv320adc3101", ADC3101 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, adc3xxx_i2c_id); - static struct i2c_driver adc3xxx_i2c_driver = { .driver = { .name = "tlv320adc3xxx-codec", .of_match_table = tlv320adc3xxx_of_match, }, - .probe = adc3xxx_i2c_probe, + .probe_new = adc3xxx_i2c_probe, .remove = adc3xxx_i2c_remove, .id_table = adc3xxx_i2c_id, }; |