From cdf9fcb1ce0639a6973a6d97b30cafe7efa6554f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 1 Aug 2023 10:53:03 +0200 Subject: [PATCH] 4.19-stable patches added patches: asoc-cs42l51-fix-driver-to-properly-autoload-with-automatic-module-loading.patch --- ...toload-with-automatic-module-loading.patch | 86 +++++++++++++++++++ queue-4.19/series | 1 + 2 files changed, 87 insertions(+) create mode 100644 queue-4.19/asoc-cs42l51-fix-driver-to-properly-autoload-with-automatic-module-loading.patch diff --git a/queue-4.19/asoc-cs42l51-fix-driver-to-properly-autoload-with-automatic-module-loading.patch b/queue-4.19/asoc-cs42l51-fix-driver-to-properly-autoload-with-automatic-module-loading.patch new file mode 100644 index 00000000000..87935056c4c --- /dev/null +++ b/queue-4.19/asoc-cs42l51-fix-driver-to-properly-autoload-with-automatic-module-loading.patch @@ -0,0 +1,86 @@ +From e51df4f81b02bcdd828a04de7c1eb6a92988b61e Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Thu, 13 Jul 2023 13:21:12 +0200 +Subject: ASoC: cs42l51: fix driver to properly autoload with automatic module loading + +From: Thomas Petazzoni + +commit e51df4f81b02bcdd828a04de7c1eb6a92988b61e upstream. + +In commit 2cb1e0259f50 ("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: 2cb1e0259f50 ("ASoC: cs42l51: re-hook of_match_table pointer") +Cc: stable@vger.kernel.org +Signed-off-by: Thomas Petazzoni +Link: https://lore.kernel.org/r/20230713112112.778576-1-thomas.petazzoni@bootlin.com +Signed-off-by: Mark Brown +Signed-off-by: Greg Kroah-Hartman +--- + sound/soc/codecs/cs42l51-i2c.c | 6 ++++++ + sound/soc/codecs/cs42l51.c | 7 ------- + sound/soc/codecs/cs42l51.h | 1 - + 3 files changed, 6 insertions(+), 8 deletions(-) + +--- a/sound/soc/codecs/cs42l51-i2c.c ++++ b/sound/soc/codecs/cs42l51-i2c.c +@@ -23,6 +23,12 @@ static struct i2c_device_id cs42l51_i2c_ + }; + MODULE_DEVICE_TABLE(i2c, cs42l51_i2c_id); + ++const struct of_device_id cs42l51_of_match[] = { ++ { .compatible = "cirrus,cs42l51", }, ++ { } ++}; ++MODULE_DEVICE_TABLE(of, cs42l51_of_match); ++ + static int cs42l51_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) + { +--- a/sound/soc/codecs/cs42l51.c ++++ b/sound/soc/codecs/cs42l51.c +@@ -563,13 +563,6 @@ error: + } + EXPORT_SYMBOL_GPL(cs42l51_probe); + +-const struct of_device_id cs42l51_of_match[] = { +- { .compatible = "cirrus,cs42l51", }, +- { } +-}; +-MODULE_DEVICE_TABLE(of, cs42l51_of_match); +-EXPORT_SYMBOL_GPL(cs42l51_of_match); +- + MODULE_AUTHOR("Arnaud Patard "); + MODULE_DESCRIPTION("Cirrus Logic CS42L51 ALSA SoC Codec Driver"); + MODULE_LICENSE("GPL"); +--- a/sound/soc/codecs/cs42l51.h ++++ b/sound/soc/codecs/cs42l51.h +@@ -22,7 +22,6 @@ struct device; + + extern const struct regmap_config cs42l51_regmap; + int cs42l51_probe(struct device *dev, struct regmap *regmap); +-extern const struct of_device_id cs42l51_of_match[]; + + #define CS42L51_CHIP_ID 0x1B + #define CS42L51_CHIP_REV_A 0x00 diff --git a/queue-4.19/series b/queue-4.19/series index 3b1391a46e2..aebba10a4df 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -282,3 +282,4 @@ dm-cache-policy-smq-ensure-io-doesn-t-prevent-cleaner-policy-progress.patch drm-client-fix-memory-leak-in-drm_client_target_cloned.patch net-sched-cls_fw-fix-improper-refcount-update-leads-to-use-after-free.patch net-sched-sch_qfq-account-for-stab-overhead-in-qfq_enqueue.patch +asoc-cs42l51-fix-driver-to-properly-autoload-with-automatic-module-loading.patch -- 2.47.3