From: sashiko-bot@kernel.org
To: "Shenghao Ding" <shenghao-ding@ti.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH v1] ASoC: tas2781: read TAS2573 status registers by entry length
Date: Fri, 27 Nov 2026 04:38:39 +0000 [thread overview]
Message-ID: <sashiko-outbox-236601@kernel.org> (raw)
In-Reply-To: <20261127042856.1672-1-shenghao-ding@ti.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] ASoC: tas2781: TAS2573_FCT_INT_LATCH uses 4-byte entry in
fct_status_regs
- [Medium] ASoC: tas2781: wrong 1-byte value offset in
tas2573_status_get_common()
--
commit 01ec8dd477ee424fc19c367d085a8a14cf238238
Author: Shenghao Ding <shenghao-ding@ti.com>
ASoC: tas2781: read TAS2573 status registers by entry length
This commit replaces the TAS2573 status register address arrays with
struct tasdev_reg_entry descriptors that carry an explicit val_len field,
and updates tas2573_status_get_common() to choose single-byte or 4-byte
bulk reads per entry.
> diff --git a/include/sound/tas2573-reg.h b/include/sound/tas2573-reg.h
> index 6f8411c695ebc..b23d14b933198 100644
> --- a/include/sound/tas2573-reg.h
> +++ b/include/sound/tas2573-reg.h
> @@ -14,16 +14,25 @@
> #ifndef __TAS2573_REG_H__
> #define __TAS2573_REG_H__
>
> +/* Descriptor of a single register field: address plus value length. */
> +struct tasdev_reg_entry {
> + const unsigned int reg;
> + const unsigned char val_len;
> +};
> +
> /*
> - * Register map descriptor: binds the register table, its length, and the log
> - * tag together into a single argument.
> + * A named group of register fields accessed together. Each entry occupies
> + * a fixed 4-byte slot in the userspace report, regardless of val_len.
> */
> -struct tasdev_reg_map {
> - const unsigned int *regs;
> - unsigned int nregs;
> +struct tasdev_reg_table {
> + const struct tasdev_reg_entry *entries;
> + unsigned int nentries;
> const char *tag;
> };
>
> +#define TASDEV_REG_ENTRY(regid) { .reg = (regid), .val_len = 4 }
> +#define TASDEV_REG_ENTRY_B1(regid) { .reg = (regid), .val_len = 1 }
> +
> #define TAS2573_TDM_DET_REG TASDEVICE_REG(0x00, 0x00, 0x14)
> #define TAS2573_FCT_INT_LATCH TASDEVICE_REG(0x00, 0x00, 0x67)
> /* YM57 */
> @@ -59,41 +68,42 @@ struct tasdev_reg_map {
> /* YM955 */
> #define TAS2573_SHORTCKT TASDEVICE_REG(0x00, 0x83, 0x6C)
>
> -/* Registers for the speaker calibration */
> -static const __maybe_unused unsigned int fct_status_regs[] = {
> - TAS2573_FCT_INT_LATCH,
> - TAS2573_FCT_STATUS_CTRL,
> - TAS2573_FCT_STATUS_BINNING,
> - TAS2573_SILENCE_DETECTED,
> - TAS2573_OPEN_CIRCUIT,
> - TAS2573_SHORTCKT,
> - TAS2573_FCT_OUTPUT_R0,
> - TAS2573_FCT_OUTPUT_R0_LOW,
> - TAS2573_FCT_OUTPUT_INV_R0,
> - TAS2573_FCT_OUTPUT_POWERTOT,
> - TAS2573_FCT_OUTPUT_F0,
> - TAS2573_RE_OUT,
> +/* Register Array for the speaker calibration */
> +static const __maybe_unused struct tasdev_reg_entry fct_status_regs[] = {
> + TASDEV_REG_ENTRY(TAS2573_FCT_INT_LATCH),
[Severity: Medium]
Should TAS2573_FCT_INT_LATCH use TASDEV_REG_ENTRY_B1() here?
Before this patch, tas2573_status_get_common() read fct_status_regs[0] as
a 1-byte register via tasdevice_dev_read(). With TASDEV_REG_ENTRY(),
val_len is 4, so reading the "Calibration Status" control will perform a
4-byte bulk read starting at Book 0, Page 0, Register 0x67 and include
three adjacent Page 0 registers in the slot.
[ ... ]
> diff --git a/sound/soc/codecs/tas2781-i2c.c b/sound/soc/codecs/tas2781-i2c.c
> index 2dbbd13f5e814..f59be9d7ac313 100644
> --- a/sound/soc/codecs/tas2781-i2c.c
> +++ b/sound/soc/codecs/tas2781-i2c.c
> @@ -1565,40 +1566,45 @@ static int tas2573_status_get_common(struct snd_kcontrol *kcontrol,
[ ... ]
> for (j = 0; j < priv->ndev; j++) {
> dst[i++] = j;
> - dst[i++] = 0;
> - dst[i++] = 0;
> - dst[i++] = 0;
> -
> - rc = tasdevice_dev_read(priv, j, map->regs[0], &val);
> - if (rc < 0)
> - dev_err(priv->dev,
> - "chn %d %s[0] rd err = %d\n",
> - j, map->tag, rc);
> - else
> - dst[i++] = val;
> -
> - for (k = 1; k < map->nregs; k++, i += 4) {
> - rc = tasdevice_dev_bulk_read(priv, j, map->regs[k],
> - &dst[i], 4);
> - if (rc < 0)
> - dev_err(priv->dev,
> - "chn %d %s[%u] bulk_rd err = %d\n",
> - j, map->tag, k, rc);
> + for (k = 0; k < map->nentries; k++, i += 4) {
> + dst[i] = 0;
> + dst[i + 1] = 0;
> + dst[i + 2] = 0;
> + dst[i + 3] = 0;
> +
> + if (map->entries[k].val_len == 4) {
> + rc = tasdevice_dev_bulk_read(priv, j,
> + map->entries[k].reg, &dst[i], 4);
> + if (rc < 0)
> + dev_err(priv->dev,
> + "chn %d %s[%u] bulk_read err = %d\n",
> + j, map->tag, k, rc);
> + } else {
> + rc = tasdevice_dev_read(priv, j,
> + map->entries[k].reg, &val);
> + if (!rc)
> + dst[i] = val;
[Severity: Medium]
Does writing dst[i] = val place 1-byte register values at the wrong
offset in the 4-byte slot?
Previously, i was incremented three times while zeroing the leading bytes
before writing dst[i++] = val, placing the byte at offset +3 ({0, 0, 0,
val}). Since i is now advanced by 4 in the loop header, dst[i] = val
stores the value at offset +0 ({val, 0, 0, 0}) instead of dst[i + 3],
changing the report layout seen by userspace.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127042856.1672-1-shenghao-ding@ti.com?part=1
next prev parent reply other threads:[~2026-11-27 4:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 4:28 [PATCH v1] ASoC: tas2781: read TAS2573 status registers by entry length Shenghao Ding
2026-11-27 4:38 ` sashiko-bot [this message]
2026-11-27 16:03 ` 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=sashiko-outbox-236601@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shenghao-ding@ti.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.