Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp992965rwp; Thu, 13 Jul 2023 04:39:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlHfpVwr8a3IRoFcyBWhL/POLvN5+ahu9tiQ74LhOKfGZSrMaR2v712Ni913/d08UAeXfxjZ X-Received: by 2002:a05:6358:88b:b0:135:6354:bb01 with SMTP id m11-20020a056358088b00b001356354bb01mr2206585rwj.0.1689248396920; Thu, 13 Jul 2023 04:39:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689248396; cv=none; d=google.com; s=arc-20160816; b=eSzh2YehYsBpEOdVoLpLiy09nw3SD5jiQnGHhaKW5LrOxP13mNMTkI7S7ZUptdUArP gXDMz+5/4C4tSLwB3Qlo2pks+fxiDACTjcpBj+YZCfuz+iBjS99NtrASZgxz4XEstUcc nz+FItmnRAi0FQg1mm2FOYFjKucIv08yvn/gpRhl/H6Dwt8cpuBSmqTfBgjOlb9DaQEn ZtIZB7rqSLBdLCZ25LiXldxPW1XVFHsflIQBrN8M7400RCd6Jd4xA+f/GFN9sixjphQV 2oK5o4AsbZnvSTjJ48rDI/XJCYEu52I2vSVUE/lL/zyNLfYvrHCTtxsMz/TJ7LxoK2gA tAWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=iaGYvCgK+q34WSSKPrB7Pwd2mXJV/fa98+tweN5VGpM=; fh=IJyxUkPTzeywnhNEQI8aK6SKf4oDF6z7MMzZe94UKMA=; b=mEkJqoYLVDoS15d5nxADaTCPL0WYTNH+eBRoRycXO3ApIll+sV7RGJcHz/2vnVbwPm sOyRp0jsD3GRt8ADEJpS6/YHhxyK5DJSg1OIp3LNJ6UG/vYQhUpM7FkSJquP+dS4/Aes sJRV5h1N2qja3x2Lf+vN6VyFjHEe8nQCNvZPY9Sw9uhFxfiLgf4hvYOoBZD/FSkay8fN 3pKTD6NbcIp/+WP3TkBulk19osd2XPTAIG3gnKLwsbxitvnSA0B3NIYXkEOqne4nm3xc QTs04eEAX+ux4thpP4iXg49k+PpbmDzsRACHlKtfueZSZyDv/G1v3Zsd+X6BBorAEMCP 0aGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=FO5o8KIN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y29-20020a63b51d000000b00542abcf2ce4si5106516pge.623.2023.07.13.04.39.43; Thu, 13 Jul 2023 04:39:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=FO5o8KIN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233931AbjGMLV4 (ORCPT + 99 others); Thu, 13 Jul 2023 07:21:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233053AbjGMLVy (ORCPT ); Thu, 13 Jul 2023 07:21:54 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0801F26AE; Thu, 13 Jul 2023 04:21:28 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPA id 11B531BF208; Thu, 13 Jul 2023 11:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1689247287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=iaGYvCgK+q34WSSKPrB7Pwd2mXJV/fa98+tweN5VGpM=; b=FO5o8KINBx1x1L7zhGkRhU8SP3FUAyfCOs7X7oc5mb8/MVXkEecsnsdJBw2FHsTj//zXWx JF2fSPm9nqxFZBGb9/5AQfXTfkVzUIFwIMQ3+3JQ8NU7g00x4gaxx20bWeZw1UDPtudnJC cdfX+WmX/UYI33ykOCFMb0uQp/Cxwr6pw7k3pAuMO0FwYoAxb9y3X0ZCEksDVf+U0xDp0Q ROegZkDmZ9o0YOSgVxwKFckGtsSlOhVTvGGbLAPoblZe2NF/htdfOa9svxJ+rQtYCCxRW9 vw4wYqRsy4vLjPqfspqG4VheFVKN5AjaKX1IgbwVc2D4zZpjsTCmXCK5NQl33w== From: Thomas Petazzoni To: James Schulman , David Rhodes , Richard Fitzgerald , Liam Girdwood , Mark Brown Cc: Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, Thomas Petazzoni , stable@vger.kernel.org Subject: [PATCH] ASoC: cs42l51: fix driver to properly autoload with automatic module loading Date: Thu, 13 Jul 2023 13:21:12 +0200 Message-ID: <20230713112112.778576-1-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: thomas.petazzoni@bootlin.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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(-) diff --git a/sound/soc/codecs/cs42l51-i2c.c b/sound/soc/codecs/cs42l51-i2c.c index b2106ff6a7cb..e7db7bcd0296 100644 --- a/sound/soc/codecs/cs42l51-i2c.c +++ b/sound/soc/codecs/cs42l51-i2c.c @@ -19,6 +19,12 @@ static struct i2c_device_id cs42l51_i2c_id[] = { }; 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) { struct regmap_config config; diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c index a67cd3ee84e0..a7079ae0ca09 100644 --- a/sound/soc/codecs/cs42l51.c +++ b/sound/soc/codecs/cs42l51.c @@ -823,13 +823,6 @@ int __maybe_unused cs42l51_resume(struct device *dev) } EXPORT_SYMBOL_GPL(cs42l51_resume); -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"); diff --git a/sound/soc/codecs/cs42l51.h b/sound/soc/codecs/cs42l51.h index a79343e8a54e..125703ede113 100644 --- a/sound/soc/codecs/cs42l51.h +++ b/sound/soc/codecs/cs42l51.h @@ -16,7 +16,6 @@ int cs42l51_probe(struct device *dev, struct regmap *regmap); void cs42l51_remove(struct device *dev); int __maybe_unused cs42l51_suspend(struct device *dev); int __maybe_unused cs42l51_resume(struct device *dev); -extern const struct of_device_id cs42l51_of_match[]; #define CS42L51_CHIP_ID 0x1B #define CS42L51_CHIP_REV_A 0x00 -- 2.41.0