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

ASoC: da7218: Use i2c_get_match_data()

Use preferred i2c_get_match_data() instead of of_match_device() and
i2c_match_id() to get the driver match data. With this, adjust the
includes to explicitly include the correct headers.

Avoid using 0 for enum da7218_dev_id so that no match data can be
distinguished.

Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20231006-dt-asoc-header-cleanups-v3-3-13a4f0f7fee6@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Rob Herring and committed by
Mark Brown
fe264255 56c075b2

+3 -28
+2 -27
sound/soc/codecs/da7218.c
··· 9 9 10 10 #include <linux/clk.h> 11 11 #include <linux/i2c.h> 12 - #include <linux/of_device.h> 12 + #include <linux/of.h> 13 13 #include <linux/regmap.h> 14 14 #include <linux/slab.h> 15 15 #include <linux/pm.h> ··· 2285 2285 }; 2286 2286 MODULE_DEVICE_TABLE(of, da7218_of_match); 2287 2287 2288 - static inline int da7218_of_get_id(struct device *dev) 2289 - { 2290 - const struct of_device_id *id = of_match_device(da7218_of_match, dev); 2291 - 2292 - if (id) 2293 - return (uintptr_t)id->data; 2294 - else 2295 - return -EINVAL; 2296 - } 2297 - 2298 2288 static enum da7218_micbias_voltage 2299 2289 da7218_of_micbias_lvl(struct snd_soc_component *component, u32 val) 2300 2290 { ··· 3243 3253 * I2C layer 3244 3254 */ 3245 3255 3246 - static const struct i2c_device_id da7218_i2c_id[]; 3247 - 3248 - static inline int da7218_i2c_get_id(struct i2c_client *i2c) 3249 - { 3250 - const struct i2c_device_id *id = i2c_match_id(da7218_i2c_id, i2c); 3251 - 3252 - if (id) 3253 - return (uintptr_t)id->driver_data; 3254 - else 3255 - return -EINVAL; 3256 - } 3257 - 3258 3256 static int da7218_i2c_probe(struct i2c_client *i2c) 3259 3257 { 3260 3258 struct da7218_priv *da7218; ··· 3254 3276 3255 3277 i2c_set_clientdata(i2c, da7218); 3256 3278 3257 - if (i2c->dev.of_node) 3258 - da7218->dev_id = da7218_of_get_id(&i2c->dev); 3259 - else 3260 - da7218->dev_id = da7218_i2c_get_id(i2c); 3279 + da7218->dev_id = (uintptr_t)i2c_get_match_data(i2c); 3261 3280 3262 3281 if ((da7218->dev_id != DA7217_DEV_ID) && 3263 3282 (da7218->dev_id != DA7218_DEV_ID)) {
+1 -1
sound/soc/codecs/da7218.h
··· 1369 1369 }; 1370 1370 1371 1371 enum da7218_dev_id { 1372 - DA7217_DEV_ID = 0, 1372 + DA7217_DEV_ID = 1, 1373 1373 DA7218_DEV_ID, 1374 1374 }; 1375 1375