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

ASoC: rt5677: Use device_get_match_data()

Use device_get_match_data() to simplify the code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230630172155.83754-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Andy Shevchenko and committed by
Mark Brown
043bb9c0 c3d42d7b

+6 -19
+4 -17
sound/soc/codecs/rt5677.c
··· 6 6 * Author: Oder Chiou <oder_chiou@realtek.com> 7 7 */ 8 8 9 - #include <linux/acpi.h> 10 9 #include <linux/fs.h> 11 10 #include <linux/module.h> 12 11 #include <linux/moduleparam.h> ··· 17 18 #include <linux/platform_device.h> 18 19 #include <linux/spi/spi.h> 19 20 #include <linux/firmware.h> 20 - #include <linux/of_device.h> 21 21 #include <linux/property.h> 22 22 #include <linux/irq.h> 23 23 #include <linux/interrupt.h> ··· 5529 5531 5530 5532 static int rt5677_i2c_probe(struct i2c_client *i2c) 5531 5533 { 5534 + struct device *dev = &i2c->dev; 5532 5535 struct rt5677_priv *rt5677; 5533 5536 int ret; 5534 5537 unsigned int val; ··· 5544 5545 INIT_DELAYED_WORK(&rt5677->dsp_work, rt5677_dsp_work); 5545 5546 i2c_set_clientdata(i2c, rt5677); 5546 5547 5547 - if (i2c->dev.of_node) { 5548 - const struct of_device_id *match_id; 5549 - 5550 - match_id = of_match_device(rt5677_of_match, &i2c->dev); 5551 - if (match_id) 5552 - rt5677->type = (enum rt5677_type)match_id->data; 5553 - } else if (ACPI_HANDLE(&i2c->dev)) { 5554 - const struct acpi_device_id *acpi_id; 5555 - 5556 - acpi_id = acpi_match_device(rt5677_acpi_match, &i2c->dev); 5557 - if (acpi_id) 5558 - rt5677->type = (enum rt5677_type)acpi_id->driver_data; 5559 - } else { 5548 + rt5677->type = (enum rt5677_type)(uintptr_t)device_get_match_data(dev); 5549 + if (rt5677->type == 0) 5560 5550 return -EINVAL; 5561 - } 5562 5551 5563 5552 rt5677_read_device_properties(rt5677, &i2c->dev); 5564 5553 ··· 5661 5674 .driver = { 5662 5675 .name = RT5677_DRV_NAME, 5663 5676 .of_match_table = rt5677_of_match, 5664 - .acpi_match_table = ACPI_PTR(rt5677_acpi_match), 5677 + .acpi_match_table = rt5677_acpi_match, 5665 5678 }, 5666 5679 .probe = rt5677_i2c_probe, 5667 5680 .remove = rt5677_i2c_remove,
+2 -2
sound/soc/codecs/rt5677.h
··· 1691 1691 }; 1692 1692 1693 1693 enum rt5677_type { 1694 - RT5677, 1695 - RT5676, 1694 + RT5677 = 1, 1695 + RT5676 = 2, 1696 1696 }; 1697 1697 1698 1698 /* ASRC clock source selection */