Skip to content

Commit e51df4f

Browse files
tpetazzonibroonie
authored andcommitted
ASoC: cs42l51: fix driver to properly autoload with automatic module loading
In commit 2cb1e02 ("ASoC: cs42l51: re-hook of_match_table pointer"), 9 years ago, some random guy fixed the cs42l51 after it was split into a core part and an I2C part to properly match based on a Device Tree compatible string. However, the fix in this commit is wrong: the MODULE_DEVICE_TABLE(of, ....) is in the core part of the driver, not the I2C part. Therefore, automatic module loading based on module.alias, based on matching with the DT compatible string, loads the core part of the driver, but not the I2C part. And threfore, the i2c_driver is not registered, and the codec is not known to the system, nor matched with a DT node with the corresponding compatible string. In order to fix that, we move the MODULE_DEVICE_TABLE(of, ...) into the I2C part of the driver. The cs42l51_of_match[] array is also moved as well, as it is not possible to have this definition in one file, and the MODULE_DEVICE_TABLE(of, ...) invocation in another file, due to how MODULE_DEVICE_TABLE works. Thanks to this commit, the I2C part of the driver now properly autoloads, and thanks to its dependency on the core part, the core part gets autoloaded as well, resulting in a functional sound card without having to manually load kernel modules. Fixes: 2cb1e02 ("ASoC: cs42l51: re-hook of_match_table pointer") Cc: stable@vger.kernel.org Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Link: https://lore.kernel.org/r/20230713112112.778576-1-thomas.petazzoni@bootlin.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 0791fae commit e51df4f

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

sound/soc/codecs/cs42l51-i2c.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ static struct i2c_device_id cs42l51_i2c_id[] = {
1919
};
2020
MODULE_DEVICE_TABLE(i2c, cs42l51_i2c_id);
2121

22+
const struct of_device_id cs42l51_of_match[] = {
23+
{ .compatible = "cirrus,cs42l51", },
24+
{ }
25+
};
26+
MODULE_DEVICE_TABLE(of, cs42l51_of_match);
27+
2228
static int cs42l51_i2c_probe(struct i2c_client *i2c)
2329
{
2430
struct regmap_config config;

sound/soc/codecs/cs42l51.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -823,13 +823,6 @@ int __maybe_unused cs42l51_resume(struct device *dev)
823823
}
824824
EXPORT_SYMBOL_GPL(cs42l51_resume);
825825

826-
const struct of_device_id cs42l51_of_match[] = {
827-
{ .compatible = "cirrus,cs42l51", },
828-
{ }
829-
};
830-
MODULE_DEVICE_TABLE(of, cs42l51_of_match);
831-
EXPORT_SYMBOL_GPL(cs42l51_of_match);
832-
833826
MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
834827
MODULE_DESCRIPTION("Cirrus Logic CS42L51 ALSA SoC Codec Driver");
835828
MODULE_LICENSE("GPL");

sound/soc/codecs/cs42l51.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ int cs42l51_probe(struct device *dev, struct regmap *regmap);
1616
void cs42l51_remove(struct device *dev);
1717
int __maybe_unused cs42l51_suspend(struct device *dev);
1818
int __maybe_unused cs42l51_resume(struct device *dev);
19-
extern const struct of_device_id cs42l51_of_match[];
2019

2120
#define CS42L51_CHIP_ID 0x1B
2221
#define CS42L51_CHIP_REV_A 0x00

0 commit comments

Comments
 (0)