From: Rosen Penev <rosenp@gmail.com>
To: linux-sound@vger.kernel.org
Cc: Shenghao Ding <shenghao-ding@ti.com>, Kevin Lu <kevin-lu@ti.com>,
Baojun Xu <baojun.xu@ti.com>, Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] ASoC: codecs: tlv320dac33: remove kmemdup_array
Date: Wed, 1 Apr 2026 19:50:40 -0700 [thread overview]
Message-ID: <20260402025040.93569-1-rosenp@gmail.com> (raw)
Use a flexible array member and struct_size to use one allocation.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
sound/soc/codecs/tlv320dac33.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c
index 605da1259fc6..223c49dfc450 100644
--- a/sound/soc/codecs/tlv320dac33.c
+++ b/sound/soc/codecs/tlv320dac33.c
@@ -91,7 +91,6 @@ struct tlv320dac33_priv {
int mode1_latency; /* latency caused by the i2c writes in
* us */
u8 burst_bclkdiv; /* BCLK divider value in burst mode */
- u8 *reg_cache;
unsigned int burst_rate; /* Interface speed in Burst modes */
int keep_bclk; /* Keep the BCLK continuously running
@@ -108,6 +107,8 @@ struct tlv320dac33_priv {
enum dac33_state state;
struct i2c_client *i2c;
+
+ u8 reg_cache[];
};
static const u8 dac33_reg[DAC33_CACHEREGNUM] = {
@@ -1477,15 +1478,12 @@ static int dac33_i2c_probe(struct i2c_client *client)
struct tlv320dac33_priv *dac33;
int ret, i;
- dac33 = devm_kzalloc(&client->dev, sizeof(struct tlv320dac33_priv),
+ dac33 = devm_kzalloc(&client->dev, struct_size(dac33, reg_cache, ARRAY_SIZE(dac33_reg)),
GFP_KERNEL);
if (dac33 == NULL)
return -ENOMEM;
- dac33->reg_cache = devm_kmemdup_array(&client->dev, dac33_reg, ARRAY_SIZE(dac33_reg),
- sizeof(dac33_reg[0]), GFP_KERNEL);
- if (!dac33->reg_cache)
- return -ENOMEM;
+ memcpy(dac33->reg_cache, dac33_reg, ARRAY_SIZE(dac33_reg));
dac33->i2c = client;
mutex_init(&dac33->mutex);
--
2.53.0
next reply other threads:[~2026-04-02 2:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 2:50 Rosen Penev [this message]
2026-04-03 14:11 ` [PATCH] ASoC: codecs: tlv320dac33: remove kmemdup_array Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260402025040.93569-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=baojun.xu@ti.com \
--cc=broonie@kernel.org \
--cc=kevin-lu@ti.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=shenghao-ding@ti.com \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox