linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] ALSA: hda/tas2781: Fix EFI name for calibration beginning with 1 instead of 0
@ 2025-08-22 13:50 Shenghao Ding
  2025-08-26  8:33 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Shenghao Ding @ 2025-08-22 13:50 UTC (permalink / raw)
  To: tiwai
  Cc: broonie, andriy.shevchenko, 13564923607, 13916275206, alsa-devel,
	linux-kernel, baojun.xu, Baojun.Xu, jesse-ji, Shenghao Ding

A bug reported by one of my customers that EFI name beginning with 0
instead of 1, and code clean for the string checking.

Fixes: 4fe238513407 ("ALSA: hda/tas2781: Move and unified the calibrated-data getting function for SPI and I2C into the tas2781_hda lib")
Signed-off-by: Shenghao Ding <shenghao-ding@ti.com>

---
v1:
 - Fix EFI name beginning with 1 instead of 0
 - Code clean for the string checking
 - Add extra comments on EFI name for calibration
 - Remove an extra space
---
 sound/hda/codecs/side-codecs/tas2781_hda_i2c.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
index ed7771ab9475..fecd5eac739b 100644
--- a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
+++ b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
@@ -340,16 +340,17 @@ static int tas2563_save_calibration(struct tas2781_hda *h)
 		data[offset] = i;
 		offset++;
 		for (j = 0; j < TASDEV_CALIB_N; ++j) {
-			ret = snprintf(var8, sizeof(var8), vars[j], i);
+			/* EFI name for calibration started with 1, not 0 */
+			ret = snprintf(var8, sizeof(var8), vars[j], i + 1);
 
-			if (ret < 0 || ret >= sizeof(var8) - 1) {
+			if (ret != strlen(var8)) {
 				dev_err(p->dev, "%s: Read %s failed\n",
 					__func__, var8);
 				return -EINVAL;
 			}
 			/*
 			 * Our variable names are ASCII by construction, but
-			 * EFI names are wide chars.  Convert and zero-pad.
+			 * EFI names are wide chars. Convert and zero-pad.
 			 */
 			memset(efi_name, 0, sizeof(efi_name));
 			for (k = 0; k < sizeof(var8) && var8[k]; k++)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] ALSA: hda/tas2781: Fix EFI name for calibration beginning with 1 instead of 0
  2025-08-22 13:50 [PATCH v1] ALSA: hda/tas2781: Fix EFI name for calibration beginning with 1 instead of 0 Shenghao Ding
@ 2025-08-26  8:33 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2025-08-26  8:33 UTC (permalink / raw)
  To: Shenghao Ding
  Cc: broonie, andriy.shevchenko, 13564923607, 13916275206, alsa-devel,
	linux-kernel, baojun.xu, Baojun.Xu, jesse-ji

On Fri, 22 Aug 2025 15:50:42 +0200,
Shenghao Ding wrote:
> 
> A bug reported by one of my customers that EFI name beginning with 0
> instead of 1, and code clean for the string checking.
> 
> Fixes: 4fe238513407 ("ALSA: hda/tas2781: Move and unified the calibrated-data getting function for SPI and I2C into the tas2781_hda lib")
> Signed-off-by: Shenghao Ding <shenghao-ding@ti.com>
> 
> ---
> v1:
>  - Fix EFI name beginning with 1 instead of 0
>  - Code clean for the string checking
>  - Add extra comments on EFI name for calibration
>  - Remove an extra space
> ---
>  sound/hda/codecs/side-codecs/tas2781_hda_i2c.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
> index ed7771ab9475..fecd5eac739b 100644
> --- a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
> +++ b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
> @@ -340,16 +340,17 @@ static int tas2563_save_calibration(struct tas2781_hda *h)
>  		data[offset] = i;
>  		offset++;
>  		for (j = 0; j < TASDEV_CALIB_N; ++j) {
> -			ret = snprintf(var8, sizeof(var8), vars[j], i);
> +			/* EFI name for calibration started with 1, not 0 */
> +			ret = snprintf(var8, sizeof(var8), vars[j], i + 1);
>  
> -			if (ret < 0 || ret >= sizeof(var8) - 1) {
> +			if (ret != strlen(var8)) {

This doesn't look like a code "cleanup".  Calling strlen() is just an
unneeded (but significant) overhead.

Please concentrate only on the correction for now.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-26  8:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-22 13:50 [PATCH v1] ALSA: hda/tas2781: Fix EFI name for calibration beginning with 1 instead of 0 Shenghao Ding
2025-08-26  8:33 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).