From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFD51376A16 for ; Sun, 26 Jul 2026 01:05:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785027931; cv=none; b=sI+pT7UdGGn7R37Hv2YXlC2+GBuD4C1v7sDGAb5PT04rCO2E1wz2/pb3yN2W6tbU9RR2RFlbhJSLZlzs+JwkazmvYKCxhgcW/VC3XGSaeoBIWj/2D2iL6WllD5EvXF8baR/ZH9LD0twkGYkNEYxMkKE3csgRvDs0Ze/vR/Ps9uk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785027931; c=relaxed/simple; bh=hyGwQgbaibMiZjMnG4rSJi5bDblLpnUJ6kVxvdWELTU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KEHjTeZv852msNg1KAziipDTwBR0Ii6uWE8GygNZO0Cx2DZFIurFD4Z+3K9drKUXTCITlXocHULlhnX12z9oSjy0fnlbJK8o2JB9aDKDDSVM3BjmC8hmkkZzSaA9lyZhIUx2L7l25Qa6JfKaQvEh2QkuQu09BL6T75XloLecTLk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LOJdacoI; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LOJdacoI" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2cc7ef7ec27so20370605ad.1 for ; Sat, 25 Jul 2026 18:05:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785027929; x=1785632729; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=JGMy5TZHPbSMBl6QwFQ1P3hdmjaDcuX7zHrmmObiXTY=; b=LOJdacoIekCkVsHPOdQpMYNeH1YMiJvJvgKGRt+bj8uGsoenkc+YkQh0IjHwypic2i yBMA3wziyNxvz2ZempoDx2DedEh81AwpJZTpFhBSm1dKcUblIKyXRIJZ6+oxbRjG9T0U w1lDtmwRbhr7FpSWMwuNmJ901Qrlf3iu533VY3aYcRR50go4v06PBI6Q3TQ6YoTZwh0F PoZeFiEnF5GNGeTZNg5IvZ3Ylf9s4N2ZJoxF8l1BlOd+/qzlVNCWId/rIXDJGtgtsaXo qCNiEvKK2nQmyCQEEOw26spxohJkaY6kBMj2VBNZWQ/6VNwwwqhivJB5dDwnFglGnG8n HT2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785027929; x=1785632729; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=JGMy5TZHPbSMBl6QwFQ1P3hdmjaDcuX7zHrmmObiXTY=; b=gW57hhEUZD5zekDtAF544nlV4L4gNbJMWlrNLruhuEUGx2TeJA1PeyXK8+G3TF4IwT CNKMqnkDgfsDSKrW+s1b3EKSQL0bu9hVkP6ava3daOCwawtpffoA0H4EXf86lUDMp+RY aKia7T1opDVP6yWlGb/twm7mEpBEFDDP+k4+KxwT1EEuwc0Ahoo3Af/ZYvsvBjq068y/ FdGAvU7Q0PEZS7TuCPbBwaq3ZhP9lJqRfHIyZq59uunbx35AGSQ29tKex3gqXEScyMWb Yiu9wGyq0KauhKMlTVNNh5v1T39kIAUK9MoV0S050rsF/VEx7Xxa8L3tYvVxbUHjFhnU vnew== X-Forwarded-Encrypted: i=1; AHgh+Rp7FikZ/2irD6y5y9cIpkN8PVBCPyji6R7/nBTNagFgXcMNL5shUKkEI5VooZMnxc233u8zLVhJdT/jiBs=@vger.kernel.org X-Gm-Message-State: AOJu0YxgC3bLjAunnWulZh5o8jIpujPk02k4LbpbNIEYP86wbJRqVo7d X3bfv23LxqiSmH4rDX6wQNwob6fkEcUmRaLQoWaeqCeNksbpAS1XBdgs X-Gm-Gg: AR+sD11fs8P6fPzlp30FQ8D2KDzH0I2JxG+IfVhScTITDjZL6GcWvVBeJMRsS2RUVIY iG2Lj2mwPzeVl+xcbYlFhV7L6yYT2ctFK9Csr0esFT2T9501lgjYrCfbl6hDWO0U+W9P/GVyQAh 2KrE5utESil7ejTL506G39nmlyBOtjZzfkSliensLLzB25ehCvZQL3HP8NwuUXHSKQAQHgI7qno XREGo8t731EzELUksKLlfZYxpGQk0N7jyGXRFvYavoGdQHYiExfSLDc4NLCrkQciYRK8XC8KL/d uRMGsASkHI9+/GPUl2YDuZz7Blz6bv4Sn/Jk1qEAkBOj9xKs8epNUCqPaX0HfajBYk+Of5Q0xQr HuXKR+u64baUg8tjkwTyggmlAsZIqbt4FchmTzaqKbva+EDjo6uXp/vdulD+FIhW5vDS91VBZzy bkJQhJ2aFjTwllCJNwKwH/N2RDdCt6jWQl4FApZKk7jn5i9fYJOAonI1unWeDI/nuLVQ== X-Received: by 2002:a17:90b:2252:b0:36b:bec8:94c5 with SMTP id 98e67ed59e1d1-38f2950c6e2mr3943726a91.10.1785027929096; Sat, 25 Jul 2026 18:05:29 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:e2c2:1f24:32d5:9d51]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13e0f4a039asm11821445c88.9.2026.07.25.18.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jul 2026 18:05:28 -0700 (PDT) From: Dmitry Torokhov To: Shenghao Ding , Kevin Lu , Baojun Xu , Sen Wang , Liam Girdwood , Mark Brown Cc: Jaroslav Kysela , Takashi Iwai , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/7] ASoC: tlv320aic32x4: move regmap_config into i2c and spi drivers Date: Sat, 25 Jul 2026 18:05:14 -0700 Message-ID: <20260726010519.117805-4-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.55.0.229.g6434b31f56-goog In-Reply-To: <20260726010519.117805-1-dmitry.torokhov@gmail.com> References: <20260726010519.117805-1-dmitry.torokhov@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Move regmap_config definitions to be static const structures in tlv320aic32x4-i2c.c and tlv320aic32x4-spi.c instead of dynamically modifying a shared base regmap_config at runtime during probe. Export aic32x4_regmap_pages so both bus drivers can reference page ranges. In addition, validate regmap initialization immediately upon creation in both bus probe routines and remove the redundant error check from core aic32x4_probe. Assisted-by: Antigravity:gemini-3.5-flash Signed-off-by: Dmitry Torokhov --- sound/soc/codecs/tlv320aic32x4-i2c.c | 16 +++++++++++----- sound/soc/codecs/tlv320aic32x4-spi.c | 20 +++++++++++++------- sound/soc/codecs/tlv320aic32x4.c | 13 ++----------- sound/soc/codecs/tlv320aic32x4.h | 2 +- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/sound/soc/codecs/tlv320aic32x4-i2c.c b/sound/soc/codecs/tlv320aic32x4-i2c.c index 449353d5f088..e031eaaa2f7f 100644 --- a/sound/soc/codecs/tlv320aic32x4-i2c.c +++ b/sound/soc/codecs/tlv320aic32x4-i2c.c @@ -16,17 +16,23 @@ #include "tlv320aic32x4.h" +static const struct regmap_config aic32x4_i2c_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = AIC32X4_REFPOWERUP, + .ranges = aic32x4_regmap_pages, + .num_ranges = 1, +}; + static int aic32x4_i2c_probe(struct i2c_client *i2c) { struct regmap *regmap; - struct regmap_config config; enum aic32x4_type type; - config = aic32x4_regmap_config; - config.reg_bits = 8; - config.val_bits = 8; + regmap = devm_regmap_init_i2c(i2c, &aic32x4_i2c_regmap_config); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); - regmap = devm_regmap_init_i2c(i2c, &config); type = (uintptr_t)i2c_get_match_data(i2c); return aic32x4_probe(&i2c->dev, regmap, type); diff --git a/sound/soc/codecs/tlv320aic32x4-spi.c b/sound/soc/codecs/tlv320aic32x4-spi.c index 92246243ff94..4f842260e325 100644 --- a/sound/soc/codecs/tlv320aic32x4-spi.c +++ b/sound/soc/codecs/tlv320aic32x4-spi.c @@ -16,19 +16,25 @@ #include "tlv320aic32x4.h" +static const struct regmap_config aic32x4_spi_regmap_config = { + .reg_bits = 7, + .pad_bits = 1, + .val_bits = 8, + .read_flag_mask = 0x01, + .max_register = AIC32X4_REFPOWERUP, + .ranges = aic32x4_regmap_pages, + .num_ranges = 1, +}; + static int aic32x4_spi_probe(struct spi_device *spi) { struct regmap *regmap; - struct regmap_config config; enum aic32x4_type type; - config = aic32x4_regmap_config; - config.reg_bits = 7; - config.pad_bits = 1; - config.val_bits = 8; - config.read_flag_mask = 0x01; + regmap = devm_regmap_init_spi(spi, &aic32x4_spi_regmap_config); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); - regmap = devm_regmap_init_spi(spi, &config); type = (uintptr_t)spi_get_device_match_data(spi); return aic32x4_probe(&spi->dev, regmap, type); diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c index 6b3ddb89f692..72be757f559c 100644 --- a/sound/soc/codecs/tlv320aic32x4.c +++ b/sound/soc/codecs/tlv320aic32x4.c @@ -581,7 +581,7 @@ static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = { {"IN3_R to Left Mixer Negative Resistor", "40 kOhm", "IN3_R"}, }; -static const struct regmap_range_cfg aic32x4_regmap_pages[] = { +const struct regmap_range_cfg aic32x4_regmap_pages[] = { { .selector_reg = 0, .selector_mask = 0xff, @@ -591,13 +591,7 @@ static const struct regmap_range_cfg aic32x4_regmap_pages[] = { .range_max = AIC32X4_REFPOWERUP, }, }; - -const struct regmap_config aic32x4_regmap_config = { - .max_register = AIC32X4_REFPOWERUP, - .ranges = aic32x4_regmap_pages, - .num_ranges = ARRAY_SIZE(aic32x4_regmap_pages), -}; -EXPORT_SYMBOL(aic32x4_regmap_config); +EXPORT_SYMBOL_GPL(aic32x4_regmap_pages); static int aic32x4_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) @@ -1326,9 +1320,6 @@ int aic32x4_probe(struct device *dev, struct regmap *regmap, struct device_node *np = dev->of_node; int ret; - if (IS_ERR(regmap)) - return PTR_ERR(regmap); - aic32x4 = devm_kzalloc(dev, sizeof(struct aic32x4_priv), GFP_KERNEL); if (aic32x4 == NULL) diff --git a/sound/soc/codecs/tlv320aic32x4.h b/sound/soc/codecs/tlv320aic32x4.h index 8eb9c6a4c99e..95d010af3d5a 100644 --- a/sound/soc/codecs/tlv320aic32x4.h +++ b/sound/soc/codecs/tlv320aic32x4.h @@ -16,7 +16,7 @@ enum aic32x4_type { AIC32X4_TYPE_TAS2505, }; -extern const struct regmap_config aic32x4_regmap_config; +extern const struct regmap_range_cfg aic32x4_regmap_pages[]; int aic32x4_probe(struct device *dev, struct regmap *regmap, enum aic32x4_type type); void aic32x4_remove(struct device *dev); -- 2.55.0.229.g6434b31f56-goog