ASoC: alc56*: 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.

The i2c id tables are moved up before the probe function, as
suggested by Wolfram Sang.

Signed-off-by: Stephen Kitt <steve@sk2.org>
Link: https://lore.kernel.org/r/20220415160613.148882-3-steve@sk2.org
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Stephen Kitt 2022-04-15 18:06:08 +02:00 committed by Mark Brown
parent e654a1331f
commit 9d8f2edd3d
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
2 changed files with 24 additions and 20 deletions

View File

@ -968,14 +968,21 @@ static const struct regmap_config alc5623_regmap = {
.cache_type = REGCACHE_RBTREE, .cache_type = REGCACHE_RBTREE,
}; };
static const struct i2c_device_id alc5623_i2c_table[] = {
{"alc5621", 0x21},
{"alc5622", 0x22},
{"alc5623", 0x23},
{}
};
MODULE_DEVICE_TABLE(i2c, alc5623_i2c_table);
/* /*
* ALC5623 2 wire address is determined by A1 pin * ALC5623 2 wire address is determined by A1 pin
* state during powerup. * state during powerup.
* low = 0x1a * low = 0x1a
* high = 0x1b * high = 0x1b
*/ */
static int alc5623_i2c_probe(struct i2c_client *client, static int alc5623_i2c_probe(struct i2c_client *client)
const struct i2c_device_id *id)
{ {
struct alc5623_platform_data *pdata; struct alc5623_platform_data *pdata;
struct alc5623_priv *alc5623; struct alc5623_priv *alc5623;
@ -983,6 +990,7 @@ static int alc5623_i2c_probe(struct i2c_client *client,
unsigned int vid1, vid2; unsigned int vid1, vid2;
int ret; int ret;
u32 val32; u32 val32;
const struct i2c_device_id *id;
alc5623 = devm_kzalloc(&client->dev, sizeof(struct alc5623_priv), alc5623 = devm_kzalloc(&client->dev, sizeof(struct alc5623_priv),
GFP_KERNEL); GFP_KERNEL);
@ -1009,6 +1017,8 @@ static int alc5623_i2c_probe(struct i2c_client *client,
} }
vid2 >>= 8; vid2 >>= 8;
id = i2c_match_id(alc5623_i2c_table, client);
if ((vid1 != 0x10ec) || (vid2 != id->driver_data)) { if ((vid1 != 0x10ec) || (vid2 != id->driver_data)) {
dev_err(&client->dev, "unknown or wrong codec\n"); dev_err(&client->dev, "unknown or wrong codec\n");
dev_err(&client->dev, "Expected %x:%lx, got %x:%x\n", dev_err(&client->dev, "Expected %x:%lx, got %x:%x\n",
@ -1060,14 +1070,6 @@ static int alc5623_i2c_probe(struct i2c_client *client,
return ret; return ret;
} }
static const struct i2c_device_id alc5623_i2c_table[] = {
{"alc5621", 0x21},
{"alc5622", 0x22},
{"alc5623", 0x23},
{}
};
MODULE_DEVICE_TABLE(i2c, alc5623_i2c_table);
#ifdef CONFIG_OF #ifdef CONFIG_OF
static const struct of_device_id alc5623_of_match[] = { static const struct of_device_id alc5623_of_match[] = {
{ .compatible = "realtek,alc5623", }, { .compatible = "realtek,alc5623", },
@ -1082,7 +1084,7 @@ static struct i2c_driver alc5623_i2c_driver = {
.name = "alc562x-codec", .name = "alc562x-codec",
.of_match_table = of_match_ptr(alc5623_of_match), .of_match_table = of_match_ptr(alc5623_of_match),
}, },
.probe = alc5623_i2c_probe, .probe_new = alc5623_i2c_probe,
.id_table = alc5623_i2c_table, .id_table = alc5623_i2c_table,
}; };

View File

@ -1092,18 +1092,24 @@ static const struct regmap_config alc5632_regmap = {
.cache_type = REGCACHE_RBTREE, .cache_type = REGCACHE_RBTREE,
}; };
static const struct i2c_device_id alc5632_i2c_table[] = {
{"alc5632", 0x5c},
{}
};
MODULE_DEVICE_TABLE(i2c, alc5632_i2c_table);
/* /*
* alc5632 2 wire address is determined by A1 pin * alc5632 2 wire address is determined by A1 pin
* state during powerup. * state during powerup.
* low = 0x1a * low = 0x1a
* high = 0x1b * high = 0x1b
*/ */
static int alc5632_i2c_probe(struct i2c_client *client, static int alc5632_i2c_probe(struct i2c_client *client)
const struct i2c_device_id *id)
{ {
struct alc5632_priv *alc5632; struct alc5632_priv *alc5632;
int ret, ret1, ret2; int ret, ret1, ret2;
unsigned int vid1, vid2; unsigned int vid1, vid2;
const struct i2c_device_id *id;
alc5632 = devm_kzalloc(&client->dev, alc5632 = devm_kzalloc(&client->dev,
sizeof(struct alc5632_priv), GFP_KERNEL); sizeof(struct alc5632_priv), GFP_KERNEL);
@ -1129,6 +1135,8 @@ static int alc5632_i2c_probe(struct i2c_client *client,
vid2 >>= 8; vid2 >>= 8;
id = i2c_match_id(alc5632_i2c_table, client);
if ((vid1 != 0x10EC) || (vid2 != id->driver_data)) { if ((vid1 != 0x10EC) || (vid2 != id->driver_data)) {
dev_err(&client->dev, dev_err(&client->dev,
"Device is not a ALC5632: VID1=0x%x, VID2=0x%x\n", vid1, vid2); "Device is not a ALC5632: VID1=0x%x, VID2=0x%x\n", vid1, vid2);
@ -1161,12 +1169,6 @@ static int alc5632_i2c_probe(struct i2c_client *client,
return ret; return ret;
} }
static const struct i2c_device_id alc5632_i2c_table[] = {
{"alc5632", 0x5c},
{}
};
MODULE_DEVICE_TABLE(i2c, alc5632_i2c_table);
#ifdef CONFIG_OF #ifdef CONFIG_OF
static const struct of_device_id alc5632_of_match[] = { static const struct of_device_id alc5632_of_match[] = {
{ .compatible = "realtek,alc5632", }, { .compatible = "realtek,alc5632", },
@ -1181,7 +1183,7 @@ static struct i2c_driver alc5632_i2c_driver = {
.name = "alc5632", .name = "alc5632",
.of_match_table = of_match_ptr(alc5632_of_match), .of_match_table = of_match_ptr(alc5632_of_match),
}, },
.probe = alc5632_i2c_probe, .probe_new = alc5632_i2c_probe,
.id_table = alc5632_i2c_table, .id_table = alc5632_i2c_table,
}; };