Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Stephen Kitt and committed by
Mark Brown
9d8f2edd e654a133

+24 -20
+13 -11
sound/soc/codecs/alc5623.c
··· 968 968 .cache_type = REGCACHE_RBTREE, 969 969 }; 970 970 971 + static const struct i2c_device_id alc5623_i2c_table[] = { 972 + {"alc5621", 0x21}, 973 + {"alc5622", 0x22}, 974 + {"alc5623", 0x23}, 975 + {} 976 + }; 977 + MODULE_DEVICE_TABLE(i2c, alc5623_i2c_table); 978 + 971 979 /* 972 980 * ALC5623 2 wire address is determined by A1 pin 973 981 * state during powerup. 974 982 * low = 0x1a 975 983 * high = 0x1b 976 984 */ 977 - static int alc5623_i2c_probe(struct i2c_client *client, 978 - const struct i2c_device_id *id) 985 + static int alc5623_i2c_probe(struct i2c_client *client) 979 986 { 980 987 struct alc5623_platform_data *pdata; 981 988 struct alc5623_priv *alc5623; ··· 990 983 unsigned int vid1, vid2; 991 984 int ret; 992 985 u32 val32; 986 + const struct i2c_device_id *id; 993 987 994 988 alc5623 = devm_kzalloc(&client->dev, sizeof(struct alc5623_priv), 995 989 GFP_KERNEL); ··· 1016 1008 return ret; 1017 1009 } 1018 1010 vid2 >>= 8; 1011 + 1012 + id = i2c_match_id(alc5623_i2c_table, client); 1019 1013 1020 1014 if ((vid1 != 0x10ec) || (vid2 != id->driver_data)) { 1021 1015 dev_err(&client->dev, "unknown or wrong codec\n"); ··· 1070 1060 return ret; 1071 1061 } 1072 1062 1073 - static const struct i2c_device_id alc5623_i2c_table[] = { 1074 - {"alc5621", 0x21}, 1075 - {"alc5622", 0x22}, 1076 - {"alc5623", 0x23}, 1077 - {} 1078 - }; 1079 - MODULE_DEVICE_TABLE(i2c, alc5623_i2c_table); 1080 - 1081 1063 #ifdef CONFIG_OF 1082 1064 static const struct of_device_id alc5623_of_match[] = { 1083 1065 { .compatible = "realtek,alc5623", }, ··· 1084 1082 .name = "alc562x-codec", 1085 1083 .of_match_table = of_match_ptr(alc5623_of_match), 1086 1084 }, 1087 - .probe = alc5623_i2c_probe, 1085 + .probe_new = alc5623_i2c_probe, 1088 1086 .id_table = alc5623_i2c_table, 1089 1087 }; 1090 1088
+11 -9
sound/soc/codecs/alc5632.c
··· 1092 1092 .cache_type = REGCACHE_RBTREE, 1093 1093 }; 1094 1094 1095 + static const struct i2c_device_id alc5632_i2c_table[] = { 1096 + {"alc5632", 0x5c}, 1097 + {} 1098 + }; 1099 + MODULE_DEVICE_TABLE(i2c, alc5632_i2c_table); 1100 + 1095 1101 /* 1096 1102 * alc5632 2 wire address is determined by A1 pin 1097 1103 * state during powerup. 1098 1104 * low = 0x1a 1099 1105 * high = 0x1b 1100 1106 */ 1101 - static int alc5632_i2c_probe(struct i2c_client *client, 1102 - const struct i2c_device_id *id) 1107 + static int alc5632_i2c_probe(struct i2c_client *client) 1103 1108 { 1104 1109 struct alc5632_priv *alc5632; 1105 1110 int ret, ret1, ret2; 1106 1111 unsigned int vid1, vid2; 1112 + const struct i2c_device_id *id; 1107 1113 1108 1114 alc5632 = devm_kzalloc(&client->dev, 1109 1115 sizeof(struct alc5632_priv), GFP_KERNEL); ··· 1134 1128 } 1135 1129 1136 1130 vid2 >>= 8; 1131 + 1132 + id = i2c_match_id(alc5632_i2c_table, client); 1137 1133 1138 1134 if ((vid1 != 0x10EC) || (vid2 != id->driver_data)) { 1139 1135 dev_err(&client->dev, ··· 1169 1161 return ret; 1170 1162 } 1171 1163 1172 - static const struct i2c_device_id alc5632_i2c_table[] = { 1173 - {"alc5632", 0x5c}, 1174 - {} 1175 - }; 1176 - MODULE_DEVICE_TABLE(i2c, alc5632_i2c_table); 1177 - 1178 1164 #ifdef CONFIG_OF 1179 1165 static const struct of_device_id alc5632_of_match[] = { 1180 1166 { .compatible = "realtek,alc5632", }, ··· 1183 1181 .name = "alc5632", 1184 1182 .of_match_table = of_match_ptr(alc5632_of_match), 1185 1183 }, 1186 - .probe = alc5632_i2c_probe, 1184 + .probe_new = alc5632_i2c_probe, 1187 1185 .id_table = alc5632_i2c_table, 1188 1186 }; 1189 1187